This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Run the following code for a FileObject owned by the attached project: ------%<----- // FileObject fo final ClasspathInfo cpi = ClasspathInfo.create(fo); final ClassIndex index = cpi.getClassIndex(); JavaSource.create(cpi).runWhenScanFinished(new CancellableTask<CompilationController>() { public void cancel() { } public void run(CompilationController controller) throws Exception { System.out.println("Finding usages"); ElementHandle<TypeElement> entityHandle = ElementHandle.create(controller.getElements().getTypeElement("javax.persistence.Entity")); for (ElementHandle<TypeElement> found : index.getElements(entityHandle, EnumSet.of(SearchKind.TYPE_REFERENCES), EnumSet.of(SearchScope.SOURCE, SearchScope.DEPENDENCIES))) { System.out.println("Found " + found); } } }, true); ------%<----- No "Found" lines will be printed. It starts working if you move the "getClassIndex()" line inside the task.
Created attachment 42240 [details] Project for reproducing the issue
*** This issue has been marked as a duplicate of 104751 ***
Not exact duplicate, reopening.
Checking in src/org/netbeans/modules/java/source/usages/ClassIndexManager.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/ClassIndexManager.java,v <-- ClassIndexManager.java new revision: 1.6; previous revision: 1.5 done