public InferredType addType(char[] className, boolean isDefinition, String providerId) {
    InferredType type = findInferredType(className);

    if (type == null && className.length > 0) {
      if (numberInferredTypes == inferredTypes.length) {
        System.arraycopy(
            inferredTypes,
            0,
            (inferredTypes = new InferredType[numberInferredTypes * 2]),
            0,
            numberInferredTypes);
      }

      type = inferredTypes[numberInferredTypes++] = new InferredType(className);
      type.inferenceProviderID = providerId;
      if (className.length > 2
          && className[className.length - 2] == '['
          && className[className.length - 1] == ']') {
        type.isArray = true;
      }

      inferredTypesHash.put(className, type);
    }
    if (isDefinition && type != null) type.setIsDefinition(isDefinition);
    return type;
  }
예제 #2
0
  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) {
      existingWords = new SimpleWordSet(1);
    }
    existingWords.add(this.allWords.add(key));
    referenceTable.put(category, existingWords);
  }
예제 #3
0
 HashtableOfObject addQueryResults(
     char[][] categories, char[] key, int matchRule, HashtableOfObject results) {
   // assumed the disk index already skipped over documents which have been added/changed/deleted
   // 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]);
               }
             }
           }
         }
       }
     }
   }
   return results;
 }
 public InferredType findInferredType(char[] name) {
   return (InferredType) inferredTypesHash.get(name);
 }