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 105618 - API review: CompilationInfo.getTopLevelElements()
Summary: API review: CompilationInfo.getTopLevelElements()
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Tomas Zezula
Depends on:
Blocks: 93100
  Show dependency tree
Reported: 2007-06-04 17:40 UTC by Tomas Zezula
Modified: 2007-06-05 14:10 UTC (History)
0 users

See Also:
Issue Type: TASK
Exception Reporter:

Diff file (5.87 KB, patch)
2007-06-04 17:43 UTC, Tomas Zezula
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Zezula 2007-06-04 17:40:14 UTC
There is no easy way how to obtain the list of top level types declared in the
java or class file.
The CompilationInfo, CompilationController & WorkingCopy were extended by method:
getTopLevelElements() returning the declared top level classes.
Comment 1 Tomas Zezula 2007-06-04 17:43:21 UTC
Created attachment 43201 [details]
Diff file
Comment 2 Jan Lahoda 2007-06-04 17:54:14 UTC
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)").
Comment 3 Tomas Zezula 2007-06-04 17:57:11 UTC
OK, the javadoc is fixed. The instanceof was moved from java/navigation, fixed.
Comment 4 Andrei Badea 2007-06-05 11:04:37 UTC
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?
Comment 5 Tomas Zezula 2007-06-05 12:58:26 UTC
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.
Comment 6 Tomas Zezula 2007-06-05 14:10:05 UTC
Checking in apichanges.xml;
/cvs/java/source/apichanges.xml,v  <--  apichanges.xml
new revision: 1.10; previous revision: 1.9
Checking in nbproject/;
/cvs/java/source/nbproject/,v  <--
new revision: 1.20; previous revision: 1.19
Checking in src/org/netbeans/api/java/source/;
new revision: 1.7; previous revision: 1.6
Checking in src/org/netbeans/api/java/source/;
/cvs/java/source/src/org/netbeans/api/java/source/,v  <--
new revision: 1.11; previous revision: 1.10
Checking in src/org/netbeans/api/java/source/;
/cvs/java/source/src/org/netbeans/api/java/source/,v  <--
new revision: 1.13; previous revision: 1.12
Checking in src/org/netbeans/api/java/source/;
/cvs/java/source/src/org/netbeans/api/java/source/,v  <--
new revision: 1.60; previous revision: 1.59
Checking in src/org/netbeans/modules/java/source/parsing/;
new revision: 1.12; previous revision: 1.11
Checking in src/org/netbeans/modules/java/source/resources/mime-resolver.xml;
 <--  mime-resolver.xml
new revision: 1.3; previous revision: 1.2
Checking in src/org/netbeans/modules/java/source/usages/;
new revision: 1.6; previous revision: 1.5
Checking in src/org/netbeans/modules/java/ui/;
/cvs/java/source/src/org/netbeans/modules/java/ui/,v  <--
new revision: 1.6; previous revision: 1.5