Example usage for org.eclipse.jdt.internal.compiler.util SuffixConstants SUFFIX_STRING_class

List of usage examples for org.eclipse.jdt.internal.compiler.util SuffixConstants SUFFIX_STRING_class

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.util SuffixConstants SUFFIX_STRING_class.

Prototype

String SUFFIX_STRING_class

To view the source code for org.eclipse.jdt.internal.compiler.util SuffixConstants SUFFIX_STRING_class.

Click Source Link

Usage

From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFile.java

License:Open Source License

public String getElementName() {
    return this.name + SuffixConstants.SUFFIX_STRING_class;
}

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

License:Open Source License

public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant,
        IJavaSearchScope scope, IProgressMonitor progressMonitor) {
    IPackageFragmentRoot root = (IPackageFragmentRoot) this.localVariable
            .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
    String documentPath;//from  w  w w.jav a2s .c  o  m
    String relativePath;
    if (root.isArchive()) {
        IType type = (IType) this.localVariable.getAncestor(IJavaElement.TYPE);
        relativePath = (type.getFullyQualifiedName('$')).replace('.', '/')
                + SuffixConstants.SUFFIX_STRING_class;
        documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
    } else {
        IPath path = this.localVariable.getPath();
        documentPath = path.toString();
        relativePath = Util.relativePath(path, 1/*remove project segment*/);
    }

    if (scope instanceof JavaSearchScope) {
        JavaSearchScope javaSearchScope = (JavaSearchScope) scope;
        // Get document path access restriction from java search scope
        // Note that requestor has to verify if needed whether the document violates the access restriction or not
        AccessRuleSet access = javaSearchScope.getAccessRuleSet(relativePath, index.containerPath);
        if (access != JavaSearchScope.NOT_ENCLOSED) { // scope encloses the path
            if (!requestor.acceptIndexMatch(documentPath, this, participant, access))
                throw new OperationCanceledException();
        }
    } else if (scope.encloses(documentPath)) {
        if (!requestor.acceptIndexMatch(documentPath, this, participant, null))
            throw new OperationCanceledException();
    }
}

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

License:Open Source License

/**
 * Creates an IType from the given simple top level type name.
 *//*  w  w  w.  j a v  a  2 s .c o  m*/
protected IType createTypeHandle(String simpleTypeName) {
    Openable openable = this.currentPossibleMatch.openable;
    if (openable instanceof CompilationUnit)
        return ((CompilationUnit) openable).getType(simpleTypeName);

    IType binaryType = ((ClassFile) openable).getType();
    String binaryTypeQualifiedName = binaryType.getTypeQualifiedName();
    if (simpleTypeName.equals(binaryTypeQualifiedName))
        return binaryType; // answer only top-level types, sometimes the classFile is for a member/local type

    // type name may be null for anonymous (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=164791)
    String classFileName = simpleTypeName.length() == 0 ? binaryTypeQualifiedName : simpleTypeName;
    IClassFile classFile = binaryType.getPackageFragment()
            .getClassFile(classFileName + SuffixConstants.SUFFIX_STRING_class);
    return classFile.getType();
}

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

License:Open Source License

public void findIndexMatches(Index index, IndexQueryRequestor requestor, SearchParticipant participant,
        IJavaSearchScope scope, IProgressMonitor progressMonitor) {
    IPackageFragmentRoot root = (IPackageFragmentRoot) this.typeParameter
            .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
    String documentPath;/*from   w w  w.j  a v  a2s  .c  om*/
    String relativePath;
    if (root.isArchive()) {
        IType type = (IType) this.typeParameter.getAncestor(IJavaElement.TYPE);
        relativePath = (type.getFullyQualifiedName('$')).replace('.', '/')
                + SuffixConstants.SUFFIX_STRING_class;
        documentPath = root.getPath() + IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR + relativePath;
    } else {
        IPath path = this.typeParameter.getPath();
        documentPath = path.toString();
        relativePath = Util.relativePath(path, 1/*remove project segment*/);
    }

    if (scope instanceof JavaSearchScope) {
        JavaSearchScope javaSearchScope = (JavaSearchScope) scope;
        // Get document path access restriction from java search scope
        // Note that requestor has to verify if needed whether the document violates the access restriction or not
        AccessRuleSet access = javaSearchScope.getAccessRuleSet(relativePath, index.containerPath);
        if (access != JavaSearchScope.NOT_ENCLOSED) { // scope encloses the path
            if (!requestor.acceptIndexMatch(documentPath, this, participant, access))
                throw new OperationCanceledException();
        }
    } else if (scope.encloses(documentPath)) {
        if (!requestor.acceptIndexMatch(documentPath, this, participant, null))
            throw new OperationCanceledException();
    }
}

From source file:com.codenvy.ide.ext.java.server.internal.core.util.JavaElementFinder.java

License:Open Source License

public void consumeLocalType(char[] uniqueKey) {
    if (this.element == null)
        return;//w  ww  .ja  v a  2  s . co m
    if (this.element instanceof BinaryType) {
        int lastSlash = CharOperation.lastIndexOf('/', uniqueKey);
        int end = CharOperation.indexOf(';', uniqueKey, lastSlash + 1);
        char[] localName = CharOperation.subarray(uniqueKey, lastSlash + 1, end);
        IPackageFragment pkg = (IPackageFragment) this.element.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
        this.element = pkg.getClassFile(new String(localName) + SuffixConstants.SUFFIX_STRING_class);
    } else {
        int firstDollar = CharOperation.indexOf('$', uniqueKey);
        int end = CharOperation.indexOf('$', uniqueKey, firstDollar + 1);
        if (end == -1)
            end = CharOperation.indexOf(';', uniqueKey, firstDollar + 1);
        char[] sourceStart = CharOperation.subarray(uniqueKey, firstDollar + 1, end);
        int position = Integer.parseInt(new String(sourceStart));
        try {
            this.element = ((ITypeRoot) this.element.getOpenable()).getElementAt(position);
        } catch (JavaModelException e) {
            this.exception = e;
        }
    }
}

From source file:org.eclipse.che.jdt.core.ToolFactory.java

License:Open Source License

/**
 * Create a default classfile reader, able to expose the internal representation of a given classfile
 * according to the decoding flag used to initialize the reader.
 * Answer null if the file named zipFileName doesn't represent a valid zip file or if the zipEntryName
 * is not a valid entry name for the specified zip file or if the bytes don't represent a valid
 * .class file according to the JVM specifications.
 * <p/>/*from  w  w  w.  ja v a 2 s  .c om*/
 * The decoding flags are described in IClassFileReader.
 *
 * @param zipFileName
 *         the name of the zip file
 * @param zipEntryName
 *         the name of the entry in the zip file to be read
 * @param decodingFlag
 *         the flag used to decode the class file reader.
 * @return a default classfile reader
 * @see org.eclipse.jdt.core.util.IClassFileReader
 */
public static IClassFileReader createDefaultClassFileReader(String zipFileName, String zipEntryName,
        int decodingFlag) {
    ZipFile zipFile = null;
    try {
        if (JavaModelManager.ZIP_ACCESS_VERBOSE) {
            System.out.println("(" + Thread.currentThread()
                    + ") [ToolFactory.createDefaultClassFileReader()] Creating ZipFile on " + zipFileName); //$NON-NLS-1$   //$NON-NLS-2$
        }
        zipFile = new ZipFile(zipFileName);
        ZipEntry zipEntry = zipFile.getEntry(zipEntryName);
        if (zipEntry == null) {
            return null;
        }
        if (!zipEntryName.toLowerCase().endsWith(SuffixConstants.SUFFIX_STRING_class)) {
            return null;
        }
        byte classFileBytes[] = Util.getZipEntryByteContent(zipEntry, zipFile);
        return new ClassFileReader(classFileBytes, decodingFlag);
    } catch (ClassFormatException e) {
        return null;
    } catch (IOException e) {
        return null;
    } finally {
        if (zipFile != null) {
            try {
                zipFile.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
}