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

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


  this.previousStructuralBuildTime = -1;
  this.structurallyChangedTypes = null;
  this.javaProjectName = javaBuilder.currentProject.getName();
  this.sourceLocations = javaBuilder.nameEnvironment.sourceLocations;
  this.binaryLocations = javaBuilder.nameEnvironment.binaryLocations;
  this.references = new SimpleLookupTable(7);
  this.typeLocators = new SimpleLookupTable(7);

  this.buildNumber = 0; // indicates a full build
  this.lastStructuralBuildTime = computeStructuralBuildTime(javaBuilder.lastState == null ? 0 : javaBuilder.lastState.lastStructuralBuildTime);
  this.structuralBuildTimes = new SimpleLookupTable(3);
}
View Full Code Here


  try {
    this.references = (SimpleLookupTable) lastState.references.clone();
    this.typeLocators = (SimpleLookupTable) lastState.typeLocators.clone();
  } catch (CloneNotSupportedException e) {
    this.references = new SimpleLookupTable(lastState.references.elementSize);
    Object[] keyTable = lastState.references.keyTable;
    Object[] valueTable = lastState.references.valueTable;
    for (int i = 0, l = keyTable.length; i < l; i++)
      if (keyTable[i] != null)
        this.references.put(keyTable[i], valueTable[i]);

    this.typeLocators = new SimpleLookupTable(lastState.typeLocators.elementSize);
    keyTable = lastState.typeLocators.keyTable;
    valueTable = lastState.typeLocators.valueTable;
    for (int i = 0, l = keyTable.length; i < l; i++)
      if (keyTable[i] != null)
        this.typeLocators.put(keyTable[i], valueTable[i]);
View Full Code Here

      case INTERNAL_JAR :
        newState.binaryLocations[i] = ClasspathLocation.forLibrary(root.getFile(new Path(in.readUTF())), readRestriction(in));
    }
  }

  newState.structuralBuildTimes = new SimpleLookupTable(length = in.readInt());
  for (int i = 0; i < length; i++)
    newState.structuralBuildTimes.put(in.readUTF(), new Long(in.readLong()));

  String[] internedTypeLocators = new String[length = in.readInt()];
  for (int i = 0; i < length; i++)
    internedTypeLocators[i] = in.readUTF();

  newState.typeLocators = new SimpleLookupTable(length = in.readInt());
  for (int i = 0; i < length; i++)
    newState.recordLocatorForType(in.readUTF(), internedTypeLocators[in.readInt()]);

  char[][] internedRootNames = ReferenceCollection.internSimpleNames(readNames(in), false);
  char[][] internedSimpleNames = ReferenceCollection.internSimpleNames(readNames(in), false);
  char[][][] internedQualifiedNames = new char[length = in.readInt()][][];
  for (int i = 0; i < length; i++) {
    int qLength = in.readInt();
    char[][] qName = new char[qLength][];
    for (int j = 0; j < qLength; j++)
      qName[j] = internedSimpleNames[in.readInt()];
    internedQualifiedNames[i] = qName;
  }
  internedQualifiedNames = ReferenceCollection.internQualifiedNames(internedQualifiedNames, false);

  newState.references = new SimpleLookupTable(length = in.readInt());
  for (int i = 0; i < length; i++) {
    String typeLocator = internedTypeLocators[in.readInt()];
    ReferenceCollection collection = null;
    switch (in.readByte()) {
      case 1 :
View Full Code Here

/*
* 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("JavaBuilder: 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("JavaBuilder: 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("JavaBuilder: Found source delta for: " + this.currentProject.getName()); //$NON-NLS-1$
      deltas.put(this.currentProject, delta);
    }
  } else {
    if (DEBUG)
      System.out.println("JavaBuilder: 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("JavaBuilder: Found binary delta for: " + p.getName()); //$NON-NLS-1$
          deltas.put(p, delta);
        }
      } else {
        if (DEBUG)
          System.out.println("JavaBuilder: 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

      int methodTypeVariablesArity = methodTypeVariables.length;
         
      MethodBinding staticFactory = new MethodBinding(method.modifiers | ClassFileConstants.AccStatic, TypeConstants.SYNTHETIC_STATIC_FACTORY,
                                    null, null, null, method.declaringClass);
      staticFactory.typeVariables = new TypeVariableBinding[classTypeVariablesArity + methodTypeVariablesArity];
      final SimpleLookupTable map = new SimpleLookupTable(classTypeVariablesArity + methodTypeVariablesArity);
      // Rename each type variable T of the type to T'
      final LookupEnvironment environment = environment();
      for (int j = 0; j < classTypeVariablesArity; j++) {
        map.put(classTypeVariables[j], staticFactory.typeVariables[j] = new TypeVariableBinding(CharOperation.concat(classTypeVariables[j].sourceName, "'".toCharArray()), //$NON-NLS-1$
                                      staticFactory, j, environment));
      }
      // Rename each type variable U of method U to U''.
      for (int j = classTypeVariablesArity, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) {
        map.put(methodTypeVariables[j - classTypeVariablesArity],
            (staticFactory.typeVariables[j] = new TypeVariableBinding(CharOperation.concat(methodTypeVariables[j - classTypeVariablesArity].sourceName, "''".toCharArray()), //$NON-NLS-1$
                                      staticFactory, j, environment)));
      }
      ReferenceBinding enclosingType = originalEnclosingType;
      while (enclosingType != null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=345968
        if (enclosingType.kind() == Binding.PARAMETERIZED_TYPE) {
          final ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) enclosingType;
          final ReferenceBinding genericType = parameterizedType.genericType();
          TypeVariableBinding[] enclosingClassTypeVariables = genericType.typeVariables();
          int enclosingClassTypeVariablesArity = enclosingClassTypeVariables.length;
          for (int j = 0; j < enclosingClassTypeVariablesArity; j++) {
            map.put(enclosingClassTypeVariables[j], parameterizedType.arguments[j]);
          }
        }
        enclosingType = enclosingType.enclosingType();
      }
      final Scope scope = this;
      Substitution substitution = new Substitution() {
          public LookupEnvironment environment() {
            return scope.environment();
          }
          public boolean isRawSubstitution() {
            return false;
          }
          public TypeBinding substitute(TypeVariableBinding typeVariable) {
            TypeBinding retVal = (TypeBinding) map.get(typeVariable);
            return retVal != null ? retVal : typeVariable;
          }
        };

      // initialize new variable bounds
      for (int j = 0, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) {
        TypeVariableBinding originalVariable = j < classTypeVariablesArity ? classTypeVariables[j] : methodTypeVariables[j - classTypeVariablesArity];
        TypeBinding substitutedType = (TypeBinding) map.get(originalVariable);
        if (substitutedType instanceof TypeVariableBinding) {
          TypeVariableBinding substitutedVariable = (TypeVariableBinding) substitutedType;
          TypeBinding substitutedSuperclass = Scope.substitute(substitution, originalVariable.superclass);
          ReferenceBinding[] substitutedInterfaces = Scope.substitute(substitution, originalVariable.superInterfaces);
          if (originalVariable.firstBound != null) {
            substitutedVariable.firstBound = originalVariable.firstBound == originalVariable.superclass
                ? substitutedSuperclass // could be array type or interface
                    : substitutedInterfaces[0];
          }
          switch (substitutedSuperclass.kind()) {
            case Binding.ARRAY_TYPE :
              substitutedVariable.superclass = environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null);
              substitutedVariable.superInterfaces = substitutedInterfaces;
              break;
            default:
              if (substitutedSuperclass.isInterface()) {
                substitutedVariable.superclass = environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null);
                int interfaceCount = substitutedInterfaces.length;
                System.arraycopy(substitutedInterfaces, 0, substitutedInterfaces = new ReferenceBinding[interfaceCount+1], 1, interfaceCount);
                substitutedInterfaces[0] = (ReferenceBinding) substitutedSuperclass;
                substitutedVariable.superInterfaces = substitutedInterfaces;
              } else {
                substitutedVariable.superclass = (ReferenceBinding) substitutedSuperclass; // typeVar was extending other typeVar which got substituted with interface
                substitutedVariable.superInterfaces = substitutedInterfaces;
              }
          }
        }
      }
        TypeVariableBinding[] returnTypeParameters = new TypeVariableBinding[classTypeVariablesArity];
      for (int j = 0; j < classTypeVariablesArity; j++) {
        returnTypeParameters[j] = (TypeVariableBinding) map.get(classTypeVariables[j]);
      }
      staticFactory.returnType = environment.createParameterizedType(allocationType, returnTypeParameters, allocationType.enclosingType());
      staticFactory.parameters = Scope.substitute(substitution, method.parameters);
      staticFactory.thrownExceptions = Scope.substitute(substitution, method.thrownExceptions);
      if (staticFactory.thrownExceptions == null) {
View Full Code Here

  this.defaultImports = null;
  this.nameEnvironment = nameEnvironment;
  this.knownPackages = new HashtableOfPackage();
  this.uniqueArrayBindings = new ArrayBinding[5][];
  this.uniqueArrayBindings[0] = new ArrayBinding[50]; // start off the most common 1 dimension array @ 50
  this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3);
  this.uniqueRawTypeBindings = new SimpleLookupTable(3);
  this.uniqueWildcardBindings = new SimpleLookupTable(3);
  this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3);
  this.uniquePolymorphicMethodBindings = new SimpleLookupTable(3);
  this.missingTypes = null;
  this.accessRestrictions = new HashMap(3);
  this.classFilePool = ClassFilePool.newInstance();
  this.typesBeingConnected = new HashSet();
}
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.