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

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

Introduction

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

Prototype

public IBinaryType getBinaryType() 

Source Link

Document

Answer the resolved binary form for the type or null if the receiver represents a compilation unit or source 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);
        }/*  w  w  w . j a  v a  2s.  c  om*/
    }
    return null;
}