Package org.eclipse.jdt.internal.compiler.util

Examples of org.eclipse.jdt.internal.compiler.util.SimpleLookupTable


/*
* String[]  Interned type locators
*/
  out.writeInt(length = this.references.elementSize);
  SimpleLookupTable internedTypeLocators = new SimpleLookupTable(length);
  if (length > 0) {
    keyTable = this.references.keyTable;
    for (int i = 0, l = keyTable.length; i < l; i++) {
      if (keyTable[i] != null) {
        length--;
        String key = (String) keyTable[i];
        out.writeUTF(key);
        internedTypeLocators.put(key, new Integer(internedTypeLocators.elementSize));
      }
    }
    if (JavaBuilder.DEBUG && length != 0)
      System.out.println("references table is inconsistent"); //$NON-NLS-1$
  }

/*
* Type locators table
* String    type name
* int      interned locator id
*/
  out.writeInt(length = this.typeLocators.elementSize);
  if (length > 0) {
    keyTable = this.typeLocators.keyTable;
    valueTable = this.typeLocators.valueTable;
    for (int i = 0, l = keyTable.length; i < l; i++) {
      if (keyTable[i] != null) {
        length--;
        out.writeUTF((String) keyTable[i]);
        Integer index = (Integer) internedTypeLocators.get(valueTable[i]);
        out.writeInt(index.intValue());
      }
    }
    if (JavaBuilder.DEBUG && length != 0)
      System.out.println("typeLocators table is inconsistent"); //$NON-NLS-1$
  }

/*
* char[][]  Interned root names
* char[][][]  Interned qualified names
* char[][]  Interned simple names
*/
  SimpleLookupTable internedRootNames = new SimpleLookupTable(3);
  SimpleLookupTable internedQualifiedNames = new SimpleLookupTable(31);
  SimpleLookupTable internedSimpleNames = new SimpleLookupTable(31);
  valueTable = this.references.valueTable;
  for (int i = 0, l = valueTable.length; i < l; i++) {
    if (valueTable[i] != null) {
      ReferenceCollection collection = (ReferenceCollection) valueTable[i];
      char[][] rNames = collection.rootReferences;
      for (int j = 0, m = rNames.length; j < m; j++) {
        char[] rName = rNames[j];
        if (!internedRootNames.containsKey(rName)) // remember the names have been interned
          internedRootNames.put(rName, new Integer(internedRootNames.elementSize));
      }
      char[][][] qNames = collection.qualifiedNameReferences;
      for (int j = 0, m = qNames.length; j < m; j++) {
        char[][] qName = qNames[j];
        if (!internedQualifiedNames.containsKey(qName)) { // remember the names have been interned
          internedQualifiedNames.put(qName, new Integer(internedQualifiedNames.elementSize));
          for (int k = 0, n = qName.length; k < n; k++) {
            char[] sName = qName[k];
            if (!internedSimpleNames.containsKey(sName)) // remember the names have been interned
              internedSimpleNames.put(sName, new Integer(internedSimpleNames.elementSize));
          }
        }
      }
      char[][] sNames = collection.simpleNameReferences;
      for (int j = 0, m = sNames.length; j < m; j++) {
        char[] sName = sNames[j];
        if (!internedSimpleNames.containsKey(sName)) // remember the names have been interned
          internedSimpleNames.put(sName, new Integer(internedSimpleNames.elementSize));
      }
    }
  }
  char[][] internedArray = new char[internedRootNames.elementSize][];
  Object[] rootNames = internedRootNames.keyTable;
  Object[] positions = internedRootNames.valueTable;
  for (int i = positions.length; --i >= 0; ) {
    if (positions[i] != null) {
      int index = ((Integer) positions[i]).intValue();
      internedArray[index] = (char[]) rootNames[i];
    }
  }
  writeNames(internedArray, out);
  // now write the interned simple names
  internedArray = new char[internedSimpleNames.elementSize][];
  Object[] simpleNames = internedSimpleNames.keyTable;
  positions = internedSimpleNames.valueTable;
  for (int i = positions.length; --i >= 0; ) {
    if (positions[i] != null) {
      int index = ((Integer) positions[i]).intValue();
      internedArray[index] = (char[]) simpleNames[i];
    }
  }
  writeNames(internedArray, out);
  // now write the interned qualified names as arrays of interned simple names
  char[][][] internedQArray = new char[internedQualifiedNames.elementSize][][];
  Object[] qualifiedNames = internedQualifiedNames.keyTable;
  positions = internedQualifiedNames.valueTable;
  for (int i = positions.length; --i >= 0; ) {
    if (positions[i] != null) {
      int index = ((Integer) positions[i]).intValue();
      internedQArray[index] = (char[][]) qualifiedNames[i];
    }
  }
  out.writeInt(length = internedQArray.length);
  for (int i = 0; i < length; i++) {
    char[][] qName = internedQArray[i];
    int qLength = qName.length;
    out.writeInt(qLength);
    for (int j = 0; j < qLength; j++) {
      Integer index = (Integer) internedSimpleNames.get(qName[j]);
      out.writeInt(index.intValue());
    }
  }

/*
* References table
* int    interned locator id
* ReferenceCollection
*/
  out.writeInt(length = this.references.elementSize);
  if (length > 0) {
    keyTable = this.references.keyTable;
    for (int i = 0, l = keyTable.length; i < l; i++) {
      if (keyTable[i] != null) {
        length--;
        Integer index = (Integer) internedTypeLocators.get(keyTable[i]);
        out.writeInt(index.intValue());
        ReferenceCollection collection = (ReferenceCollection) valueTable[i];
        if (collection instanceof AdditionalTypeCollection) {
          out.writeByte(1);
          AdditionalTypeCollection atc = (AdditionalTypeCollection) collection;
          writeNames(atc.definedTypeNames, out);
        } else {
          out.writeByte(2);
        }
        char[][][] qNames = collection.qualifiedNameReferences;
        int qLength = qNames.length;
        out.writeInt(qLength);
        for (int j = 0; j < qLength; j++) {
          index = (Integer) internedQualifiedNames.get(qNames[j]);
          out.writeInt(index.intValue());
        }
        char[][] sNames = collection.simpleNameReferences;
        int sLength = sNames.length;
        out.writeInt(sLength);
        for (int j = 0; j < sLength; j++) {
          index = (Integer) internedSimpleNames.get(sNames[j]);
          out.writeInt(index.intValue());
        }
        char[][] rNames = collection.rootReferences;
        int rLength = rNames.length;
        out.writeInt(rLength);
View Full Code Here


          if (DEBUG)
            System.out.println("Performing full build since classpath has changed"); //$NON-NLS-1$
          buildAll();
        } else if (this.nameEnvironment.sourceLocations.length > 0) {
          // if there is no source to compile & no classpath changes then we are done
          SimpleLookupTable deltas = findDeltas();
          if (deltas == null) {
            if (DEBUG)
              System.out.println("Performing full build since deltas are missing after incremental request"); //$NON-NLS-1$
            buildAll();
          } else if (deltas.elementSize > 0) {
View Full Code Here

}

private SimpleLookupTable findDeltas() {
  this.notifier.subTask(Messages.bind(Messages.build_readingDelta, this.currentProject.getName()));
  IResourceDelta delta = getDelta(this.currentProject);
  SimpleLookupTable deltas = new SimpleLookupTable(3);
  if (delta != null) {
    if (delta.getKind() != IResourceDelta.NO_CHANGE) {
      if (DEBUG)
        System.out.println("Found source delta for: " + this.currentProject.getName()); //$NON-NLS-1$
      deltas.put(this.currentProject, delta);
    }
  } else {
    if (DEBUG)
      System.out.println("Missing delta for: " + this.currentProject.getName()); //$NON-NLS-1$
    this.notifier.subTask(""); //$NON-NLS-1$
    return null;
  }

  Object[] keyTable = this.binaryLocationsPerProject.keyTable;
  Object[] valueTable = this.binaryLocationsPerProject.valueTable;
  nextProject : for (int i = 0, l = keyTable.length; i < l; i++) {
    IProject p = (IProject) keyTable[i];
    if (p != null && p != this.currentProject) {
      State s = getLastState(p);
      if (!this.lastState.wasStructurallyChanged(p, s)) { // see if we can skip its delta
        if (s.wasNoopBuild())
          continue nextProject; // project has no source folders and can be skipped
        ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[]) valueTable[i];
        boolean canSkip = true;
        for (int j = 0, m = classFoldersAndJars.length; j < m; j++) {
          if (classFoldersAndJars[j].isOutputFolder())
            classFoldersAndJars[j] = null; // can ignore output folder since project was not structurally changed
          else
            canSkip = false;
        }
        if (canSkip) continue nextProject; // project has no structural changes in its output folders
      }

      this.notifier.subTask(Messages.bind(Messages.build_readingDelta, p.getName()));
      delta = getDelta(p);
      if (delta != null) {
        if (delta.getKind() != IResourceDelta.NO_CHANGE) {
          if (DEBUG)
            System.out.println("Found binary delta for: " + p.getName()); //$NON-NLS-1$
          deltas.put(p, delta);
        }
      } else {
        if (DEBUG)
          System.out.println("Missing delta for: " + p.getName());   //$NON-NLS-1$
        this.notifier.subTask(""); //$NON-NLS-1$
View Full Code Here

      builtProjects = new ArrayList();
    }
    builtProjects.add(projectName);
  }

  this.binaryLocationsPerProject = new SimpleLookupTable(3);
  this.nameEnvironment = new NameEnvironment(this.workspaceRoot, this.javaProject, this.binaryLocationsPerProject, this.notifier);

  if (forBuild) {
    String filterSequence = this.javaProject.getOption(JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true);
    char[][] filters = filterSequence != null && filterSequence.length() > 0
View Full Code Here

    if (packagePath == null) {
      int count = sourceFile.sourceLocation.sourceFolder.getFullPath().segmentCount();
      packagePath = sourceFile.resource.getFullPath().removeFirstSegments(count).removeLastSegments(1);
    }
    if (this.secondaryTypesToRemove == null)
      this.secondaryTypesToRemove = new SimpleLookupTable();
    ArrayList types = (ArrayList) this.secondaryTypesToRemove.get(sourceFile.sourceLocation.binaryFolder);
    if (types == null)
      types = new ArrayList(definedTypeNames.size());
    types.add(packagePath.append(new String(previous)));
    this.secondaryTypesToRemove.put(sourceFile.sourceLocation.binaryFolder, types);
View Full Code Here

           * If not, then we want to check that there is no missing entry, if
           * one entry is missing then we recreate the index
           */
          String EXISTS = "OK"; //$NON-NLS-1$
          String DELETED = "DELETED"; //$NON-NLS-1$
          SimpleLookupTable indexedFileNames = new SimpleLookupTable(max == 0 ? 33 : max + 11);
          for (int i = 0; i < max; i++)
            indexedFileNames.put(paths[i], DELETED);
          for (Enumeration e = zip.entries(); e.hasMoreElements();) {
            // iterate each entry to index it
            ZipEntry ze = (ZipEntry) e.nextElement();
            String zipEntryName = ze.getName();
            if (Util.isClassFileName(zipEntryName) && isValidPackageNameForClass(zipEntryName))
                // the class file may not be there if the package name is not valid
              indexedFileNames.put(zipEntryName, EXISTS);
          }
          boolean needToReindex = indexedFileNames.elementSize != max; // a new file was added
          if (!needToReindex) {
            Object[] valueTable = indexedFileNames.valueTable;
            for (int i = 0, l = valueTable.length; i < l; i++) {
View Full Code Here

  char[][] fullExclusionPatternChars;
  char[][] fulInclusionPatternChars;

ClasspathSourceDirectory(IContainer sourceFolder, char[][] fullExclusionPatternChars, char[][] fulInclusionPatternChars) {
  this.sourceFolder = sourceFolder;
  this.directoryCache = new SimpleLookupTable(5);
  this.fullExclusionPatternChars = fullExclusionPatternChars;
  this.fulInclusionPatternChars = fulInclusionPatternChars;
}
View Full Code Here

public void cleanup() {
  this.directoryCache = null;
}

SimpleLookupTable directoryTable(String qualifiedPackageName) {
  SimpleLookupTable dirTable = (SimpleLookupTable) this.directoryCache.get(qualifiedPackageName);
  if (dirTable == this.missingPackageHolder) return null; // package exists in another classpath directory or jar
  if (dirTable != null) return dirTable;

  try {
    IResource container = this.sourceFolder.findMember(qualifiedPackageName); // this is a case-sensitive check
    if (container instanceof IContainer) {
      IResource[] members = ((IContainer) container).members();
      dirTable = new SimpleLookupTable();
      for (int i = 0, l = members.length; i < l; i++) {
        IResource m = members[i];
        String name;
        if (m.getType() == IResource.FILE) {
          int index = Util.indexOfJavaLikeExtension(name = m.getName());
          if (index >= 0) {
            String fullPath = m.getFullPath().toString();
            if (!org.eclipse.jdt.internal.compiler.util.Util.isExcluded(fullPath.toCharArray(), this.fulInclusionPatternChars, this.fullExclusionPatternChars, false/*not a folder path*/)) {
              dirTable.put(name.substring(0, index), m);
            }
          }
        }
      }
      this.directoryCache.put(qualifiedPackageName, dirTable);
View Full Code Here

  return this.sourceFolder.equals(((ClasspathSourceDirectory) o).sourceFolder);
}

public NameEnvironmentAnswer findClass(String sourceFileWithoutExtension, String qualifiedPackageName, String qualifiedSourceFileWithoutExtension) {
  SimpleLookupTable dirTable = directoryTable(qualifiedPackageName);
  if (dirTable != null && dirTable.elementSize > 0) {
    IFile file = (IFile) dirTable.get(sourceFileWithoutExtension);
    if (file != null) {
      return new NameEnvironmentAnswer(new ResourceCompilationUnit(file, file.getLocationURI()), null /* no access restriction */);
    }
  }
  return null;
View Full Code Here

public boolean isPackage(String qualifiedPackageName) {
  return directoryTable(qualifiedPackageName) != null;
}

public void reset() {
  this.directoryCache = new SimpleLookupTable(5);
}
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.util.SimpleLookupTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.