Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.util.stream.Collectors;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
Expand Down Expand Up @@ -72,7 +74,7 @@ public class PackageCommand {
commands.put(NodeKind.CONTAINER, PackageCommand::getPackageFragmentRoots);
commands.put(NodeKind.PACKAGEROOT, PackageCommand::getPackages);
commands.put(NodeKind.PACKAGE, PackageCommand::getRootTypes);
commands.put(NodeKind.Folder, PackageCommand::getFolderChildren);
commands.put(NodeKind.FOLDER, PackageCommand::getFolderChildren);
}

/**
Expand Down Expand Up @@ -288,6 +290,12 @@ private static List<PackageNode> getFolderChildren(PackageParams query, IProgres
if (children != null) {
return convertToPackageNode(children);
}
} else if (resource instanceof IFolder) {
IFolder directory = (IFolder) resource;
Object[] children = directory.members();
if (children != null) {
return convertToPackageNode(children);
}
}
}

Expand Down Expand Up @@ -329,6 +337,16 @@ private static List<PackageNode> convertToPackageNode(Object[] rootContent) thro
if (jarNode != null) {
result.add(jarNode);
}
} else if (root instanceof IFile) {
IFile file = (IFile) root;
PackageNode entry = new PackageNode(file.getName(), null, NodeKind.FILE);
entry.setUri(JDTUtils.getFileURI(file));
result.add(entry);
} else if (root instanceof IFolder) {
IFolder folder = (IFolder) root;
PackageNode entry = new PackageNode(folder.getName(), null, NodeKind.FOLDER);
entry.setUri(JDTUtils.getFileURI(folder));
result.add(entry);
}
}

Expand All @@ -337,7 +355,7 @@ private static List<PackageNode> convertToPackageNode(Object[] rootContent) thro

private static PackageNode getJarEntryResource(JarEntryResource resource) {
if (resource instanceof JarEntryDirectory) {
return new PackageNode(resource.getName(), resource.getFullPath().toPortableString(), NodeKind.Folder);
return new PackageNode(resource.getName(), resource.getFullPath().toPortableString(), NodeKind.FOLDER);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format is not consistent

} else if (resource instanceof JarEntryFile) {
PackageNode entry = new PackageNode(resource.getName(), resource.getFullPath().toPortableString(), NodeKind.FILE);
entry.setUri(ExtUtils.toUri((JarEntryFile) resource));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum NodeKind {

TYPEROOT(6),

Folder(7),
FOLDER(7),

FILE(8);

Expand Down
4 changes: 2 additions & 2 deletions src/views/dependencyExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class DependencyExplorer {
this._dependencyViewer = window.createTreeView("javaDependencyExplorer", { treeDataProvider: this._dataProvider });

window.onDidChangeActiveTextEditor((textEditor: TextEditor) => {
if (textEditor && textEditor.document && textEditor.document.languageId === "java" && Settings.syncWithFolderExplorer()) {
if (textEditor && textEditor.document && Settings.syncWithFolderExplorer()) {
this.reveal(textEditor.document.uri);
}
});
Expand Down Expand Up @@ -63,7 +63,7 @@ export class DependencyExplorer {
private visitChildren(children: DataNode[], paths: INodeData[]): void {
if (children && paths) {
for (const c of children) {
if (c.path === paths[0].path) {
if (c.path === paths[0].path && c.nodeData.name === paths[0].name) {
if (paths.length === 1) {
if (this._dependencyViewer.visible) {
this._dependencyViewer.reveal(c);
Expand Down
2 changes: 1 addition & 1 deletion src/views/folderNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export class FolderNode extends DataNode {
}

protected get iconPath(): ThemeIcon {
return ThemeIcon.Folder;
return ExplorerNode.resolveIconPath("packagefolder");
Copy link
Contributor

@yaohaizh yaohaizh Nov 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use the ThemeIcon.Folder which is the VSCode provided. To keep consistent with UI. The packagefolder is for packaging only.

}
}