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.
There is no easy way how to obtain the list of top level types declared in the java or class file. Solution: The CompilationInfo, CompilationController & WorkingCopy were extended by method: getTopLevelElements() returning the declared top level classes.
Created attachment 43201 [details] Diff file
I agree with this change. Nitpicking: javadoc in CompilationController once references CompilationInfo, while it probably should reference CompilationController. Please do not use instanceof on Elements ("if (e instanceof TypeElement)").
OK, the javadoc is fixed. The instanceof was moved from java/navigation, fixed.
Nice. A few nitpicks though: AB01: isn't getTopLevelTypes() a better name, since you return a list of TypeElements? With the proposed name one could e.g. wonder if the result also contains package elements. AB02: can't you rather return an empty list than null? I guess you want null to allow the client to detect that the CompilationController is not in the right phase. However, will the client usually care? Or, shouldn't you rather throw an exception if the CC is not in the right phase? AB03: consider returning an unmodifiable list. AB04: doesn't the ISE thrown when jfo == null deserve a message?
AB01: getTopLevelTypes - this was the original name but some people think that it implies that it returns Type not Element. AB02: No, null - wrong phase, empty list - file with no types. AB03: OK AB04: Is quite obvious, when you create JS with no file, you cannot ask for top levels. But I've added note.
Checking in apichanges.xml; /cvs/java/source/apichanges.xml,v <-- apichanges.xml new revision: 1.10; previous revision: 1.9 done Checking in nbproject/project.properties; /cvs/java/source/nbproject/project.properties,v <-- project.properties new revision: 1.20; previous revision: 1.19 done Checking in src/org/netbeans/api/java/source/CompilationController.java; /cvs/java/source/src/org/netbeans/api/java/source/CompilationController.java,v <-- CompilationController.java new revision: 1.7; previous revision: 1.6 done Checking in src/org/netbeans/api/java/source/CompilationInfo.java; /cvs/java/source/src/org/netbeans/api/java/source/CompilationInfo.java,v <-- CompilationInfo.java new revision: 1.11; previous revision: 1.10 done Checking in src/org/netbeans/api/java/source/ElementHandle.java; /cvs/java/source/src/org/netbeans/api/java/source/ElementHandle.java,v <-- ElementHandle.java new revision: 1.13; previous revision: 1.12 done Checking in src/org/netbeans/api/java/source/JavaSource.java; /cvs/java/source/src/org/netbeans/api/java/source/JavaSource.java,v <-- JavaSource.java new revision: 1.60; previous revision: 1.59 done Checking in src/org/netbeans/modules/java/source/parsing/SourceFileObject.java; /cvs/java/source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java,v <-- SourceFileObject.java new revision: 1.12; previous revision: 1.11 done Checking in src/org/netbeans/modules/java/source/resources/mime-resolver.xml; /cvs/java/source/src/org/netbeans/modules/java/source/resources/mime-resolver.xml,v <-- mime-resolver.xml new revision: 1.3; previous revision: 1.2 done Checking in src/org/netbeans/modules/java/source/usages/ClassFileUtil.java; /cvs/java/source/src/org/netbeans/modules/java/source/usages/ClassFileUtil.java,v <-- ClassFileUtil.java new revision: 1.6; previous revision: 1.5 done Checking in src/org/netbeans/modules/java/ui/Icons.java; /cvs/java/source/src/org/netbeans/modules/java/ui/Icons.java,v <-- Icons.java new revision: 1.6; previous revision: 1.5 done