Example usage for org.eclipse.jdt.internal.core.builder StringSet includes

List of usage examples for org.eclipse.jdt.internal.core.builder StringSet includes

Introduction

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

Prototype

public boolean includes(String value) 

Source Link

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) {
    // 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;//from  www  .  j a v  a 2s .  c  o m
    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.jdt.internal.core.builder.IncrementalImageBuilder.java

License:Open Source License

protected void findAffectedSourceFiles(IResourceDelta binaryDelta, int segmentCount,
        StringSet structurallyChangedTypes) {
    // When a package becomes a type or vice versa, expect 2 deltas,
    // one on the folder & one on the class file
    IResource resource = binaryDelta.getResource();
    switch (resource.getType()) {
    case IResource.FOLDER:
        switch (binaryDelta.getKind()) {
        case IResourceDelta.ADDED:
        case IResourceDelta.REMOVED:
            IPath packagePath = resource.getFullPath().removeFirstSegments(segmentCount);
            String packageName = packagePath.toString();
            if (binaryDelta.getKind() == IResourceDelta.ADDED) {
                // see if any known source file is from the same package... classpath already includes new package
                if (!this.newState.isKnownPackage(packageName)) {
                    if (JavaBuilder.DEBUG)
                        System.out.println("Found added package " + packageName); //$NON-NLS-1$
                    addDependentsOf(packagePath, false);
                    return;
                }/*from  www . j  a  va2  s . c  om*/
                if (JavaBuilder.DEBUG)
                    System.out.println("Skipped dependents of added package " + packageName); //$NON-NLS-1$
            } else {
                // see if the package still exists on the classpath
                if (!this.nameEnvironment.isPackage(packageName)) {
                    if (JavaBuilder.DEBUG)
                        System.out.println("Found removed package " + packageName); //$NON-NLS-1$
                    addDependentsOf(packagePath, false);
                    return;
                }
                if (JavaBuilder.DEBUG)
                    System.out.println("Skipped dependents of removed package " + packageName); //$NON-NLS-1$
            }
            //$FALL-THROUGH$ traverse the sub-packages and .class files
        case IResourceDelta.CHANGED:
            IResourceDelta[] children = binaryDelta.getAffectedChildren();
            for (int i = 0, l = children.length; i < l; i++)
                findAffectedSourceFiles(children[i], segmentCount, structurallyChangedTypes);
        }
        return;
    case IResource.FILE:
        if (org.eclipse.jdt.internal.compiler.util.Util.isClassFileName(resource.getName())) {
            IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
            switch (binaryDelta.getKind()) {
            case IResourceDelta.ADDED:
            case IResourceDelta.REMOVED:
                if (JavaBuilder.DEBUG)
                    System.out.println("Found added/removed class file " + typePath); //$NON-NLS-1$
                addDependentsOf(typePath, false);
                return;
            case IResourceDelta.CHANGED:
                if ((binaryDelta.getFlags() & IResourceDelta.CONTENT) == 0)
                    return; // skip it since it really isn't changed
                if (structurallyChangedTypes != null && !structurallyChangedTypes.includes(typePath.toString()))
                    return; // skip since it wasn't a structural change
                if (JavaBuilder.DEBUG)
                    System.out.println("Found changed class file " + typePath); //$NON-NLS-1$
                addDependentsOf(typePath, false);
            }
            return;
        }
    }
}