11
11
12
12
package com .microsoft .jdtls .ext .core .model ;
13
13
14
+ import java .net .URI ;
14
15
import java .util .List ;
15
16
16
17
import org .eclipse .core .resources .IFile ;
@@ -133,11 +134,11 @@ public static PackageNode createNodeForPackageFragmentRoot(IPackageFragmentRoot
133
134
if (entry .getEntryKind () == IClasspathEntry .CPE_VARIABLE ) {
134
135
return createNodeForClasspathVariable (entry );
135
136
} else {
136
- return new PackageRootNode (pkgRoot . getElementName () , pkgRoot .getPath (). toPortableString () , NodeKind .PACKAGEROOT , pkgRoot . getKind () );
137
+ return new PackageRootNode (pkgRoot , pkgRoot .getElementName () , NodeKind .PACKAGEROOT );
137
138
}
138
139
} else {
139
- return new PackageRootNode (ExtUtils . removeProjectSegment ( pkgRoot . getJavaProject (). getElementName (), pkgRoot . getPath ()). toPortableString () ,
140
- pkgRoot .getPath ().toPortableString (), NodeKind .PACKAGEROOT , pkgRoot . getKind () );
140
+ return new PackageRootNode (pkgRoot ,
141
+ ExtUtils . removeProjectSegment ( pkgRoot .getJavaProject (). getElementName (), pkgRoot . getPath ()) .toPortableString (), NodeKind .PACKAGEROOT );
141
142
}
142
143
}
143
144
@@ -161,17 +162,21 @@ public static PackageNode createNodeForClasspathEntry(IClasspathEntry classpathE
161
162
container = JavaCore .getClasspathContainer (entry .getPath (), javaProject );
162
163
}
163
164
if (container != null ) {
164
- switch (nodeKind ) {
165
- case CONTAINER :
166
- return new ContainerNode (container .getDescription (), container .getPath ().toPortableString (), nodeKind , entry .getEntryKind ());
167
- case PACKAGEROOT :
165
+ PackageNode node = null ;
166
+ if (nodeKind == NodeKind .CONTAINER ) {
167
+ node = new ContainerNode (container .getDescription (), container .getPath ().toPortableString (), nodeKind , entry .getEntryKind ());
168
+ final URI containerURI = ExtUtils .getContainerURI (javaProject , container );
169
+ node .setUri (containerURI != null ? containerURI .toString () : null );
170
+ } else if (nodeKind == NodeKind .PACKAGEROOT ) { // ClasspathEntry for referenced jar files
168
171
// Use package name as package root name
169
172
String [] pathSegments = container .getPath ().segments ();
170
- return new PackageRootNode (pathSegments [pathSegments .length - 1 ], container .getPath ().toPortableString (), nodeKind ,
171
- IPackageFragmentRoot .K_BINARY );
172
- default :
173
- return null ;
173
+ node = new PackageRootNode (
174
+ pathSegments [pathSegments .length - 1 ],
175
+ container .getPath ().toPortableString (),
176
+ container .getPath ().toFile ().toURI ().toString (),
177
+ nodeKind , IPackageFragmentRoot .K_BINARY );
174
178
}
179
+ return node ;
175
180
}
176
181
} catch (CoreException e ) {
177
182
JdtlsExtActivator .logException ("Problems when convert classpath entry to package node " , e );
@@ -201,7 +206,8 @@ public static PackageNode createNodeForClasspathVariable(IClasspathEntry classpa
201
206
IClasspathEntry entry = JavaCore .getResolvedClasspathEntry (classpathEntry );
202
207
String name = classpathEntry .getPath ().toPortableString ();
203
208
String path = entry .getPath ().toPortableString ();
204
- return new PackageRootNode (name , path , NodeKind .PACKAGEROOT , IPackageFragmentRoot .K_BINARY );
209
+ String uri = entry .getPath ().toFile ().toURI ().toString ();
210
+ return new PackageRootNode (name , path , uri , NodeKind .PACKAGEROOT , IPackageFragmentRoot .K_BINARY );
205
211
}
206
212
207
213
public String getName () {
0 commit comments