nus-yam/ex-repair huggingface dataset:
Program: 185976
Project: 185976
Buggy source:
private void addEdit(TextEdit edit){
  if (edit instanceof DeleteEdit && edit.getLength() == 0) {
    return;
  }
  if (edit instanceof ReplaceEdit && edit.getLength() == 0 && ((ReplaceEdit)edit).getText().isEmpty()) {
    return;
  }
  if (edit instanceof InsertEdit && ((InsertEdit)edit).getText().isEmpty()) {
    return;
  }
  if (edit != null && edit.getOffset() >= formatter.formatOffset && edit.getOffset() + edit.getLength() <= formatter.formatOffset + formatter.formatLength) {
    if (edit instanceof DeleteEdit) {
      debug("String_Node_Str" + edit.getOffset() + "String_Node_Str"+ edit.getLength());
      debug("String_Node_Str");
      IDocument doc=formatter.getProgressDocument();
      try {
        debug(doc.get(0,edit.getOffset()) + "String_Node_Str" + doc.get(edit.getOffset(),edit.getLength())+ "String_Node_Str"+ doc.get(edit.getOffset() + edit.getLength(),doc.getLength() - (edit.getOffset() + edit.getLength())));
      }
 catch (      BadLocationException e) {
        e.printStackTrace();
      }
      debug("String_Node_Str");
    }
    try {
      indentationEdits.addChild(edit);
    }
 catch (    MalformedTreeException e) {
      debug("String_Node_Str" + edit);
      GroovyCore.logException("String_Node_Str",e);
    }
  }
}

Fixed version (ground truth):
private void addEdit(TextEdit edit){
  if (edit instanceof DeleteEdit && edit.getLength() == 0) {
    return;
  }
  if (edit instanceof ReplaceEdit && edit.getLength() == 0 && ((ReplaceEdit)edit).getText().length() < 1) {
    return;
  }
  if (edit instanceof InsertEdit && ((InsertEdit)edit).getText().length() < 1) {
    return;
  }
  if (edit != null && edit.getOffset() >= formatter.formatOffset && edit.getOffset() + edit.getLength() <= formatter.formatOffset + formatter.formatLength) {
    if (edit instanceof DeleteEdit) {
      debug("String_Node_Str" + edit.getOffset() + "String_Node_Str"+ edit.getLength());
      debug("String_Node_Str");
      IDocument doc=formatter.getProgressDocument();
      try {
        debug(doc.get(0,edit.getOffset()) + "String_Node_Str" + doc.get(edit.getOffset(),edit.getLength())+ "String_Node_Str"+ doc.get(edit.getOffset() + edit.getLength(),doc.getLength() - (edit.getOffset() + edit.getLength())));
      }
 catch (      BadLocationException e) {
        e.printStackTrace();
      }
      debug("String_Node_Str");
    }
    try {
      indentationEdits.addChild(edit);
    }
 catch (    MalformedTreeException e) {
      debug("String_Node_Str" + edit);
      GroovyCore.logException("String_Node_Str",e);
    }
  }
}
Program: 185978
Project: 185978
Buggy source:
private void visitUnaryExpression(Expression node,Expression expression,String operation){
  scopes.peek().setCurrentNode(node);
  completeExpressionStack.push(node);
  if (isDependentExpression(node)) {
    primaryTypeStack.pop();
  }
  expression.visit(this);
  ClassNode primaryType=primaryTypeStack.pop();
  String associatedMethod=findUnaryOperatorName(operation);
  ClassNode completeExprType;
  if (associatedMethod == null && primaryType.equals(VariableScope.NUMBER_CLASS_NODE) || primaryType.isDerivedFrom(VariableScope.NUMBER_CLASS_NODE)) {
    completeExprType=primaryType;
  }
 else {
    TypeLookupResult result=lookupExpressionType(new ConstantExpression(associatedMethod),primaryType,false,scopes.peek());
    completeExprType=result.type;
  }
  completeExpressionStack.pop();
  handleCompleteExpression(node,completeExprType,null);
}

Fixed version (ground truth):
private void visitUnaryExpression(Expression node,Expression expression,String operation){
  scopes.peek().setCurrentNode(node);
  completeExpressionStack.push(node);
  if (isDependentExpression(node)) {
    primaryTypeStack.pop();
  }
  expression.visit(this);
  ClassNode primaryType=primaryTypeStack.pop();
  String associatedMethod=findUnaryOperatorName(operation);
  ClassNode completeExprType;
  if (associatedMethod == null && primaryType.equals(VariableScope.NUMBER_CLASS_NODE) || ClassHelper.getWrapper(primaryType).isDerivedFrom(VariableScope.NUMBER_CLASS_NODE)) {
    completeExprType=primaryType;
  }
 else {
    TypeLookupResult result=lookupExpressionType(new ConstantExpression(associatedMethod),primaryType,false,scopes.peek());
    completeExprType=result.type;
  }
  completeExpressionStack.pop();
  handleCompleteExpression(node,completeExprType,null);
}
Program: 185979
Project: 185979
Buggy source:
/** 
 * Finds argument types of the current method call. Returns null if not a method call.
 * @return
 */
private List<ClassNode> getMethodCallArgs(){
  ASTNode peek=completeExpressionStack.peek();
  if (peek instanceof MethodCallExpression) {
    MethodCallExpression call=(MethodCallExpression)peek;
    Expression arguments=call.getArguments();
    if (arguments instanceof ArgumentListExpression) {
      ArgumentListExpression list=(ArgumentListExpression)arguments;
      List<Expression> expressions=list.getExpressions();
      List<ClassNode> types=new ArrayList<ClassNode>();
      for (      Expression expression : expressions) {
        types.add(expression.getType());
      }
      return types;
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Finds argument types of the current method call. Returns null if not a method call.
 * @return
 */
private List<ClassNode> getMethodCallArgs(){
  ASTNode peek=completeExpressionStack.peek();
  if (peek instanceof MethodCallExpression) {
    MethodCallExpression call=(MethodCallExpression)peek;
    Expression arguments=call.getArguments();
    if (arguments instanceof ArgumentListExpression) {
      ArgumentListExpression list=(ArgumentListExpression)arguments;
      List<Expression> expressions=list.getExpressions();
      List<ClassNode> types=new ArrayList<ClassNode>();
      for (      Expression expression : expressions) {
        types.add(expression.getType());
      }
      return types;
    }
 else {
      return new ArrayList<ClassNode>();
    }
  }
  return null;
}
Program: 185981
Project: 185981
Buggy source:
public void testDefaultAndStaticMethodInInterface(){
  assertTrue("String_Node_Str",GroovyUtils.GROOVY_LEVEL >= 23);
  assertTrue("String_Node_Str",isJRELevel(AbstractCompilerTest.F_1_8));
  Map customOptions=getCompilerOptions();
  customOptions.put(CompilerOptions.OPTION_Source,CompilerOptions.VERSION_1_8);
  this.runConformTest(true,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"},null,customOptions,"String_Node_Str","String_Node_Str",null,new JavacTestOptions("String_Node_Str"));
}

Fixed version (ground truth):
public void testDefaultAndStaticMethodInInterface(){
  assertTrue("String_Node_Str",GroovyUtils.GROOVY_LEVEL >= 23);
  assertTrue("String_Node_Str",isJRELevel(AbstractCompilerTest.F_1_8));
  Map customOptions=getCompilerOptions();
  customOptions.put(CompilerOptions.OPTION_Source,"String_Node_Str");
  this.runConformTest(true,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"},null,customOptions,"String_Node_Str","String_Node_Str",null,new JavacTestOptions("String_Node_Str"));
}
Program: 185982
Project: 185982
Buggy source:
public static Test suite(){
  return buildUniqueComplianceTestSuite(testClass(),ClassFileConstants.JDK1_8);
}

Fixed version (ground truth):
public static Test suite(){
  return buildUniqueComplianceTestSuite(testClass(),JDK1_8);
}
Program: 185983
Project: 185983
Buggy source:
protected void setUp() throws Exception {
  super.setUp();
  complianceLevel=ClassFileConstants.JDK1_8;
}

Fixed version (ground truth):
protected void setUp() throws Exception {
  super.setUp();
  complianceLevel=JDK1_8;
}
Program: 185984
Project: 185984
Buggy source:
public static <T>Object throwableExecutePrivateMethod(Class<T> clazz,String methodName,Class<?>[] types,Object target,Object[] args) throws Exception {
  Method method=clazz.getDeclaredMethod(methodName,types);
  method.setAccessible(true);
  return method.invoke(target,args);
}

Fixed version (ground truth):
public static <T>Object throwableExecutePrivateMethod(Class<T> clazz,String methodName,Class<?>[] types,T target,Object[] args) throws Exception {
  Method method=clazz.getDeclaredMethod(methodName,types);
  method.setAccessible(true);
  return method.invoke(target,args);
}
Program: 185985
Project: 185985
Buggy source:
/** 
 * Create type name taking into account inner types
 */
private String createName(IType type){
  StringBuilder sb=new StringBuilder();
  while (type != null) {
    if (sb.length() > 0) {
      sb.insert(0,'$');
    }
    if (type instanceof SourceType && type.getElementName().isEmpty()) {
      sb.insert(0,((SourceType)type).localOccurrenceCount);
    }
 else {
      sb.insert(0,type.getElementName());
    }
    type=(IType)type.getParent().getAncestor(IJavaElement.TYPE);
  }
  return sb.toString();
}

Fixed version (ground truth):
/** 
 * Create type name taking into account inner types
 */
private String createName(IType type){
  StringBuilder sb=new StringBuilder();
  while (type != null) {
    if (sb.length() > 0) {
      sb.insert(0,'$');
    }
    if (type instanceof SourceType && type.getElementName().isEmpty()) {
      int count;
      try {
        count=(Integer)ReflectionUtils.throwableGetPrivateField(SourceType.class,"String_Node_Str",(SourceType)type);
      }
 catch (      Exception e) {
        count=type.getOccurrenceCount();
      }
      sb.insert(0,count);
    }
 else {
      sb.insert(0,type.getElementName());
    }
    type=(IType)type.getParent().getAncestor(IJavaElement.TYPE);
  }
  return sb.toString();
}
Program: 185987
Project: 185987
Buggy source:
public static boolean isNumberType(ClassNode cn){
  return cn == Byte_TYPE || cn == Short_TYPE || cn == Integer_TYPE || cn == Long_TYPE || cn == Float_TYPE || cn == Double_TYPE || cn == byte_TYPE || cn == short_TYPE || cn == int_TYPE || cn == long_TYPE || cn == float_TYPE || cn == double_TYPE;
}

Fixed version (ground truth):
public static boolean isNumberType(ClassNode cn){
  return cn.equals(Byte_TYPE) || cn.equals(Short_TYPE) || cn.equals(Integer_TYPE)|| cn.equals(Long_TYPE)|| cn.equals(Float_TYPE)|| cn.equals(Double_TYPE)|| cn == byte_TYPE || cn == short_TYPE || cn == int_TYPE || cn == long_TYPE || cn == float_TYPE || cn == double_TYPE;
}
Program: 185988
Project: 185988
Buggy source:
@Override public void start(BundleContext context) throws Exception {
  super.start(context);
  try {
    GROOVY_JAR_URL=FileLocator.resolve(context.getBundle().getEntry(GroovyActivator.GROOVY_JAR));
    GROOVY_ALL_JAR_URL=FileLocator.resolve(context.getBundle().getEntry(GroovyActivator.GROOVY_ALL_JAR));
    ASM_JAR_URL=FileLocator.resolve(context.getBundle().getEntry(GroovyActivator.ASM_JAR));
    GROOVY_GPP_URL=FileLocator.resolve(context.getBundle().getEntry(GroovyActivator.GROOVY_GPP_JAR));
  }
 catch (  Exception e) {
    getLog().log(new Status(IStatus.ERROR,PLUGIN_ID,"String_Node_Str",e));
  }
}

Fixed version (ground truth):
@Override public void start(BundleContext context) throws Exception {
  super.start(context);
  try {
    GROOVY_JAR_URL=FileLocator.resolve(context.getBundle().getEntry(GroovyActivator.GROOVY_JAR));
    GROOVY_ALL_JAR_URL=FileLocator.resolve(context.getBundle().getEntry(GroovyActivator.GROOVY_ALL_JAR));
    ASM_JAR_URL=FileLocator.resolve(context.getBundle().getEntry(GroovyActivator.ASM_JAR));
  }
 catch (  Exception e) {
    getLog().log(new Status(IStatus.ERROR,PLUGIN_ID,"String_Node_Str",e));
  }
}
Program: 185989
Project: 185989
Buggy source:
/** 
 * @see IEditorActionDelegate#setActiveEditor(bIAction,IEditorPart)
 */
public void setActiveEditor(IAction callerAction,IEditorPart targetEditor){
  fEditorPart=targetEditor;
  super.setActiveEditor(callerAction,targetEditor);
}

Fixed version (ground truth):
/** 
 * @see IEditorActionDelegate#setActiveEditor(bIAction,IEditorPart)
 */
@Override public void setActiveEditor(IAction callerAction,IEditorPart targetEditor){
  fEditorPart=targetEditor;
  super.setActiveEditor(callerAction,targetEditor);
}
Program: 185990
Project: 185990
Buggy source:
/** 
 * @see AbstractRulerActionDelegate#createAction()
 */
protected IAction createAction(ITextEditor editor,IVerticalRulerInfo rulerInfo){
  IResource resource;
  IEditorInput editorInput=editor.getEditorInput();
  if (editorInput instanceof IFileEditorInput) {
    resource=((IFileEditorInput)editorInput).getFile();
    if (GroovyNature.hasGroovyNature(resource.getProject())) {
      return new GroovyBreakpointRulerAction(rulerInfo,editor,fEditorPart);
    }
  }
  return super.createAction(editor,rulerInfo);
}

Fixed version (ground truth):
/** 
 * @see AbstractRulerActionDelegate#createAction()
 */
@Override protected IAction createAction(ITextEditor editor,IVerticalRulerInfo rulerInfo){
  IResource resource;
  IEditorInput editorInput=editor.getEditorInput();
  if (editorInput instanceof IFileEditorInput) {
    resource=((IFileEditorInput)editorInput).getFile();
    if (GroovyNature.hasGroovyNature(resource.getProject())) {
      groovyDelegate=new GroovyBreakpointRulerAction(rulerInfo,editor,fEditorPart);
      return groovyDelegate;
    }
  }
  return super.createAction(editor,rulerInfo);
}
Program: 185991
Project: 185991
Buggy source:
public List<IJavaCompletionProposal> getQuickFixProposals(){
  Collection<ICommandAccess> proposals=new ArrayList<ICommandAccess>(2);
  LocalCorrectionsSubProcessor.addUnimplementedMethodsProposals(getQuickFixProblem().getContext(),getQuickFixProblem().getLocation(),proposals);
  List<IJavaCompletionProposal> newProposals=new ArrayList<IJavaCompletionProposal>();
  for (  ICommandAccess command : proposals) {
    if (command instanceof IJavaCompletionProposal) {
      newProposals.add((IJavaCompletionProposal)command);
    }
  }
  return newProposals;
}

Fixed version (ground truth):
public List<IJavaCompletionProposal> getQuickFixProposals(){
  Collection<IJavaCompletionProposal> proposals=new ArrayList<IJavaCompletionProposal>(2);
  addUnimplementedMethodsProposals(getQuickFixProblem().getContext(),getQuickFixProblem().getLocation(),proposals);
  List<IJavaCompletionProposal> newProposals=new ArrayList<IJavaCompletionProposal>();
  for (  Object command : proposals) {
    if (command instanceof IJavaCompletionProposal) {
      newProposals.add((IJavaCompletionProposal)command);
    }
  }
  return newProposals;
}
Program: 185992
Project: 185992
Buggy source:
public static Bundle getActiveGroovyBundle(){
  String version17="String_Node_Str";
  String version18="String_Node_Str";
  String version20="String_Node_Str";
  String versionToUse=version20;
  if (isGroovy20DisabledOrMissing()) {
    if (isGroovy18DisabledOrMissing()) {
      versionToUse=version17;
    }
 else {
      versionToUse=version18;
    }
  }
  Bundle[] active=Platform.getBundles("String_Node_Str",version20);
  return active != null && active.length > 0 ? active[0] : null;
}

Fixed version (ground truth):
public static Bundle getActiveGroovyBundle(){
  String version17="String_Node_Str";
  String version18="String_Node_Str";
  String version20="String_Node_Str";
  String versionToUse=version20;
  if (isGroovy20DisabledOrMissing()) {
    if (isGroovy18DisabledOrMissing()) {
      versionToUse=version17;
    }
 else {
      versionToUse=version18;
    }
  }
  Bundle[] active=Platform.getBundles("String_Node_Str",versionToUse);
  return active != null && active.length > 0 ? active[0] : null;
}
Program: 185993
Project: 185993
Buggy source:
@Override protected IPreferenceStore doGetPreferenceStore(){
  IProject project=getProject();
  ScopedPreferenceStore store;
  if (project == null) {
    preferences=InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    store=new ScopedPreferenceStore(InstanceScope.INSTANCE,Activator.PLUGIN_ID);
  }
 else {
    IScopeContext projectScope=new ProjectScope(project);
    preferences=projectScope.getNode(Activator.PLUGIN_ID);
    store=new ScopedPreferenceStore(projectScope,Activator.PLUGIN_ID);
  }
  return store;
}

Fixed version (ground truth):
@Override protected IPreferenceStore doGetPreferenceStore(){
  IProject project=getProject();
  ScopedPreferenceStore store;
  if (project == null) {
    IScopeContext scope=new InstanceScope();
    preferences=scope.getNode(Activator.PLUGIN_ID);
    store=new ScopedPreferenceStore(scope,Activator.PLUGIN_ID);
  }
 else {
    IScopeContext projectScope=new ProjectScope(project);
    preferences=projectScope.getNode(Activator.PLUGIN_ID);
    store=new ScopedPreferenceStore(projectScope,Activator.PLUGIN_ID);
  }
  return store;
}
Program: 185994
Project: 185994
Buggy source:
public GroovyImageDecorator(){
  problemsDecorator=new TreeHierarchyLayoutProblemsDecorator();
  decman=WorkbenchPlugin.getDefault().getDecoratorManager();
  listener=new PreferenceChangeListener();
  InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID).addPreferenceChangeListener(listener);
  scriptFolderSelector=new ScriptFolderSelector(null);
}

Fixed version (ground truth):
public GroovyImageDecorator(){
  problemsDecorator=new TreeHierarchyLayoutProblemsDecorator();
  decman=WorkbenchPlugin.getDefault().getDecoratorManager();
  listener=new PreferenceChangeListener();
  new InstanceScope().getNode(Activator.PLUGIN_ID).addPreferenceChangeListener(listener);
  scriptFolderSelector=new ScriptFolderSelector(null);
}
Program: 185995
Project: 185995
Buggy source:
@Override public void configure(ProjectConfigurationRequest request,IProgressMonitor monitor) throws CoreException {
  super.configure(request,monitor);
  IProject project=request.getProject();
  if (getSourceType(request.getMavenProjectFacade()) != null) {
    if (!project.hasNature(GroovyNature.GROOVY_NATURE)) {
      if (!project.hasNature(JavaCore.NATURE_ID)) {
        addJavaNature(project);
      }
      GroovyRuntime.addGroovyNature(project);
    }
    IJavaProject javaProject=JavaCore.create(project);
    if (!GroovyRuntime.hasClasspathContainer(javaProject,GroovyRuntime.DSLD_CONTAINER_ID)) {
      GroovyRuntime.addLibraryToClasspath(javaProject,GroovyRuntime.DSLD_CONTAINER_ID);
    }
  }
 else {
    GroovyRuntime.removeGroovyNature(project);
  }
}

Fixed version (ground truth):
@Override public void configure(ProjectConfigurationRequest request,IProgressMonitor monitor) throws CoreException {
  super.configure(request,monitor);
  IProject project=request.getProject();
  if (getSourceType(request.getMavenProjectFacade()) != null) {
    if (!project.hasNature(GroovyNature.GROOVY_NATURE)) {
      if (!project.hasNature(JavaCore.NATURE_ID)) {
        addJavaNature(project);
      }
      GroovyRuntime.addGroovyNature(project);
    }
    IJavaProject javaProject=JavaCore.create(project);
    if (!GroovyRuntime.hasClasspathContainer(javaProject,GroovyRuntime.DSLD_CONTAINER_ID)) {
      GroovyRuntime.addLibraryToClasspath(javaProject,GroovyRuntime.DSLD_CONTAINER_ID,false);
    }
  }
 else {
    GroovyRuntime.removeGroovyNature(project);
  }
}
Program: 185996
Project: 185996
Buggy source:
private ASTNode getLast(BlockStatement statements,List<MethodNode> methods){
  Statement lastStatement=hasScriptStatements(statements) ? statements.getStatements().get(statements.getStatements().size() - 1) : null;
  MethodNode lastMethod=hasScriptMethods(methods) ? methods.get(methods.size() - 1) : null;
  int statementStart=lastStatement != null ? lastStatement.getEnd() : Integer.MIN_VALUE;
  int methodStart=lastMethod != null ? lastMethod.getStart() : Integer.MIN_VALUE;
  return statementStart >= methodStart ? lastStatement : lastMethod;
}

Fixed version (ground truth):
private ASTNode getLast(BlockStatement statements,List<MethodNode> methods){
  Statement lastStatement=hasScriptStatements(statements) ? statements.getStatements().get(statements.getStatements().size() - 1) : null;
  MethodNode lastMethod=hasScriptMethods(methods) ? methods.get(methods.size() - 1) : null;
  if (lastMethod == null && (lastStatement == null || (lastStatement.getStart() == 0 && lastStatement.getLength() == 0))) {
    lastStatement=createSyntheticAfterImports();
  }
  int statementStart=lastStatement != null ? lastStatement.getEnd() : Integer.MIN_VALUE;
  int methodStart=lastMethod != null ? lastMethod.getStart() : Integer.MIN_VALUE;
  return statementStart >= methodStart ? lastStatement : lastMethod;
}
Program: 185997
Project: 185997
Buggy source:
private ASTNode getFirst(BlockStatement statements,List<MethodNode> methods){
  Statement firstStatement=hasScriptStatements(statements) ? statements.getStatements().get(0) : null;
  MethodNode firstMethod=hasScriptMethods(methods) ? methods.get(0) : null;
  int statementStart=firstStatement != null ? firstStatement.getStart() : Integer.MAX_VALUE;
  int methodStart=firstMethod != null ? firstMethod.getStart() : Integer.MAX_VALUE;
  return statementStart <= methodStart ? firstStatement : firstMethod;
}

Fixed version (ground truth):
private ASTNode getFirst(BlockStatement statements,List<MethodNode> methods){
  Statement firstStatement=hasScriptStatements(statements) ? statements.getStatements().get(0) : null;
  MethodNode firstMethod=hasScriptMethods(methods) ? methods.get(0) : null;
  if (firstMethod == null && (firstStatement == null || (firstStatement.getStart() == 0 && firstStatement.getLength() == 0))) {
    firstStatement=createSyntheticAfterImports();
  }
  int statementStart=firstStatement != null ? firstStatement.getStart() : Integer.MAX_VALUE;
  int methodStart=firstMethod != null ? firstMethod.getStart() : Integer.MAX_VALUE;
  return statementStart <= methodStart ? firstStatement : firstMethod;
}
Program: 185999
Project: 185999
Buggy source:
private ASTNode getLast(BlockStatement statements,List<MethodNode> methods){
  Statement lastStatement=hasScriptStatements(statements) ? statements.getStatements().get(statements.getStatements().size() - 1) : null;
  MethodNode lastMethod=hasScriptMethods(methods) ? methods.get(methods.size() - 1) : null;
  int statementStart=lastStatement != null ? lastStatement.getEnd() : Integer.MIN_VALUE;
  int methodStart=lastMethod != null ? lastMethod.getStart() : Integer.MIN_VALUE;
  return statementStart >= methodStart ? lastStatement : lastMethod;
}

Fixed version (ground truth):
private ASTNode getLast(BlockStatement statements,List<MethodNode> methods){
  Statement lastStatement=hasScriptStatements(statements) ? statements.getStatements().get(statements.getStatements().size() - 1) : null;
  MethodNode lastMethod=hasScriptMethods(methods) ? methods.get(methods.size() - 1) : null;
  if (lastMethod == null && (lastStatement == null || (lastStatement.getStart() == 0 && lastStatement.getLength() == 0))) {
    lastStatement=createSyntheticAfterImports();
  }
  int statementStart=lastStatement != null ? lastStatement.getEnd() : Integer.MIN_VALUE;
  int methodStart=lastMethod != null ? lastMethod.getStart() : Integer.MIN_VALUE;
  return statementStart >= methodStart ? lastStatement : lastMethod;
}
Program: 186000
Project: 186000
Buggy source:
private ASTNode getFirst(BlockStatement statements,List<MethodNode> methods){
  Statement firstStatement=hasScriptStatements(statements) ? statements.getStatements().get(0) : null;
  MethodNode firstMethod=hasScriptMethods(methods) ? methods.get(0) : null;
  int statementStart=firstStatement != null ? firstStatement.getStart() : Integer.MAX_VALUE;
  int methodStart=firstMethod != null ? firstMethod.getStart() : Integer.MAX_VALUE;
  return statementStart <= methodStart ? firstStatement : firstMethod;
}

Fixed version (ground truth):
private ASTNode getFirst(BlockStatement statements,List<MethodNode> methods){
  Statement firstStatement=hasScriptStatements(statements) ? statements.getStatements().get(0) : null;
  MethodNode firstMethod=hasScriptMethods(methods) ? methods.get(0) : null;
  if (firstMethod == null && (firstStatement == null || (firstStatement.getStart() == 0 && firstStatement.getLength() == 0))) {
    firstStatement=createSyntheticAfterImports();
  }
  int statementStart=firstStatement != null ? firstStatement.getStart() : Integer.MAX_VALUE;
  int methodStart=firstMethod != null ? firstMethod.getStart() : Integer.MAX_VALUE;
  return statementStart <= methodStart ? firstStatement : firstMethod;
}
Program: 186002
Project: 186002
Buggy source:
/** 
 * Try to get the source locations for type declarations to be as correct as possible
 */
private void fixupSourceLocationsForTypeDeclaration(GroovyTypeDeclaration typeDeclaration,ClassNode classNode){
  typeDeclaration.sourceStart=Math.max(classNode.getNameStart(),classNode.getStart());
  typeDeclaration.sourceEnd=Math.max(classNode.getNameEnd(),classNode.getStart());
  int line=classNode.getLineNumber();
  Javadoc doc=findJavadoc(line);
  typeDeclaration.javadoc=doc;
  typeDeclaration.declarationSourceStart=doc == null ? classNode.getStart() : doc.sourceStart;
  typeDeclaration.declarationSourceEnd=classNode.getEnd() - 1;
  typeDeclaration.bodyStart=Math.max(classNode.getNameEnd(),classNode.getStart());
  typeDeclaration.bodyEnd=classNode.getEnd() - 1;
  typeDeclaration.modifiersSourceStart=classNode.getStart();
}

Fixed version (ground truth):
/** 
 * Try to get the source locations for type declarations to be as correct as possible
 */
private void fixupSourceLocationsForTypeDeclaration(GroovyTypeDeclaration typeDeclaration,ClassNode classNode){
  typeDeclaration.sourceStart=Math.max(classNode.getNameStart(),classNode.getStart());
  typeDeclaration.sourceEnd=Math.max(classNode.getNameEnd(),classNode.getStart());
  int line=classNode.getLineNumber();
  Javadoc doc=findJavadoc(line);
  if (doc != null) {
    if (imports != null && imports.length > 0) {
      if (doc.sourceStart < imports[imports.length - 1].sourceStart) {
        doc=null;
      }
    }
 else     if (currentPackage != null) {
      if (doc.sourceStart < currentPackage.sourceStart) {
        doc=null;
      }
    }
  }
  typeDeclaration.javadoc=doc;
  typeDeclaration.declarationSourceStart=doc == null ? classNode.getStart() : doc.sourceStart;
  typeDeclaration.declarationSourceEnd=classNode.getEnd() - 1;
  typeDeclaration.bodyStart=Math.max(classNode.getNameEnd(),classNode.getStart());
  typeDeclaration.bodyEnd=classNode.getEnd() - 1;
  typeDeclaration.modifiersSourceStart=classNode.getStart();
}
Program: 186004
Project: 186004
Buggy source:
protected IStatus checkJavaType(String value){
  return JavaConventions.validateJavaTypeName(value,JavaCore.VERSION_1_3,JavaCore.VERSION_1_3);
}

Fixed version (ground truth):
protected IStatus checkJavaType(String value){
  return JavaConventions.validateIdentifier(value,JavaCore.VERSION_1_3,JavaCore.VERSION_1_3);
}
Program: 186005
Project: 186005
Buggy source:
public ValueStatus checkValidity(Object value){
  if (value instanceof String) {
    String name=(String)value;
    IStatus status=JavaConventions.validateJavaTypeName(name,JavaCore.VERSION_1_3,JavaCore.VERSION_1_3);
    if (status.getSeverity() != IStatus.ERROR) {
      try {
        IType type=getActualType(name);
        if (type != null) {
          return ValueStatus.getValidStatus(value);
        }
 else {
          return ValueStatus.getErrorStatus(value,THE_SPECIFIED_JAVA_TYPES_DO_NOT_EXIST + name);
        }
      }
 catch (      JavaModelException e) {
        Activator.logError(e);
      }
    }
 else {
      return ValueStatus.getErrorStatus(value,status.getMessage());
    }
  }
  return ValueStatus.getErrorStatus(value,INVALID_JAVA);
}

Fixed version (ground truth):
public ValueStatus checkValidity(Object value){
  if (value instanceof String) {
    String name=(String)value;
    IStatus status=JavaConventions.validateJavaTypeName(name,JavaCore.VERSION_1_3,JavaCore.VERSION_1_3);
    if (status.getSeverity() != IStatus.ERROR) {
      try {
        IType type=getActualType(name);
        if (type != null) {
          return ValueStatus.getValidStatus(value);
        }
 else {
          return ValueStatus.getErrorStatus(value,THE_SPECIFIED_JAVA_TYPES_DO_NOT_EXIST + name);
        }
      }
 catch (      JavaModelException e) {
        Activator.logError(e);
      }
    }
 else {
      return ValueStatus.getErrorStatus(value,INVALID_JAVA);
    }
  }
  return ValueStatus.getErrorStatus(value,INVALID_JAVA);
}
Program: 186006
Project: 186006
Buggy source:
protected Shell getShell(){
  Display display=Display.getCurrent();
  if (display == null) {
    display=Display.getDefault();
  }
  Shell shell=display.getActiveShell();
  if (shell == null || shell.isDisposed()) {
    for (    Shell shll : display.getShells()) {
      if (shll != null && !shll.isDisposed()) {
        shell=shll;
        break;
      }
    }
  }
  return shell;
}

Fixed version (ground truth):
protected Shell getShell(){
  Display display=Display.getCurrent();
  if (display == null) {
    display=Display.getDefault();
  }
  if (display == null) {
    return null;
  }
  Shell shell=display.getActiveShell();
  if (shell == null || shell.isDisposed()) {
    for (    Shell shll : display.getShells()) {
      if (shll != null && !shll.isDisposed()) {
        shell=shll;
        break;
      }
    }
  }
  return shell;
}
Program: 186007
Project: 186007
Buggy source:
public VisitStatus acceptASTNode(ASTNode node,TypeLookupResult result,IJavaElement enclosingElement){
  if (!interestingElement(enclosingElement)) {
    return VisitStatus.CANCEL_MEMBER;
  }
  if (node instanceof ImportNode) {
    node=((ImportNode)node).getType();
    if (node == null) {
      return VisitStatus.CONTINUE;
    }
  }
  if (node instanceof ConstantExpression && doTest(node)) {
    ConstantExpression expression=(ConstantExpression)node;
    descriptor=createDescriptor(expression,result);
    return VisitStatus.STOP_VISIT;
  }
  return VisitStatus.CONTINUE;
}

Fixed version (ground truth):
public VisitStatus acceptASTNode(ASTNode node,TypeLookupResult result,IJavaElement enclosingElement){
  if (!interestingElement(enclosingElement)) {
    return VisitStatus.CANCEL_MEMBER;
  }
  if (node instanceof ImportNode) {
    node=((ImportNode)node).getType();
    if (node == null) {
      return VisitStatus.CONTINUE;
    }
  }
  if (isValidNode(node) && doTest(node)) {
    Expression expression=(Expression)node;
    descriptor=createDescriptor(expression,result);
    return VisitStatus.STOP_VISIT;
  }
  return VisitStatus.CONTINUE;
}
Program: 186008
Project: 186008
Buggy source:
protected SuggestionDescriptor createDescriptor(ConstantExpression suggestionNode,TypeLookupResult result){
  ClassNode declaringTypeNode=result.declaringType;
  ClassNode suggestionTypeNode=result.type;
  VariableScope scope=result.scope;
  String declaringTypeName=declaringTypeNode.getName();
  String suggestionType=suggestionTypeNode.getName();
  Object suggestionName=suggestionNode.getValue();
  String name=suggestionName instanceof String ? (String)suggestionName : null;
  boolean isStatic=false;
  String javaDoc=null;
  boolean useNamedArguments=false;
  List<MethodParameter> parameters=null;
  boolean isMethod=isMethod(scope);
  boolean isActive=true;
  return isMethod ? new SuggestionDescriptor(declaringTypeName,isStatic,name,javaDoc,suggestionType,useNamedArguments,parameters,isActive) : new SuggestionDescriptor(declaringTypeName,isStatic,name,javaDoc,suggestionType,isActive);
}

Fixed version (ground truth):
protected SuggestionDescriptor createDescriptor(Expression suggestionNode,TypeLookupResult result){
  ClassNode declaringTypeNode=result.declaringType;
  ClassNode suggestionTypeNode=result.type;
  VariableScope scope=result.scope;
  String declaringTypeName=declaringTypeNode.getName();
  String suggestionType=suggestionTypeNode.getName();
  Object suggestionName=suggestionNode instanceof ConstantExpression ? ((ConstantExpression)suggestionNode).getValue() : suggestionNode.getText();
  String name=suggestionName instanceof String ? (String)suggestionName : null;
  boolean isStatic=false;
  String javaDoc=null;
  boolean useNamedArguments=false;
  List<MethodParameter> parameters=null;
  boolean isMethod=isMethod(scope);
  boolean isActive=true;
  return isMethod ? new SuggestionDescriptor(declaringTypeName,isStatic,name,javaDoc,suggestionType,useNamedArguments,parameters,isActive) : new SuggestionDescriptor(declaringTypeName,isStatic,name,javaDoc,suggestionType,isActive);
}
Program: 186009
Project: 186009
Buggy source:
protected ColumnTypes getColumnType(TreeColumn column){
  String columnName=column.getText();
  for (  ColumnTypes type : ColumnTypes.values()) {
    if (type.equals(columnName)) {
      return type;
    }
  }
  return null;
}

Fixed version (ground truth):
protected ColumnTypes getColumnType(TreeColumn column){
  String columnName=column.getText();
  for (  ColumnTypes type : ColumnTypes.values()) {
    if (type.getName().equals(columnName)) {
      return type;
    }
  }
  return null;
}
Program: 186010
Project: 186010
Buggy source:
protected String constructName(){
  if (suggestion == null) {
    return null;
  }
  StringBuffer buffer=new StringBuffer();
  String name=suggestion.getName();
  buffer.append(name);
  buffer.append(EMPTY_SPACE);
  buffer.append(COLON);
  buffer.append(EMPTY_SPACE);
  String typeName=suggestion.getType();
  buffer.append(typeName);
  List<MethodParameter> methodArguments=suggestion.getParameters();
  if (methodArguments != null) {
    buffer.append(OPEN_PAR);
    int size=methodArguments.size();
    for (    MethodParameter argument : methodArguments) {
      buffer.append(argument.getType());
      buffer.append(EMPTY_SPACE);
      buffer.append(argument.getName());
      if (--size > 0) {
        buffer.append(COMMA);
        buffer.append(EMPTY_SPACE);
      }
    }
    buffer.append(CLOSE_PAR);
  }
  return buffer.toString();
}

Fixed version (ground truth):
protected String constructName(){
  if (suggestion == null) {
    return null;
  }
  StringBuffer buffer=new StringBuffer();
  String name=suggestion.getName();
  buffer.append(name);
  String typeName=suggestion.getType();
  if (typeName != null && typeName.length() > 0) {
    buffer.append(EMPTY_SPACE);
    buffer.append(COLON);
    buffer.append(EMPTY_SPACE);
    buffer.append(typeName);
  }
  List<MethodParameter> parameters=suggestion.getParameters();
  if (parameters != null) {
    buffer.append(OPEN_PAR);
    int size=parameters.size();
    for (    MethodParameter param : parameters) {
      String paramType=param.getType();
      if (paramType != null && paramType.length() > 0) {
        buffer.append(paramType);
        buffer.append(EMPTY_SPACE);
      }
      buffer.append(param.getName());
      if (--size > 0) {
        buffer.append(COMMA);
        buffer.append(EMPTY_SPACE);
      }
    }
    buffer.append(CLOSE_PAR);
  }
  return buffer.toString();
}
Program: 186011
Project: 186011
Buggy source:
protected String constructName(){
  if (property == null) {
    return null;
  }
  StringBuffer buffer=new StringBuffer();
  String name=property.getName();
  buffer.append(name);
  buffer.append(EMPTY_SPACE);
  buffer.append(COLON);
  buffer.append(EMPTY_SPACE);
  String type=property.getType();
  buffer.append(type);
  return buffer.toString();
}

Fixed version (ground truth):
protected String constructName(){
  if (property == null) {
    return null;
  }
  StringBuffer buffer=new StringBuffer();
  String name=property.getName();
  buffer.append(name);
  String type=property.getType();
  if (type != null && type.length() > 0) {
    buffer.append(EMPTY_SPACE);
    buffer.append(COLON);
    buffer.append(EMPTY_SPACE);
    buffer.append(type);
  }
  return buffer.toString();
}
Program: 186012
Project: 186012
Buggy source:
public ValidatedValueSelectionListener(IDialogueControlDescriptor descriptor,Object initialValue){
  invalidValues.put(descriptor,new SetValue(initialValue,null));
}

Fixed version (ground truth):
public ValidatedValueSelectionListener(IDialogueControlDescriptor descriptor,Object initialValue){
  if (descriptor != null) {
    invalidValues.put(descriptor,new SetValue(initialValue,null));
  }
}
Program: 186014
Project: 186014
Buggy source:
protected void createCommandArea(Composite parent){
  JavaTextControl nameControl=new JavaTextControl(ControlTypes.NAME,getOffsetLabelLocation(),name){
    protected ValueStatus isControlValueValid(    Control control){
      ValueStatus status=super.isControlValueValid(control);
      if (!status.isError()) {
        status=new DuplicateParameterRule(existingParameters).checkValidity(status.getValue());
      }
      return status;
    }
  }
;
  nameControl.createControlArea(parent);
  nameControl.addSelectionListener(new ValidatedValueSelectionListener(ControlTypes.NAME,name){
    protected void handleValidatedValue(    ControlSelectionEvent event){
      Object selection=event.getSelectionData();
      if (selection instanceof String) {
        name=(String)selection;
      }
    }
  }
);
  JavaTypeBrowsingControl declaringTypeControl=new JavaTypeBrowsingControl(ControlTypes.TYPE,getOffsetLabelLocation(),type,javaProject){
    protected ValueStatus isControlValueValid(    String value){
      if (value == null || value.length() == 0) {
        return ValueStatus.getValidStatus(value);
      }
      return super.isControlValueValid(value);
    }
  }
;
  declaringTypeControl.createControlArea(parent);
  declaringTypeControl.addSelectionListener(new ValidatedValueSelectionListener(){
    protected void handleValidatedValue(    ControlSelectionEvent event){
      Object selection=event.getSelectionData();
      if (selection instanceof String) {
        type=(String)selection;
      }
    }
  }
);
}

Fixed version (ground truth):
protected void createCommandArea(Composite parent){
  JavaTextControl nameControl=new JavaTextControl(ControlTypes.NAME,getOffsetLabelLocation(),name){
    protected ValueStatus isControlValueValid(    Control control){
      ValueStatus status=super.isControlValueValid(control);
      if (!status.isError()) {
        status=new DuplicateParameterRule(existingParameters).checkValidity(status.getValue());
      }
      return status;
    }
  }
;
  nameControl.createControlArea(parent);
  nameControl.addSelectionListener(new ValidatedValueSelectionListener(ControlTypes.NAME,name){
    protected void handleValidatedValue(    ControlSelectionEvent event){
      Object selection=event.getSelectionData();
      if (selection instanceof String) {
        name=(String)selection;
      }
    }
  }
);
  JavaTypeBrowsingControl typeControl=new JavaTypeBrowsingControl(ControlTypes.TYPE,getOffsetLabelLocation(),type,javaProject){
    protected ValueStatus isControlValueValid(    String value){
      if (value == null || value.length() == 0) {
        return ValueStatus.getValidStatus(value);
      }
      return super.isControlValueValid(value);
    }
  }
;
  typeControl.createControlArea(parent);
  typeControl.addSelectionListener(new ValidatedValueSelectionListener(){
    protected void handleValidatedValue(    ControlSelectionEvent event){
      Object selection=event.getSelectionData();
      if (selection instanceof String) {
        type=(String)selection;
      }
    }
  }
);
}
Program: 186015
Project: 186015
Buggy source:
public IJavaCompletionProposal[] getAssists(IInvocationContext context,IProblemLocation[] locations) throws CoreException {
  List<IJavaCompletionProposal> proposalList=new ArrayList<IJavaCompletionProposal>();
  IJavaCompletionProposal javaProposal=new InferencingSuggestionsQuickAssistProposal(context).convertToJavaCompletionProposal();
  proposalList.add(javaProposal);
  return proposalList.toArray(new IJavaCompletionProposal[]{});
}

Fixed version (ground truth):
public IJavaCompletionProposal[] getAssists(IInvocationContext context,IProblemLocation[] locations) throws CoreException {
  List<IJavaCompletionProposal> proposalList=new ArrayList<IJavaCompletionProposal>();
  IJavaCompletionProposal javaProposal=new AddSuggestionsQuickAssistProposal(context).convertToJavaCompletionProposal();
  proposalList.add(javaProposal);
  return proposalList.toArray(new IJavaCompletionProposal[]{});
}
Program: 186016
Project: 186016
Buggy source:
protected boolean allTypesExist(Type type,StringBuffer source,List<String> nonExistantTypes) throws JavaModelException {
  String typeName=getTypeName(type,source);
  IType actualType=getActualType(typeName);
  if (actualType != null) {
    if (type instanceof ParameterizedType) {
      List<?> parameterisedNodes=((ParameterizedType)type).typeArguments();
      if (parameterisedNodes != null) {
        boolean allParamsValid=true;
        for (        Object node : parameterisedNodes) {
          if (!(node instanceof Type) || !allTypesExist((Type)node,source,nonExistantTypes)) {
            allParamsValid=false;
            break;
          }
        }
        return allParamsValid;
      }
    }
    return true;
  }
 else {
    if (nonExistantTypes != null && !nonExistantTypes.contains(typeName)) {
      nonExistantTypes.add(typeName);
    }
  }
  return false;
}

Fixed version (ground truth):
protected boolean allTypesExist(Type type,StringBuffer source,List<String> nonExistantTypes) throws JavaModelException {
  String typeName=getTypeName(type,source);
  IType actualType=getActualType(typeName);
  if (actualType != null) {
    if (type instanceof ParameterizedType) {
      List<?> parameterisedNodes=((ParameterizedType)type).typeArguments();
      if (parameterisedNodes != null) {
        boolean allParamsValid=true;
        for (        Object node : parameterisedNodes) {
          if (!(node instanceof Type) || !allTypesExist((Type)node,source,nonExistantTypes)) {
            allParamsValid=false;
            break;
          }
        }
        return allParamsValid;
      }
    }
    return true;
  }
 else   if (type instanceof PrimitiveType || type instanceof ArrayType) {
    return true;
  }
 else {
    if (nonExistantTypes != null && !nonExistantTypes.contains(typeName)) {
      nonExistantTypes.add(typeName);
    }
  }
  return false;
}
Program: 186018
Project: 186018
Buggy source:
protected void handleSelectionButtonEnablement(List<Object> selectedObjects){
  if (projects == null || projects.isEmpty()) {
    selectionButtons.get(ButtonTypes.ADD).setEnabled(false);
    selectionButtons.get(ButtonTypes.EDIT).setEnabled(false);
    selectionButtons.get(ButtonTypes.REMOVE).setEnabled(false);
  }
 else   if (selectedObjects == null || selectedObjects.isEmpty()) {
    selectionButtons.get(ButtonTypes.ADD).setEnabled(true);
    selectionButtons.get(ButtonTypes.EDIT).setEnabled(false);
    selectionButtons.get(ButtonTypes.REMOVE).setEnabled(false);
  }
 else   if (selectedObjects.size() == 1) {
    Object selectedObj=selectedObjects.get(0);
    if (selectedObj instanceof GroovySuggestionDeclaringType) {
      selectionButtons.get(ButtonTypes.ADD).setEnabled(true);
      selectionButtons.get(ButtonTypes.EDIT).setEnabled(false);
      selectionButtons.get(ButtonTypes.REMOVE).setEnabled(true);
    }
 else     if (selectedObj instanceof IGroovySuggestion) {
      selectionButtons.get(ButtonTypes.ADD).setEnabled(false);
      selectionButtons.get(ButtonTypes.EDIT).setEnabled(true);
      selectionButtons.get(ButtonTypes.REMOVE).setEnabled(true);
    }
  }
 else {
    selectionButtons.get(ButtonTypes.ADD).setEnabled(false);
    selectionButtons.get(ButtonTypes.EDIT).setEnabled(false);
    selectionButtons.get(ButtonTypes.REMOVE).setEnabled(true);
  }
}

Fixed version (ground truth):
protected void handleSelectionButtonEnablement(List<Object> selectedObjects){
  if (projects == null || projects.isEmpty()) {
    selectionButtons.get(ButtonTypes.ADD).setEnabled(false);
    selectionButtons.get(ButtonTypes.EDIT).setEnabled(false);
    selectionButtons.get(ButtonTypes.REMOVE).setEnabled(false);
  }
 else   if (selectedObjects == null || selectedObjects.isEmpty()) {
    selectionButtons.get(ButtonTypes.ADD).setEnabled(true);
    selectionButtons.get(ButtonTypes.EDIT).setEnabled(false);
    selectionButtons.get(ButtonTypes.REMOVE).setEnabled(false);
  }
 else   if (selectedObjects.size() == 1) {
    Object selectedObj=selectedObjects.get(0);
    if (selectedObj instanceof GroovySuggestionDeclaringType) {
      selectionButtons.get(ButtonTypes.ADD).setEnabled(true);
      selectionButtons.get(ButtonTypes.EDIT).setEnabled(false);
      selectionButtons.get(ButtonTypes.REMOVE).setEnabled(true);
    }
 else     if (selectedObj instanceof IGroovySuggestion) {
      selectionButtons.get(ButtonTypes.ADD).setEnabled(true);
      selectionButtons.get(ButtonTypes.EDIT).setEnabled(true);
      selectionButtons.get(ButtonTypes.REMOVE).setEnabled(true);
    }
  }
 else {
    selectionButtons.get(ButtonTypes.ADD).setEnabled(false);
    selectionButtons.get(ButtonTypes.EDIT).setEnabled(false);
    selectionButtons.get(ButtonTypes.REMOVE).setEnabled(true);
  }
}
Program: 186019
Project: 186019
Buggy source:
/** 
 * Dialogue can only be opened on ONE selection or no selections. It will not be opened on multiple selections.
 */
protected void editSuggestion(){
  if (getSelections().size() > 1) {
    return;
  }
 else {
    if (getSelections().size() == 1) {
      Object selectedObj=getSelections().get(0);
      if (selectedObj instanceof IGroovySuggestion) {
        IGroovySuggestion suggestion=(IGroovySuggestion)selectedObj;
        InferencingContributionDialogue dialogue=new InferencingContributionDialogue(getShell(),suggestion,getSelectedProject());
        if (dialogue.open() == Window.OK) {
          SuggestionDescriptor descriptor=dialogue.getSuggestionChange();
          GroovySuggestionDeclaringType declaringType=suggestion.getDeclaringType();
          IGroovySuggestion replacedSuggestion=declaringType.replaceSuggestion(descriptor,suggestion);
          refresh();
          setCheckState(replacedSuggestion);
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Dialogue can only be opened on ONE selection or no selections. It will not be opened on multiple selections.
 */
protected void editSuggestion(){
  if (getSelections().size() > 1) {
    return;
  }
 else {
    if (getSelections().size() == 1) {
      Object selectedObj=getSelections().get(0);
      if (selectedObj instanceof IGroovySuggestion) {
        IGroovySuggestion existingSuggestion=(IGroovySuggestion)selectedObj;
        InferencingContributionDialogue dialogue=new InferencingContributionDialogue(getShell(),existingSuggestion,getSelectedProject());
        IGroovySuggestion editedSuggestion=null;
        if (dialogue.open() == Window.OK) {
          SuggestionDescriptor descriptor=dialogue.getSuggestionChange();
          GroovySuggestionDeclaringType declaringType=existingSuggestion.getDeclaringType();
          if (!declaringType.getName().equals(descriptor.getDeclaringTypeName())) {
            declaringType.removeSuggestion(existingSuggestion);
            ProjectSuggestions projectSuggestions=InferencingSuggestionsManager.getInstance().getSuggestions(getSelectedProject());
            if (declaringType.getSuggestions().isEmpty()) {
              projectSuggestions.removeDeclaringType(declaringType);
            }
            editedSuggestion=projectSuggestions.addSuggestion(descriptor);
          }
 else {
            editedSuggestion=declaringType.replaceSuggestion(descriptor,existingSuggestion);
          }
          refresh();
          setCheckState(editedSuggestion);
        }
      }
    }
  }
}