Skip to content

Commit 25ebb67

Browse files
authored
Add jar attribute support. (#152)
1 parent bfa9fcb commit 25ebb67

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/PackageCommand.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.eclipse.core.runtime.Path;
3737
import org.eclipse.core.runtime.Status;
3838
import org.eclipse.jdt.core.IClassFile;
39+
import org.eclipse.jdt.core.IClasspathAttribute;
3940
import org.eclipse.jdt.core.IClasspathEntry;
4041
import org.eclipse.jdt.core.IJarEntryResource;
4142
import org.eclipse.jdt.core.IJavaElement;
@@ -279,12 +280,21 @@ private static List<PackageNode> getPackageFragmentRoots(PackageParams query, IP
279280
if (fragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) {
280281
displayName = ExtUtils.removeProjectSegment(javaProject.getElementName(), fragmentRoot.getPath()).toPortableString();
281282
}
282-
PackageNode node = new PackageRootNode(displayName, fragmentRoot.getPath().toPortableString(), NodeKind.PACKAGEROOT,
283+
PackageRootNode node = new PackageRootNode(displayName, fragmentRoot.getPath().toPortableString(), NodeKind.PACKAGEROOT,
283284
fragmentRoot.getKind());
284285
children.add(node);
285286
if (fragmentRoot instanceof JrtPackageFragmentRoot) {
286287
node.setModuleName(fragmentRoot.getModuleDescription().getElementName());
287288
}
289+
290+
IClasspathEntry resolvedClasspathEntry = fragmentRoot.getResolvedClasspathEntry();
291+
if (resolvedClasspathEntry != null) {
292+
Map<String, String> attributes = new HashMap<>();
293+
for (IClasspathAttribute attribute : resolvedClasspathEntry.getExtraAttributes()) {
294+
attributes.put(attribute.getName(), attribute.getValue());
295+
}
296+
node.setAttributes(attributes);
297+
}
288298
}
289299
return children;
290300
} else if (query.getPath().equals(PackageNode.REFERENCED_LIBRARIES_PATH)) {

jdtls.ext/com.microsoft.jdtls.ext.core/src/com/microsoft/jdtls/ext/core/model/PackageRootNode.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111

1212
package com.microsoft.jdtls.ext.core.model;
1313

14+
import java.util.Map;
15+
1416
public class PackageRootNode extends PackageNode {
1517

1618
private int entryKind;
1719

20+
private Map<String, String> attributes;
21+
1822
public PackageRootNode(String name, String path, NodeKind kind, int entryKind) {
1923
super(name, path, kind);
2024
this.entryKind = entryKind;
@@ -23,4 +27,12 @@ public PackageRootNode(String name, String path, NodeKind kind, int entryKind) {
2327
public int getEntryType() {
2428
return this.entryKind;
2529
}
30+
31+
public void setAttributes(Map<String, String> attributes) {
32+
this.attributes = attributes;
33+
}
34+
35+
public Map<String, String> getAttributes() {
36+
return this.attributes;
37+
}
2638
}

src/java/packageRootNodeData.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ export enum PackageRootKind {
1818

1919
export interface IPackageRootNodeData extends INodeData {
2020
entryKind: PackageRootKind;
21+
22+
attributes: Map<string, string>;
2123
}

0 commit comments

Comments
 (0)