diff --git a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java index e2f35f3b..1bb2e99b 100644 --- a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java +++ b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java @@ -303,10 +303,8 @@ private static List getProjectChildren(PackageParams query, IProgre List result = visitor.getNodes(); // Invisible project will always have the referenced libraries entry - if (!ProjectUtils.isVisibleProject(project)) { + if (!ProjectUtils.isVisibleProject(project) || hasReferencedLibraries) { result.add(PackageNode.REFERENCED_LIBRARIES_CONTAINER); - } else if (hasReferencedLibraries) { - result.add(PackageNode.IMMUTABLE_REFERENCED_LIBRARIES_CONTAINER); } return result; } @@ -589,7 +587,7 @@ public static IProject getProject(String projectUri) { } // This must be an invisible project. - // There might be more than one way to access it, but all containers should link to the same project. + // There might be more than one way to access it, but all containers should link to the same project. return containers[0].getProject(); } } diff --git a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/model/PackageNode.java b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/model/PackageNode.java index f945bfd0..7f146d8d 100644 --- a/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/model/PackageNode.java +++ b/jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/model/PackageNode.java @@ -69,13 +69,9 @@ public class PackageNode { public static final String REFERENCED_LIBRARIES_PATH = "REFERENCED_LIBRARIES_PATH"; private static final String REFERENCED_LIBRARIES_CONTAINER_NAME = "Referenced Libraries"; - private static final String IMMUTABLE_REFERENCED_LIBRARIES_CONTAINER_NAME = "Referenced Libraries (Read-only)"; public static final ContainerNode REFERENCED_LIBRARIES_CONTAINER = new ContainerNode( REFERENCED_LIBRARIES_CONTAINER_NAME, REFERENCED_LIBRARIES_PATH, NodeKind.CONTAINER, IClasspathEntry.CPE_CONTAINER); - public static final ContainerNode IMMUTABLE_REFERENCED_LIBRARIES_CONTAINER = new ContainerNode( - IMMUTABLE_REFERENCED_LIBRARIES_CONTAINER_NAME, - REFERENCED_LIBRARIES_PATH, NodeKind.CONTAINER, IClasspathEntry.CPE_CONTAINER); /** * Nature Id for the IProject. diff --git a/src/views/containerNode.ts b/src/views/containerNode.ts index 9d7b0691..0245514c 100644 --- a/src/views/containerNode.ts +++ b/src/views/containerNode.ts @@ -27,7 +27,8 @@ export class ContainerNode extends DataNode { return ContainerType.Maven; } else if (containerPath.startsWith(ContainerPath.Gradle)) { return ContainerType.Gradle; - } else if (containerPath.startsWith(ContainerPath.ReferencedLibrary)) { + } else if (containerPath.startsWith(ContainerPath.ReferencedLibrary) && this._project.isUnmanagedFolder()) { + // currently, we only support editing referenced libraries in unmanaged folders return ContainerType.ReferencedLibrary; } return ContainerType.Unknown; diff --git a/src/views/packageRootNode.ts b/src/views/packageRootNode.ts index a4951a28..63de2c65 100644 --- a/src/views/packageRootNode.ts +++ b/src/views/packageRootNode.ts @@ -59,7 +59,8 @@ export class PackageRootNode extends DataNode { if (data.entryKind === PackageRootKind.K_BINARY) { contextValue = Explorer.ContextValueType.Jar; const parent = this.getParent(); - if (parent.path?.startsWith("REFERENCED_LIBRARIES_PATH")) { + // currently, we only support editing referenced libraries in unmanaged folders + if (parent.path?.startsWith("REFERENCED_LIBRARIES_PATH") && this._project.isUnmanagedFolder()) { contextValue += "+referencedLibrary"; } return contextValue; diff --git a/test/suite/contextValue.test.ts b/test/suite/contextValue.test.ts index 3cb04022..34639bbc 100644 --- a/test/suite/contextValue.test.ts +++ b/test/suite/contextValue.test.ts @@ -182,7 +182,7 @@ const referencedLibrariesContainer: ContainerNode = new ContainerNode({ uri: Uri.file(__dirname).toString(), kind: NodeKind.Container, path: "REFERENCED_LIBRARIES_PATH", -}, mavenProject, mavenProject); +}, mavenProject, unmanagedFolder); const sourceRoot: PackageRootNode = new PackageRootNode({ name: "src/main/java", @@ -220,7 +220,7 @@ const referencedLibraryJar: PackageRootNode = new PackageRootNode({ uri: Uri.file(__dirname).toString(), kind: NodeKind.PackageRoot, entryKind: PackageRootKind.K_BINARY, -} as INodeData, referencedLibrariesContainer, mavenProject); +} as INodeData, referencedLibrariesContainer, unmanagedFolder); const sourcePackage: PackageNode = new PackageNode({ name: "com.microsoft.java",