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.

Bug 103554 - getElements() returns empty result when ClassIndex obtained during intial scan
Summary: getElements() returns empty result when ClassIndex obtained during intial scan
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords:
Depends on:
Blocks: 95534
  Show dependency tree
 
Reported: 2007-05-09 12:55 UTC by Andrei Badea
Modified: 2007-07-03 09:25 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Project for reproducing the issue (11.65 KB, application/x-compressed)
2007-05-09 12:58 UTC, Andrei Badea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrei Badea 2007-05-09 12:55:19 UTC
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.
Comment 1 Andrei Badea 2007-05-09 12:58:27 UTC
Created attachment 42240 [details]
Project for reproducing the issue
Comment 2 Tomas Zezula 2007-05-29 07:51:29 UTC

*** This issue has been marked as a duplicate of 104751 ***
Comment 3 Tomas Zezula 2007-05-30 12:28:12 UTC
Not exact duplicate, reopening.
Comment 4 Tomas Zezula 2007-07-03 09:25:06 UTC
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