@@ -88,7 +88,7 @@ public class PackageCommand {
8888 */
8989 public static List <PackageNode > getChildren (List <Object > arguments , IProgressMonitor pm ) throws CoreException {
9090 if (arguments == null || arguments .size () < 1 ) {
91- throw new IllegalArgumentException ("Should have at least one arugments for getChildren" );
91+ throw new IllegalArgumentException ("Should have at least one arugment for getChildren" );
9292 }
9393 PackageParams params = gson .fromJson (gson .toJson (arguments .get (0 )), PackageParams .class );
9494
@@ -100,6 +100,48 @@ public static List<PackageNode> getChildren(List<Object> arguments, IProgressMon
100100 return result ;
101101 }
102102
103+ /**
104+ * Resolve the path for Java file URI
105+ *
106+ * @param arguments
107+ * List of the arguments which contain one entry of the target
108+ * compilation unit URI.
109+ *
110+ * @return the list of the path
111+ * @throws CoreException
112+ */
113+ public static List <PackageNode > resolvePath (List <Object > arguments , IProgressMonitor pm ) throws CoreException {
114+ if (arguments == null || arguments .size () < 1 ) {
115+ throw new IllegalArgumentException ("Should have one arugment for resolvePath" );
116+ }
117+ String typeRootUri = (String ) arguments .get (0 );
118+
119+ List <PackageNode > result = new ArrayList <>();
120+
121+ ICompilationUnit cu = JDTUtils .resolveCompilationUnit (typeRootUri );
122+
123+ // Add project node:
124+ IProject proj = cu .getJavaProject ().getProject ();
125+ PackageNode projectNode = new PackageNode (proj .getName (), proj .getFullPath ().toPortableString (), NodeKind .PROJECT );
126+ projectNode .setUri (proj .getLocationURI ().toString ());
127+ result .add (projectNode );
128+
129+ IPackageFragment packageFragment = (IPackageFragment ) cu .getParent ();
130+ String packageName = packageFragment .isDefaultPackage () ? DEFAULT_PACKAGE_DISPLAYNAME : packageFragment .getElementName ();
131+ PackageNode packageNode = new PackageNode (packageName , packageFragment .getPath ().toPortableString (), NodeKind .PACKAGE );
132+ IPackageFragmentRoot pkgRoot = (IPackageFragmentRoot ) packageFragment .getParent ();
133+ PackageNode rootNode = new PackageRootNode (ExtUtils .removeProjectSegment (cu .getJavaProject ().getElementName (), pkgRoot .getPath ()).toPortableString (),
134+ pkgRoot .getPath ().toPortableString (), NodeKind .PACKAGEROOT , pkgRoot .getKind ());
135+ result .add (rootNode );
136+ result .add (packageNode );
137+
138+ PackageNode item = new TypeRootNode (cu .getElementName (), cu .getPath ().toPortableString (), NodeKind .TYPEROOT , TypeRootNode .K_SOURCE );
139+ item .setUri (JDTUtils .toURI (cu ));
140+ result .add (item );
141+
142+ return result ;
143+ }
144+
103145 /**
104146 * Get the class path container list.
105147 */
0 commit comments