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

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


      }
    }

    // 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) {
        // We used to report an error for initializers declared inside interfaces, but
        // now this error reporting is moved into the parser itself. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=212713
      } 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


  return results;
}
private HashtableOfObject addQueryResult(HashtableOfObject results, char[] word, Object docs, MemoryIndex memoryIndex, boolean prevResults) throws IOException {
  // must skip over documents which have been added/changed/deleted in the memory index
  if (results == null)
    results = new HashtableOfObject(13);
  EntryResult result = prevResults ? (EntryResult) results.get(word) : null;
  if (memoryIndex == null) {
    if (result == null)
      results.putUnsafely(word, new EntryResult(word, docs));
    else
View Full Code Here

}
HashtableOfObject addQueryResults(char[][] categories, char[] key, int matchRule, MemoryIndex memoryIndex) throws IOException {
  // assumes sender has called startQuery() & will call stopQuery() when finished
  if (this.categoryOffsets == null) return null; // file is empty

  HashtableOfObject results = null; // initialized if needed
 
  // No need to check the results table for duplicates while processing the
  // first category table or if the first category tables doesn't have any results.
  boolean prevResults = false;
  if (key == null) {
    for (int i = 0, l = categories.length; i < l; i++) {
      HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], true); // cache if key is null since its a definite match
      if (wordsToDocNumbers != null) {
        char[][] words = wordsToDocNumbers.keyTable;
        Object[] values = wordsToDocNumbers.valueTable;
        if (results == null)
          results = new HashtableOfObject(wordsToDocNumbers.elementSize);
        for (int j = 0, m = words.length; j < m; j++)
          if (words[j] != null)
            results = addQueryResult(results, words[j], values[j], memoryIndex, prevResults);
      }
      prevResults = results != null;
    }
    if (results != null && this.cachedChunks == null)
      cacheDocumentNames();
  } else {
    switch (matchRule) {
      case SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE:
        for (int i = 0, l = categories.length; i < l; i++) {
          HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false);
          Object value;
          if (wordsToDocNumbers != null && (value = wordsToDocNumbers.get(key)) != null)
            results = addQueryResult(results, key, value, memoryIndex, prevResults);
          prevResults = results != null;
        }
        break;
      case SearchPattern.R_PREFIX_MATCH | SearchPattern.R_CASE_SENSITIVE:
        for (int i = 0, l = categories.length; i < l; i++) {
          HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false);
          if (wordsToDocNumbers != null) {
            char[][] words = wordsToDocNumbers.keyTable;
            Object[] values = wordsToDocNumbers.valueTable;
            for (int j = 0, m = words.length; j < m; j++) {
              char[] word = words[j];
              if (word != null && key[0] == word[0] && CharOperation.prefixEquals(key, word))
                results = addQueryResult(results, word, values[j], memoryIndex, prevResults);
            }
          }
          prevResults = results != null;
        }
        break;
      default:
        for (int i = 0, l = categories.length; i < l; i++) {
          HashtableOfObject wordsToDocNumbers = readCategoryTable(categories[i], false);
          if (wordsToDocNumbers != null) {
            char[][] words = wordsToDocNumbers.keyTable;
            Object[] values = wordsToDocNumbers.valueTable;
            for (int j = 0, m = words.length; j < m; j++) {
              char[] word = words[j];
View Full Code Here

  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

  }

  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

    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

  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;
    }
  }

  InputStream stream = this.indexLocation.getInputStream();
  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.indexLocation); //$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.indexLocation); //$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 = this.indexLocation.getInputStream();
    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

    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

    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

    } 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

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.