Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -14,7 +14,6 @@
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
Expand All @@ -34,6 +33,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.apache.commons.io.FilenameUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
Expand All @@ -56,7 +56,6 @@
import org.eclipse.jdt.ls.core.internal.managers.UpdateClasspathJob;
import org.eclipse.jdt.ls.core.internal.preferences.Preferences.ReferencedLibraries;

import com.microsoft.jdtls.ext.core.model.NodeKind;
import com.microsoft.jdtls.ext.core.model.PackageNode;
import org.eclipse.lsp4j.jsonrpc.json.adapters.CollectionTypeAdapter;
import org.eclipse.lsp4j.jsonrpc.json.adapters.EnumTypeAdapter;
Expand Down Expand Up @@ -90,15 +89,15 @@ public static List<PackageNode> listProjects(List<Object> arguments, IProgressMo

IProject[] projects = getWorkspaceRoot().getProjects();
ArrayList<PackageNode> children = new ArrayList<>();
List<IPath> paths = Arrays.asList(workspacePath);
for (IProject project : projects) {
if (!ProjectUtils.isJavaProject(project)) {
if (!project.isAccessible() || !ProjectUtils.isJavaProject(project) || Objects.equals(project, JavaLanguageServerPlugin.getProjectsManager().getDefaultProject())) {
continue;
}
if (project.exists() && (ResourceUtils.isContainedIn(project.getLocation(), paths) || Objects.equals(project.getName(), invisibleProjectName))) {
PackageNode projectNode = PackageNode.createNodeForProject(JavaCore.create(project));
children.add(projectNode);
PackageNode projectNode = PackageNode.createNodeForProject(JavaCore.create(project));
if (Objects.equals(project.getName(), invisibleProjectName)) {
projectNode.setDisplayName(FilenameUtils.getBaseName(workspaceUri));
}
children.add(projectNode);
}
return children;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public class PackageNode {
*/
private String name;

/**
* The display name of the node
*/
private String displayName;

/**
* The module name of the PackageNode for Java 9 and above
*/
Expand Down Expand Up @@ -275,6 +280,10 @@ public String getName() {
return name;
}

public void setDisplayName(String displayName) {
this.displayName = displayName;
}

public void setModuleName(String moduleName) {
this.moduleName = moduleName;
}
Expand Down
1 change: 1 addition & 0 deletions src/java/nodeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export enum TypeKind {
}

export interface INodeData {
displayName?: string;
name: string;
moduleName?: string;
path?: string;
Expand Down
5 changes: 4 additions & 1 deletion src/views/dataNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export abstract class DataNode extends ExplorerNode {

public getTreeItem(): TreeItem | Promise<TreeItem> {
if (this._nodeData) {
const item = new TreeItem(this._nodeData.name, this.hasChildren() ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None);
const item = new TreeItem(
this._nodeData.displayName || this._nodeData.name,
this.hasChildren() ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None,
);
item.description = this.description;
item.iconPath = this.iconPath;
item.command = this.command;
Expand Down