@@ -598,43 +598,14 @@ private static void extractDetailedClassInfo(org.eclipse.jdt.core.IType type, Li
598598 }
599599 }
600600
601+ // Helper method: Get fully qualified class name (used as identifier instead of file URI)
601602 private static String getTypeUri (org .eclipse .jdt .core .IType type ) {
602603 try {
603- // Get the resource where the type is located
604- IResource resource = type .getResource ();
605- if (resource != null && resource .exists ()) {
606- // Get the complete path of the file
607- IPath location = resource .getLocation ();
608- if (location != null ) {
609- // 转换为 URI 格式
610- return location .toFile ().toURI ().toString ();
611- }
612-
613- // If unable to get physical path, use workspace relative path
614- String workspacePath = resource .getFullPath ().toString ();
615- IWorkspaceRoot root = ResourcesPlugin .getWorkspace ().getRoot ();
616- IPath rootLocation = root .getLocation ();
617- if (rootLocation != null ) {
618- IPath fullPath = rootLocation .append (workspacePath );
619- return fullPath .toFile ().toURI ().toString ();
620- }
621- }
622-
623- // As a fallback, try to get from compilation unit
624- org .eclipse .jdt .core .ICompilationUnit compilationUnit = type .getCompilationUnit ();
625- if (compilationUnit != null ) {
626- IResource cuResource = compilationUnit .getResource ();
627- if (cuResource != null && cuResource .exists ()) {
628- IPath cuLocation = cuResource .getLocation ();
629- if (cuLocation != null ) {
630- return cuLocation .toFile ().toURI ().toString ();
631- }
632- }
633- }
634-
635- return null ;
604+ // Return the fully qualified class name instead of file URI
605+ // This matches the import statement format like "com.acme.user.UserService"
606+ return type .getFullyQualifiedName ();
636607 } catch (Exception e ) {
637- JdtlsExtActivator .logException ("Error getting type URI for: " + type .getElementName (), e );
608+ JdtlsExtActivator .logException ("Error getting type name for: " + type .getElementName (), e );
638609 return null ;
639610 }
640611 }
0 commit comments