Example usage for org.eclipse.jdt.internal.compiler.env NameEnvironmentAnswer isSourceType

List of usage examples for org.eclipse.jdt.internal.compiler.env NameEnvironmentAnswer isSourceType

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.env NameEnvironmentAnswer isSourceType.

Prototype

public boolean isSourceType() 

Source Link

Document

Answer whether the receiver contains the unresolved source form of the type.

Usage

From source file:com.codenvy.ide.ext.java.SearchableEnvironmentTest.java

License:Open Source License

private String processAnswer(NameEnvironmentAnswer answer, IJavaProject project, INameEnvironment environment)
        throws JavaModelException {
    if (answer == null)
        return null;
    if (answer.isBinaryType()) {
        IBinaryType binaryType = answer.getBinaryType();
        return BinaryTypeConvector.toJsonBinaryType(binaryType);
    } else if (answer.isCompilationUnit()) {
        ICompilationUnit compilationUnit = answer.getCompilationUnit();
        return getSourceTypeInfo(project, environment, compilationUnit);
    } else if (answer.isSourceType()) {
        ISourceType[] sourceTypes = answer.getSourceTypes();
        if (sourceTypes.length == 1) {
            ISourceType sourceType = sourceTypes[0];
            SourceTypeElementInfo elementInfo = (SourceTypeElementInfo) sourceType;
            IType handle = elementInfo.getHandle();
            org.eclipse.jdt.core.ICompilationUnit unit = handle.getCompilationUnit();
            return getSourceTypeInfo(project, environment, (ICompilationUnit) unit);
        }/*from   w w  w  .j  av  a 2 s  .  c  o m*/
    }
    return null;
}