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

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

Introduction

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

Prototype

public ISourceType[] getSourceTypes() 

Source Link

Document

Answer the unresolved source forms for the type or null if the receiver represents a compilation unit or binary 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  ww . j  a va 2s  .co m
    }
    return null;
}