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

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


   * ConstantPool constructor comment.
   */
  public ConstantPool(ClassFile classFile) {
    this.UTF8Cache = new CharArrayCache(UTF8_INITIAL_SIZE);
    this.stringCache = new CharArrayCache(STRING_INITIAL_SIZE);
    this.methodsAndFieldsCache = new HashtableOfObject(METHODS_AND_FIELDS_INITIAL_SIZE);
    this.classCache = new CharArrayCache(CLASS_INITIAL_SIZE);
    this.nameAndTypeCacheForFieldsAndMethods = new HashtableOfObject(NAMEANDTYPE_INITIAL_SIZE);
    this.offsets = new int[5];
    initialize(classFile);
  }
View Full Code Here


   * @param value the new index
   * @return the given index
   */
  private int putInCacheIfAbsent(final char[] key1, final char[] key2, final char[] key3, int value) {
    int index;
    HashtableOfObject key1Value = (HashtableOfObject) this.methodsAndFieldsCache.get(key1);
    if (key1Value == null) {
      key1Value = new HashtableOfObject();
      this.methodsAndFieldsCache.put(key1, key1Value);
      CachedIndexEntry cachedIndexEntry = new CachedIndexEntry(key3, value);
      index = -value;
      key1Value.put(key2, cachedIndexEntry);
    } else {
      Object key2Value = key1Value.get(key2);
      if (key2Value == null) {
        CachedIndexEntry cachedIndexEntry = new CachedIndexEntry(key3, value);
        index = -value;
        key1Value.put(key2, cachedIndexEntry);
      } else if (key2Value instanceof CachedIndexEntry) {
        // adding a second entry
        CachedIndexEntry entry = (CachedIndexEntry) key2Value;
        if (CharOperation.equals(key3, entry.signature)) {
          index = entry.index;
        } else {
          CharArrayCache charArrayCache = new CharArrayCache();
          charArrayCache.putIfAbsent(entry.signature, entry.index);
          index = charArrayCache.putIfAbsent(key3, value);
          key1Value.put(key2, charArrayCache);
        }
      } else {
        CharArrayCache charArrayCache = (CharArrayCache) key2Value;
        index = charArrayCache.putIfAbsent(key3, value);
      }
View Full Code Here

      if (referenceTables[i] != null && ((String) paths[i]).startsWith(substring, 0))
        results.add(paths[i]);
  }
}
void addIndexEntry(char[] category, char[] key, String documentName) {
  HashtableOfObject referenceTable;
  if (documentName.equals(this.lastDocumentName))
    referenceTable = this.lastReferenceTable;
  else {
    // assumed a document was removed before its reindexed
    referenceTable = (HashtableOfObject) this.docsToReferences.get(documentName);
    if (referenceTable == null)
      this.docsToReferences.put(documentName, referenceTable = new HashtableOfObject(3));
    this.lastDocumentName = documentName;
    this.lastReferenceTable = referenceTable;
  }

  SimpleWordSet existingWords = (SimpleWordSet) referenceTable.get(category);
  if (existingWords == null)
    referenceTable.put(category, existingWords = new SimpleWordSet(1));

  existingWords.add(this.allWords.add(key));
}
View Full Code Here

  // results maps a word -> EntryResult
  Object[] paths = this.docsToReferences.keyTable;
  Object[] referenceTables = this.docsToReferences.valueTable;
  if (matchRule == (SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE) && key != null) {
    nextPath : for (int i = 0, l = referenceTables.length; i < l; i++) {
      HashtableOfObject categoryToWords = (HashtableOfObject) referenceTables[i];
      if (categoryToWords != null) {
        for (int j = 0, m = categories.length; j < m; j++) {
          SimpleWordSet wordSet = (SimpleWordSet) categoryToWords.get(categories[j]);
          if (wordSet != null && wordSet.includes(key)) {
            if (results == null)
              results = new HashtableOfObject(13);
            EntryResult result = (EntryResult) results.get(key);
            if (result == null)
              results.put(key, result = new EntryResult(key, null));
            result.addDocumentName((String) paths[i]);
            continue nextPath;
          }
        }
      }
    }
  } else {
    for (int i = 0, l = referenceTables.length; i < l; i++) {
      HashtableOfObject categoryToWords = (HashtableOfObject) referenceTables[i];
      if (categoryToWords != null) {
        for (int j = 0, m = categories.length; j < m; j++) {
          SimpleWordSet wordSet = (SimpleWordSet) categoryToWords.get(categories[j]);
          if (wordSet != null) {
            char[][] words = wordSet.words;
            for (int k = 0, n = words.length; k < n; k++) {
              char[] word = words[k];
              if (word != null && Index.isMatch(key, word, matchRule)) {
                if (results == null)
                  results = new HashtableOfObject(13);
                EntryResult result = (EntryResult) results.get(word);
                if (result == null)
                  results.put(word, result = new EntryResult(word, null));
                result.addDocumentName((String) paths[i]);
              }
View Full Code Here

*/
void computeInheritedMethods(ReferenceBinding superclass, ReferenceBinding[] superInterfaces) {
  // only want to remember inheritedMethods that can have an impact on the current type
  // if an inheritedMethod has been 'replaced' by a supertype's method then skip it

  this.inheritedMethods = new HashtableOfObject(51); // maps method selectors to an array of methods... must search to match paramaters & return type
  ReferenceBinding[] interfacesToVisit = null;
  int nextPosition = 0;
  ReferenceBinding[] itsInterfaces = superInterfaces;
  if (itsInterfaces != Binding.NO_SUPERINTERFACES) {
    nextPosition = itsInterfaces.length;
    interfacesToVisit = itsInterfaces;
  }

  ReferenceBinding superType = superclass;
  HashtableOfObject nonVisibleDefaultMethods = new HashtableOfObject(3); // maps method selectors to an array of methods
  boolean allSuperclassesAreAbstract = true;

  while (superType != null && superType.isValidBinding()) {
      if (allSuperclassesAreAbstract) {
        if (superType.isAbstract()) {
        // only need to include superinterfaces if immediate superclasses are abstract
        if ((itsInterfaces = superType.superInterfaces()) != Binding.NO_SUPERINTERFACES) {
          if (interfacesToVisit == null) {
            interfacesToVisit = itsInterfaces;
            nextPosition = interfacesToVisit.length;
          } else {
            int itsLength = itsInterfaces.length;
            if (nextPosition + itsLength >= interfacesToVisit.length)
              System.arraycopy(interfacesToVisit, 0, interfacesToVisit = new ReferenceBinding[nextPosition + itsLength + 5], 0, nextPosition);
            nextInterface : for (int a = 0; a < itsLength; a++) {
              ReferenceBinding next = itsInterfaces[a];
              for (int b = 0; b < nextPosition; b++)
                if (next == interfacesToVisit[b]) continue nextInterface;
              interfacesToVisit[nextPosition++] = next;
            }
          }
        }
      } else {
          allSuperclassesAreAbstract = false;
      }
    }

    MethodBinding[] methods = superType.unResolvedMethods();
    nextMethod : for (int m = methods.length; --m >= 0;) {
      MethodBinding inheritedMethod = methods[m];
      if (inheritedMethod.isPrivate() || inheritedMethod.isConstructor() || inheritedMethod.isDefaultAbstract())
        continue nextMethod;
      MethodBinding[] existingMethods = (MethodBinding[]) this.inheritedMethods.get(inheritedMethod.selector);
      if (existingMethods != null) {
        existing : for (int i = 0, length = existingMethods.length; i < length; i++) {
          MethodBinding existingMethod = existingMethods[i];
          if (existingMethod.declaringClass != inheritedMethod.declaringClass && areMethodsCompatible(existingMethod, inheritedMethod)) {
            if (inheritedMethod.isDefault()) {
              if (inheritedMethod.isAbstract()) {
                checkPackagePrivateAbstractMethod(inheritedMethod);
              } else if (existingMethod.declaringClass.fPackage != inheritedMethod.declaringClass.fPackage) {
                if (this.type.fPackage == inheritedMethod.declaringClass.fPackage && !areReturnTypesCompatible(inheritedMethod, existingMethod))
                  continue existing; // may need to record incompatible return type
              }
            }
            continue nextMethod;
          }
        }
      }

      if (!inheritedMethod.isDefault() || inheritedMethod.declaringClass.fPackage == this.type.fPackage) {
        if (existingMethods == null) {
          existingMethods = new MethodBinding[] {inheritedMethod};
        } else {
          int length = existingMethods.length;
          System.arraycopy(existingMethods, 0, existingMethods = new MethodBinding[length + 1], 0, length);
          existingMethods[length] = inheritedMethod;
        }
        this.inheritedMethods.put(inheritedMethod.selector, existingMethods);
      } else {
        MethodBinding[] nonVisible = (MethodBinding[]) nonVisibleDefaultMethods.get(inheritedMethod.selector);
        if (nonVisible != null)
          for (int i = 0, l = nonVisible.length; i < l; i++)
            if (areMethodsCompatible(nonVisible[i], inheritedMethod))
              continue nextMethod;
        if (nonVisible == null) {
          nonVisible = new MethodBinding[] {inheritedMethod};
        } else {
          int length = nonVisible.length;
          System.arraycopy(nonVisible, 0, nonVisible = new MethodBinding[length + 1], 0, length);
          nonVisible[length] = inheritedMethod;
        }
        nonVisibleDefaultMethods.put(inheritedMethod.selector, nonVisible);

        if (inheritedMethod.isAbstract() && !this.type.isAbstract()) // non visible abstract methods cannot be overridden so the type must be defined abstract
          problemReporter().abstractMethodCannotBeOverridden(this.type, inheritedMethod);

        MethodBinding[] current = (MethodBinding[]) this.currentMethods.get(inheritedMethod.selector);
View Full Code Here

}

void computeMethods() {
  MethodBinding[] methods = this.type.methods();
  int size = methods.length;
  this.currentMethods = new HashtableOfObject(size == 0 ? 1 : size); // maps method selectors to an array of methods... must search to match paramaters & return type
  for (int m = size; --m >= 0;) {
    MethodBinding method = methods[m];
    if (!(method.isConstructor() || method.isDefaultAbstract())) { // keep all methods which are NOT constructors or default abstract
      MethodBinding[] existingMethods = (MethodBinding[]) this.currentMethods.get(method.selector);
      if (existingMethods == null)
View Full Code Here

* ConstantPool constructor comment.
*/
public ConstantPool(ClassFile classFile) {
    this.UTF8Cache = new CharArrayCache(UTF8_INITIAL_SIZE);
    this.stringCache = new CharArrayCache(STRING_INITIAL_SIZE);
    this.methodsAndFieldsCache = new HashtableOfObject(METHODS_AND_FIELDS_INITIAL_SIZE);
    this.classCache = new CharArrayCache(CLASS_INITIAL_SIZE);
    this.nameAndTypeCacheForFieldsAndMethods = new HashtableOfObject(NAMEANDTYPE_INITIAL_SIZE);
    this.offsets = new int[5];
    initialize(classFile);
}
View Full Code Here

* @param value the new index
* @return the given index
*/
private int putInCacheIfAbsent(final char[] key1, final char[] key2, final char[] key3, int value) {
    int index;
    HashtableOfObject key1Value = (HashtableOfObject) this.methodsAndFieldsCache.get(key1);
    if (key1Value == null) {
        key1Value = new HashtableOfObject();
        this.methodsAndFieldsCache.put(key1, key1Value);
        CachedIndexEntry cachedIndexEntry = new CachedIndexEntry(key3, value);
        index = -value;
        key1Value.put(key2, cachedIndexEntry);
    } else {
        Object key2Value = key1Value.get(key2);
        if (key2Value == null) {
            CachedIndexEntry cachedIndexEntry = new CachedIndexEntry(key3, value);
            index = -value;
            key1Value.put(key2, cachedIndexEntry);
        } else if (key2Value instanceof CachedIndexEntry) {
            // adding a second entry
            CachedIndexEntry entry = (CachedIndexEntry) key2Value;
            if (CharOperation.equals(key3, entry.signature)) {
                index = entry.index;
            } else {
                CharArrayCache charArrayCache = new CharArrayCache();
                charArrayCache.putIfAbsent(entry.signature, entry.index);
                index = charArrayCache.putIfAbsent(key3, value);
                key1Value.put(key2, charArrayCache);
            }
        } else {
            CharArrayCache charArrayCache = (CharArrayCache) key2Value;
            index = charArrayCache.putIfAbsent(key3, value);
        }
View Full Code Here

    TypeVariableBinding var = this.type.typeVariables[i];
    // must verify bounds if the variable has more than 1
    if (var.superInterfaces == Binding.NO_SUPERINTERFACES) continue;
    if (var.superInterfaces.length == 1 && var.superclass.id == TypeIds.T_JavaLangObject) continue;

    this.currentMethods = new HashtableOfObject(0);
    ReferenceBinding superclass = var.superclass();
    if (superclass.kind() == Binding.TYPE_PARAMETER)
      superclass = (ReferenceBinding) superclass.erasure();
    ReferenceBinding[] itsInterfaces = var.superInterfaces();
    ReferenceBinding[] superInterfaces = new ReferenceBinding[itsInterfaces.length];
View Full Code Here

      }
    }

    // iterate the field declarations to create the bindings, lose all duplicates
    FieldBinding[] fieldBindings = new FieldBinding[count];
    HashtableOfObject knownFieldNames = new HashtableOfObject(count);
    count = 0;
    for (int i = 0; i < size; i++) {
      FieldDeclaration field = fields[i];
      if (field.getKind() == AbstractVariableDeclaration.INITIALIZER) {
        if (sourceType.isInterface())
          problemReporter().interfaceCannotHaveInitializers(sourceType, field);
      } else {
        FieldBinding fieldBinding = new FieldBinding(field, null, field.modifiers | ExtraCompilerModifiers.AccUnresolved, sourceType);
        fieldBinding.id = count;
        // field's type will be resolved when needed for top level types
        checkAndSetModifiersForField(fieldBinding, field);

        if (knownFieldNames.containsKey(field.name)) {
          FieldBinding previousBinding = (FieldBinding) knownFieldNames.get(field.name);
          if (previousBinding != null) {
            for (int f = 0; f < i; f++) {
              FieldDeclaration previousField = fields[f];
              if (previousField.binding == previousBinding) {
                problemReporter().duplicateFieldInType(sourceType, previousField);
                break;
              }
            }
          }
          knownFieldNames.put(field.name, null); // ensure that the duplicate field is found & removed
          problemReporter().duplicateFieldInType(sourceType, field);
          field.binding = null;
        } else {
          knownFieldNames.put(field.name, fieldBinding);
          // remember that we have seen a field with this name
          fieldBindings[count++] = fieldBinding;
        }
      }
    }
View Full Code Here

TOP

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

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.