Java Code Examples for org.netbeans.api.java.source.JavaSource.Phase#ELEMENTS_RESOLVED

The following examples show how to use org.netbeans.api.java.source.JavaSource.Phase#ELEMENTS_RESOLVED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaOperationsImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
@NonNull
public Collection<? extends String> getTopLevelClasses() throws QueryException {
    try {
        if (control.toPhase(Phase.ELEMENTS_RESOLVED) != Phase.ELEMENTS_RESOLVED) {
            throw new QueryException("Cannot resolve file: " +  //NOI18N
                    Optional.ofNullable(control.getFileObject())
                    .map((fo) -> FileUtil.getFileDisplayName(fo))
                    .orElse("<unkown>"));   //NOI18N
        }
    } catch (IOException ioe) {
        throw new QueryException(ioe);
    }
    final Collection<? extends Element> topLevels = control.getTopLevelElements();
    final List<String> result = new ArrayList<String>(topLevels.size());
    for (Element topLevel : topLevels) {
        result.add(((TypeElement)topLevel).getQualifiedName().toString());
    }
    return result;
}
 
Example 2
Source File: ClassMemberNavigatorJavaSourceFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ClassMemberNavigatorJavaSourceFactory() {        
    super(
        Phase.ELEMENTS_RESOLVED,
        Priority.NORMAL,
        TaskIndexingMode.ALLOWED_DURING_SCAN,
        "text/x-java",
        "application/x-class-file");
}
 
Example 3
Source File: JavaOperationsImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private TypeElement findClass(
        @NonNull final String clz) throws QueryException {
    try {
        if (control.toPhase(Phase.ELEMENTS_RESOLVED) != Phase.ELEMENTS_RESOLVED) {
            throw new QueryException("Cannot resolve file: " +  //NOI18N
                    Optional.ofNullable(control.getFileObject())
                    .map((fo) -> FileUtil.getFileDisplayName(fo))
                    .orElse("<unkown>"));   //NOI18N
        }
    } catch (IOException ioe) {
        throw new QueryException(ioe);
    }
    return control.getElements().getTypeElement(clz);
}
 
Example 4
Source File: BeanNavigatorJavaSourceFactory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public BeanNavigatorJavaSourceFactory() {        
    super(Phase.ELEMENTS_RESOLVED, Priority.NORMAL);
}