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()
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: API_REVIEW_FAST
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:


Attachments
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.
Solution:
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
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