Example usage for org.eclipse.jdt.internal.core CompilationUnit getType

List of usage examples for org.eclipse.jdt.internal.core CompilationUnit getType

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core CompilationUnit getType.

Prototype

@Override
public IType getType(String typeName) 

Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.PossibleMatch.java

License:Open Source License

private char[] getQualifiedName() {
    if (this.openable instanceof CompilationUnit) {
        // get file name
        String fileName = this.openable.getElementName(); // working copy on a .class file may not have a resource, so use the element name
        // get main type name
        char[] mainTypeName = Util.getNameWithoutJavaLikeExtension(fileName).toCharArray();
        CompilationUnit cu = (CompilationUnit) this.openable;
        return cu.getType(new String(mainTypeName)).getFullyQualifiedName().toCharArray();
    } else if (this.openable instanceof ClassFile) {
        String fileName = getSourceFileName();
        if (fileName == NO_SOURCE_FILE_NAME)
            return ((ClassFile) this.openable).getType().getFullyQualifiedName('.').toCharArray();

        // Class file may have a source file name with ".java" extension (see bug 73784)
        int index = Util.indexOfJavaLikeExtension(fileName);
        String simpleName = index == -1 ? fileName : fileName.substring(0, index);
        PackageFragment pkg = (PackageFragment) this.openable.getParent();
        return Util.concatWith(pkg.names, simpleName, '.').toCharArray();
    }/*w w  w  . j  av a 2 s  . co  m*/
    return null;
}