nus-yam/ex-repair huggingface dataset:
Program: 185506
Project: 185506
Buggy source:
private boolean qualifiedNameMatches(String fullyQualifiedName){
  String[] tuple=splitQualifierAndSimpleName(fullyQualifiedName);
  String name=tuple[1], qualifier=tuple[0];
  if (!isCaseSensitive) {
    name=name.toLowerCase();
    qualifier=qualifier.toLowerCase();
  }
  boolean match=true;
  if (namePattern != null) {
    if (isCamelCase) {
      match=CharOperation.camelCaseMatch(namePattern,name.toCharArray());
    }
 else {
      match=CharOperation.equals(namePattern,name.toCharArray());
    }
  }
  if (match && qualificationPattern != null) {
    if (isCamelCase) {
      match=CharOperation.camelCaseMatch(qualificationPattern,qualifier.toCharArray());
    }
 else {
      match=CharOperation.equals(qualificationPattern,qualifier.toCharArray());
    }
  }
  if (!match && namePattern != null && qualificationPattern != null && qualifier.length() > (namePattern.length + qualificationPattern.length)) {
    char[] q=qualifier.toCharArray();
    int qualEnd=qualificationPattern.length, nameEnd=qualificationPattern.length + 1 + namePattern.length;
    if ((q[qualEnd] == '.' || q[qualEnd] == '$') && CharOperation.equals(qualificationPattern,q,0,qualEnd) && CharOperation.equals(namePattern,q,qualEnd + 1,nameEnd)) {
      match=(nameEnd == q.length || q[nameEnd] == '.' || q[nameEnd] == '$');
    }
  }
  return match;
}

Fixed version (ground truth):
private boolean qualifiedNameMatches(String fullyQualifiedName){
  String[] tuple=splitQualifierAndSimpleName(fullyQualifiedName);
  String name=tuple[1], qualifier=tuple[0];
  boolean match=unqualifiedNameMatches(name);
  if (match) {
    if (isCamelCase) {
      match=CharOperation.camelCaseMatch(qualificationPattern,qualifier.toCharArray());
    }
 else {
      match=CharOperation.match(qualificationPattern,qualifier.toCharArray(),isCaseSensitive);
    }
  }
  if (!match && namePattern != null && qualificationPattern != null && qualifier.length() > (namePattern.length + qualificationPattern.length)) {
    char[] q=qualifier.toCharArray();
    int qualEnd=qualificationPattern.length, nameEnd=qualificationPattern.length + namePattern.length + 1;
    if ((q[qualEnd] == '.' || q[qualEnd] == '$') && (q.length == nameEnd || q[nameEnd] == '.' || q[nameEnd] == '$') && CharOperation.match(CharOperation.concat(qualificationPattern,namePattern,'?'),q,isCaseSensitive)) {
      match=true;
    }
  }
  return match;
}
Program: 185507
Project: 185507
Buggy source:
/** 
 * The problem that this method gets around is that we can't tell exactly what the text is and exactly where or if there is a match in the source location. For example, in the text, the type can be fully qualified, or array, or coming from an alias, or a bound type parameter. On top of that, some source locations are off by one. All these will have location relative to the offset provided in the start and end fields of the   {@link ClassNode}.
 * @param node the class node to find in the source
 * @param elem the element used to find the text
 * @return the start and end offsets of the actual match, or null if no match exists.
 */
private int[] getMatchLocation(ClassNode node,IJavaElement elem,int maybeStart,int maybeEnd){
  if (cachedContentsAvailable(elem)) {
    int nameLength=maybeEnd - maybeStart;
    int start=-1, until=-1;
    String name=node.getName();
    int dollarIndex=name.lastIndexOf('$');
    name=name.substring(dollarIndex + 1);
    if (name.length() <= nameLength) {
      start=CharOperation.indexOf(name.toCharArray(),cachedContents,isCaseSensitive,maybeStart,maybeEnd + 1);
      until=start + name.length();
    }
    if (start == -1) {
      String nameWithoutPackage=node.getNameWithoutPackage();
      start=CharOperation.indexOf(nameWithoutPackage.toCharArray(),cachedContents,isCaseSensitive,maybeStart,maybeEnd + 1);
      until=start + nameWithoutPackage.length();
    }
    if (start != -1) {
      return new int[]{start,until};
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * The problem that this method gets around is that we can't tell exactly what the text is and exactly where or if there is a match in the source location. For example, in the text, the type can be fully qualified, or array, or coming from an alias, or a bound type parameter. On top of that, some source locations are off by one. All these will have location relative to the offset provided in the start and end fields of the   {@link ClassNode}.
 * @param node the class node to find in the source
 * @param elem the element used to find the text
 * @return the start and end offsets of the actual match, or null if no match exists.
 */
private int[] getMatchLocation(ClassNode node,IJavaElement elem,int maybeStart,int maybeEnd){
  if (maybeEnd > 0 && cachedContentsAvailable(elem)) {
    return getMatchLocation0(node.getName(),maybeStart,maybeEnd);
  }
  return null;
}
Program: 185508
Project: 185508
Buggy source:
@Test public void testAnonymousInner1() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    IType anonType=(IType)children[0];
    assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
    children=anonType.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    assertEquals("String_Node_Str",children[0].getElementName());
  }
  finally {
    unit.discardWorkingCopy();
  }
}

Fixed version (ground truth):
@Test @Ignore("String_Node_Str") public void testAnonymousInner1() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    IType anonType=(IType)children[0];
    assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
    children=anonType.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    assertEquals("String_Node_Str",children[0].getElementName());
  }
  finally {
    unit.discardWorkingCopy();
  }
}
Program: 185509
Project: 185509
Buggy source:
@Test public void testAnonymousInner2() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),2,children.length);
    for (int i=0; i < 2; i++) {
      IType anonType=(IType)children[i];
      assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
      IJavaElement[] anonChildren=anonType.getChildren();
      assertEquals("String_Node_Str" + Arrays.toString(anonChildren),i + 1,anonChildren.length);
      assertEquals("String_Node_Str",anonChildren[0].getElementName());
      if (i == 1) {
        assertEquals("String_Node_Str",anonChildren[1].getElementName());
      }
    }
  }
  finally {
    unit.discardWorkingCopy();
  }
}

Fixed version (ground truth):
@Test @Ignore("String_Node_Str") public void testAnonymousInner2() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),2,children.length);
    for (int i=0; i < 2; i++) {
      IType anonType=(IType)children[i];
      assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
      IJavaElement[] anonChildren=anonType.getChildren();
      assertEquals("String_Node_Str" + Arrays.toString(anonChildren),i + 1,anonChildren.length);
      assertEquals("String_Node_Str",anonChildren[0].getElementName());
      if (i == 1) {
        assertEquals("String_Node_Str",anonChildren[1].getElementName());
      }
    }
  }
  finally {
    unit.discardWorkingCopy();
  }
}
Program: 185510
Project: 185510
Buggy source:
@Test public void testAnonymousInner3() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    IType anonType=(IType)children[0];
    assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
    children=anonType.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    assertEquals("String_Node_Str",children[0].getElementName());
  }
  finally {
    unit.discardWorkingCopy();
  }
}

Fixed version (ground truth):
@Test @Ignore("String_Node_Str") public void testAnonymousInner3() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    IType anonType=(IType)children[0];
    assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
    children=anonType.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    assertEquals("String_Node_Str",children[0].getElementName());
  }
  finally {
    unit.discardWorkingCopy();
  }
}
Program: 185511
Project: 185511
Buggy source:
@Test public void testAnonymousInner4() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),2,children.length);
    for (int i=0; i < 2; i++) {
      IType anonType=(IType)children[i];
      assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
      IJavaElement[] innerChildren=anonType.getChildren();
      assertEquals("String_Node_Str" + Arrays.toString(children),i + 1,innerChildren.length);
      assertEquals("String_Node_Str",innerChildren[0].getElementName());
      if (i == 1) {
        assertEquals("String_Node_Str",innerChildren[1].getElementName());
      }
    }
  }
  finally {
    unit.discardWorkingCopy();
  }
}

Fixed version (ground truth):
@Test @Ignore("String_Node_Str") public void testAnonymousInner4() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),2,children.length);
    for (int i=0; i < 2; i++) {
      IType anonType=(IType)children[i];
      assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
      IJavaElement[] innerChildren=anonType.getChildren();
      assertEquals("String_Node_Str" + Arrays.toString(children),i + 1,innerChildren.length);
      assertEquals("String_Node_Str",innerChildren[0].getElementName());
      if (i == 1) {
        assertEquals("String_Node_Str",innerChildren[1].getElementName());
      }
    }
  }
  finally {
    unit.discardWorkingCopy();
  }
}
Program: 185512
Project: 185512
Buggy source:
@Test public void testAnonymousInner5() throws Exception {
  IPath path=env.addGroovyClass(createAnnotationGroovyProject(),"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IField field=type.getField("String_Node_Str");
    assertEquals(0,field.getChildren().length);
    IType anon=type.getType("String_Node_Str");
    assertTrue("String_Node_Str",anon.exists());
  }
  finally {
    unit.discardWorkingCopy();
  }
}

Fixed version (ground truth):
@Test @Ignore("String_Node_Str") public void testAnonymousInner5() throws Exception {
  IPath path=env.addGroovyClass(createAnnotationGroovyProject(),"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    IType type=unit.getType("String_Node_Str");
    IField field=type.getField("String_Node_Str");
    assertEquals(0,field.getChildren().length);
    IType anon=type.getType("String_Node_Str");
    assertTrue("String_Node_Str",anon.exists());
  }
  finally {
    unit.discardWorkingCopy();
  }
}
Program: 185513
Project: 185513
Buggy source:
@Test public void testAnonymousInner6() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    unit.getType("String_Node_Str").exists();
    unit.getType("String_Node_Str").exists();
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    IType anonType=(IType)children[0];
    assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
    children=anonType.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    assertEquals("String_Node_Str",children[0].getElementName());
  }
  finally {
    unit.discardWorkingCopy();
  }
}

Fixed version (ground truth):
@Test @Ignore("String_Node_Str") public void testAnonymousInner6() throws Exception {
  IPath root=createAnnotationGroovyProject();
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  incrementalBuild();
  env.waitForAutoBuild();
  expectingNoProblems();
  GroovyCompilationUnit unit=env.getUnit(path);
  unit.becomeWorkingCopy(new NullProgressMonitor());
  try {
    unit.getType("String_Node_Str").exists();
    unit.getType("String_Node_Str").exists();
    IType type=unit.getType("String_Node_Str");
    IMethod method=type.getMethod("String_Node_Str",new String[0]);
    IJavaElement[] children=method.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    IType anonType=(IType)children[0];
    assertEquals("String_Node_Str","String_Node_Str",anonType.getElementName());
    children=anonType.getChildren();
    assertEquals("String_Node_Str" + Arrays.toString(children),1,children.length);
    assertEquals("String_Node_Str",children[0].getElementName());
  }
  finally {
    unit.discardWorkingCopy();
  }
}
Program: 185514
Project: 185514
Buggy source:
@Override public void buildFieldsAndMethods(){
  super.buildFieldsAndMethods();
  GroovyTypeDeclaration context=(GroovyTypeDeclaration)referenceContext;
  GroovyTypeDeclaration[] anonymousTypes=context.getAnonymousTypes();
  if (anonymousTypes != null) {
    for (    GroovyTypeDeclaration anonType : anonymousTypes) {
      GroovyClassScope anonScope=new GroovyClassScope(this,anonType);
      anonType.scope=anonScope;
      anonType.resolve(anonType.enclosingMethod.scope);
    }
  }
  for (  MethodBinding method : referenceContext.binding.methods()) {
    fixupTypeParameters(method);
  }
}

Fixed version (ground truth):
@Override public void buildFieldsAndMethods(){
  super.buildFieldsAndMethods();
  GroovyTypeDeclaration context=(GroovyTypeDeclaration)referenceContext;
  GroovyTypeDeclaration[] anonymousTypes=context.getAnonymousTypes();
  if (anonymousTypes != null) {
    for (    GroovyTypeDeclaration anonType : anonymousTypes) {
      anonType.scope=new GroovyClassScope(this,anonType);
      anonType.resolve(anonType.enclosingScope);
    }
  }
  for (  MethodBinding method : referenceContext.binding.methods()) {
    fixupTypeParameters(method);
  }
}
Program: 185515
Project: 185515
Buggy source:
@Test public void testClosure9(){
  String contents="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Test public void testClosure9(){
  String contents="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
}
Program: 185516
Project: 185516
Buggy source:
@Test public void testClosure7(){
  String contents="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Test public void testClosure7(){
  String contents="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
}
Program: 185517
Project: 185517
Buggy source:
@Test public void testClosure8(){
  String contents="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Test public void testClosure8(){
  String contents="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
  assertExprType(contents,"String_Node_Str","String_Node_Str");
}
Program: 185518
Project: 185518
Buggy source:
protected ClassNode findDeclaringType(Expression node,VariableScope scope,TypeConfidence[] confidence){
  if (node instanceof ClassExpression || node instanceof ConstructorCallExpression) {
    return node.getType();
  }
 else   if (node instanceof FieldExpression) {
    return ((FieldExpression)node).getField().getDeclaringClass();
  }
 else   if (node instanceof StaticMethodCallExpression) {
    return ((StaticMethodCallExpression)node).getOwnerType();
  }
 else   if (node instanceof ConstantExpression && scope.isMethodCall()) {
    return scope.getDelegateOrThis();
  }
 else   if (node instanceof VariableExpression) {
    Variable var=((VariableExpression)node).getAccessedVariable();
    if (var != null && !(var instanceof Parameter || var instanceof VariableExpression)) {
      ClassNode ownerType;
      ownerType=scope.getEnclosingTypeDeclaration();
      return ownerType;
    }
  }
  return VariableScope.OBJECT_CLASS_NODE;
}

Fixed version (ground truth):
protected ClassNode findDeclaringType(Expression node,VariableScope scope,TypeConfidence[] confidence){
  if (node instanceof ClassExpression || node instanceof ConstructorCallExpression) {
    return node.getType();
  }
 else   if (node instanceof FieldExpression) {
    return ((FieldExpression)node).getField().getDeclaringClass();
  }
 else   if (node instanceof StaticMethodCallExpression) {
    return ((StaticMethodCallExpression)node).getOwnerType();
  }
 else   if (node instanceof ConstantExpression && scope.isMethodCall()) {
    ClassNode ownerType;
    if (scope.getEnclosingClosure() != null) {
      ownerType=scope.getOwner();
    }
 else {
      ownerType=scope.getEnclosingTypeDeclaration();
    }
    return ownerType;
  }
 else   if (node instanceof VariableExpression) {
    Variable var=((VariableExpression)node).getAccessedVariable();
    if (var != null && !(var instanceof Parameter || var instanceof VariableExpression)) {
      ClassNode ownerType;
      if (scope.getEnclosingClosure() != null) {
        ownerType=scope.getOwner();
      }
 else {
        ownerType=scope.getEnclosingTypeDeclaration();
      }
      return ownerType;
    }
  }
  return VariableScope.OBJECT_CLASS_NODE;
}
Program: 185519
Project: 185519
Buggy source:
protected static boolean isCompatible(AnnotatedNode declaration,boolean isStaticExpression){
  if (declaration != null) {
    boolean isStatic=false;
    if (declaration instanceof FieldNode) {
      isStatic=((FieldNode)declaration).isStatic();
    }
 else     if (declaration instanceof MethodNode) {
      isStatic=((MethodNode)declaration).isStatic();
    }
 else     if (declaration instanceof PropertyNode) {
      isStatic=((PropertyNode)declaration).isStatic();
    }
    if (!isStaticExpression || isStatic || declaration.getDeclaringClass().equals(VariableScope.CLASS_CLASS_NODE)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
protected static boolean isCompatible(AnnotatedNode declaration,boolean isStaticExpression){
  if (declaration != null) {
    boolean isStatic=false;
    if (declaration instanceof FieldNode) {
      isStatic=((FieldNode)declaration).isStatic();
    }
 else     if (declaration instanceof MethodNode) {
      isStatic=((MethodNode)declaration).isStatic();
    }
 else     if (declaration instanceof PropertyNode) {
      isStatic=((PropertyNode)declaration).isStatic();
    }
    if (!isStaticExpression || isStatic || VariableScope.CLASS_CLASS_NODE.equals(declaration.getDeclaringClass())) {
      return true;
    }
  }
  return false;
}
Program: 185520
Project: 185520
Buggy source:
protected ASTNode findDeclarationForDynamicVariable(VariableExpression var,ClassNode owner,VariableScope scope,int resolveStrategy){
  ASTNode candidate=null;
  List<ClassNode> callArgs=scope.getMethodCallArgumentTypes();
  boolean isLhsExpr=(scope.getWormhole().remove("String_Node_Str") == var);
  if (resolveStrategy == Closure.DELEGATE_FIRST || resolveStrategy == Closure.DELEGATE_ONLY) {
    candidate=findDeclaration(var.getName(),scope.getDelegate(),isLhsExpr,false,false,callArgs);
  }
  if (candidate == null && resolveStrategy < Closure.DELEGATE_ONLY) {
    candidate=findDeclaration(var.getName(),owner,isLhsExpr,scope.isOwnerStatic(),scope.isFieldAccessDirect(),callArgs);
    if (candidate == null && resolveStrategy < Closure.DELEGATE_FIRST && scope.getEnclosingClosure() != null) {
      candidate=findDeclaration(var.getName(),scope.getDelegate(),isLhsExpr,false,false,callArgs);
    }
  }
  if (candidate == null && (resolveStrategy <= Closure.DELEGATE_FIRST || resolveStrategy == Closure.TO_SELF) && (resolveStrategy > 0 || scope.getEnclosingClosure() != null)) {
    candidate=findDeclaration(var.getName(),VariableScope.CLOSURE_CLASS_NODE,isLhsExpr,false,false,callArgs);
  }
  return candidate;
}

Fixed version (ground truth):
protected ASTNode findDeclarationForDynamicVariable(VariableExpression var,ClassNode owner,VariableScope scope,int resolveStrategy){
  ASTNode candidate=null;
  List<ClassNode> callArgs=scope.getMethodCallArgumentTypes();
  boolean isLhsExpr=(scope.getWormhole().remove("String_Node_Str") == var);
  if (resolveStrategy == Closure.DELEGATE_FIRST || resolveStrategy == Closure.DELEGATE_ONLY) {
    candidate=findDeclaration(var.getName(),scope.getDelegate(),isLhsExpr,false,false,callArgs);
  }
  if (candidate == null && resolveStrategy < Closure.DELEGATE_ONLY) {
    VariableScope outer=owner.getNodeMetaData("String_Node_Str");
    if (outer != null) {
      if (isLhsExpr)       scope.getWormhole().put("String_Node_Str",var);
      VariableScope.CallAndType cat=outer.getEnclosingMethodCallExpression();
      int enclosingResolveStrategy=(cat == null ? 0 : cat.getResolveStrategy(outer.getEnclosingClosure()));
      candidate=findDeclarationForDynamicVariable(var,outer.getOwner(),outer,enclosingResolveStrategy);
    }
 else {
      candidate=findDeclaration(var.getName(),owner,isLhsExpr,scope.isOwnerStatic(),scope.isFieldAccessDirect(),callArgs);
    }
    if (candidate == null && resolveStrategy < Closure.DELEGATE_FIRST && scope.getEnclosingClosure() != null) {
      candidate=findDeclaration(var.getName(),scope.getDelegate(),isLhsExpr,false,false,callArgs);
    }
  }
  if (candidate == null && (resolveStrategy <= Closure.DELEGATE_FIRST || resolveStrategy == Closure.TO_SELF) && (resolveStrategy > 0 || scope.getEnclosingClosure() != null)) {
    candidate=findDeclaration(var.getName(),VariableScope.CLOSURE_CLASS_NODE,isLhsExpr,false,false,callArgs);
  }
  return candidate;
}
Program: 185523
Project: 185523
Buggy source:
public ClassNode getThis(){
  VariableInfo thiz=lookupName("String_Node_Str");
  return thiz != null ? thiz.type : null;
}

Fixed version (ground truth):
public ClassNode getThis(){
  VariableInfo info=lookupName("String_Node_Str");
  return info != null ? info.type : null;
}
Program: 185524
Project: 185524
Buggy source:
public ClassNode getDelegate(){
  VariableInfo delegate=lookupName("String_Node_Str");
  return delegate != null ? delegate.type : null;
}

Fixed version (ground truth):
public ClassNode getDelegate(){
  VariableInfo info=lookupName("String_Node_Str");
  return info != null ? info.type : null;
}
Program: 185525
Project: 185525
Buggy source:
public ClassNode getDelegateOrThis(){
  VariableInfo info=getDelegateOrThisInfo();
  return info != null ? info.type : null;
}

Fixed version (ground truth):
/** 
 * @return the current delegate type if exists, or this type if exists.Returns null if in top level scope (i.e. in import statement).
 */
public ClassNode getDelegateOrThis(){
  ClassNode type=getDelegate();
  if (type == null) {
    type=getThis();
  }
  return type;
}
Program: 185526
Project: 185526
Buggy source:
private VariableScope getEnclosingClosureScope(){
  VariableScope scope=this;
  do {
    if (scope.scopeNode instanceof ClosureExpression) {
      return scope;
    }
  }
 while ((scope=scope.parent) != null);
  return null;
}

Fixed version (ground truth):
VariableScope getEnclosingClosureScope(){
  VariableScope scope=this;
  do {
    if (scope.scopeNode instanceof ClosureExpression) {
      return scope;
    }
  }
 while ((scope=scope.parent) != null);
  return null;
}
Program: 185527
Project: 185527
Buggy source:
@Test public void testDGM2(){
  String contents="String_Node_Str";
  int start=contents.lastIndexOf("String_Node_Str");
  assertType(contents,start,start + 5,"String_Node_Str");
}

Fixed version (ground truth):
@Test public void testDGM2(){
  String contents="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
  int start=contents.lastIndexOf("String_Node_Str");
  assertType(contents,start,start + 5,"String_Node_Str");
}
Program: 185529
Project: 185529
Buggy source:
@Override public void visitArgumentlistExpression(ArgumentListExpression node){
  CallAndType callAndType=scopes.getLast().getEnclosingMethodCallExpression();
  boolean closureFound=false;
  if (callAndType != null && callAndType.declaration instanceof MethodNode) {
    Map<ClosureExpression,ClassNode> map=new HashMap<ClosureExpression,ClassNode>();
    MethodNode methodNode=(MethodNode)callAndType.declaration;
    if (node.getExpressions().size() == methodNode.getParameters().length) {
      for (int i=0; i < node.getExpressions().size(); i++) {
        if (node.getExpression(i) instanceof ClosureExpression) {
          map.put((ClosureExpression)node.getExpression(i),methodNode.getParameters()[i].getType());
          closureFound=true;
        }
      }
    }
    if (closureFound) {
      closureTypes.addLast(map);
    }
  }
  visitTupleExpression(node);
  if (closureFound) {
    closureTypes.removeLast();
  }
}

Fixed version (ground truth):
@Override public void visitArgumentlistExpression(ArgumentListExpression node){
  VariableScope.CallAndType callAndType=scopes.getLast().getEnclosingMethodCallExpression();
  boolean closureFound=false;
  if (callAndType != null && callAndType.declaration instanceof MethodNode) {
    Map<ClosureExpression,ClassNode> map=new HashMap<ClosureExpression,ClassNode>();
    MethodNode methodNode=(MethodNode)callAndType.declaration;
    if (node.getExpressions().size() == methodNode.getParameters().length) {
      for (int i=0; i < node.getExpressions().size(); i++) {
        if (node.getExpression(i) instanceof ClosureExpression) {
          map.put((ClosureExpression)node.getExpression(i),methodNode.getParameters()[i].getType());
          closureFound=true;
        }
      }
    }
    if (closureFound) {
      closureTypes.addLast(map);
    }
  }
  visitTupleExpression(node);
  if (closureFound) {
    closureTypes.removeLast();
  }
}
Program: 185531
Project: 185531
Buggy source:
@Override public void visitMethodCallExpression(MethodCallExpression node){
  scopes.getLast().setCurrentNode(node);
  if (isDependentExpression(node)) {
    primaryTypeStack.removeLast();
  }
  completeExpressionStack.add(node);
  node.getObjectExpression().visit(this);
  if (node.isSpreadSafe()) {
    ClassNode objType=primaryTypeStack.removeLast();
    primaryTypeStack.add(VariableScope.extractElementType(objType));
  }
  if (node.isUsingGenerics()) {
    visitGenericTypes(node.getGenericsTypes(),null);
  }
  node.getMethod().visit(this);
  ClassNode returnType=dependentTypeStack.removeLast();
  Tuple t=dependentDeclarationStack.removeLast();
  CallAndType call=new CallAndType(node,t.declaringType,t.declaration,unit.getModuleNode());
  completeExpressionStack.removeLast();
  ClassNode catNode=isCategoryDeclaration(node);
  if (catNode != null) {
    scopes.getLast().setCategoryBeingDeclared(catNode);
  }
  VariableScope scope=scopes.getLast();
  scope.addEnclosingMethodCall(call);
  node.getArguments().visit(this);
  scope.forgetEnclosingMethodCall();
  if (node.isSpreadSafe()) {
    returnType=createParameterizedList(returnType);
  }
  Expression expr=GroovyUtils.getTraitFieldExpression(node);
  if (expr != null) {
    handleSimpleExpression(expr);
    postVisit(node,returnType,t.declaringType,node);
  }
 else {
    handleCompleteExpression(node,returnType,t.declaringType);
  }
  scopes.getLast().forgetCurrentNode();
}

Fixed version (ground truth):
@Override public void visitMethodCallExpression(MethodCallExpression node){
  scopes.getLast().setCurrentNode(node);
  if (isDependentExpression(node)) {
    primaryTypeStack.removeLast();
  }
  completeExpressionStack.add(node);
  node.getObjectExpression().visit(this);
  if (node.isSpreadSafe()) {
    ClassNode objType=primaryTypeStack.removeLast();
    primaryTypeStack.add(VariableScope.extractElementType(objType));
  }
  if (node.isUsingGenerics()) {
    visitGenericTypes(node.getGenericsTypes(),null);
  }
  node.getMethod().visit(this);
  ClassNode returnType=dependentTypeStack.removeLast();
  Tuple t=dependentDeclarationStack.removeLast();
  VariableScope.CallAndType call=new VariableScope.CallAndType(node,t.declaringType,t.declaration,unit.getModuleNode());
  completeExpressionStack.removeLast();
  ClassNode catNode=isCategoryDeclaration(node);
  if (catNode != null) {
    scopes.getLast().setCategoryBeingDeclared(catNode);
  }
  VariableScope scope=scopes.getLast();
  scope.addEnclosingMethodCall(call);
  node.getArguments().visit(this);
  scope.forgetEnclosingMethodCall();
  if (node.isSpreadSafe()) {
    returnType=createParameterizedList(returnType);
  }
  Expression expr=GroovyUtils.getTraitFieldExpression(node);
  if (expr != null) {
    handleSimpleExpression(expr);
    postVisit(node,returnType,t.declaringType,node);
  }
 else {
    handleCompleteExpression(node,returnType,t.declaringType);
  }
  scopes.getLast().forgetCurrentNode();
}
Program: 185532
Project: 185532
Buggy source:
public void addEnclosingMethodCall(CallAndType enclosingMethodCall){
  shared.enclosingCallStack.add(enclosingMethodCall);
}

Fixed version (ground truth):
public void addEnclosingMethodCall(CallAndType enclosingMethodCall){
}
Program: 185533
Project: 185533
Buggy source:
public int getEnclosingClosureResolveStrategy(){
  int resolveStrategy=Closure.OWNER_FIRST;
  CallAndType cat=getEnclosingMethodCallExpression();
  if (cat != null) {
    resolveStrategy=cat.getResolveStrategy(getEnclosingClosure());
  }
  return resolveStrategy;
}

Fixed version (ground truth):
public int getEnclosingClosureResolveStrategy(){
  VariableScope scope=getEnclosingClosureScope();
  int resolveStrategy=Closure.OWNER_FIRST;
  if (scope != null) {
    CallAndType cat=scope.getEnclosingMethodCallExpression();
    if (cat != null) {
      resolveStrategy=cat.getResolveStrategy((ClosureExpression)scope.scopeNode);
    }
  }
  return resolveStrategy;
}
Program: 185534
Project: 185534
Buggy source:
public VariableScope(VariableScope parent,ASTNode enclosingNode,boolean isStatic){
  this.parent=parent;
  this.scopeNode=enclosingNode;
  this.shared=parent != null ? parent.shared : new SharedState();
  this.isStaticScope=(isStatic || (parent != null && parent.isStaticScope)) && (getEnclosingClosure() == null);
  if (enclosingNode instanceof MethodNode) {
    this.shared.isRunMethod=((MethodNode)enclosingNode).isScriptBody();
  }
 else   if (enclosingNode instanceof FieldNode || enclosingNode instanceof ClassNode) {
    this.shared.isRunMethod=false;
  }
}

Fixed version (ground truth):
public VariableScope(VariableScope parent,ASTNode enclosingNode,boolean isStatic){
  this.parent=parent;
  this.scopeNode=enclosingNode;
  this.shared=parent != null ? parent.shared : new SharedState();
  this.enclosingCallStackDepth=shared.enclosingCallStack.size();
  this.isStaticScope=(isStatic || (parent != null && parent.isStaticScope)) && (getEnclosingClosure() == null);
  if (enclosingNode instanceof MethodNode) {
    this.shared.isRunMethod=((MethodNode)enclosingNode).isScriptBody();
  }
 else   if (enclosingNode instanceof FieldNode || enclosingNode instanceof ClassNode) {
    this.shared.isRunMethod=false;
  }
}
Program: 185535
Project: 185535
Buggy source:
public ClosureExpression getEnclosingClosure(){
  if (scopeNode instanceof ClosureExpression) {
    return (ClosureExpression)scopeNode;
  }
  if (parent != null) {
    return parent.getEnclosingClosure();
  }
  return null;
}

Fixed version (ground truth):
public ClosureExpression getEnclosingClosure(){
  VariableScope scope=getEnclosingClosureScope();
  return (scope != null ? (ClosureExpression)scope.scopeNode : null);
}
Program: 185536
Project: 185536
Buggy source:
public void forgetEnclosingMethodCall(){
  shared.enclosingCallStack.removeLast();
}

Fixed version (ground truth):
public void forgetEnclosingMethodCall(){
}
Program: 185537
Project: 185537
Buggy source:
public CallAndType getEnclosingMethodCallExpression(){
  if (shared.enclosingCallStack.isEmpty()) {
    return null;
  }
 else {
    return shared.enclosingCallStack.getLast();
  }
}

Fixed version (ground truth):
public CallAndType getEnclosingMethodCallExpression(){
  List<CallAndType> enclosingCalls=getAllEnclosingMethodCallExpressions();
  return (!enclosingCalls.isEmpty() ? enclosingCalls.get(enclosingCalls.size() - 1) : null);
}
Program: 185538
Project: 185538
Buggy source:
/** 
 * @return the enclosing method call expression if one exists, or null otherwise.For example, when visiting the following closure, the enclosing method call is 'run' <pre> def runner = new Runner() runner.run { print "hello!" } </pre>
 */
public List<CallAndType> getAllEnclosingMethodCallExpressions(){
  return shared.enclosingCallStack;
}

Fixed version (ground truth):
/** 
 * @return the enclosing method call expression if one exists, or null otherwise.For example, when visiting the following closure, the enclosing method call is 'run' <pre> def runner = new Runner() runner.run { print "hello!" } </pre>
 */
public List<CallAndType> getAllEnclosingMethodCallExpressions(){
  return shared.enclosingCallStack.subList(0,enclosingCallStackDepth);
}
Program: 185539
Project: 185539
Buggy source:
protected ASTNode findDeclarationForDynamicVariable(VariableExpression var,ClassNode owner,VariableScope scope,int resolveStrategy){
  ASTNode candidate=null;
  List<ClassNode> callArgs=scope.getMethodCallArgumentTypes();
  boolean isLhsExpr=(scope.getWormhole().remove("String_Node_Str") == var);
  if (resolveStrategy > 0) {
    if (resolveStrategy == Closure.DELEGATE_FIRST || resolveStrategy == Closure.DELEGATE_ONLY) {
      candidate=findDeclaration(var.getName(),scope.getDelegate(),isLhsExpr,false,callArgs);
    }
 else     if (resolveStrategy == Closure.TO_SELF) {
      candidate=findDeclaration(var.getName(),VariableScope.CLOSURE_CLASS_NODE,isLhsExpr,false,callArgs);
    }
  }
  if (candidate == null && resolveStrategy < Closure.DELEGATE_ONLY) {
    candidate=findDeclaration(var.getName(),owner,isLhsExpr,isOwnerStatic(scope),callArgs);
    if (candidate == null && resolveStrategy < Closure.OWNER_FIRST) {
      candidate=findDeclaration(var.getName(),scope.getDelegate(),isLhsExpr,false,callArgs);
    }
  }
  return candidate;
}

Fixed version (ground truth):
protected ASTNode findDeclarationForDynamicVariable(VariableExpression var,ClassNode owner,VariableScope scope,int resolveStrategy){
  ASTNode candidate=null;
  List<ClassNode> callArgs=scope.getMethodCallArgumentTypes();
  boolean isLhsExpr=(scope.getWormhole().remove("String_Node_Str") == var);
  if (resolveStrategy > 0) {
    if (resolveStrategy == Closure.DELEGATE_FIRST || resolveStrategy == Closure.DELEGATE_ONLY) {
      candidate=findDeclaration(var.getName(),scope.getDelegate(),isLhsExpr,false,callArgs);
    }
 else     if (resolveStrategy == Closure.TO_SELF) {
      candidate=findDeclaration(var.getName(),VariableScope.CLOSURE_CLASS_NODE,isLhsExpr,false,callArgs);
    }
  }
  if (candidate == null && resolveStrategy < Closure.DELEGATE_ONLY) {
    candidate=findDeclaration(var.getName(),owner,isLhsExpr,scope.isOwnerStatic(),callArgs);
    if (candidate == null && resolveStrategy < Closure.OWNER_FIRST) {
      candidate=findDeclaration(var.getName(),scope.getDelegate(),isLhsExpr,false,callArgs);
    }
  }
  return candidate;
}
Program: 185541
Project: 185541
Buggy source:
private ICompletionProposal proposeImportableType(char[] packageName,char[] simpleTypeName,int modifiers,int accessibility,char[] qualifiedTypeName,char[] fullyQualifiedName,boolean isQualified){
  GroovyCompletionProposal proposal=createProposal(CompletionProposal.TYPE_REF,context.completionLocation - offset);
  proposal.setAccessibility(accessibility);
  proposal.setCompletion(isQualified ? fullyQualifiedName : simpleTypeName);
  proposal.setDeclarationSignature(packageName);
  proposal.setFlags(modifiers);
  proposal.setNameLookup(nameLookup);
  proposal.setPackageName(packageName);
  proposal.setReplaceRange(offset,offset + replaceLength);
  proposal.setRelevance(IRelevanceRule.DEFAULT.getRelevance(fullyQualifiedName,allTypesInUnit,accessibility,modifiers));
  proposal.setSignature(CompletionEngine.createNonGenericTypeSignature(packageName,simpleTypeName));
  proposal.setTokenRange(offset,context.completionLocation);
  proposal.setTypeName(simpleTypeName);
  LazyJavaTypeCompletionProposal javaCompletionProposal=new LazyJavaTypeCompletionProposal(proposal,javaContext);
  javaCompletionProposal.setTriggerCharacters(ProposalUtils.TYPE_TRIGGERS);
  javaCompletionProposal.setRelevance(proposal.getRelevance());
  ImportRewrite r=groovyRewriter.getImportRewrite(monitor);
  if (r != null) {
    ReflectionUtils.setPrivateField(LazyJavaTypeCompletionProposal.class,"String_Node_Str",javaCompletionProposal,r);
  }
  return javaCompletionProposal;
}

Fixed version (ground truth):
private ICompletionProposal proposeImportableType(char[] packageName,char[] simpleTypeName,int modifiers,int accessibility,char[] qualifiedTypeName,char[] fullyQualifiedName,boolean isQualified){
  GroovyCompletionProposal proposal=createProposal(CompletionProposal.TYPE_REF,context.completionLocation - offset);
  proposal.setAccessibility(accessibility);
  proposal.setCompletion(isQualified ? fullyQualifiedName : simpleTypeName);
  proposal.setDeclarationSignature(packageName);
  proposal.setFlags(modifiers);
  proposal.setNameLookup(nameLookup);
  proposal.setPackageName(packageName);
  proposal.setReplaceRange(offset,offset + replaceLength);
  proposal.setRelevance(IRelevanceRule.DEFAULT.getRelevance(fullyQualifiedName,allTypesInUnit,accessibility,modifiers));
  proposal.setSignature(CompletionEngine.createNonGenericTypeSignature(packageName,simpleTypeName));
  proposal.setTokenRange(offset,context.completionLocation);
  proposal.setTypeName(simpleTypeName);
  LazyJavaTypeCompletionProposal javaProposal=new LazyJavaTypeCompletionProposal(proposal,javaContext);
  javaProposal.setTriggerCharacters(ProposalUtils.TYPE_TRIGGERS);
  javaProposal.setRelevance(proposal.getRelevance());
  ImportRewrite r=groovyRewriter.getImportRewrite(monitor);
  if (r != null) {
    ReflectionUtils.setPrivateField(LazyJavaTypeCompletionProposal.class,"String_Node_Str",javaProposal,r);
  }
  return javaProposal;
}
Program: 185542
Project: 185542
Buggy source:
List<ICompletionProposal> processAcceptedPackages(){
  checkCancel();
  List<ICompletionProposal> proposals=new LinkedList<ICompletionProposal>();
  if (acceptedPackages != null && acceptedPackages.size() > 0) {
    for (    String packageNameStr : acceptedPackages) {
      char[] packageName=packageNameStr.toCharArray();
      GroovyCompletionProposal proposal=createProposal(CompletionProposal.PACKAGE_REF,context.completionLocation);
      proposal.setDeclarationSignature(packageName);
      proposal.setPackageName(packageName);
      proposal.setCompletion(packageName);
      proposal.setReplaceRange(offset,context.completionLocation);
      proposal.setTokenRange(offset,context.completionLocation);
      proposal.setRelevance(Relevance.LOWEST.getRelevance());
      LazyJavaCompletionProposal javaProposal=new LazyJavaCompletionProposal(proposal,javaContext);
      proposals.add(javaProposal);
      javaProposal.setRelevance(proposal.getRelevance());
    }
  }
  return proposals;
}

Fixed version (ground truth):
List<ICompletionProposal> processAcceptedPackages(){
  checkCancel();
  List<ICompletionProposal> proposals=new LinkedList<ICompletionProposal>();
  if (acceptedPackages != null && acceptedPackages.size() > 0) {
    for (    String packageNameStr : acceptedPackages) {
      char[] packageName=packageNameStr.toCharArray();
      GroovyCompletionProposal proposal=createProposal(CompletionProposal.PACKAGE_REF,context.completionLocation);
      proposal.setDeclarationSignature(packageName);
      proposal.setPackageName(packageName);
      proposal.setCompletion(packageName);
      proposal.setReplaceRange(offset,context.completionLocation);
      proposal.setTokenRange(offset,context.completionLocation);
      proposal.setRelevance(Relevance.LOWEST.getRelevance());
      LazyJavaCompletionProposal javaProposal=new LazyJavaCompletionProposal(proposal,javaContext);
      javaProposal.setTriggerCharacters(ProposalUtils.TYPE_TRIGGERS);
      javaProposal.setRelevance(proposal.getRelevance());
      proposals.add(javaProposal);
    }
  }
  return proposals;
}