|
org.netbeans.modules.java.source 0.80.1 17 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.netbeans.api.java.source.SourceUtils
public class SourceUtils
Method Summary | |
---|---|
static boolean |
checkTypesAssignable(CompilationInfo info,
TypeMirror from,
TypeMirror to)
|
static List<? extends Completion> |
getAttributeValueCompletions(CompilationInfo info,
Element element,
AnnotationMirror annotation,
ExecutableElement member,
String userText)
Returns a list of completions for an annotation attribute value suggested by annotation processors. |
static TypeMirror |
getBound(WildcardType wildcardType)
|
static Set<URL> |
getDependentRoots(URL root)
Returns the dependent source path roots for given source root. |
static TypeElement |
getEnclosingTypeElement(Element element)
Deprecated. use ElementUtilities.enclosingTypeElement(javax.lang.model.element.Element) |
static FileObject |
getFile(Element element,
ClasspathInfo cpInfo)
Deprecated. use getFile(ElementHandle, ClasspathInfo) |
static FileObject |
getFile(ElementHandle<? extends Element> handle,
ClasspathInfo cpInfo)
Returns a FileObject of the source file in which the handle is declared. |
static URL |
getJavadoc(Element element,
ClasspathInfo cpInfo)
Finds URL of a javadoc page for given element when available. |
static TokenSequence<org.netbeans.api.java.lexer.JavaTokenId> |
getJavaTokenSequence(TokenHierarchy hierarchy,
int offset)
|
static Collection<ElementHandle<TypeElement>> |
getMainClasses(FileObject fo)
Returns classes declared in the given source file which have the main method. |
static Collection<ElementHandle<TypeElement>> |
getMainClasses(FileObject[] sourceRoots)
Returns classes declared under the given source roots which have the main method. |
static TypeElement |
getOutermostEnclosingTypeElement(Element element)
|
static boolean |
isMainClass(String qualifiedName,
ClasspathInfo cpInfo)
Returns true when the class contains main method. |
static boolean |
isMainClass(String qualifiedName,
ClasspathInfo cpInfo,
boolean optimistic)
Returns true when the class contains main method. |
static boolean |
isMainMethod(ExecutableElement method)
Returns true if the method is a main method |
static boolean |
isScanInProgress()
Tests whether the initial scan is in progress. |
static WildcardType |
resolveCapturedType(TypeMirror type)
|
static String |
resolveImport(CompilationInfo info,
TreePath context,
String fqn)
Resolve full qualified name in the given context. |
static void |
waitScanFinished()
Deprecated. use JavaSource.runWhenScanFinished(org.netbeans.api.java.source.Task |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static TokenSequence<org.netbeans.api.java.lexer.JavaTokenId> getJavaTokenSequence(TokenHierarchy hierarchy, int offset)
public static boolean checkTypesAssignable(CompilationInfo info, TypeMirror from, TypeMirror to)
public static TypeMirror getBound(WildcardType wildcardType)
public static List<? extends Completion> getAttributeValueCompletions(CompilationInfo info, Element element, AnnotationMirror annotation, ExecutableElement member, String userText)
info
- the CompilationInfo used to resolve annotation processorselement
- the element being annotatedannotation
- the (perhaps partial) annotation being applied to the elementmember
- the annotation member to return possible completions foruserText
- source code text to be completed
@Deprecated public static TypeElement getEnclosingTypeElement(Element element) throws IllegalArgumentException
ElementUtilities.enclosingTypeElement(javax.lang.model.element.Element)
IllegalArgumentException
- if the provided element is a package elementpublic static TypeElement getOutermostEnclosingTypeElement(Element element)
public static String resolveImport(CompilationInfo info, TreePath context, String fqn) throws NullPointerException, IOException
info
passed to this method is not an instance of WorkingCopy
,
missing import statement is added from a separate modification task executed asynchronously.
info
- CompilationInfo over which the method should workcontext
- in which the fully qualified should be resolvedfqn
- the fully qualified name to resolve
NullPointerException
IOException
public static FileObject getFile(Element element, ClasspathInfo cpInfo)
getFile(ElementHandle, ClasspathInfo)
FileObject
in which the Element is defined.
element
- for which the FileObject
should be locatedcpInfo
- the classpaths context
FileObject
or null if it cannot be
foundpublic static FileObject getFile(ElementHandle<? extends Element> handle, ClasspathInfo cpInfo)
FileObject
of the source file in which the handle is declared.
handle
- to find the FileObject
forcpInfo
- classpaths for resolving handle
FileObject
or null when the source file cannot be foundpublic static URL getJavadoc(Element element, ClasspathInfo cpInfo)
URL
of a javadoc page for given element when available. This method
uses JavadocForBinaryQuery
to find the javadoc page for the give element.
For PackageElement
it returns the package-summary.html for given package.
element
- to find the Javadoc forcpInfo
- classpaths used to resolve (currently unused)
public static boolean isScanInProgress()
public static void waitScanFinished() throws InterruptedException
JavaSource.runWhenScanFinished(org.netbeans.api.java.source.Task, boolean)
InterruptedException
- is thrown when the waiting thread is interrupted.public static Set<URL> getDependentRoots(URL root)
root
- to find the dependent roots for
Set
of URL
s containing at least the
incoming root, never returns null.public static Collection<ElementHandle<TypeElement>> getMainClasses(FileObject fo)
fo
- source file
IllegalArgumentException
- when file does not exist or is not a java source file.public static boolean isMainClass(String qualifiedName, ClasspathInfo cpInfo)
qualifiedName
- the fully qualified name of classcpInfo
- the classpath used to resolve the class
public static boolean isMainClass(String qualifiedName, ClasspathInfo cpInfo, boolean optimistic)
qualifiedName
- the fully qualified name of classcpInfo
- the classpath used to resolve the classoptimistic
- when true does only index check without parsing the file.
The optimistic check is faster but it works only for source file not for binaries
for which index does not exist. It also does not handle inheritance of the main method.
public static boolean isMainMethod(ExecutableElement method)
method
- to be checked
public static Collection<ElementHandle<TypeElement>> getMainClasses(FileObject[] sourceRoots)
sourceRoots
- the source roots
public static WildcardType resolveCapturedType(TypeMirror type)
|
org.netbeans.modules.java.source 0.80.1 17 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |