コード例 #1
0
  public String toString() {
    // TODO (jerome) should show both tables
    StringBuffer result = new StringBuffer();
    result.append("Exact matches:"); // $NON-NLS-1$
    Object[] keyTable = this.matchingNodes.keyTable;
    Object[] valueTable = this.matchingNodes.valueTable;
    for (int i = 0, l = keyTable.length; i < l; i++) {
      ASTNode node = (ASTNode) keyTable[i];
      if (node == null) continue;
      result.append("\n\t"); // $NON-NLS-1$
      switch (((Integer) valueTable[i]).intValue()) {
        case SearchMatch.A_ACCURATE:
          result.append("ACCURATE_MATCH: "); // $NON-NLS-1$
          break;
        case SearchMatch.A_INACCURATE:
          result.append("INACCURATE_MATCH: "); // $NON-NLS-1$
          break;
        case SearchPattern.R_ERASURE_MATCH:
          result.append("ERASURE_MATCH: "); // $NON-NLS-1$
          break;
      }
      node.print(0, result);
    }

    result.append("\nPossible matches:"); // $NON-NLS-1$
    Object[] nodes = this.possibleMatchingNodesSet.values;
    for (int i = 0, l = nodes.length; i < l; i++) {
      ASTNode node = (ASTNode) nodes[i];
      if (node == null) continue;
      result.append("\nPOSSIBLE_MATCH: "); // $NON-NLS-1$
      node.print(0, result);
    }
    return result.toString();
  }
コード例 #2
0
  public void addPossibleMatch(ASTNode node) {
    // remove existing node at same position from set
    // (case of recovery that created the same node several time
    // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
    long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
    ASTNode existing = (ASTNode) this.possibleMatchingNodesKeys.get(key);
    if (existing != null && existing.getClass().equals(node.getClass()))
      this.possibleMatchingNodesSet.remove(existing);

    // add node to set
    this.possibleMatchingNodesSet.add(node);
    this.possibleMatchingNodesKeys.put(key, node);
  }
コード例 #3
0
  void addTrustedMatch(ASTNode node, Integer level) {
    // remove existing node at same position from set
    // (case of recovery that created the same node several time
    // see http://bugs.eclipse.org/bugs/show_bug.cgi?id=29366)
    long key = (((long) node.sourceStart) << 32) + node.sourceEnd;
    ASTNode existing = (ASTNode) this.matchingNodesKeys.get(key);
    if (existing != null && existing.getClass().equals(node.getClass()))
      this.matchingNodes.removeKey(existing);

    // map node to its accuracy level
    this.matchingNodes.put(node, level);
    this.matchingNodesKeys.put(key, node);
  }
コード例 #4
0
ファイル: FieldBinding.java プロジェクト: beefeather/ohl
 /**
  * Compute the tagbits for standard annotations. For source types, these could require lazily
  * resolving corresponding annotation nodes, in case of forward references.
  *
  * @see org.eclipse.jdt.internal.compiler.lookup.Binding#getAnnotationTagBits()
  */
 public long getAnnotationTagBits() {
   FieldBinding originalField = original();
   if ((originalField.tagBits & TagBits.AnnotationResolved) == 0
       && originalField.declaringClass instanceof SourceTypeBinding) {
     ClassScope scope = ((SourceTypeBinding) originalField.declaringClass).scope;
     if (scope == null) { // synthetic fields do not have a scope nor any annotations
       this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
       return 0;
     }
     TypeDeclaration typeDecl = scope.referenceContext;
     FieldDeclaration fieldDecl = typeDecl.declarationOf(originalField);
     if (fieldDecl != null) {
       MethodScope initializationScope =
           isStatic() ? typeDecl.staticInitializerScope : typeDecl.initializerScope;
       FieldBinding previousField = initializationScope.initializedField;
       int previousFieldID = initializationScope.lastVisibleFieldID;
       try {
         initializationScope.initializedField = originalField;
         initializationScope.lastVisibleFieldID = originalField.id;
         ASTNode.resolveAnnotations(initializationScope, fieldDecl.annotations, originalField);
       } finally {
         initializationScope.initializedField = previousField;
         initializationScope.lastVisibleFieldID = previousFieldID;
       }
     }
   }
   return originalField.tagBits;
 }
コード例 #5
0
ファイル: PatchFixes.java プロジェクト: HamletDRC/lombok
 public static void setIsGeneratedFlag(
     org.eclipse.jdt.core.dom.ASTNode domNode,
     org.eclipse.jdt.internal.compiler.ast.ASTNode internalNode)
     throws Exception {
   if (internalNode == null || domNode == null) return;
   boolean isGenerated =
       internalNode.getClass().getField("$generatedBy").get(internalNode) != null;
   if (isGenerated) {
     domNode.getClass().getField("$isGenerated").set(domNode, true);
     domNode.setFlags(domNode.getFlags() & ~org.eclipse.jdt.core.dom.ASTNode.ORIGINAL);
   }
 }
コード例 #6
0
 /**
  * @param node
  * @param scope
  * @param oldName
  * @param newName
  * @return Has any replacement been performed?
  */
 public static boolean performReplacement(
     ASTNode node, BlockScope scope, char[] oldName, final char[] newName) {
   final int start = node.sourceStart;
   IExpressionProvider provider =
       new IExpressionProvider() {
         public Expression newExpression() {
           return new SingleNameReference(newName, start);
         }
       };
   ReplaceSingleNameVisitor replaceSingleNameVisitor =
       new ReplaceSingleNameVisitor(oldName, provider);
   node.traverse(replaceSingleNameVisitor, scope);
   return replaceSingleNameVisitor._hasChanges;
 }