Example usage for org.eclipse.jdt.internal.core.builder ReferenceCollection internSimpleNames

List of usage examples for org.eclipse.jdt.internal.core.builder ReferenceCollection internSimpleNames

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.builder ReferenceCollection internSimpleNames.

Prototype

public static char[][] internSimpleNames(char[][] simpleNames, boolean removeWellKnown) 

Source Link

Document

Use a flyweight cache for the char arrays to avoid duplicated arrays with the same contents.

Usage

From source file:org.eclipse.jdt.internal.core.builder.IncrementalImageBuilder.java

License:Open Source License

protected void addAffectedSourceFiles(StringSet qualifiedSet, StringSet simpleSet, StringSet rootSet,
        StringSet affectedTypes) {//from  w  w  w  .  java 2 s.  c om
    // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are just 'X'
    char[][][] internedQualifiedNames = ReferenceCollection.internQualifiedNames(qualifiedSet);
    // if a well known qualified name was found then we can skip over these
    if (internedQualifiedNames.length < qualifiedSet.elementSize)
        internedQualifiedNames = null;
    char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(simpleSet, true);
    // if a well known name was found then we can skip over these
    if (internedSimpleNames.length < simpleSet.elementSize)
        internedSimpleNames = null;
    char[][] internedRootNames = ReferenceCollection.internSimpleNames(rootSet, false);

    Object[] keyTable = this.newState.references.keyTable;
    Object[] valueTable = this.newState.references.valueTable;
    next: for (int i = 0, l = valueTable.length; i < l; i++) {
        String typeLocator = (String) keyTable[i];
        if (typeLocator != null) {
            if (affectedTypes != null && !affectedTypes.includes(typeLocator))
                continue next;
            ReferenceCollection refs = (ReferenceCollection) valueTable[i];
            if (refs.includes(internedQualifiedNames, internedSimpleNames, internedRootNames)) {
                IFile file = this.javaBuilder.currentProject.getFile(typeLocator);
                SourceFile sourceFile = findSourceFile(file, true);
                if (sourceFile == null)
                    continue next;
                if (this.sourceFiles.contains(sourceFile))
                    continue next;
                if (this.compiledAllAtOnce && this.previousSourceFiles != null
                        && this.previousSourceFiles.contains(sourceFile))
                    continue next; // can skip previously compiled files since already saw hierarchy related problems

                if (JavaBuilder.DEBUG)
                    System.out.println("  adding affected source file " + typeLocator); //$NON-NLS-1$
                this.sourceFiles.add(sourceFile);
            }
        }
    }
}

From source file:org.eclipse.pde.api.tools.internal.builder.IncrementalApiBuilder.java

License:Open Source License

/**
 * Adds the dependent files from the current build context based on the
 * current JDT build state to either the structural or description
 * dependents./*from   ww w  . j  av a2  s .c o m*/
 * 
 * @param project the current project being built
 * @param state the current JDT build state
 * @param types dot and $ qualified names of base types that changed
 * @param kind mask of STRUCTURAL or DESCRIPTION
 */
private void addDependents(final IProject project, State state, String[] types, int kind) {
    StringSet packages = new StringSet(16);
    StringSet typenames = new StringSet(16);
    for (int i = 0; i < types.length; i++) {
        if (types[i] != null) {
            splitName(types[i], packages, typenames);
        }
    }
    // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are
    // just 'X'
    char[][][] internedQualifiedNames = ReferenceCollection.internQualifiedNames(packages);
    // if a well known qualified name was found then we can skip over these
    if (internedQualifiedNames.length < packages.elementSize) {
        internedQualifiedNames = null;
    }
    char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(typenames, true);
    // if a well known name was found then we can skip over these
    if (internedSimpleNames.length < typenames.elementSize) {
        internedSimpleNames = null;
    }
    Object[] keyTable = state.getReferences().keyTable;
    Object[] valueTable = state.getReferences().valueTable;
    IFile file = null;
    String typeLocator = null;
    for (int i = 0; i < valueTable.length; i++) {
        typeLocator = (String) keyTable[i];
        if (typeLocator != null) {
            ReferenceCollection refs = (ReferenceCollection) valueTable[i];
            if (refs.includes(internedQualifiedNames, internedSimpleNames, null)) {
                file = project.getFile(typeLocator);
                if (file == null) {
                    continue;
                }
                if (ApiPlugin.DEBUG_BUILDER) {
                    System.out.println("ApiAnalysisBuilder:   adding affected source file " + file.getName()); //$NON-NLS-1$
                }
                addDependentTypeToContext(file, kind);
            }
        }
    }
}