Examples of HashtableOfObject


Examples of org.aspectj.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);
  initialize(classFile);
}
View Full Code Here

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

* @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

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

*/
public CompilationUnit[] getCompilationUnits()
  throws InvalidInputException {
  int fileCount = this.filenames.length;
  CompilationUnit[] units = new CompilationUnit[fileCount];
  HashtableOfObject knownFileNames = new HashtableOfObject(fileCount);

  String defaultEncoding = (String) this.options.get(CompilerOptions.OPTION_Encoding);
  if (Util.EMPTY_STRING.equals(defaultEncoding))
    defaultEncoding = null;

  for (int i = 0; i < fileCount; i++) {
    char[] charName = this.filenames[i].toCharArray();
    if (knownFileNames.get(charName) != null)
      throw new InvalidInputException(this.bind("unit.more", this.filenames[i])); //$NON-NLS-1$
    knownFileNames.put(charName, charName);
    File file = new File(this.filenames[i]);
    if (!file.exists())
      throw new InvalidInputException(this.bind("unit.missing", this.filenames[i])); //$NON-NLS-1$
    String encoding = this.encodings[i];
    if (encoding == null)
View Full Code Here

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

    this.totalUnits = 0;
    this.unitsToProcess = new CompilationUnitDeclaration[maxUnits];
    int index = 0;

    // walks the source units
    this.requestedSources = new HashtableOfObject();
    for (int i = 0; i < sourceLength; i++) {
      org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit = sourceUnits[i];
      CompilationUnitDeclaration parsedUnit;
      CompilationResult unitResult =
        new CompilationResult(sourceUnit, index++, maxUnits, this.options.maxProblemsPerUnit);
      try {
        if (options.verbose) {
          this.out.println(
            Messages.bind(Messages.compilation_request,
            new String[] {
              String.valueOf(index++ + 1),
              String.valueOf(maxUnits),
              new String(sourceUnit.getFileName())
            }));
        }
        // diet parsing for large collection of units
        if (this.totalUnits < this.parseThreshold) {
          parsedUnit = this.parser.parse(sourceUnit, unitResult);
        } else {
          parsedUnit = this.parser.dietParse(sourceUnit, unitResult);
        }
        // initial type binding creation
        this.lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
        addCompilationUnit(sourceUnit, parsedUnit);
        this.requestedSources.put(unitResult.getFileName(), sourceUnit);
        worked(1);
      } finally {
        sourceUnits[i] = null; // no longer hold onto the unit
      }
    }

    // walk the binding keys
    this.requestedKeys = new HashtableOfObject();
    for (int i = 0; i < keyLength; i++) {
      BindingKeyResolver resolver = new BindingKeyResolver(bindingKeys[i], this, this.lookupEnvironment);
      resolver.parse(true/*pause after fully qualified name*/);
      // If it doesn't have a type name, then it is either an array type, package or base type, which will definitely not have a compilation unit.
      // Skipping it will speed up performance because the call will open jars. (theodora)
View Full Code Here

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

  int waitingPolicy,  // WaitUntilReadyToSearch | ForceImmediateSearch | CancelIfNotReadyToSearch
  final IProgressMonitor progressMonitor) {

  /* embed constructs inside arrays so as to pass them to (inner) collector */
  final Queue queue = new Queue();
  final HashtableOfObject foundSuperNames = new HashtableOfObject(5);

  IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager();

  /* use a special collector to collect paths and queue new subtype names */
  IndexQueryRequestor searchRequestor = new IndexQueryRequestor() {
    public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) {
      SuperTypeReferencePattern record = (SuperTypeReferencePattern)indexRecord;
      boolean isLocalOrAnonymous = record.enclosingTypeName == IIndexConstants.ONE_ZERO;
      pathRequestor.acceptPath(documentPath, isLocalOrAnonymous);
      char[] typeName = record.simpleName;
      int suffix = documentPath.toLowerCase().lastIndexOf(SUFFIX_STRING_class);
      if (suffix != -1){
        HierarchyBinaryType binaryType = (HierarchyBinaryType)binariesFromIndexMatches.get(documentPath);
        if (binaryType == null){
          char[] enclosingTypeName = record.enclosingTypeName;
          if (isLocalOrAnonymous) {
            int lastSlash = documentPath.lastIndexOf('/');
            int lastDollar = documentPath.lastIndexOf('$');
            if (lastDollar == -1) {
              // malformed local or anonymous type: it doesn't contain a $ in its name
              // treat it as a top level type
              enclosingTypeName = null;
              typeName = documentPath.substring(lastSlash+1, suffix).toCharArray();
            } else {
              enclosingTypeName = documentPath.substring(lastSlash+1, lastDollar).toCharArray();
              typeName = documentPath.substring(lastDollar+1, suffix).toCharArray();
            }
          }
          binaryType = new HierarchyBinaryType(record.modifiers, record.pkgName, typeName, enclosingTypeName, record.typeParameterSignatures, record.classOrInterface);
          binariesFromIndexMatches.put(documentPath, binaryType);
        }
        binaryType.recordSuperType(record.superSimpleName, record.superQualification, record.superClassOrInterface);
      }
      if (!isLocalOrAnonymous // local or anonymous types cannot have subtypes outside the cu that define them
          && !foundSuperNames.containsKey(typeName)){
        foundSuperNames.put(typeName, typeName);
        queue.add(typeName);
      }
      return true;
    }   
  };
View Full Code Here

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

      IJavaProject javaProject) {
    super(settings);
    this.javaProject = javaProject;
    this.requestor = requestor;
    this.nameEnvironment = nameEnvironment;
    this.typeCache = new HashtableOfObject(5);

    this.problemFactory = new CompletionProblemFactory(Locale.getDefault());
    this.problemReporter = new ProblemReporter(
        DefaultErrorHandlingPolicies.proceedWithAllProblems(),
        this.compilerOptions,
View Full Code Here

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

   
    int length = this.acceptedTypes.size();
   
    if(length == 0) return;
   
    HashtableOfObject onDemandFound = new HashtableOfObject();
   
    next : for (int i = 0; i < length; i++) {
      AcceptedType acceptedType = (AcceptedType)this.acceptedTypes.elementAt(i);
      char[] packageName = acceptedType.packageName;
      char[] simpleTypeName = acceptedType.simpleTypeName;
      char[][] enclosingTypeNames = acceptedType.enclosingTypeNames;
      int modifiers = acceptedType.modifiers;
      int accessibility = acceptedType.accessibility;
     
      char[] typeName;
      char[] flatEnclosingTypeNames;
      if(enclosingTypeNames == null || enclosingTypeNames.length == 0) {
        flatEnclosingTypeNames = null;
        typeName = simpleTypeName;
      } else {
        flatEnclosingTypeNames = CharOperation.concatWith(acceptedType.enclosingTypeNames, '.');
        typeName = CharOperation.concat(flatEnclosingTypeNames, simpleTypeName, '.');
      }
      char[] fullyQualifiedName = CharOperation.concat(packageName, typeName, '.');
     
      if (this.knownTypes.containsKey(fullyQualifiedName)) continue next;
 
      this.knownTypes.put(fullyQualifiedName, this);
     
      if (this.resolvingImports) {
        char[] completionName;
       
        if(this.resolvingStaticImports) {
          if(enclosingTypeNames == null || enclosingTypeNames.length == 0) {
            completionName = CharOperation.concat(fullyQualifiedName, new char[] { '.' });
          } else if ((modifiers & ClassFileConstants.AccStatic) == 0) {
            continue next;
          } else {
            completionName = CharOperation.concat(fullyQualifiedName, new char[] { ';' });
          }
        } else {
          completionName = CharOperation.concat(fullyQualifiedName, new char[] { ';' });
        }
       
        int relevance = computeBaseRelevance();
        relevance += computeRelevanceForResolution();
        relevance += computeRelevanceForInterestingProposal();
        relevance += computeRelevanceForRestrictions(accessibility);
        if(insideQualifiedReference) {
          relevance += computeRelevanceForCaseMatching(this.completionToken, fullyQualifiedName);
        } else {
          relevance += computeRelevanceForCaseMatching(this.completionToken, simpleTypeName);
        }
       
        this.noProposal = false;
        if(!this.requestor.isIgnored(CompletionProposal.TYPE_REF)) {
          createTypeProposal(packageName, typeName, modifiers, accessibility, completionName, relevance);
        }
      } else {
        if(!this.importCachesInitialized) {
          this.initializeImportCaches();
        }
     
        for (int j = 0; j < this.importCacheCount; j++) {
          char[][] importName = this.importsCache[j];
          if(CharOperation.equals(typeName, importName[0])) {
            proposeType(
                packageName,
                simpleTypeName,
                modifiers,
                accessibility,
                typeName,
                fullyQualifiedName,
                !CharOperation.equals(fullyQualifiedName, importName[1]),
                scope);
            continue next;
          }
        }
       
       
        if ((enclosingTypeNames == null || enclosingTypeNames.length == 0 ) && CharOperation.equals(this.currentPackageName, packageName)) {
          proposeType(
              packageName,
              simpleTypeName,
              modifiers,
              accessibility,
              typeName,
              fullyQualifiedName,
              false,
              scope);
          continue next;
        } else {
          char[] fullyQualifiedEnclosingTypeOrPackageName = null;
     
          AcceptedType foundType = null;
          if((foundType = (AcceptedType)onDemandFound.get(simpleTypeName)) == null) {
            for (int j = 0; j < this.onDemandImportCacheCount; j++) {
              ImportBinding importBinding = this.onDemandImportsCache[j];

              char[][] importName = importBinding.compoundName;
              char[] importFlatName = CharOperation.concatWith(importName, '.');
           
              if(fullyQualifiedEnclosingTypeOrPackageName == null) {
                if(enclosingTypeNames != null && enclosingTypeNames.length != 0) {
                  fullyQualifiedEnclosingTypeOrPackageName =
                    CharOperation.concat(
                        packageName,
                        flatEnclosingTypeNames,
                        '.');
                } else {
                  fullyQualifiedEnclosingTypeOrPackageName =
                    packageName;
                }
              }
              if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
                if(importBinding.isStatic()) {
                  if((modifiers & ClassFileConstants.AccStatic) != 0) {
                    acceptedType.qualifiedTypeName = typeName;
                    acceptedType.fullyQualifiedName = fullyQualifiedName;
                    onDemandFound.put(
                        simpleTypeName,
                        acceptedType);
                    continue next;
                  }
                } else {
                  acceptedType.qualifiedTypeName = typeName;
                  acceptedType.fullyQualifiedName = fullyQualifiedName;
                  onDemandFound.put(
                      simpleTypeName,
                      acceptedType);
                  continue next;
                }
              }
View Full Code Here

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

  }

  protected void reset() {

    super.reset();
    this.knownPkgs = new HashtableOfObject(10);
    this.knownTypes = new HashtableOfObject(10);
  }
View Full Code Here

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

  if (offset == HashtableOfIntValues.NO_VALUE) {
    return null;
  }

  if (this.categoryTables == null) {
    this.categoryTables = new HashtableOfObject(3);
  } else {
    HashtableOfObject cachedTable = (HashtableOfObject) this.categoryTables.get(categoryName);
    if (cachedTable != null) {
      if (readDocNumbers) { // must cache remaining document number arrays
        Object[] arrayOffsets = cachedTable.valueTable;
        for (int i = 0, l = arrayOffsets.length; i < l; i++)
          if (arrayOffsets[i] instanceof Integer)
            arrayOffsets[i] = readDocumentNumbers(arrayOffsets[i]);
      }
      return cachedTable;
    }
  }

  FileInputStream stream = new FileInputStream(this.indexFile);
  HashtableOfObject categoryTable = null;
  char[][] matchingWords = null;
  int count = 0;
  int firstOffset = -1;
  this.streamBuffer = new byte[BUFFER_READ_SIZE];
  try {
    stream.skip(offset);
    this.bufferIndex = 0;
    this.bufferEnd = stream.read(this.streamBuffer, 0, this.streamBuffer.length);
    int size = readStreamInt(stream);
    try {
      if (size < 0) { // DEBUG
        System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$
        System.err.println("file = "+this.indexFile); //$NON-NLS-1$
        System.err.println("offset = "+offset); //$NON-NLS-1$
        System.err.println("size = "+size); //$NON-NLS-1$
        System.err.println("--------------------   END   --------------------"); //$NON-NLS-1$
      }
      categoryTable = new HashtableOfObject(size);
    } catch (OutOfMemoryError oom) {
      // DEBUG
      oom.printStackTrace();
      System.err.println("-------------------- DEBUG --------------------"); //$NON-NLS-1$
      System.err.println("file = "+this.indexFile); //$NON-NLS-1$
      System.err.println("offset = "+offset); //$NON-NLS-1$
      System.err.println("size = "+size); //$NON-NLS-1$
      System.err.println("--------------------   END   --------------------"); //$NON-NLS-1$
      throw oom;
    }
    int largeArraySize = 256;
    for (int i = 0; i < size; i++) {
      char[] word = readStreamChars(stream);
      int arrayOffset = readStreamInt(stream);
      // if arrayOffset is:
      //    <= 0 then the array size == 1 with the value -> -arrayOffset
      //    > 1 & < 256 then the size of the array is > 1 & < 256, the document array follows immediately
      //    256 if the array size >= 256 followed by another int which is the offset to the array (written prior to the table)
      if (arrayOffset <= 0) {
        categoryTable.put(word, new int[] {-arrayOffset}); // store 1 element array by negating documentNumber
      } else if (arrayOffset < largeArraySize) {
        categoryTable.put(word, readStreamDocumentArray(stream, arrayOffset)); // read in-lined array providing size
      } else {
        arrayOffset = readStreamInt(stream); // read actual offset
        if (readDocNumbers) {
          if (matchingWords == null)
            matchingWords = new char[size][];
          if (count == 0)
            firstOffset = arrayOffset;
          matchingWords[count++] = word;
        }
        categoryTable.put(word, new Integer(arrayOffset)); // offset to array in the file
      }
    }
    this.categoryTables.put(INTERNED_CATEGORY_NAMES.get(categoryName), categoryTable);
    // cache the table as long as its not too big
    // in practice, some tables can be greater than 500K when they contain more than 10K elements
    this.cachedCategoryName = categoryTable.elementSize < 20000 ? categoryName : null;
  } catch (IOException ioe) {
    this.streamBuffer = null;
    throw ioe;
  } finally {
    stream.close();
  }

  if (matchingWords != null && count > 0) {
    stream = new FileInputStream(this.indexFile);
    try {
      stream.skip(firstOffset);
      this.bufferIndex = 0;
      this.bufferEnd = stream.read(this.streamBuffer, 0, this.streamBuffer.length);
      for (int i = 0; i < count; i++) { // each array follows the previous one
        categoryTable.put(matchingWords[i], readStreamDocumentArray(stream, readStreamInt(stream)));
      }
    } catch (IOException ioe) {
      this.streamBuffer = null;
      throw ioe;
    } finally {
View Full Code Here

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

    previousCategory = categoryName;
  }
  if (previousCategory != null) {
    this.categoryEnds.put(previousCategory, this.headerInfoOffset); // cache end of the category table
  }
  this.categoryTables = new HashtableOfObject(3);
}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.