Program: 83474
Project: 83474
Buggy source:
/** 
 * Invoked by   {@link AstGenerator}'s constructor to complete the initialization. <p> This is where the actual annotation of the source code happens.
 */
protected void configure(final CompilationUnitTree cu,final AstGenerator gen) throws IOException {
  final LineMap lineMap=cu.getLineMap();
  JavaLexer lexer=new JavaLexer(new CharSequenceReader(gen.sourceFile));
  lexer.setTabSize(tabWidth);
  try {
    Stack<Long> openBraces=new Stack<Long>();
    while (true) {
      Token token=lexer.nextToken();
      int type=token.getType();
      if (type == JavaTokenTypes.EOF)       break;
      if (type == JavaTokenTypes.IDENT && ReservedWords.LIST.contains(token.getText()))       gen.add(new Tag.ReservedWord(lineMap,token));
      if (type == JavaTokenTypes.ML_COMMENT || type == JavaTokenTypes.SL_COMMENT)       gen.add(new Tag.Comment(lineMap,token));
      if (type == JavaTokenTypes.LCURLY || type == JavaTokenTypes.LPAREN) {
        openBraces.push(getPosition(lineMap,token));
        gen.add(new Tag.Killer(lineMap,token));
      }
      if (type == JavaTokenTypes.RCURLY) {
        long sp=openBraces.pop();
        gen.add(new Tag.CurlyBracket(sp,getPosition(lineMap,token) + 1));
        gen.add(new Tag.Killer(lineMap,token));
      }
      if (type == JavaTokenTypes.RPAREN) {
        long sp=openBraces.pop();
        gen.add(new Tag.Parenthesis(sp,getPosition(lineMap,token) + 1));
        gen.add(new Tag.Killer(lineMap,token));
      }
    }
  }
 catch (  TokenStreamException e) {
  }
  final Name CLASS=elements.getName("String_Node_Str");
  new TreeScanner<Void,Void>(){
    /** 
 * primitive types like int, long, void, etc.
 */
    public Void visitPrimitiveType(    PrimitiveTypeTree pt,    Void _){
      return super.visitPrimitiveType(pt,_);
    }
    /** 
 * literal string, int, etc. Null.
 */
    public Void visitLiteral(    LiteralTree lit,    Void _){
      gen.add(new Literal(cu,srcPos,lit));
      return super.visitLiteral(lit,_);
    }
    /** 
 * Definition of a variable, such as parameter, field, and local variables.
 */
    public Void visitVariable(    VariableTree vt,    Void _){
      VariableElement e=(VariableElement)TreeUtil.getElement(vt);
      if (e != null) {
switch (e.getKind()) {
case ENUM_CONSTANT:
case FIELD:
          gen.add(new FieldDecl(cu,srcPos,vt));
        break;
case EXCEPTION_PARAMETER:
case LOCAL_VARIABLE:
case PARAMETER:
      gen.add(new LocalVarDecl(cu,srcPos,vt,e));
    break;
}
Token token;
if (e.getKind() != ElementKind.ENUM_CONSTANT) {
  token=gen.findTokenAfter(vt.getType(),true,vt.getName().toString());
}
 else {
  token=gen.findTokenAfter(vt,false,vt.getName().toString());
}
if (token != null) gen.add(new DeclName(lineMap,token));
}
return super.visitVariable(vt,_);
}
/** 
 * Method declaration.
 */
public Void visitMethod(MethodTree mt,Void _){
ExecutableElement e=(ExecutableElement)TreeUtil.getElement(mt);
if (e != null) {
if (e.getKind() == ElementKind.CONSTRUCTOR && e.getEnclosingElement().getSimpleName().length() == 0) return _;
Tree prev=mt.getReturnType();
String name=mt.getName().toString();
Token token;
if (prev != null) token=gen.findTokenAfter(prev,true,name);
 else token=gen.findTokenAfter(mt,false,name);
if (token != null) gen.add(new DeclName(lineMap,token));
ParsedType pt=getParsedType((TypeElement)e.getEnclosingElement());
gen.add(new MethodDecl(cu,srcPos,mt,e,pt.findOverriddenMethods(elements,e),pt.findOverridingMethods(elements,e)));
}
return super.visitMethod(mt,_);
}
/** 
 * Class declaration.
 */
public Void visitClass(ClassTree ct,Void _){
TypeElement e=(TypeElement)TreeUtil.getElement(ct);
if (e != null) {
Token token=null;
if (ct.getModifiers() != null) token=gen.findTokenAfter(ct.getModifiers(),true,ct.getSimpleName().toString());
if (token == null) token=gen.findTokenAfter(ct,false,ct.getSimpleName().toString());
if (token != null) gen.add(new DeclName(lineMap,token));
List<ParsedType> descendants=getParsedType(e).descendants;
gen.add(new ClassDecl(cu,srcPos,ct,e,descendants));
if (e.getNestingKind() == NestingKind.ANONYMOUS) {
  scan(ct.getMembers());
  return _;
}
}
return super.visitClass(ct,_);
}
/** 
 * All the symbols found in the source code.
 */
public Void visitIdentifier(IdentifierTree id,Void _){
if (!ReservedWords.LIST.contains(id.getName().toString())) {
Element e=TreeUtil.getElement(id);
if (e != null) {
switch (e.getKind()) {
case ANNOTATION_TYPE:
case CLASS:
case ENUM:
case INTERFACE:
    gen.add(new TypeRef(cu,srcPos,id,(TypeElement)e));
  break;
case FIELD:
case ENUM_CONSTANT:
gen.add(new FieldRef(cu,srcPos,id,(VariableElement)e));
break;
case PARAMETER:
case EXCEPTION_PARAMETER:
case LOCAL_VARIABLE:
gen.add(new LocalVarRef(cu,srcPos,id,(VariableElement)e));
break;
}
}
}
return super.visitIdentifier(id,_);
}
/** 
 * "exp.token"
 */
public Void visitMemberSelect(MemberSelectTree mst,Void _){
if (!mst.getIdentifier().equals(CLASS)) {
long ep=srcPos.getEndPosition(cu,mst);
long sp=ep - mst.getIdentifier().length();
Element e=TreeUtil.getElement(mst);
if (e != null) {
switch (e.getKind()) {
case FIELD:
case ENUM_CONSTANT:
gen.add(new FieldRef(sp,ep,(VariableElement)e));
break;
case ANNOTATION_TYPE:
case CLASS:
case ENUM:
case INTERFACE:
gen.add(new TypeRef(sp,ep,(TypeElement)e));
break;
}
}
}
return super.visitMemberSelect(mst,_);
}
/** 
 * Constructor invocation.
 */
public Void visitNewClass(NewClassTree nt,Void _){
long ep=srcPos.getEndPosition(cu,nt.getIdentifier());
long sp=srcPos.getStartPosition(cu,nt.getIdentifier());
Element e=TreeUtil.getElement(nt);
if (e instanceof ExecutableElement) {
ExecutableElement ee=(ExecutableElement)e;
TypeElement ownerType=(TypeElement)ee.getEnclosingElement();
if (ownerType.getSimpleName().length() == 0) {
scan(nt.getIdentifier());
}
 else {
gen.add(new MethodRef(sp,ep,ee));
}
}
scan(nt.getEnclosingExpression());
scan(nt.getArguments());
scan(nt.getTypeArguments());
scan(nt.getClassBody());
return _;
}
/** 
 * Method invocation of the form "exp.method()"
 */
public Void visitMethodInvocation(MethodInvocationTree mi,Void _){
ExpressionTree ms=mi.getMethodSelect();
Element e=TreeUtil.getElement(mi);
if (e instanceof ExecutableElement) {
ExecutableElement ee=(ExecutableElement)e;
Name methodName=ee.getSimpleName();
long ep=srcPos.getEndPosition(cu,ms);
if (ep >= 0) {
gen.add(new MethodRef(ep - methodName.length(),ep,ee));
}
}
return super.visitMethodInvocation(mi,_);
}
private void scan(List<? extends Tree> list){
for (Tree t : list) scan(t);
}
private void scan(Tree t){
scan(t,null);
}
}
.scan(cu,null);
ExpressionTree packageName=cu.getPackageName();
if (packageName != null) {
new TreeScanner<String,Void>(){
/** 
 * For "a" of "a.b.c"
 */
public String visitIdentifier(IdentifierTree id,Void _){
String name=id.getName().toString();
PackageElement pe=elements.getPackageElement(name);
return name;
}
public String visitMemberSelect(MemberSelectTree mst,Void _){
String baseName=scan(mst.getExpression(),_);
String name=mst.getIdentifier().toString();
if (baseName.length() > 0) name=baseName + '.' + name;
PackageElement pe=elements.getPackageElement(name);
long ep=srcPos.getEndPosition(cu,mst);
long sp=ep - mst.getIdentifier().length();
return name;
}
}
.scan(packageName,null);
}
}

Fixed version (ground truth):
/** 
 * Invoked by   {@link AstGenerator}'s constructor to complete the initialization. <p> This is where the actual annotation of the source code happens.
 */
protected void configure(final CompilationUnitTree cu,final AstGenerator gen) throws IOException {
  final LineMap lineMap=cu.getLineMap();
  JavaLexer lexer=new JavaLexer(new CharSequenceReader(gen.sourceFile));
  lexer.setTabSize(tabWidth);
  try {
    Stack<Long> openBraces=new Stack<Long>();
    while (true) {
      Token token=lexer.nextToken();
      int type=token.getType();
      if (type == JavaTokenTypes.EOF)       break;
      if (type == JavaTokenTypes.IDENT && ReservedWords.LIST.contains(token.getText()))       gen.add(new Tag.ReservedWord(lineMap,token));
      if (type == JavaTokenTypes.ML_COMMENT || type == JavaTokenTypes.SL_COMMENT)       gen.add(new Tag.Comment(lineMap,token));
      if (type == JavaTokenTypes.LCURLY || type == JavaTokenTypes.LPAREN) {
        openBraces.push(getPosition(lineMap,token));
        gen.add(new Tag.Killer(lineMap,token));
      }
      if (type == JavaTokenTypes.RCURLY) {
        long sp=openBraces.pop();
        gen.add(new Tag.CurlyBracket(sp,getPosition(lineMap,token) + 1));
        gen.add(new Tag.Killer(lineMap,token));
      }
      if (type == JavaTokenTypes.RPAREN) {
        long sp=openBraces.pop();
        gen.add(new Tag.Parenthesis(sp,getPosition(lineMap,token) + 1));
        gen.add(new Tag.Killer(lineMap,token));
      }
    }
  }
 catch (  TokenStreamException e) {
  }
  final Name CLASS=elements.getName("String_Node_Str");
  new TreeScanner<Void,Void>(){
    /** 
 * primitive types like int, long, void, etc.
 */
    public Void visitPrimitiveType(    PrimitiveTypeTree pt,    Void _){
      return super.visitPrimitiveType(pt,_);
    }
    /** 
 * literal string, int, etc. Null.
 */
    public Void visitLiteral(    LiteralTree lit,    Void _){
      gen.add(new Literal(cu,srcPos,lit));
      return super.visitLiteral(lit,_);
    }
    /** 
 * Definition of a variable, such as parameter, field, and local variables.
 */
    public Void visitVariable(    VariableTree vt,    Void _){
      VariableElement e=(VariableElement)TreeUtil.getElement(vt);
      if (e != null) {
switch (e.getKind()) {
case ENUM_CONSTANT:
case FIELD:
          gen.add(new FieldDecl(cu,srcPos,vt));
        break;
case EXCEPTION_PARAMETER:
case LOCAL_VARIABLE:
case PARAMETER:
      gen.add(new LocalVarDecl(cu,srcPos,vt,e));
    break;
}
Token token;
if (e.getKind() != ElementKind.ENUM_CONSTANT) {
  token=gen.findTokenAfter(vt.getType(),true,vt.getName().toString());
}
 else {
  token=gen.findTokenAfter(vt,false,vt.getName().toString());
}
if (token != null) gen.add(new DeclName(lineMap,token));
}
return super.visitVariable(vt,_);
}
/** 
 * Method declaration.
 */
public Void visitMethod(MethodTree mt,Void _){
ExecutableElement e=(ExecutableElement)TreeUtil.getElement(mt);
if (e != null) {
if (e.getKind() == ElementKind.CONSTRUCTOR && e.getEnclosingElement().getSimpleName().length() == 0) return _;
Tree prev=mt.getReturnType();
String name;
if (e.getKind() == ElementKind.CONSTRUCTOR) name=e.getEnclosingElement().getSimpleName().toString();
 else name=mt.getName().toString();
Token token;
if (prev != null) token=gen.findTokenAfter(prev,true,name);
 else token=gen.findTokenAfter(mt,false,name);
if (token != null) gen.add(new DeclName(lineMap,token));
ParsedType pt=getParsedType((TypeElement)e.getEnclosingElement());
gen.add(new MethodDecl(cu,srcPos,mt,e,pt.findOverriddenMethods(elements,e),pt.findOverridingMethods(elements,e)));
}
return super.visitMethod(mt,_);
}
/** 
 * Class declaration.
 */
public Void visitClass(ClassTree ct,Void _){
TypeElement e=(TypeElement)TreeUtil.getElement(ct);
if (e != null) {
Token token=null;
if (ct.getModifiers() != null) token=gen.findTokenAfter(ct.getModifiers(),true,ct.getSimpleName().toString());
if (token == null) token=gen.findTokenAfter(ct,false,ct.getSimpleName().toString());
if (token != null) gen.add(new DeclName(lineMap,token));
List<ParsedType> descendants=getParsedType(e).descendants;
gen.add(new ClassDecl(cu,srcPos,ct,e,descendants));
if (e.getNestingKind() == NestingKind.ANONYMOUS) {
  scan(ct.getMembers());
  return _;
}
}
return super.visitClass(ct,_);
}
/** 
 * All the symbols found in the source code.
 */
public Void visitIdentifier(IdentifierTree id,Void _){
if (!ReservedWords.LIST.contains(id.getName().toString())) {
Element e=TreeUtil.getElement(id);
if (e != null) {
switch (e.getKind()) {
case ANNOTATION_TYPE:
case CLASS:
case ENUM:
case INTERFACE:
    gen.add(new TypeRef(cu,srcPos,id,(TypeElement)e));
  break;
case FIELD:
case ENUM_CONSTANT:
gen.add(new FieldRef(cu,srcPos,id,(VariableElement)e));
break;
case PARAMETER:
case EXCEPTION_PARAMETER:
case LOCAL_VARIABLE:
gen.add(new LocalVarRef(cu,srcPos,id,(VariableElement)e));
break;
}
}
}
return super.visitIdentifier(id,_);
}
/** 
 * "exp.token"
 */
public Void visitMemberSelect(MemberSelectTree mst,Void _){
if (!mst.getIdentifier().equals(CLASS)) {
long ep=srcPos.getEndPosition(cu,mst);
long sp=ep - mst.getIdentifier().length();
Element e=TreeUtil.getElement(mst);
if (e != null) {
switch (e.getKind()) {
case FIELD:
case ENUM_CONSTANT:
gen.add(new FieldRef(sp,ep,(VariableElement)e));
break;
case ANNOTATION_TYPE:
case CLASS:
case ENUM:
case INTERFACE:
gen.add(new TypeRef(sp,ep,(TypeElement)e));
break;
}
}
}
return super.visitMemberSelect(mst,_);
}
/** 
 * Constructor invocation.
 */
public Void visitNewClass(NewClassTree nt,Void _){
long ep=srcPos.getEndPosition(cu,nt.getIdentifier());
long sp=srcPos.getStartPosition(cu,nt.getIdentifier());
Element e=TreeUtil.getElement(nt);
if (e instanceof ExecutableElement) {
ExecutableElement ee=(ExecutableElement)e;
TypeElement ownerType=(TypeElement)ee.getEnclosingElement();
if (ownerType.getSimpleName().length() == 0) {
scan(nt.getIdentifier());
}
 else {
gen.add(new MethodRef(sp,ep,ee));
}
}
scan(nt.getEnclosingExpression());
scan(nt.getArguments());
scan(nt.getTypeArguments());
scan(nt.getClassBody());
return _;
}
/** 
 * Method invocation of the form "exp.method()"
 */
public Void visitMethodInvocation(MethodInvocationTree mi,Void _){
ExpressionTree ms=mi.getMethodSelect();
Element e=TreeUtil.getElement(mi);
if (e instanceof ExecutableElement) {
ExecutableElement ee=(ExecutableElement)e;
Name methodName=ee.getSimpleName();
long ep=srcPos.getEndPosition(cu,ms);
if (ep >= 0) {
gen.add(new MethodRef(ep - methodName.length(),ep,ee));
}
}
return super.visitMethodInvocation(mi,_);
}
private void scan(List<? extends Tree> list){
for (Tree t : list) scan(t);
}
private void scan(Tree t){
scan(t,null);
}
}
.scan(cu,null);
ExpressionTree packageName=cu.getPackageName();
if (packageName != null) {
new TreeScanner<String,Void>(){
/** 
 * For "a" of "a.b.c"
 */
public String visitIdentifier(IdentifierTree id,Void _){
String name=id.getName().toString();
PackageElement pe=elements.getPackageElement(name);
return name;
}
public String visitMemberSelect(MemberSelectTree mst,Void _){
String baseName=scan(mst.getExpression(),_);
String name=mst.getIdentifier().toString();
if (baseName.length() > 0) name=baseName + '.' + name;
PackageElement pe=elements.getPackageElement(name);
long ep=srcPos.getEndPosition(cu,mst);
long sp=ep - mst.getIdentifier().length();
return name;
}
}
.scan(packageName,null);
}
}