Program: 185414
Project: 185414
Buggy source:
@Override public VisitStatus acceptASTNode(ASTNode node,TypeLookupResult result,IJavaElement enclosingElement){
  boolean doCheck=false;
  boolean isAssignment=false;
  boolean isDeclaration=false;
  int start=0;
  int end=0;
  if (node instanceof ConstantExpression) {
    if (fieldName.equals(((ConstantExpression)node).getText()) && (result.confidence == TypeConfidence.UNKNOWN || result.declaringType.getField(fieldName) != null || result.declaringType.getProperty(fieldName) != null)) {
      doCheck=true;
      isAssignment=EqualityVisitor.checkForAssignment(node,result.enclosingAssignment);
      start=node.getStart();
      end=node.getEnd();
    }
  }
 else   if (node instanceof FieldExpression) {
    if (fieldName.equals(((FieldExpression)node).getFieldName())) {
      doCheck=true;
      isAssignment=EqualityVisitor.checkForAssignment(node,result.enclosingAssignment);
      start=end - fieldName.length();
      end=node.getEnd();
    }
  }
 else   if (node instanceof FieldNode) {
    FieldNode fnode=(FieldNode)node;
    if (fieldName.equals(fnode.getName())) {
      doCheck=true;
      isAssignment=true;
      isDeclaration=true;
      start=fnode.getNameStart();
      end=fnode.getNameEnd() + 1;
    }
  }
 else   if (node instanceof VariableExpression) {
    String vname=((VariableExpression)node).getName();
    if (fieldName.equals(vname)) {
      doCheck=true;
      isAssignment=EqualityVisitor.checkForAssignment(node,result.enclosingAssignment);
      start=node.getStart();
      end=start + vname.length();
    }
  }
  if (doCheck && end > 0 && result.declaringType != null) {
    Position position=new Position(start,end - start);
    if (!acceptedPositions.contains(position)) {
      boolean isCompleteMatch=qualifiedNameMatches(GroovyUtils.getBaseType(result.declaringType));
      if (isCompleteMatch && ((isAssignment && writeAccess) || (!isAssignment && readAccess) || (isDeclaration && findDeclarations))) {
        SearchMatch match=null;
        IJavaElement realElement=enclosingElement.getOpenable() instanceof GroovyClassFileWorkingCopy ? ((GroovyClassFileWorkingCopy)enclosingElement.getOpenable()).convertToBinary(enclosingElement) : enclosingElement;
        if (isDeclaration && findDeclarations) {
          match=new FieldDeclarationMatch(realElement,getAccuracy(result.confidence,isCompleteMatch),start,end - start,participant,realElement.getResource());
        }
 else         if (!isDeclaration && findReferences) {
          match=new FieldReferenceMatch(realElement,getAccuracy(result.confidence,isCompleteMatch),start,end - start,!isAssignment,isAssignment,false,participant,realElement.getResource());
        }
        if (match != null) {
          try {
            requestor.acceptSearchMatch(match);
            acceptedPositions.add(position);
          }
 catch (          CoreException e) {
            Util.log(e,"String_Node_Str" + realElement + "String_Node_Str"+ realElement.getResource());
          }
        }
      }
    }
  }
  return VisitStatus.CONTINUE;
}

Fixed version (ground truth):
@Override public VisitStatus acceptASTNode(ASTNode node,TypeLookupResult result,IJavaElement enclosingElement){
  boolean doCheck=false;
  boolean isAssignment=false;
  boolean isDeclaration=false;
  int start=0;
  int end=0;
  if (node instanceof ConstantExpression) {
    if (fieldName.equals(((ConstantExpression)node).getText()) && (result.confidence == TypeConfidence.UNKNOWN || result.declaringType.getField(fieldName) != null || result.declaringType.getProperty(fieldName) != null)) {
      doCheck=true;
      isAssignment=EqualityVisitor.checkForAssignment(node,result.enclosingAssignment);
      start=node.getStart();
      end=node.getEnd();
    }
  }
 else   if (node instanceof FieldExpression) {
    if (fieldName.equals(((FieldExpression)node).getFieldName())) {
      doCheck=true;
      isAssignment=EqualityVisitor.checkForAssignment(node,result.enclosingAssignment);
      start=node.getEnd() - fieldName.length();
      end=node.getEnd();
    }
  }
 else   if (node instanceof FieldNode) {
    FieldNode fnode=(FieldNode)node;
    if (fieldName.equals(fnode.getName())) {
      doCheck=true;
      isAssignment=true;
      isDeclaration=true;
      start=fnode.getNameStart();
      end=fnode.getNameEnd() + 1;
    }
  }
 else   if (node instanceof VariableExpression) {
    if (fieldName.equals(((VariableExpression)node).getName()) && (result.declaration instanceof FieldNode || result.declaration instanceof PropertyNode)) {
      doCheck=true;
      isAssignment=EqualityVisitor.checkForAssignment(node,result.enclosingAssignment);
      start=node.getStart();
      end=node.getEnd();
    }
  }
  if (doCheck && end > 0 && result.declaringType != null) {
    Position position=new Position(start,end - start);
    if (!acceptedPositions.contains(position)) {
      boolean isCompleteMatch=qualifiedNameMatches(GroovyUtils.getBaseType(result.declaringType));
      if (isCompleteMatch && ((isAssignment && writeAccess) || (!isAssignment && readAccess) || (isDeclaration && findDeclarations))) {
        SearchMatch match=null;
        if (enclosingElement.getOpenable() instanceof GroovyClassFileWorkingCopy)         enclosingElement=((GroovyClassFileWorkingCopy)enclosingElement.getOpenable()).convertToBinary(enclosingElement);
        if (isDeclaration && findDeclarations) {
          match=new FieldDeclarationMatch(enclosingElement,getAccuracy(result.confidence,isCompleteMatch),start,end - start,participant,enclosingElement.getResource());
        }
 else         if (!isDeclaration && findReferences) {
          match=new FieldReferenceMatch(enclosingElement,getAccuracy(result.confidence,isCompleteMatch),start,end - start,!isAssignment,isAssignment,false,participant,enclosingElement.getResource());
        }
        if (match != null) {
          try {
            requestor.acceptSearchMatch(match);
            acceptedPositions.add(position);
          }
 catch (          CoreException e) {
            Util.log(e,"String_Node_Str" + enclosingElement + "String_Node_Str"+ enclosingElement.getResource());
          }
        }
      }
    }
  }
  return VisitStatus.CONTINUE;
}