Examples of HashtableOfObject


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

  Object[] wordSets = categoryToWords.valueTable;
  for (int i = 0, l = categoryNames.length; i < l; i++) {
    char[] categoryName = categoryNames[i];
    if (categoryName != null) {
      SimpleWordSet wordSet = (SimpleWordSet) wordSets[i];
      HashtableOfObject wordsToDocs = (HashtableOfObject) this.categoryTables.get(categoryName);
      if (wordsToDocs == null)
        this.categoryTables.put(categoryName, wordsToDocs = new HashtableOfObject(wordSet.elementSize));

      char[][] words = wordSet.words;
      for (int j = 0, m = words.length; j < m; j++) {
        char[] word = words[j];
        if (word != null) {
          Object o = wordsToDocs.get(word);
          if (o == null) {
            wordsToDocs.putUnsafely(word, new int[] {newPosition});
          } else if (o instanceof IntList) {
            ((IntList) o).add(newPosition);
          } else {
            IntList list = new IntList((int[]) o);
            list.add(newPosition);
            wordsToDocs.put(word, list);
          }
        }
      }
    }
  }
View Full Code Here

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

  }

  int size = diskIndex.categoryOffsets == null ? 8 : diskIndex.categoryOffsets.elementSize;
  this.categoryOffsets = new HashtableOfIntValues(size);
  this.categoryEnds = new HashtableOfIntValues(size);
  this.categoryTables = new HashtableOfObject(size);
  this.separator = diskIndex.separator;
}
View Full Code Here

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

    if (categoryNames[i] != null)
      mergeCategory(categoryNames[i], onDisk, positions, stream);
  this.categoryTables = null;
}
private void mergeCategory(char[] categoryName, DiskIndex onDisk, int[] positions, FileOutputStream stream) throws IOException {
  HashtableOfObject wordsToDocs = (HashtableOfObject) this.categoryTables.get(categoryName);
  if (wordsToDocs == null)
    wordsToDocs = new HashtableOfObject(3);

  HashtableOfObject oldWordsToDocs = onDisk.readCategoryTable(categoryName, true);
  if (oldWordsToDocs != null) {
    char[][] oldWords = oldWordsToDocs.keyTable;
    Object[] oldArrayOffsets = oldWordsToDocs.valueTable;
    nextWord: for (int i = 0, l = oldWords.length; i < l; i++) {
      char[] oldWord = oldWords[i];
View Full Code Here

Examples of 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.putUnsafely(word, new int[] {-arrayOffset}); // store 1 element array by negating documentNumber
      } else if (arrayOffset < largeArraySize) {
        categoryTable.putUnsafely(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.putUnsafely(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.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

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

    this.cachedChunks = null;
    if (this.categoryTables != null) {
      if (this.cachedCategoryName == null) {
        this.categoryTables = null;
      } else if (this.categoryTables.elementSize > 1) {
        HashtableOfObject newTables = new HashtableOfObject(3);
        newTables.put(this.cachedCategoryName, this.categoryTables.get(this.cachedCategoryName));
        this.categoryTables = newTables;
      }
    }
  }
}
View Full Code Here

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

    } finally {
      this.monitor.exitWriteEnterRead();
    }
  }

  HashtableOfObject results;
  int rule = matchRule & MATCH_RULE_INDEX_MASK;
  if (this.memoryIndex.hasChanged()) {
    results = this.diskIndex.addQueryResults(categories, key, rule, this.memoryIndex);
    results = this.memoryIndex.addQueryResults(categories, key, rule, results);
  } else {
View Full Code Here

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

      IProgressMonitor monitor) {
    super(settings);
    this.javaProject = javaProject;
    this.requestor = requestor;
    this.nameEnvironment = nameEnvironment;
    this.typeCache = new HashtableOfObject(5);
    this.openedBinaryTypes = 0;

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

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

    int length = this.acceptedConstructors.size();

    if(length == 0) return;
   
    HashtableOfObject onDemandFound = new HashtableOfObject();
   
    ArrayList deferredProposals = null;
    if (DEFER_QUALIFIED_PROPOSALS) {
      deferredProposals = new ArrayList();
    }
   
    try {
      next : for (int i = 0; i < length; i++) {
       
        // does not check cancellation for every types to avoid performance loss
        if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
       
        AcceptedConstructor acceptedConstructor = (AcceptedConstructor)this.acceptedConstructors.elementAt(i);
        final int typeModifiers = acceptedConstructor.typeModifiers;
        final char[] packageName = acceptedConstructor.packageName;
        final char[] simpleTypeName = acceptedConstructor.simpleTypeName;
        final int modifiers = acceptedConstructor.modifiers;
        final int parameterCount = acceptedConstructor.parameterCount;
        final char[] signature = acceptedConstructor.signature;
        final char[][] parameterTypes = acceptedConstructor.parameterTypes;
        final char[][] parameterNames = acceptedConstructor.parameterNames;
        final int extraFlags = acceptedConstructor.extraFlags;
        final int accessibility = acceptedConstructor.accessibility;
       
        boolean proposeType = hasArrayTypeAsExpectedSuperTypes() || (extraFlags & ExtraFlags.HasNonPrivateStaticMemberTypes) != 0;
       
        char[] fullyQualifiedName = CharOperation.concat(packageName, simpleTypeName, '.');
           
        Object knownTypeKind = this.knownTypes.get(fullyQualifiedName);
        if (knownTypeKind != null) {
          if (knownTypeKind == KNOWN_TYPE_WITH_KNOWN_CONSTRUCTORS) {
            // the type and its constructors are already accepted
            continue next;
          }
          // this type is already accepted
          proposeType = false;
        } else {
          this.knownTypes.put(fullyQualifiedName, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
        }
       
        boolean proposeConstructor = true;
         
        if (this.options.checkVisibility) {
          if((modifiers & ClassFileConstants.AccPublic) == 0) {
            if((modifiers & ClassFileConstants.AccPrivate) != 0) {
              if (!proposeType) continue next;
              proposeConstructor = false;
            } else {
              if (this.currentPackageName == null) {
                initializePackageCache();
              }
             
              if(!CharOperation.equals(packageName, this.currentPackageName)) {
               
                if((typeModifiers & ClassFileConstants.AccAbstract) == 0 ||
                    (modifiers & ClassFileConstants.AccProtected) == 0) {
                  if (!proposeType) continue next;
                  proposeConstructor = false;
                }
              }
            }
          }
        }
       
        acceptedConstructor.fullyQualifiedName = fullyQualifiedName;
        acceptedConstructor.proposeType = proposeType;
        acceptedConstructor.proposeConstructor = proposeConstructor;
       
       
        if(!this.importCachesInitialized) {
          initializeImportCaches();
        }
       
        for (int j = 0; j < this.importCacheCount; j++) {
          char[][] importName = this.importsCache[j];
          if(CharOperation.equals(simpleTypeName, importName[0])) {
            if (proposeType) {
              proposeType(
                  packageName,
                  simpleTypeName,
                  typeModifiers,
                  accessibility,
                  simpleTypeName,
                  fullyQualifiedName,
                  !CharOperation.equals(fullyQualifiedName, importName[1]),
                  scope);
            }
           
            if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
              boolean isQualified = !CharOperation.equals(fullyQualifiedName, importName[1]);
              if (!isQualified) {
                proposeConstructor(
                    simpleTypeName,
                    parameterCount,
                    signature,
                    parameterTypes,
                    parameterNames,
                    modifiers,
                    packageName,
                    typeModifiers,
                    accessibility,
                    simpleTypeName,
                    fullyQualifiedName,
                    isQualified,
                    scope,
                    extraFlags);
              } else {
                acceptedConstructor.mustBeQualified = true;
                if (DEFER_QUALIFIED_PROPOSALS) {
                  deferredProposals.add(acceptedConstructor);
                } else {
                  proposeConstructor(acceptedConstructor, scope);
                }
              }
            }
            continue next;
          }
        }


        if (CharOperation.equals(this.currentPackageName, packageName)) {
          if (proposeType) {
            proposeType(
                packageName,
                simpleTypeName,
                typeModifiers,
                accessibility,
                simpleTypeName,
                fullyQualifiedName,
                false,
                scope);
          }
         
          if (proposeConstructor && !Flags.isEnum(typeModifiers)) {
            proposeConstructor(
                simpleTypeName,
                parameterCount,
                signature,
                parameterTypes,
                parameterNames,
                modifiers,
                packageName,
                typeModifiers,
                accessibility,
                simpleTypeName,
                fullyQualifiedName,
                false,
                scope,
                extraFlags);
          }
          continue next;
        } else {
          char[] fullyQualifiedEnclosingTypeOrPackageName = null;

          AcceptedConstructor foundConstructor = null;
          if((foundConstructor = (AcceptedConstructor)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) {
                fullyQualifiedEnclosingTypeOrPackageName = packageName;
              }
              if(CharOperation.equals(fullyQualifiedEnclosingTypeOrPackageName, importFlatName)) {
                if(importBinding.isStatic()) {
                  if((typeModifiers & ClassFileConstants.AccStatic) != 0) {
                    onDemandFound.put(
                        simpleTypeName,
                        acceptedConstructor);
                    continue next;
                  }
                } else {
                  onDemandFound.put(
                      simpleTypeName,
                      acceptedConstructor);
                  continue next;
                }
              }
View Full Code Here

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

    int length = this.acceptedTypes.size();

    if(length == 0) return;

    HashtableOfObject onDemandFound = new HashtableOfObject();
   
    try {
      next : for (int i = 0; i < length; i++) {
       
        // does not check cancellation for every types to avoid performance loss
        if ((i % CHECK_CANCEL_FREQUENCY) == 0) checkCancel();
       
        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, KNOWN_TYPE_WITH_UNKNOWN_CONSTRUCTORS);
 
        if (this.resolvingImports) {
          if(this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_4 && packageName.length == 0) {
            continue next; // import of default package is forbidden when compliance is 1.4 or higher
          }
 
          char[] completionName = this.insideQualifiedReference ? simpleTypeName : fullyQualifiedName;
 
          if(this.resolvingStaticImports) {
            if(enclosingTypeNames == null || enclosingTypeNames.length == 0) {
              completionName = CharOperation.concat(completionName, new char[] { '.' });
            } else if ((modifiers & ClassFileConstants.AccStatic) == 0) {
              continue next;
            } else {
              completionName = CharOperation.concat(completionName, new char[] { ';' });
            }
          } else {
            completionName = CharOperation.concat(completionName, new char[] { ';' });
          }
 
          int relevance = computeBaseRelevance();
          relevance += computeRelevanceForResolution();
          relevance += computeRelevanceForInterestingProposal(packageName, fullyQualifiedName);
          relevance += computeRelevanceForRestrictions(accessibility);
          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) {
            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
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.