nus-yam/ex-repair huggingface dataset:
Program: 185416
Project: 185416
Buggy source:
@Override public void visitConstructorOrMethod(MethodNode node,boolean isConstructor){
  TypeLookupResult result=null;
  VariableScope scope=scopes.getLast();
  for (  ITypeLookup lookup : lookups) {
    TypeLookupResult candidate=lookup.lookupType(node,scope);
    if (candidate != null) {
      if (result == null || result.confidence.isLessThan(candidate.confidence)) {
        result=candidate;
      }
      if (result.confidence.isAtLeast(TypeConfidence.INFERRED)) {
        break;
      }
    }
  }
  scope.setPrimaryNode(false);
  VisitStatus status=notifyRequestor(node,requestor,result);
switch (status) {
case CONTINUE:
    visitGenericTypes(node.getGenericsTypes(),null);
  visitClassReference(node.getReturnType());
if (node.getExceptions() != null) {
  for (  ClassNode e : node.getExceptions()) {
    visitClassReference(e);
  }
}
if (handleParameterList(node.getParameters())) {
super.visitConstructorOrMethod(node,isConstructor);
}
case CANCEL_BRANCH:
return;
case CANCEL_MEMBER:
case STOP_VISIT:
throw new VisitCompleted(status);
}
}

Fixed version (ground truth):
@Override public void visitConstructorOrMethod(MethodNode node,boolean isConstructor){
  TypeLookupResult result=null;
  VariableScope scope=scopes.getLast();
  for (  ITypeLookup lookup : lookups) {
    TypeLookupResult candidate=lookup.lookupType(node,scope);
    if (candidate != null) {
      if (result == null || result.confidence.isLessThan(candidate.confidence)) {
        result=candidate;
      }
      if (result.confidence.isAtLeast(TypeConfidence.INFERRED)) {
        break;
      }
    }
  }
  scope.setPrimaryNode(false);
  VisitStatus status=notifyRequestor(node,requestor,result);
switch (status) {
case CONTINUE:
    visitGenericTypes(node.getGenericsTypes(),null);
  visitClassReference(node.getReturnType());
if (node.getExceptions() != null) {
  for (  ClassNode e : node.getExceptions()) {
    visitClassReference(e);
  }
}
if (handleParameterList(node.getParameters())) {
visitAnnotations(node);
if (!isConstructor || !(node.getCode() instanceof BlockStatement)) {
  visitClassCodeContainer(node.getCode());
}
 else {
  for (  Statement stmt : ((BlockStatement)node.getCode()).getStatements()) {
    if (stmt.getEnd() > 0) {
      stmt.visit(this);
    }
  }
}
}
case CANCEL_BRANCH:
return;
case CANCEL_MEMBER:
case STOP_VISIT:
throw new VisitCompleted(status);
}
}
Program: 185417
Project: 185417
Buggy source:
private boolean handleParameterList(Parameter[] params){
  if (params != null) {
    VariableScope scope=scopes.getLast();
    scope.setPrimaryNode(false);
    for (    Parameter param : params) {
      if (!scope.containsInThisScope(param.getName())) {
        scope.addVariable(param);
      }
      TypeLookupResult result=null;
      for (      ITypeLookup lookup : lookups) {
        TypeLookupResult candidate=lookup.lookupType(param,scope);
        if (candidate != null) {
          if (result == null || result.confidence.isLessThan(candidate.confidence)) {
            result=candidate;
          }
          if (result.confidence.isAtLeast(TypeConfidence.INFERRED)) {
            break;
          }
        }
      }
      TypeLookupResult parameterResult=new TypeLookupResult(result.type,result.declaringType,param,TypeConfidence.EXACT,scope);
      VisitStatus status=notifyRequestor(param,requestor,parameterResult);
switch (status) {
case CONTINUE:
        break;
case CANCEL_BRANCH:
      return false;
case CANCEL_MEMBER:
case STOP_VISIT:
    throw new VisitCompleted(status);
}
visitClassReference(param.getOriginType());
visitAnnotations(param);
Expression init=param.getInitialExpression();
if (init != null) {
  init.visit(this);
}
}
}
return true;
}

Fixed version (ground truth):
private boolean handleParameterList(Parameter[] params){
  if (params != null) {
    VariableScope scope=scopes.getLast();
    scope.setPrimaryNode(false);
    for (    Parameter param : params) {
      if (!scope.containsInThisScope(param.getName())) {
        scope.addVariable(param);
      }
      TypeLookupResult result=null;
      for (      ITypeLookup lookup : lookups) {
        TypeLookupResult candidate=lookup.lookupType(param,scope);
        if (candidate != null) {
          if (result == null || result.confidence.isLessThan(candidate.confidence)) {
            result=candidate;
          }
          if (result.confidence.isAtLeast(TypeConfidence.INFERRED)) {
            break;
          }
        }
      }
      TypeLookupResult parameterResult=new TypeLookupResult(result.type,result.declaringType,param,TypeConfidence.EXACT,scope);
      VisitStatus status=notifyRequestor(param,requestor,parameterResult);
switch (status) {
case CONTINUE:
        break;
case CANCEL_BRANCH:
      return false;
case CANCEL_MEMBER:
case STOP_VISIT:
    throw new VisitCompleted(status);
}
visitAnnotations(param);
visitClassReference(param.getOriginType());
Expression init=param.getInitialExpression();
if (init != null) {
  init.visit(this);
}
}
}
return true;
}
Program: 185418
Project: 185418
Buggy source:
@Override public void visitConstructorCallExpression(ConstructorCallExpression expression){
  char[] typeName=expression.getType().getName().toCharArray();
  for (int i=0; i < 10; i+=1) {
    requestor.acceptConstructorReference(typeName,i,expression.getStart());
  }
  super.visitConstructorCallExpression(expression);
}

Fixed version (ground truth):
@Override public void visitConstructorCallExpression(ConstructorCallExpression expression){
  char[] typeName=expression.getType().getName().toCharArray();
  for (int i=0; i <= 9; i+=1) {
    requestor.acceptConstructorReference(typeName,i,expression.getStart());
  }
  ((TupleExpression)expression.getArguments()).getExpressions().stream().filter(e -> e instanceof NamedArgumentListExpression).flatMap(e -> ((NamedArgumentListExpression)e).getMapEntryExpressions().stream()).forEach(kv -> {
    if (kv.getKeyExpression() instanceof ConstantExpression) {
      visitNameReference(AccessorSupport.SETTER,kv.getKeyExpression().getText(),kv.getKeyExpression().getStart());
    }
  }
);
  super.visitConstructorCallExpression(expression);
}
Program: 185419
Project: 185419
Buggy source:
@Override public void visitMethodCallExpression(MethodCallExpression expression){
  String methodStr=expression.getMethodAsString();
  if (methodStr != null) {
    char[] methodName=methodStr.toCharArray();
    requestor.acceptFieldReference(methodName,expression.getStart());
    for (int i=0; i < 7; i+=1) {
      requestor.acceptMethodReference(methodName,i,expression.getStart());
    }
  }
  if (expression.isUsingGenerics() && isNotEmpty(expression.getGenericsTypes())) {
    visitTypeParameters(expression.getGenericsTypes(),null);
  }
  super.visitMethodCallExpression(expression);
}

Fixed version (ground truth):
@Override public void visitMethodCallExpression(MethodCallExpression expression){
  String methodStr=expression.getMethodAsString();
  if (methodStr != null) {
    char[] methodName=methodStr.toCharArray();
    requestor.acceptFieldReference(methodName,expression.getStart());
    for (int i=0; i <= 7; i+=1) {
      requestor.acceptMethodReference(methodName,i,expression.getStart());
    }
  }
  if (expression.isUsingGenerics() && isNotEmpty(expression.getGenericsTypes())) {
    visitTypeParameters(expression.getGenericsTypes(),null);
  }
  super.visitMethodCallExpression(expression);
}
Program: 185420
Project: 185420
Buggy source:
@Override public void visitConstantExpression(ConstantExpression expression){
  if (!(expression.isNullExpression() || expression.isTrueExpression() || expression.isFalseExpression()|| expression.isEmptyStringExpression())) {
    if (expression instanceof AnnotationConstantExpression) {
      visitTypeReference(expression.getType(),true,true);
    }
    char[] constName=expression.getValue().toString().toCharArray();
    requestor.acceptFieldReference(constName,expression.getStart());
    for (int i=0; i < 7; i+=1) {
      requestor.acceptMethodReference(constName,i,expression.getStart());
    }
  }
  super.visitConstantExpression(expression);
}

Fixed version (ground truth):
@Override public void visitConstantExpression(ConstantExpression expression){
  if (!(expression.isNullExpression() || expression.isTrueExpression() || expression.isFalseExpression()|| expression.isEmptyStringExpression())) {
    if (expression instanceof AnnotationConstantExpression) {
      visitTypeReference(expression.getType(),true,true);
    }
    char[] constName=expression.getValue().toString().toCharArray();
    requestor.acceptFieldReference(constName,expression.getStart());
    for (int i=0; i <= 7; i+=1) {
      requestor.acceptMethodReference(constName,i,expression.getStart());
    }
  }
  super.visitConstantExpression(expression);
}
Program: 185421
Project: 185421
Buggy source:
private ICompletionProposal newEnumProposal(Position position,String replacement,CompletionProposal supporting,Image image,char[] triggers){
  CompletionProposal groovyProposal=CompletionProposal.create(CompletionProposal.METHOD_REF,0);
  groovyProposal.setRequiredProposals(new CompletionProposal[]{supporting});
  JavaCompletionProposal javaProposal=new JavaCompletionProposal(replacement,0,0,image,null,1,false,invocationContext){
    @Override public int getReplacementLength(){
      return position.getLength();
    }
    @Override public int getReplacementOffset(){
      return position.getOffset();
    }
  }
;
  javaProposal.setProposalInfo(new FieldProposalInfo(invocationContext.getProject(),groovyProposal));
  javaProposal.setTriggerCharacters(triggers);
  return javaProposal;
}

Fixed version (ground truth):
private ICompletionProposal newEnumProposal(Position position,String replacement,CompletionProposal supporting,Image image,char[] triggers){
  CompletionProposal groovyProposal=CompletionProposal.create(CompletionProposal.METHOD_REF,0);
  groovyProposal.setRequiredProposals(new CompletionProposal[]{supporting});
  JavaCompletionProposal javaProposal=new JavaCompletionProposal(replacement,0,0,image,null,1,false,invocationContext){
    @Override public int getReplacementLength(){
      return position.getLength();
    }
    @Override public int getReplacementOffset(){
      return position.getOffset();
    }
    @Override public void setReplacementOffset(    int offset){
      if (offset > getReplacementOffset() && getReplacementLength() > super.getReplacementLength()) {
        offset=getReplacementOffset() + (getReplacementLength() - super.getReplacementLength());
        position.setOffset(offset);
        position.setLength(super.getReplacementLength());
      }
    }
  }
;
  javaProposal.setProposalInfo(new FieldProposalInfo(invocationContext.getProject(),groovyProposal));
  javaProposal.setTriggerCharacters(triggers);
  return javaProposal;
}
Program: 185422
Project: 185422
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()) {
    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;
}

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=getBaseDeclaringType(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=getBaseDeclaringType(scope.getOwner());
      }
 else {
        ownerType=scope.getEnclosingTypeDeclaration();
      }
      return ownerType;
    }
  }
  return VariableScope.OBJECT_CLASS_NODE;
}
Program: 185423
Project: 185423
Buggy source:
@Test public void testTraitBasics() throws Exception {
  IPath projectPath=env.addProject("String_Node_Str");
  env.addExternalJars(projectPath,Util.getJavaClassLibs());
  env.addGroovyJars(projectPath);
  fullBuild(projectPath);
  env.removePackageFragmentRoot(projectPath,"String_Node_Str");
  IPath root=env.addPackageFragmentRoot(projectPath,"String_Node_Str");
  env.setOutputFolder(projectPath,"String_Node_Str");
  env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str");
  incrementalBuild(projectPath);
  expectingCompiledClasses("String_Node_Str","String_Node_Str");
  expectingNoProblems();
}

Fixed version (ground truth):
@Test public void testTraitBasics() throws Exception {
  IPath projectPath=env.addProject("String_Node_Str");
  env.addExternalJars(projectPath,Util.getJavaClassLibs());
  env.addGroovyJars(projectPath);
  fullBuild(projectPath);
  env.removePackageFragmentRoot(projectPath,"String_Node_Str");
  IPath root=env.addPackageFragmentRoot(projectPath,"String_Node_Str");
  env.setOutputFolder(projectPath,"String_Node_Str");
  env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str");
  incrementalBuild(projectPath);
  expectingCompiledClasses("String_Node_Str","String_Node_Str");
  expectingNoProblems();
}
Program: 185424
Project: 185424
Buggy source:
@Test public void testPackageNames_GRE342_3() throws Exception {
  IPath projectPath=env.addProject("String_Node_Str");
  env.addExternalJars(projectPath,Util.getJavaClassLibs());
  env.addGroovyJars(projectPath);
  fullBuild(projectPath);
  env.removePackageFragmentRoot(projectPath,"String_Node_Str");
  IPath root=env.addPackageFragmentRoot(projectPath,"String_Node_Str");
  env.setOutputFolder(projectPath,"String_Node_Str");
  env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str");
  incrementalBuild(projectPath);
  expectingNoProblems();
  executeClass(projectPath,"String_Node_Str","String_Node_Str","String_Node_Str");
}

Fixed version (ground truth):
@Test public void testPackageNames_GRE342_3() throws Exception {
  IPath projectPath=env.addProject("String_Node_Str");
  env.addExternalJars(projectPath,Util.getJavaClassLibs());
  env.addGroovyJars(projectPath);
  fullBuild(projectPath);
  env.removePackageFragmentRoot(projectPath,"String_Node_Str");
  IPath root=env.addPackageFragmentRoot(projectPath,"String_Node_Str");
  env.setOutputFolder(projectPath,"String_Node_Str");
  IPath path=env.addGroovyClass(root,"String_Node_Str","String_Node_Str","String_Node_Str");
  incrementalBuild(projectPath);
  expectingSpecificProblemFor(path,new Problem("String_Node_Str","String_Node_Str",path,0,1,60,IMarker.SEVERITY_ERROR));
}
Program: 185425
Project: 185425
Buggy source:
@Override protected boolean reportPackageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl){
  if (!isScript && compUnitDecl != null && compUnitDecl.compilationResult != null && compUnitDecl.compilationResult.compilationUnit != null) {
    char[][] packageName=compUnitDecl.compilationResult.compilationUnit.getPackageName();
    String shouldBe=packageName == null ? "String_Node_Str" : CharOperation.toString(packageName);
    String actuallyIs=compUnitDecl.currentPackage == null ? "String_Node_Str" : CharOperation.toString(compUnitDecl.currentPackage.tokens);
    if (actuallyIs.length() > 0 && !shouldBe.equals(actuallyIs)) {
      problemReporter().packageIsNotExpectedPackage(compUnitDecl);
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks expected package against actual package declaration.
 */
@Override protected boolean reportPackageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl){
  if (compUnitDecl != null && compUnitDecl.compilationResult != null && compUnitDecl.compilationResult.compilationUnit != null) {
    char[][] expectedPackage=compUnitDecl.compilationResult.compilationUnit.getPackageName();
    if (expectedPackage != null && !CharOperation.equals(expectedPackage,compUnitDecl.currentPackage != null ? compUnitDecl.currentPackage.tokens : CharOperation.NO_CHAR_CHAR)) {
      problemReporter().packageIsNotExpectedPackage(compUnitDecl);
      return true;
    }
  }
  return false;
}
Program: 185428
Project: 185428
Buggy source:
public FieldReferenceSearchRequestor(FieldPattern pattern,SearchRequestor requestor,SearchParticipant participant){
  this.requestor=requestor;
  this.participant=participant;
  name=(char[])ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
  char[] arr=(char[])ReflectionUtils.getPrivateField(FieldPattern.class,"String_Node_Str",pattern);
  String declaringSimpleName=arr == null ? "String_Node_Str" : String.valueOf(arr);
  arr=(char[])ReflectionUtils.getPrivateField(FieldPattern.class,"String_Node_Str",pattern);
  String declaringQualification=((arr == null || arr.length == 0) ? "String_Node_Str" : (String.valueOf(arr) + "String_Node_Str"));
  declaringQualifiedName=declaringQualification + declaringSimpleName;
  readAccess=(Boolean)ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
  writeAccess=(Boolean)ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
  findDeclarations=(Boolean)ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
  findReferences=(Boolean)ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
}

Fixed version (ground truth):
public FieldReferenceSearchRequestor(FieldPattern pattern,SearchRequestor requestor,SearchParticipant participant){
  this.requestor=requestor;
  this.participant=participant;
  char[] arr=(char[])ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
  fieldName=String.valueOf(arr);
  arr=(char[])ReflectionUtils.getPrivateField(FieldPattern.class,"String_Node_Str",pattern);
  String declaringSimpleName=((arr == null || arr.length == 0) ? "String_Node_Str" : String.valueOf(arr));
  arr=(char[])ReflectionUtils.getPrivateField(FieldPattern.class,"String_Node_Str",pattern);
  String declaringQualification=((arr == null || arr.length == 0) ? "String_Node_Str" : (String.valueOf(arr) + "String_Node_Str"));
  declaringQualifiedName=declaringQualification + declaringSimpleName;
  readAccess=(Boolean)ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
  writeAccess=(Boolean)ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
  findReferences=(Boolean)ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
  findDeclarations=(Boolean)ReflectionUtils.getPrivateField(VariablePattern.class,"String_Node_Str",pattern);
}
Program: 185429
Project: 185429
Buggy source:
private boolean qualifiedNameMatches(ClassNode declaringType){
  if (declaringType == null) {
    return false;
  }
 else   if (declaringQualifiedName == null || declaringQualifiedName.equals("String_Node_Str")) {
    return true;
  }
 else   if (declaringType.getName().equals(declaringQualifiedName)) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
private boolean qualifiedNameMatches(ClassNode declaringType){
  if (declaringType == null) {
    return false;
  }
 else   if (declaringQualifiedName.isEmpty()) {
    return true;
  }
 else   if (declaringType.getName().equals(declaringQualifiedName)) {
    return true;
  }
 else {
    return false;
  }
}
Program: 185432
Project: 185432
Buggy source:
@Test public void testParsingDotTerminatedImportStatic_538() throws Exception {
  runNegativeTest(new String[]{"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");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  Map<String,ImportNode> imports=mn.getStaticStarImports();
  ImportNode brokenImportNode=imports.get("String_Node_Str");
  assertEquals("String_Node_Str",brokenImportNode.getType().getName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}

Fixed version (ground truth):
@Test public void testParsingDotTerminatedImportStatic_538(){
  runNegativeTest(new String[]{"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");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  Map<String,ImportNode> imports=mn.getStaticStarImports();
  ImportNode recoveredImport=imports.get("String_Node_Str");
  assertEquals("String_Node_Str",recoveredImport.getType().getName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}
Program: 185433
Project: 185433
Buggy source:
@Test public void testParsingDotTerminatedImportFollowedByClassDeclaration_538() throws Exception {
  runNegativeTest(new String[]{"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");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getStarImports();
  ImportNode brokenImportNode=imports.get(0);
  assertEquals("String_Node_Str",brokenImportNode.getPackageName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}

Fixed version (ground truth):
@Test public void testParsingDotTerminatedImportFollowedByClassDeclaration_538(){
  runNegativeTest(new String[]{"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");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getStarImports();
  ImportNode recoveredImport=imports.get(0);
  assertEquals("String_Node_Str",recoveredImport.getPackageName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}
Program: 185434
Project: 185434
Buggy source:
@Test public void testParsingBlankImportStatic_538() throws Exception {
  runNegativeTest(new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  Map<String,ImportNode> imports=mn.getStaticImports();
  ImportNode brokenImportNode=imports.get("String_Node_Str");
  assertEquals("String_Node_Str",brokenImportNode.getType().getName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertTrue(cn.getName().equals("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testParsingBlankImportStatic_538(){
  runNegativeTest(new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getImports();
  ImportNode recoveredImport=imports.get(0);
  assertEquals(0,recoveredImport.getStart());
  assertEquals(14,recoveredImport.getEnd());
  assertEquals("String_Node_Str",recoveredImport.getType().getName());
  assertTrue(mn.getStaticImports().isEmpty());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertTrue(cn.getName().equals("String_Node_Str"));
}
Program: 185435
Project: 185435
Buggy source:
@Test public void testParsingIncompleteClassDeclaration_495() throws Exception {
  runNegativeTest(new String[]{"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"+ "String_Node_Str"+ "String_Node_Str");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  List<ClassNode> l=mn.getClasses();
  for (int i=0; i < l.size(); i++) {
    System.out.println(l.get(i));
  }
  assertFalse(mn.encounteredUnrecoverableError());
  ClassNode cn=mn.getClasses().get(2);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
  cn=mn.getClasses().get(1);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}

Fixed version (ground truth):
@Test public void testParsingIncompleteClassDeclaration_495(){
  runNegativeTest(new String[]{"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"+ "String_Node_Str"+ "String_Node_Str");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  List<ClassNode> l=mn.getClasses();
  for (int i=0; i < l.size(); i++) {
    System.out.println(l.get(i));
  }
  assertFalse(mn.encounteredUnrecoverableError());
  ClassNode cn=mn.getClasses().get(2);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
  cn=mn.getClasses().get(1);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}
Program: 185436
Project: 185436
Buggy source:
@Test public void testParsingDotTerminatedImport_538() throws Exception {
  runNegativeTest(new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getStarImports();
  ImportNode brokenImportNode=imports.get(0);
  assertEquals("String_Node_Str",brokenImportNode.getPackageName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertTrue(cn.getName().equals("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testParsingDotTerminatedImport_538(){
  runNegativeTest(new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getStarImports();
  ImportNode recoveredImport=imports.get(0);
  assertEquals("String_Node_Str",recoveredImport.getPackageName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertTrue(cn.getName().equals("String_Node_Str"));
}
Program: 185437
Project: 185437
Buggy source:
@Test public void testParsingBlankImportFollowedByClassDeclaration_538() throws Exception {
  runNegativeTest(new String[]{"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");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getImports();
  ImportNode brokenImportNode=imports.get(0);
  assertEquals("String_Node_Str",brokenImportNode.getType().getName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}

Fixed version (ground truth):
@Test public void testParsingBlankImportFollowedByClassDeclaration_538(){
  runNegativeTest(new String[]{"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");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getImports();
  ImportNode recoveredImport=imports.get(0);
  assertEquals("String_Node_Str",recoveredImport.getType().getName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}
Program: 185438
Project: 185438
Buggy source:
@Test public void testParsingBlankImport_538() throws Exception {
  runNegativeTest(new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getImports();
  ImportNode brokenImportNode=imports.get(0);
  assertEquals(0,brokenImportNode.getStart());
  assertEquals(6,brokenImportNode.getEnd());
  assertEquals("String_Node_Str",brokenImportNode.getType().getName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertTrue(cn.getName().equals("String_Node_Str"));
}

Fixed version (ground truth):
@Test public void testParsingBlankImport_538(){
  runNegativeTest(new String[]{"String_Node_Str","String_Node_Str"},"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getImports();
  ImportNode recoveredImport=imports.get(0);
  assertEquals(0,recoveredImport.getStart());
  assertEquals(7,recoveredImport.getEnd());
  assertEquals("String_Node_Str",recoveredImport.getType().getName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertTrue(cn.getName().equals("String_Node_Str"));
}
Program: 185439
Project: 185439
Buggy source:
@Test public void testInnerClass4() throws Exception {
  runConformTest(new String[]{"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");
}

Fixed version (ground truth):
@Test public void testInnerClass4(){
  runConformTest(new String[]{"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");
}
Program: 185440
Project: 185440
Buggy source:
@Test public void testInnerClass5() throws Exception {
  runNegativeTest(new String[]{"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");
}

Fixed version (ground truth):
@Test public void testInnerClass5(){
  runNegativeTest(new String[]{"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");
}
Program: 185441
Project: 185441
Buggy source:
@Test public void testParsingDotTerminatedImportFollowedByModifierAndClassDeclaration_538() throws Exception {
  runNegativeTest(new String[]{"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");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getStarImports();
  ImportNode brokenImportNode=imports.get(0);
  assertEquals("String_Node_Str",brokenImportNode.getPackageName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}

Fixed version (ground truth):
@Test public void testParsingDotTerminatedImportFollowedByModifierAndClassDeclaration_538(){
  runNegativeTest(new String[]{"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");
  ModuleNode mn=getModuleNode("String_Node_Str");
  assertNotNull(mn);
  assertFalse(mn.encounteredUnrecoverableError());
  List<ImportNode> imports=mn.getStarImports();
  ImportNode recoveredImport=imports.get(0);
  assertEquals("String_Node_Str",recoveredImport.getPackageName());
  ClassNode cn=mn.getClasses().get(0);
  assertNotNull(cn);
  assertEquals("String_Node_Str",cn.getName());
}
Program: 185442
Project: 185442
Buggy source:
@Test public void testInnerClass2() throws Exception {
  runConformTest(new String[]{"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");
}

Fixed version (ground truth):
@Test public void testInnerClass2(){
  runConformTest(new String[]{"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");
}
Program: 185443
Project: 185443
Buggy source:
@Test public void testInnerClass3() throws Exception {
  runConformTest(new String[]{"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");
}

Fixed version (ground truth):
@Test public void testInnerClass3(){
  runConformTest(new String[]{"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");
}
Program: 185444
Project: 185444
Buggy source:
@Test public void testInnerClass1() throws Exception {
  runConformTest(new String[]{"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"},"String_Node_Str");
}

Fixed version (ground truth):
@Test public void testInnerClass1(){
  runConformTest(new String[]{"String_Node_Str","String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"},"String_Node_Str");
}
Program: 185445
Project: 185445
Buggy source:
protected GenericsType[] makeGenericsType(AST rootNode){
  AST typeParameter=rootNode.getFirstChild();
  LinkedList ret=new LinkedList();
  assertNodeType(TYPE_PARAMETER,typeParameter);
  while (isType(TYPE_PARAMETER,typeParameter)) {
    AST typeNode=typeParameter.getFirstChild();
    ClassNode type=makeType(typeParameter);
    GenericsType gt=new GenericsType(type,makeGenericsBounds(typeNode,TYPE_UPPER_BOUNDS),null);
    configureAST(gt,typeParameter);
    ret.add(gt);
    typeParameter=typeParameter.getNextSibling();
  }
  return (GenericsType[])ret.toArray(new GenericsType[0]);
}

Fixed version (ground truth):
protected GenericsType[] makeGenericsType(AST rootNode){
  AST typeParameter=rootNode.getFirstChild();
  LinkedList ret=new LinkedList();
  assertNodeType(TYPE_PARAMETER,typeParameter);
  while (isType(TYPE_PARAMETER,typeParameter)) {
    AST typeNode=typeParameter.getFirstChild();
    ClassNode type=makeType(typeParameter);
    GenericsType gt=new GenericsType(type,makeGenericsBounds(typeNode,TYPE_UPPER_BOUNDS),null);
    configureAST(gt,typeParameter);
    ret.add(gt);
    typeParameter=typeParameter.getNextSibling();
  }
  return (GenericsType[])ret.toArray(new GenericsType[ret.size()]);
}
Program: 185446
Project: 185446
Buggy source:
protected void packageDef(AST packageDef){
  List<AnnotationNode> annotations=new ArrayList<AnnotationNode>();
  AST node=packageDef.getFirstChild();
  if (isType(ANNOTATIONS,node)) {
    processAnnotations(annotations,node);
    node=node.getNextSibling();
  }
  if (node == null)   return;
  String name=qualifiedName(node);
  setPackageName(name);
  if (name != null && !name.isEmpty()) {
    name+='.';
  }
  PackageNode packageNode=new PackageNode(name);
  packageNode.addAnnotations(annotations);
  output.setPackage(packageNode);
  configureAST(packageNode,node);
}

Fixed version (ground truth):
protected void packageDef(AST packageDef){
  List<AnnotationNode> annotations=new ArrayList<AnnotationNode>();
  AST node=packageDef.getFirstChild();
  if (isType(ANNOTATIONS,node)) {
    processAnnotations(annotations,node);
    node=node.getNextSibling();
  }
  String name=qualifiedName(node);
  PackageNode packageNode=setPackage(name,annotations);
  configureAST(packageNode,node);
}
Program: 185448
Project: 185448
Buggy source:
@Override public void visitCastExpression(CastExpression expression){
  if (expression.getEnd() > 0 && expression.getStart() == expression.getType().getStart()) {
    visitTypeReference(expression.getType(),false,true);
  }
  super.visitCastExpression(expression);
}

Fixed version (ground truth):
@Override public void visitCastExpression(CastExpression expression){
  if (expression.getEnd() > 0 && (expression.getStart() == expression.getType().getStart() || expression.getEnd() == expression.getType().getEnd())) {
    visitTypeReference(expression.getType(),false,true);
  }
  super.visitCastExpression(expression);
}
Program: 185451
Project: 185451
Buggy source:
@Override protected IContextInformation computeContextInformation(){
  if (hasParameters() && (fProposal.getKind() == CompletionProposal.METHOD_REF || fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION)) {
    ProposalContextInformation contextInformation=new ProposalContextInformation(fProposal);
    if (fContextInformationPosition != 0 && fProposal.getCompletion().length == 0)     contextInformation.setContextInformationPosition(fContextInformationPosition);
    return contextInformation;
  }
  return super.computeContextInformation();
}

Fixed version (ground truth):
@Override protected IContextInformation computeContextInformation(){
  if (hasParameters() && (fProposal.getKind() == CompletionProposal.METHOD_REF || fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION)) {
    return new ProposalContextInformation(fProposal);
  }
  return super.computeContextInformation();
}
Program: 185452
Project: 185452
Buggy source:
@Override public void apply(IDocument document,char trigger,int offset){
  try {
    if (trigger == '{' && (fProposal.getCompletion() != null && fProposal.getCompletion().length > 0)) {
      String replacement=getReplacementString();
      if (replacement.endsWith("String_Node_Str") || fProposal.getKind() == CompletionProposal.METHOD_NAME_REFERENCE) {
        trigger=0;
      }
 else       if (fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || !fPreferences.isEnabled(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES) || !lastParamAcceptsClosure(Signature.getParameterTypes(fProposal.getSignature()))) {
        if (fPreferences.isEnabled(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK)) {
          setReplacementString(replacement + SPACE);
        }
      }
 else {
        setReplacementString(recomputeReplacementString());
        trigger=0;
      }
    }
    super.apply(document,trigger,offset);
    if (fContextInformationPosition > 0) {
      setContextInformationPosition(getReplacementOffset() + fContextInformationPosition);
      if (fPositions == null || fPositions.isEmpty()) {
        fSelectedRegion=new Region(fContextInformationPosition,0);
      }
 else {
        fSelectedRegion=new Region(fPositions.get(0).getOffset(),fPositions.get(0).getLength());
      }
    }
  }
 catch (  Exception e) {
    GroovyContentAssist.logError(e);
    ensurePositionCategoryRemoved(document);
  }
}

Fixed version (ground truth):
@Override public void apply(IDocument document,char trigger,int offset){
  try {
    if (trigger == '{' && (fProposal.getCompletion() != null && fProposal.getCompletion().length > 0)) {
      String replacement=getReplacementString();
      if (replacement.endsWith("String_Node_Str") || fProposal.getKind() == CompletionProposal.METHOD_NAME_REFERENCE) {
        trigger=0;
      }
 else       if (fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || !fPreferences.isEnabled(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES) || !lastParamAcceptsClosure(Signature.getParameterTypes(fProposal.getSignature()))) {
        if (fPreferences.isEnabled(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK)) {
          setReplacementString(replacement + SPACE);
        }
      }
 else {
        setReplacementString(recomputeReplacementString());
        trigger=0;
      }
    }
    super.apply(document,trigger,offset);
    if (fContextInformationPosition > 0) {
      setContextInformationPosition(getReplacementOffset() + fContextInformationPosition);
      if (fProposal.getCompletion() != null && fProposal.getCompletion().length > 0) {
        if (fPositions == null || fPositions.isEmpty()) {
          fSelectedRegion=new Region(fContextInformationPosition,0);
        }
 else {
          fSelectedRegion=new Region(fPositions.get(0).getOffset(),fPositions.get(0).getLength());
        }
      }
    }
  }
 catch (  Exception e) {
    GroovyContentAssist.logError(e);
    ensurePositionCategoryRemoved(document);
  }
}
Program: 185457
Project: 185457
Buggy source:
@Override public void apply(IDocument document,char trigger,int offset){
  try {
    if (trigger == '{' && (fProposal.getCompletion() != null && fProposal.getCompletion().length > 0)) {
      String replacement=getReplacementString();
      if (replacement.endsWith("String_Node_Str") || fProposal.getKind() == CompletionProposal.METHOD_NAME_REFERENCE) {
        trigger=0;
      }
 else       if (fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || !fPreferences.isEnabled(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES) || !lastParamAcceptsClosure(Signature.getParameterTypes(fProposal.getSignature()))) {
        if (fPreferences.isEnabled(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK)) {
          setReplacementString(replacement + SPACE);
        }
      }
 else {
        setReplacementString(recomputeReplacementString());
        trigger=0;
      }
    }
    super.apply(document,trigger,offset);
    if (getContextInformationPosition() > 0) {
      setContextInformationPosition(getContextInformationPosition() + getReplacementOffset());
    }
    if (fPositions != null && !fPositions.isEmpty()) {
      fSelectedRegion=new Region(fPositions.get(0).getOffset(),fPositions.get(0).getLength());
    }
  }
 catch (  Exception e) {
    GroovyContentAssist.logError(e);
    ensurePositionCategoryRemoved(document);
  }
}

Fixed version (ground truth):
@Override public void apply(IDocument document,char trigger,int offset){
  try {
    if (trigger == '{' && (fProposal.getCompletion() != null && fProposal.getCompletion().length > 0)) {
      String replacement=getReplacementString();
      if (replacement.endsWith("String_Node_Str") || fProposal.getKind() == CompletionProposal.METHOD_NAME_REFERENCE) {
        trigger=0;
      }
 else       if (fProposal.getKind() == CompletionProposal.CONSTRUCTOR_INVOCATION || !fPreferences.isEnabled(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES) || !lastParamAcceptsClosure(Signature.getParameterTypes(fProposal.getSignature()))) {
        if (fPreferences.isEnabled(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK)) {
          setReplacementString(replacement + SPACE);
        }
      }
 else {
        setReplacementString(recomputeReplacementString());
        trigger=0;
      }
    }
    super.apply(document,trigger,offset);
    if (fContextInformationPosition > 0) {
      setContextInformationPosition(getReplacementOffset() + fContextInformationPosition);
      if (fPositions == null || fPositions.isEmpty()) {
        fSelectedRegion=new Region(fContextInformationPosition,0);
      }
 else {
        fSelectedRegion=new Region(fPositions.get(0).getOffset(),fPositions.get(0).getLength());
      }
    }
  }
 catch (  Exception e) {
    GroovyContentAssist.logError(e);
    ensurePositionCategoryRemoved(document);
  }
}
Program: 185458
Project: 185458
Buggy source:
private ICompletionProposal newEnumProposal(Position position,String replacement,CompletionProposal supporting,Image image,char[] triggers){
  CompletionProposal groovyProposal=CompletionProposal.create(CompletionProposal.METHOD_REF,0);
  groovyProposal.setRequiredProposals(new CompletionProposal[]{supporting});
  JavaCompletionProposal javaProposal=new JavaCompletionProposal(replacement,0,0,image,null,1,false,invocationContext){
    @Override public int getReplacementLength(){
      return position.getLength();
    }
    @Override public int getReplacementOffset(){
      return position.getOffset();
    }
    @Override public void setReplacementOffset(    int offset){
      if (offset > getReplacementOffset()) {
        position.setOffset(getReplacementOffset() + (getReplacementLength() - super.getReplacementLength()));
        position.setLength(super.getReplacementLength());
      }
      super.setReplacementOffset(offset);
    }
    @Override public void setReplacementLength(    int length){
      super.setReplacementLength(length);
    }
  }
;
  javaProposal.setProposalInfo(new FieldProposalInfo(invocationContext.getProject(),groovyProposal));
  javaProposal.setTriggerCharacters(triggers);
  return javaProposal;
}

Fixed version (ground truth):
private ICompletionProposal newEnumProposal(Position position,String replacement,CompletionProposal supporting,Image image,char[] triggers){
  CompletionProposal groovyProposal=CompletionProposal.create(CompletionProposal.METHOD_REF,0);
  groovyProposal.setRequiredProposals(new CompletionProposal[]{supporting});
  JavaCompletionProposal javaProposal=new JavaCompletionProposal(replacement,0,0,image,null,1,false,invocationContext){
    @Override public int getReplacementLength(){
      return position.getLength();
    }
    @Override public int getReplacementOffset(){
      return position.getOffset();
    }
  }
;
  javaProposal.setProposalInfo(new FieldProposalInfo(invocationContext.getProject(),groovyProposal));
  javaProposal.setTriggerCharacters(triggers);
  return javaProposal;
}