nus-yam/ex-repair huggingface dataset:
Program: 93462
Project: 93462
Buggy source:
@Override public final Control createControl(final Composite parent,final IWorkbenchPartSite partSite){
  composite=SwtFactory.createGridComposite(parent,1,0,6,8,10);
  final CLabel label=new CLabel(composite,SWT.NONE);
  label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
  label.setImage(getIcon());
  label.setText(getProviderFullName());
  SwtFactory.createSeparator(composite);
  createContentControl(composite);
  return composite;
}

Fixed version (ground truth):
@Override public final Control createControl(final Composite parent,final IWorkbenchPartSite partSite){
  composite=SwtFactory.createGridComposite(parent,1,0,4,8,10);
  final CLabel label=new CLabel(composite,SWT.NONE);
  label.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
  label.setImage(getIcon());
  label.setText(getProviderFullName());
  SwtFactory.createSeparator(composite);
  createContentControl(composite);
  return composite;
}
Program: 93463
Project: 93463
Buggy source:
@Override public Variable findMatchingVariable(final String variableName){
  AbstractVariableDeclaration match=findMatchingLocalVariable(getReceiverName());
  if (match == null) {
    match=findMatchingFieldDeclaration(variableName);
  }
  if (match == null) {
    return null;
  }
  final String name=String.valueOf(match.name);
  final ITypeName type=CompilerBindings.toTypeName(match.type);
  return Variable.create(name,type,getEnclosingMethod());
}

Fixed version (ground truth):
@Override public Variable findMatchingVariable(final String variableName){
  AbstractVariableDeclaration match=findMatchingLocalVariable(getReceiverName());
  if (match == null) {
    match=findMatchingFieldDeclaration(variableName);
    if (match == null) {
      match=findMatchingLocalVariable(variableName);
    }
  }
  if (match == null) {
    return null;
  }
  final String name=String.valueOf(match.name);
  final ITypeName type=CompilerBindings.toTypeName(match.type);
  return Variable.create(name,type,getEnclosingMethod());
}
Program: 93464
Project: 93464
Buggy source:
private Set<IMethodName> resolveCalledMethods(){
  for (  final IVariableUsageResolver resolver : usageResolversProvider.get()) {
    if (resolver.canResolve(context)) {
      return resolver.getReceiverMethodInvocations();
    }
  }
  return Sets.newHashSet();
}

Fixed version (ground truth):
private Set<IMethodName> resolveCalledMethods(){
  for (  final IVariableUsageResolver resolver : usageResolversProvider.get()) {
    if (resolver.canResolve(context)) {
      final Set<IMethodName> receiverMethodInvocations=resolver.getReceiverMethodInvocations();
      return receiverMethodInvocations;
    }
  }
  return Sets.newHashSet();
}
Program: 93465
Project: 93465
Buggy source:
private boolean displayProposalsForMethod(final IMethod method){
  System.err.println("String_Node_Str");
  final ITypeName typeName=JavaElementResolver.INSTANCE.toRecMethod(method).getDeclaringType();
  if (modelStore.hasModel(typeName)) {
    final IObjectMethodCallsNet model=getModel(typeName,new HashSet<IMethodName>());
    final boolean success=displayProposals(method,model.getRecommendedMethodCalls(0.01,5));
    modelStore.releaseModel(model);
    return success;
  }
  return false;
}

Fixed version (ground truth):
private boolean displayProposalsForMethod(final IMethod method){
  System.err.println("String_Node_Str");
  final ITypeName typeName=JavaElementResolver.INSTANCE.toRecMethod(method).getDeclaringType();
  if (modelStore.hasModel(typeName)) {
    final IObjectMethodCallsNet model=getModel(typeName,new HashSet<IMethodName>());
    final boolean success=displayProposals(method,model.getRecommendedMethodCalls(0.01,5));
    modelStore.releaseModel(model);
    return success;
  }
 else {
    IMethod findOverriddenMethod;
    try {
      findOverriddenMethod=SuperTypeHierarchyCache.getMethodOverrideTester(method.getDeclaringType()).findOverriddenMethod(method,true);
      if (findOverriddenMethod != null) {
        return displayProposalsForMethod(findOverriddenMethod);
      }
    }
 catch (    final JavaModelException e) {
      e.printStackTrace();
    }
  }
  return false;
}
Program: 93466
Project: 93466
Buggy source:
private boolean displayProposals(final IJavaElement element,final SortedSet<Tuple<IMethodName,Double>> proposals){
  if (proposals.isEmpty()) {
    return false;
  }
  if (calls != null) {
    calls.dispose();
    line.dispose();
    if (templates != null) {
      templates.dispose();
      line2.dispose();
    }
  }
  final String text="String_Node_Str" + element.getElementName() + "String_Node_Str";
  line=new TextAndFeaturesLine(composite,text,element,element.getElementName(),this,server,new TemplateEditDialog(getShell()));
  line.createStyleRange(15,element.getElementName().length(),SWT.NORMAL,false,true);
  calls=SwtFactory.createGridComposite(composite,3,12,2,12,0);
  for (  final Tuple<IMethodName,Double> proposal : proposals) {
    SwtFactory.createSquare(calls);
    SwtFactory.createLabel(calls,Names.vm2srcSimpleMethod(proposal.getFirst()),false,false,true);
    SwtFactory.createLabel(calls,Math.round(proposal.getSecond() * 100) + "String_Node_Str",false,true,false);
  }
  composite.layout(true);
  return true;
}

Fixed version (ground truth):
private boolean displayProposals(final IJavaElement element,final SortedSet<Tuple<IMethodName,Double>> proposals){
  if (proposals.isEmpty()) {
    return false;
  }
  if (calls != null) {
    calls.dispose();
    line.dispose();
    if (templates != null) {
      templates.dispose();
      line2.dispose();
    }
  }
  final String text="String_Node_Str" + element.getElementName() + "String_Node_Str";
  line=new TextAndFeaturesLine(composite,text,element,element.getElementName(),this,server,new TemplateEditDialog(getShell()));
  line.createStyleRange(15,element.getElementName().length(),SWT.NORMAL,false,true);
  calls=SwtFactory.createGridComposite(composite,3,12,2,12,0);
  for (  final Tuple<IMethodName,Double> proposal : proposals) {
    SwtFactory.createSquare(calls);
    final IMethodName method=proposal.getFirst();
    final String prefix=method.isInit() ? "String_Node_Str" : method.getDeclaringType().getClassName() + "String_Node_Str";
    SwtFactory.createLabel(calls,prefix + Names.vm2srcSimpleMethod(method),false,false,true);
    SwtFactory.createLabel(calls,Math.round(proposal.getSecond() * 100) + "String_Node_Str",false,true,false);
  }
  composite.layout(true);
  return true;
}
Program: 93467
Project: 93467
Buggy source:
@Override protected boolean updateContent(final IJavaElementSelection selection){
  context=selection.getInvocationContext() == null ? null : contextResolver.resolveContext(selection.getInvocationContext());
  final IJavaElement element=selection.getJavaElement();
  if (context != null && context.getVariable() != null) {
    return displayProposalsForVariable(element,context.getVariable());
  }
 else   if (element instanceof IType) {
    return displayProposalsForType((IType)element);
  }
 else   if (element instanceof IMethod) {
    return displayProposalsForMethod((IMethod)element);
  }
 else   if (element instanceof ILocalVariable || element instanceof SourceField) {
    try {
      return displayProposalsForUnresolvedVariable(element);
    }
 catch (    final JavaModelException e) {
      throw new IllegalStateException(e);
    }
  }
  return false;
}

Fixed version (ground truth):
@Override protected boolean updateContent(final IJavaElementSelection selection){
  if (selection.getInvocationContext() == null) {
    return false;
  }
  context=contextResolver.resolveContext(selection.getInvocationContext());
  final IJavaElement element=selection.getJavaElement();
  if (element instanceof ILocalVariable) {
    createFakeContextForLocalVariableSelection(element);
  }
 else   if (element instanceof IField) {
    createFakeContextForFieldSelection(element);
  }
 else   if (element instanceof IType) {
    context=new DelegatingIntelligentCompletionContext(context){
      @Override public Variable getVariable(){
        return null;
      }
    }
;
  }
  if (context.getVariable() != null) {
    return displayProposalsForVariable(element,context.getVariable());
  }
 else   if (element instanceof IType) {
    return displayProposalsForType((IType)element);
  }
 else   if (element instanceof IMethod) {
    return displayProposalsForMethod((IMethod)element);
  }
 else   if (element instanceof ILocalVariable || element instanceof SourceField) {
    try {
      return displayProposalsForUnresolvedVariable(element);
    }
 catch (    final JavaModelException e) {
      throw new IllegalStateException(e);
    }
  }
  return false;
}
Program: 93468
Project: 93468
Buggy source:
@Override public Variable getVariable(){
  if (isReceiverImplicitThis()) {
    return Variable.create("String_Node_Str",getSuperclassOfEnclosingType(),getEnclosingMethod());
  }
  if (getReceiverName() != null && getReceiverType() != null) {
    return Variable.create(getReceiverName(),getReceiverType(),getEnclosingMethod());
  }
  final LocalDeclaration match=findMatchingLocalVariable(getReceiverName());
  if (match == null) {
    return null;
  }
  final String name=String.valueOf(match.name);
  final ITypeName type=CompilerBindings.toTypeName(match.type);
  return Variable.create(name,type,getEnclosingMethod());
}

Fixed version (ground truth):
@Override public Variable getVariable(){
  if (isReceiverImplicitThis() || isReceiverExplicitThis()) {
    return Variable.create("String_Node_Str",getSuperclassOfEnclosingType(),getEnclosingMethod());
  }
  if (getReceiverName() != null && getReceiverType() != null) {
    return Variable.create(getReceiverName(),getReceiverType(),getEnclosingMethod());
  }
  final LocalDeclaration match=findMatchingLocalVariable(getReceiverName());
  if (match == null) {
    return null;
  }
  final String name=String.valueOf(match.name);
  final ITypeName type=CompilerBindings.toTypeName(match.type);
  return Variable.create(name,type,getEnclosingMethod());
}
Program: 93469
Project: 93469
Buggy source:
@Override public boolean canResolve(final IIntelligentCompletionContext ctx){
  this.ctx=ensureIsNotNull(ctx);
  final ASTNode completionNode=ctx.getCompletionNode();
  return completionNode instanceof CompletionOnMemberAccess;
}

Fixed version (ground truth):
@Override public boolean canResolve(final IIntelligentCompletionContext ctx){
  this.ctx=ensureIsNotNull(ctx);
  final ASTNode completionNode=ctx.getCompletionNode();
  final boolean isThis="String_Node_Str".equals(ctx.getReceiverName());
  return !isThis && completionNode instanceof CompletionOnMemberAccess;
}
Program: 93470
Project: 93470
Buggy source:
@Override protected void configure(){
  configureModelStore();
  configureRecommendationsViewPublisher();
}

Fixed version (ground truth):
@Override protected void configure(){
  configureArchiveModelStore();
  configureRecommendationsViewPublisher();
}
Program: 93471
Project: 93471
Buggy source:
private void prefetch(){
  final ICallsModelStore s=InjectionService.getInstance().requestInstance(CallsModelStore.class);
  s.hasModel(VmTypeName.BOOLEAN);
}

Fixed version (ground truth):
private void prefetch(){
  final ICallsModelStore s=InjectionService.getInstance().requestInstance(ICallsModelStore.class);
  s.hasModel(VmTypeName.BOOLEAN);
}
Program: 93472
Project: 93472
Buggy source:
private String getFilenameFromType(final ITypeName type){
  return type.getIdentifier() + MODEL_POSTFIX;
}

Fixed version (ground truth):
private String getFilenameFromType(final ITypeName type){
  return type.getIdentifier().replaceAll("String_Node_Str","String_Node_Str") + MODEL_POSTFIX;
}
Program: 93473
Project: 93473
Buggy source:
private ITypeName getTypeNameFromFilename(final String filename){
  return VmTypeName.get(filename.substring(filename.length() - MODEL_POSTFIX.length(),filename.length()));
}

Fixed version (ground truth):
private ITypeName getTypeNameFromFilename(final String filename){
  return VmTypeName.get(filename.substring(0,filename.length() - MODEL_POSTFIX.length()).replaceAll("String_Node_Str","String_Node_Str"));
}
Program: 93474
Project: 93474
Buggy source:
/** 
 * @param returnType The type as returned by the invoked method.
 * @return The template code which generates a new variable name based onthe new variable type (as given by the return type).
 */
private static String getNewVariableNameFromReturnType(final ITypeName returnType){
  final String returnTypeName=Names.vm2srcTypeName(returnType.getIdentifier());
  return String.format("String_Node_Str",returnTypeName);
}

Fixed version (ground truth):
/** 
 * @param returnType The type as returned by the invoked method.
 * @return The template code which generates a new variable name based onthe new variable type (as given by the return type).
 */
private static String getNewVariableNameFromReturnType(final ITypeName returnType){
  return String.format("String_Node_Str",getTypeIdentifier(returnType));
}
Program: 93475
Project: 93475
Buggy source:
/** 
 * @param methodCall {@link MethodCall} holding information about the method callto format and on which variable it is invoked.
 * @return A variable name from the given method's name (e.g. "<code>getText</code>" to "<code>text</code>") or its return type (e.g. "<code>someMethod : String</code>" to "<code>string</code> ").
 */
private static String getNewVariableNameFromMethod(final MethodCall methodCall){
  String variableName;
  final IMethodName invokedMethod=methodCall.getInvokedMethod();
  if (invokedMethod.isInit()) {
    final String type=Names.vm2srcTypeName(invokedMethod.getDeclaringType().getIdentifier());
    variableName=String.format("String_Node_Str",type);
  }
 else {
    if (invokedMethod.getName().startsWith("String_Node_Str")) {
      variableName=StringUtils.uncapitalize(invokedMethod.getName().substring(3));
    }
 else {
      variableName=StringUtils.uncapitalize(invokedMethod.getReturnType().getClassName());
    }
    if (variableName.equals(methodCall.getVariableName())) {
      variableName=getNewVariableNameFromReturnType(invokedMethod.getReturnType());
    }
  }
  return variableName;
}

Fixed version (ground truth):
/** 
 * @param methodCall {@link MethodCall} holding information about the method callto format and on which variable it is invoked.
 * @return A variable name from the given method's name (e.g. "<code>getText</code>" to "<code>text</code>") or its return type (e.g. "<code>someMethod : String</code>" to "<code>string</code> ").
 */
private static String getNewVariableNameFromMethod(final MethodCall methodCall){
  String variableName;
  final IMethodName invokedMethod=methodCall.getInvokedMethod();
  if (invokedMethod.isInit()) {
    variableName=String.format("String_Node_Str",getTypeIdentifier(invokedMethod.getDeclaringType()));
  }
 else {
    if (invokedMethod.getName().startsWith("String_Node_Str")) {
      variableName=StringUtils.uncapitalize(invokedMethod.getName().substring(3));
    }
 else {
      variableName=StringUtils.uncapitalize(invokedMethod.getReturnType().getClassName());
    }
    if (variableName.equals(methodCall.getVariableName())) {
      variableName=getNewVariableNameFromReturnType(invokedMethod.getReturnType());
    }
  }
  return variableName;
}
Program: 93476
Project: 93476
Buggy source:
/** 
 * @param invokedMethod The method which will return or construct the new variable.
 * @return How the type of the new variable is declared, as part of thevariable declaration, e.g. " <code>Button</code>".
 */
private static String getNewVariableTypeString(final IMethodName invokedMethod){
  if (invokedMethod.isInit()) {
    return String.format("String_Node_Str",Names.vm2srcQualifiedType(invokedMethod.getDeclaringType()));
  }
  return String.format("String_Node_Str",Names.vm2srcQualifiedType(invokedMethod.getReturnType()));
}

Fixed version (ground truth):
/** 
 * @param invokedMethod The method which will return or construct the new variable.
 * @return How the type of the new variable is declared, as part of thevariable declaration, e.g. " <code>Button</code>".
 */
private static String getNewVariableTypeString(final IMethodName invokedMethod){
  if (invokedMethod.isInit()) {
    return String.format("String_Node_Str",getTypeIdentifier(invokedMethod.getDeclaringType()));
  }
  final ITypeName returnType=invokedMethod.getReturnType();
  if (returnType.isPrimitiveType()) {
    return Names.vm2srcSimpleTypeName(returnType);
  }
 else {
    return String.format("String_Node_Str",getTypeIdentifier(returnType),returnType.isArrayType() ? StringUtils.repeat("String_Node_Str",returnType.getArrayDimensions()) : "String_Node_Str");
  }
}
Program: 93477
Project: 93477
Buggy source:
/** 
 * @param invokedMethod The method which will return or construct the new variable.
 * @return How the type of the new variable is declared, as part of thevariable declaration, e.g. " <code>Button</code>".
 */
private static String getNewVariableTypeString(final IMethodName invokedMethod){
  if (invokedMethod.isInit()) {
    return String.format("String_Node_Str",Names.vm2srcQualifiedType(invokedMethod.getDeclaringType()));
  }
  return String.format("String_Node_Str",Names.vm2srcSimpleTypeName(invokedMethod.getReturnType()));
}

Fixed version (ground truth):
/** 
 * @param invokedMethod The method which will return or construct the new variable.
 * @return How the type of the new variable is declared, as part of thevariable declaration, e.g. " <code>Button</code>".
 */
private static String getNewVariableTypeString(final IMethodName invokedMethod){
  if (invokedMethod.isInit()) {
    return String.format("String_Node_Str",Names.vm2srcQualifiedType(invokedMethod.getDeclaringType()));
  }
  return String.format("String_Node_Str",Names.vm2srcQualifiedType(invokedMethod.getReturnType()));
}
Program: 93478
Project: 93478
Buggy source:
@Override public void setMethodContext(IMethodName newActiveMethodContext){
  if (newActiveMethodContext == null) {
    newActiveMethodContext=NetworkUtils.CTX_DUMMY;
  }
  contextNode.observeState(newActiveMethodContext.getIdentifier());
}

Fixed version (ground truth):
@Override public void setMethodContext(IMethodName newActiveMethodContext){
  if (newActiveMethodContext == null) {
    newActiveMethodContext=NetworkUtils.CTX_NULL;
  }
  contextNode.observeState(newActiveMethodContext.getIdentifier());
}
Program: 93479
Project: 93479
Buggy source:
/** 
 * @param invokedMethod The method which will return or construct the new variable.
 * @return How the type of the new variable is declared, as part of thevariable declaration, e.g. " <code>Button</code>".
 */
private static String getNewVariableTypeString(final IMethodName invokedMethod){
  if (invokedMethod.isInit()) {
    return String.format("String_Node_Str",Names.vm2srcQualifiedType(invokedMethod.getDeclaringType()));
  }
  return String.format("String_Node_Str",Names.vm2srcSimpleTypeName(invokedMethod.getReturnType()));
}

Fixed version (ground truth):
/** 
 * @param invokedMethod The method which will return or construct the new variable.
 * @return How the type of the new variable is declared, as part of thevariable declaration, e.g. " <code>Button</code>".
 */
private static String getNewVariableTypeString(final IMethodName invokedMethod){
  if (invokedMethod.isInit()) {
    return String.format("String_Node_Str",Names.vm2srcQualifiedType(invokedMethod.getDeclaringType()));
  }
  return String.format("String_Node_Str",Names.vm2srcQualifiedType(invokedMethod.getReturnType()));
}
Program: 93480
Project: 93480
Buggy source:
@Test public void testNameWithGenerics(){
  new VmTypeName("String_Node_Str");
}

Fixed version (ground truth):
@Test public void testNameWithGenerics(){
  VmTypeName.get("String_Node_Str");
}
Program: 93481
Project: 93481
Buggy source:
private void checkIsAssignmentForMethodReturn(final VariableDeclarationFragment fragment){
  final SimpleName name=fragment.getName();
  if (name.getIdentifier().equals(localVariable.getNameLiteral())) {
    localVariableKind=Kind.RETURN;
  }
}

Fixed version (ground truth):
private void checkIsAssignmentForMethodReturn(final VariableDeclarationFragment fragment){
  if (isVariableDeclarationOfCurrentVariable(fragment) && !isConstructorCall(fragment.getInitializer())) {
    localVariableKind=Kind.RETURN;
  }
}
Program: 93483
Project: 93483
Buggy source:
private boolean findExpectedClass(){
  final ITypeName expectedTypeName=ctx.getExpectedType();
  if (expectedTypeName == null) {
    if (ctx.getCompletionNode() instanceof CompletionOnMessageSend) {
      CompletionOnMessageSend completiononMessageSend=(CompletionOnMessageSend)ctx.getCompletionNode();
      computeExpectedMethodTypes(completiononMessageSend);
      return expectedTypeList.size() > 0;
    }
    return false;
  }
  expectedTypeList=new ArrayList<Tuple<IClass,Integer>>();
  int expectedTypeArrayDimension=expectedTypeName.getArrayDimensions();
  IClass expectedType=toWalaClass(expectedTypeName.isArrayType() ? expectedTypeName.getArrayBaseType() : expectedTypeName);
  if (expectedType.getReference().getName().getClassName().toString().equals("String_Node_Str")) {
    expectedType=null;
  }
  expectedTypeList.add(Tuple.create(expectedType,expectedTypeArrayDimension));
  return expectedType != null;
}

Fixed version (ground truth):
private boolean findExpectedClass(){
  final ITypeName expectedTypeName=ctx.getExpectedType();
  if (expectedTypeName == null) {
    if (ctx.getCompletionNode() instanceof CompletionOnMessageSend) {
      CompletionOnMessageSend completiononMessageSend=(CompletionOnMessageSend)ctx.getCompletionNode();
      computeExpectedMethodTypes(completiononMessageSend);
      return expectedTypeList.size() > 0;
    }
    return false;
  }
  expectedTypeList=new ArrayList<Tuple<IClass,Integer>>();
  int expectedTypeArrayDimension=expectedTypeName.getArrayDimensions();
  IClass expectedType=toWalaClass(expectedTypeName.isArrayType() ? expectedTypeName.getArrayBaseType() : expectedTypeName);
  if (expectedType != null && expectedType.getReference().getName().getClassName().toString().equals("String_Node_Str")) {
    expectedType=null;
  }
  expectedTypeList.add(Tuple.create(expectedType,expectedTypeArrayDimension));
  return expectedType != null;
}
Program: 93484
Project: 93484
Buggy source:
/** 
 * Clears the selection state of a node (if one). Returns <code>true</code> if previously set and cleared, <code>false</code> otherwise.
 */
public boolean clearEvidence(){
  if (!isEvidence()) {
    return false;
  }
  network.clearEvidence(nodeId);
  return true;
}

Fixed version (ground truth):
/** 
 * Clears the selection state of a node (if one). Returns <code>true</code> if previously set and cleared, <code>false</code> otherwise.
 */
public boolean clearEvidence(){
  try {
    if (!isEvidence()) {
      return false;
    }
    network.clearEvidence(nodeId);
    return true;
  }
 catch (  final SMILEException x) {
    RecommendersPlugin.logError(x,"String_Node_Str");
    return false;
  }
}
Program: 93485
Project: 93485
Buggy source:
private boolean isAccessible(final IMember member){
  if (ctx.isReceiverImplicitThis()) {
    if (enclosingMethod != null && enclosingMethod.isStatic() && !member.isStatic()) {
      return false;
    }
  }
  if (ctx.getCompletionNode() instanceof CompletionOnQualifiedNameReference) {
    return member.isStatic();
  }
  if (member.getDeclaringClass() == receiverType) {
    return true;
  }
  if (!member.isPrivate()) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean isAccessible(final IMember member){
  if (ctx.isReceiverImplicitThis()) {
    if (enclosingMethod != null && enclosingMethod.isStatic() && !member.isStatic()) {
      return false;
    }
  }
  final Variable var=ctx.getVariable();
  if (var == null) {
    return member.isStatic();
  }
  if (member.getDeclaringClass() == receiverType) {
    return true;
  }
  if (!member.isPrivate()) {
    return true;
  }
  return false;
}
Program: 93486
Project: 93486
Buggy source:
private void computeAccessibleLocals(){
  if (!ctx.getVariable().isThis()) {
    return;
  }
  for (  final LocalDeclaration local : ctx.getLocalDeclarations()) {
    final ITypeName typeName=CompilerBindings.toTypeName(local.type);
    final IClass localType=toWalaClass(typeName);
    if (localType == null) {
      continue;
    }
    final String localName=String.valueOf(local.name);
    if (!localName.startsWith(ctx.getPrefixToken())) {
      continue;
    }
    if (ctx.getCompletionNodeParent() instanceof LocalDeclaration) {
      final LocalDeclaration node=cast(ctx.getCompletionNodeParent());
      final String name=String.valueOf(node.name);
      if (name.equals(localName)) {
        continue;
      }
    }
    final IChainElement element=new LocalChainElement(localName,localType);
    accessibleLocals.add(element);
  }
}

Fixed version (ground truth):
private void computeAccessibleLocals(){
  if (ctx.getVariable() == null) {
    return;
  }
  if (!ctx.getVariable().isThis()) {
    return;
  }
  for (  final LocalDeclaration local : ctx.getLocalDeclarations()) {
    final ITypeName typeName=CompilerBindings.toTypeName(local.type);
    final IClass localType=toWalaClass(typeName);
    if (localType == null) {
      continue;
    }
    final String localName=String.valueOf(local.name);
    if (!localName.startsWith(ctx.getPrefixToken())) {
      continue;
    }
    if (ctx.getCompletionNodeParent() instanceof LocalDeclaration) {
      final LocalDeclaration node=cast(ctx.getCompletionNodeParent());
      final String name=String.valueOf(node.name);
      if (name.equals(localName)) {
        continue;
      }
    }
    final IChainElement element=new LocalChainElement(localName,localType);
    accessibleLocals.add(element);
  }
}
Program: 93487
Project: 93487
Buggy source:
private void waitForThreadPoolTermination(){
  try {
    executor.awaitTermination(Constants.AlgorithmSettings.EXECUTOR_ALIVE_TIME_IN_MS,TimeUnit.MILLISECONDS);
  }
 catch (  final InterruptedException e) {
    JavaPlugin.log(e);
  }
}

Fixed version (ground truth):
private void waitForThreadPoolTermination(){
  if (executor.getTaskCount() > 0) {
    try {
      executor.awaitTermination(Constants.AlgorithmSettings.EXECUTOR_ALIVE_TIME_IN_MS,TimeUnit.MILLISECONDS);
    }
 catch (    final InterruptedException e) {
      JavaPlugin.log(e);
    }
  }
}
Program: 93488
Project: 93488
Buggy source:
@Override public IClass lookupClass(final TypeReference typeRef){
  final TypeName name=typeRef.getName();
  if (isClassAlreadyDefinedOrCurrentlyLoaded(typeRef)) {
    return ensureIsNotNull(clazzes.get(name));
  }
  if (typeRef.isArrayType()) {
    final ArrayClassLoader arrayClassLoader=scope.getArrayClassLoader();
    final IClass lookupClass=arrayClassLoader.lookupClass(name,appLoader,this);
    if (lookupClass == null) {
      System.err.println("String_Node_Str" + name);
    }
    return lookupClass;
  }
  try {
    if (typeRef.getClassLoader().equals(SYNTETIC)) {
      return ensureIsNotNull(loadSynteticType(typeRef));
    }
    final IType type=findEclipseHandle(typeRef);
    if (type instanceof BinaryType) {
      return ensureIsNotNull(loadBinaryClass((BinaryType)type));
    }
 else     if (type instanceof SourceType) {
      return ensureIsNotNull(loadFromProjectOutputLocation((SourceType)type));
    }
  }
 catch (  final JavaModelException e) {
    throwUnhandledException(e);
  }
  return null;
}

Fixed version (ground truth):
@Override public IClass lookupClass(final TypeReference typeRef){
  final TypeName name=typeRef.getName();
  if (isClassAlreadyDefinedOrCurrentlyLoaded(typeRef)) {
    return ensureIsNotNull(clazzes.get(name));
  }
  if (typeRef.isArrayType()) {
    final ArrayClassLoader arrayClassLoader=scope.getArrayClassLoader();
    final IClass lookupClass=arrayClassLoader.lookupClass(name,appLoader,this);
    if (lookupClass == null) {
      System.err.println("String_Node_Str" + name);
    }
    return lookupClass;
  }
  try {
    if (typeRef.getClassLoader().equals(SYNTETIC)) {
      return ensureIsNotNull(loadSynteticType(typeRef));
    }
    final IType type=findEclipseHandle(typeRef);
    if (type instanceof BinaryType) {
      return ensureIsNotNull(loadBinaryClass((BinaryType)type));
    }
 else     if (type instanceof SourceType) {
      return loadFromProjectOutputLocation((SourceType)type);
    }
  }
 catch (  final JavaModelException e) {
    throwUnhandledException(e);
  }
  return null;
}
Program: 93489
Project: 93489
Buggy source:
private IClass loadFromProjectOutputLocation(final SourceType type) throws JavaModelException {
  final IFile eclipseFile=createClassFileHandleForClassName(type);
  if (eclipseFile == null) {
    final String msg=format("String_Node_Str",type.getFullyQualifiedName(),type.getJavaProject().getElementName());
    log.error(msg);
    throwUnreachable();
    return null;
  }
  final File file=eclipseFile.getLocation().toFile();
  final ShrikeClassReaderHandle handle=new ShrikeClassReaderHandle(new ClassFileModule(file));
  ShrikeClass res;
  try {
    res=new ShrikeClass(handle,appLoader,this);
  }
 catch (  final InvalidClassFileException e) {
    throw throwUnhandledException(e);
  }
  System.out.println("String_Node_Str" + res.getName());
  clazzes.put(res.getName(),res);
  watchlist.put(eclipseFile,res.getName());
  res.getSuperclass();
  return res;
}

Fixed version (ground truth):
private IClass loadFromProjectOutputLocation(final SourceType type) throws JavaModelException {
  final IFile eclipseFile=createClassFileHandleForClassName(type);
  if (eclipseFile == null) {
    final String msg=format("String_Node_Str",type.getFullyQualifiedName(),type.getJavaProject().getElementName());
    log.warn(msg);
    return null;
  }
  final File file=eclipseFile.getLocation().toFile();
  final ShrikeClassReaderHandle handle=new ShrikeClassReaderHandle(new ClassFileModule(file));
  ShrikeClass res;
  try {
    res=new ShrikeClass(handle,appLoader,this);
  }
 catch (  final InvalidClassFileException e) {
    throw throwUnhandledException(e);
  }
  System.out.println("String_Node_Str" + res.getName());
  clazzes.put(res.getName(),res);
  watchlist.put(eclipseFile,res.getName());
  res.getSuperclass();
  return res;
}
Program: 93490
Project: 93490
Buggy source:
private void initializeAccessibleElements(){
  if (!findEnclosingClass()) {
    return;
  }
  if (!findEnclosingMethod()) {
  }
  if (!findReceiverClass()) {
    return;
  }
  if (!findExpectedClass()) {
    return;
  }
  computeAccessibleFields();
  computeAccessibleMethods();
  computeAccessibleLocals();
}

Fixed version (ground truth):
private void initializeAccessibleElements(){
  if (!findExpectedClass()) {
    return;
  }
  if (!findEnclosingClass()) {
    return;
  }
  if (!findEnclosingMethod()) {
  }
  if (!findReceiverClass()) {
    return;
  }
  computeAccessibleFields();
  computeAccessibleMethods();
  computeAccessibleLocals();
}
Program: 93491
Project: 93491
Buggy source:
public void execute(final IIntelligentCompletionContext ictx) throws JavaModelException {
  initializeChainCompletionContext(ictx);
  if (canComputeProposals()) {
    initializeThreadPool();
    processMembers();
    waitForThreadPoolTermination();
  }
}

Fixed version (ground truth):
public void execute(final IIntelligentCompletionContext ictx) throws JavaModelException {
  if (!ictx.expectsReturnValue()) {
    return;
  }
  initializeChainCompletionContext(ictx);
  initializeThreadPool();
  processMembers();
  waitForThreadPoolTermination();
}
Program: 93492
Project: 93492
Buggy source:
/** 
 * @param receiverName The variable name if it could be extracted from the context.
 * @param receiverType The type of the variable on which completion is requested.
 * @param context The context holding information about the completion request.
 * @param needsConstructor True, if the completion is invoked while a new variable is defined, e.g. <code>Button b<^Space></code>.
 * @return The {@link CompletionTargetVariable} representing the variable onwhich the request was invoked or which shall be constructed in case it was invoked while defining a new variable.
 */
private static CompletionTargetVariable createInvokedVariable(final String receiverName,final ITypeName receiverType,final IIntelligentCompletionContext context,final boolean needsConstructor){
  CompletionTargetVariable completionTargetVariable=null;
  if (receiverType != null) {
    int variableNameLength=0;
    if (!needsConstructor && receiverName.length() > 0) {
      variableNameLength=receiverName.length() + 1;
    }
    final int documentOffset=context.getReplacementRegion().getOffset() - variableNameLength;
    final int replacementLength=context.getReplacementRegion().getLength() + variableNameLength;
    completionTargetVariable=new CompletionTargetVariable(receiverName,receiverType,new Region(documentOffset,replacementLength),needsConstructor);
  }
  return completionTargetVariable;
}

Fixed version (ground truth):
/** 
 * @param receiverName The variable name if it could be extracted from the context.
 * @param receiverType The type of the variable on which completion is requested.
 * @param receiverCalls
 * @param context The context holding information about the completion request.
 * @param needsConstructor True, if the completion is invoked while a new variable is defined, e.g. <code>Button b<^Space></code>.
 * @return The {@link CompletionTargetVariable} representing the variable onwhich the request was invoked or which shall be constructed in case it was invoked while defining a new variable.
 */
private static CompletionTargetVariable createInvokedVariable(final String receiverName,final ITypeName receiverType,final Set<IMethodName> receiverCalls,final IIntelligentCompletionContext context,final boolean needsConstructor){
  CompletionTargetVariable completionTargetVariable=null;
  if (receiverType != null) {
    int variableNameLength=0;
    if (!needsConstructor && receiverName.length() > 0) {
      variableNameLength=receiverName.length() + 1;
    }
    final int documentOffset=context.getReplacementRegion().getOffset() - variableNameLength;
    final int replacementLength=context.getReplacementRegion().getLength() + variableNameLength;
    completionTargetVariable=new CompletionTargetVariable(receiverName,receiverType,receiverCalls,new Region(documentOffset,replacementLength),needsConstructor);
  }
  return completionTargetVariable;
}
Program: 93493
Project: 93493
Buggy source:
/** 
 * @param context The context from where to resolve variable usage.
 * @return True, if a new variable is to be constructed or an existing'susage could be resolved.
 */
private boolean canFindVariableUsage(final IIntelligentCompletionContext context){
  boolean result=true;
  if (context.getVariable() == null) {
    receiverMethodInvocations=Sets.newHashSet();
  }
 else {
    result=canResolveVariableUsage(context);
  }
  return result;
}

Fixed version (ground truth):
/** 
 * @param targetVariable The variable on which the completion request was invoked.
 * @param context The context from where to resolve variable usage.
 * @return True, if a new variable is to be constructed or an existing'susage could be resolved.
 */
private boolean canFindVariableUsage(final CompletionTargetVariable targetVariable,final IIntelligentCompletionContext context){
  boolean result=true;
  if (context.getVariable() == null) {
    receiverMethodInvocations=targetVariable.getReceiverCalls();
  }
 else {
    result=canResolveVariableUsage(context);
  }
  return result;
}
Program: 93494
Project: 93494
Buggy source:
/** 
 * @param targetVariable The variable on which the completion request was invoked.
 * @param context The context from where the completion request was invoked.
 * @return The {@link PatternRecommendation}s holding information for the templates to be displayed.
 */
public ImmutableSet<PatternRecommendation> computeRecommendations(final CompletionTargetVariable targetVariable,final IIntelligentCompletionContext context){
  if (canFindVariableUsage(context) && canFindModel(targetVariable.getType())) {
    updateModel(context.getVariable(),context.getEnclosingMethodsFirstDeclaration());
    return computeRecommendationsForModel(targetVariable.isNeedsConstructor());
  }
  return ImmutableSet.of();
}

Fixed version (ground truth):
/** 
 * @param targetVariable The variable on which the completion request was invoked.
 * @param context The context from where the completion request was invoked.
 * @return The {@link PatternRecommendation}s holding information for the templates to be displayed.
 */
public ImmutableSet<PatternRecommendation> computeRecommendations(final CompletionTargetVariable targetVariable,final IIntelligentCompletionContext context){
  if (canFindVariableUsage(targetVariable,context) && canFindModel(targetVariable.getType())) {
    updateModel(context.getVariable(),context.getEnclosingMethodsFirstDeclaration());
    return computeRecommendationsForModel(targetVariable.isNeedsConstructor());
  }
  return ImmutableSet.of();
}
Program: 93495
Project: 93495
Buggy source:
/** 
 * @return True, if a model for the current receiver type could be found.
 */
private boolean canFindModel(final ITypeName receiverType){
  boolean result=false;
  System.err.println("String_Node_Str" + receiverType);
  if (callsModelStore.hasModel(receiverType)) {
    model=callsModelStore.getModel(receiverType);
    this.receiverType=receiverType;
    result=true;
  }
  return result;
}

Fixed version (ground truth):
/** 
 * @return True, if a model for the current receiver type could be found.
 */
private boolean canFindModel(final ITypeName receiverType){
  boolean result=false;
  if (callsModelStore.hasModel(receiverType)) {
    model=callsModelStore.getModel(receiverType);
    this.receiverType=receiverType;
    result=true;
  }
  return result;
}
Program: 93496
Project: 93496
Buggy source:
/** 
 * @param name The name of the variable on which the completion was triggered.
 * @param typeName The type of the variable on which the completion was triggered.
 * @param documentRegion True, if the templates proposals definitely have to contain constructors, e.g. in "<code>Button b<^Space></code>".
 * @param needsConstructor The region inside the document which shall be replaced by completion proposals for this variable.
 */
public CompletionTargetVariable(final String name,final ITypeName typeName,final Region documentRegion,final boolean needsConstructor){
  this.name=name;
  this.typeName=Checks.ensureIsNotNull(typeName);
  this.documentRegion=documentRegion;
  this.needsConstructor=needsConstructor;
}

Fixed version (ground truth):
/** 
 * @param name The name of the variable on which the completion was triggered.
 * @param typeName The type of the variable on which the completion was triggered.
 * @param receiverCalls
 * @param documentRegion True, if the templates proposals definitely have to contain constructors, e.g. in "<code>Button b<^Space></code>".
 * @param needsConstructor The region inside the document which shall be replaced by completion proposals for this variable.
 */
public CompletionTargetVariable(final String name,final ITypeName typeName,final Set<IMethodName> receiverCalls,final Region documentRegion,final boolean needsConstructor){
  this.name=name;
  this.typeName=Checks.ensureIsNotNull(typeName);
  this.receiverCalls=receiverCalls;
  this.documentRegion=documentRegion;
  this.needsConstructor=needsConstructor;
}
Program: 93498
Project: 93498
Buggy source:
private List<IJavaCompletionProposal> computeProposals(final ChainingAlgorithm algorithm){
  final ChainProposalTemplateGenerator chainProposalGenerator=new ChainProposalTemplateGenerator();
  return chainProposalGenerator.generateJavaCompletionProposals(algorithm.getProposals(),jCtx,sw.getTime());
}

Fixed version (ground truth):
private List<IJavaCompletionProposal> computeProposals(final ChainingAlgorithm algorithm){
  final ChainTemplateProposalGenerator chainProposalGenerator=new ChainTemplateProposalGenerator();
  return chainProposalGenerator.generateJavaCompletionProposals(algorithm.getProposals(),jCtx,sw.getTime());
}
Program: 93499
Project: 93499
Buggy source:
private void computeAccessibleLocals(){
  if (!ctx.getVariable().isThis()) {
    return;
  }
  for (  final LocalDeclaration local : ctx.getLocalDeclarations()) {
    final ITypeName typeName=CompilerBindings.toTypeName(local.type);
    final IClass localType=toWalaClass(typeName);
    final String localName=String.valueOf(local.name);
    final IChainElement element=new LocalVariableChainElement(localName,localType);
    accessibleLocals.add(element);
  }
}

Fixed version (ground truth):
private void computeAccessibleLocals(){
  if (!ctx.getVariable().isThis()) {
    return;
  }
  for (  final LocalDeclaration local : ctx.getLocalDeclarations()) {
    final ITypeName typeName=CompilerBindings.toTypeName(local.type);
    final IClass localType=toWalaClass(typeName);
    final String localName=String.valueOf(local.name);
    final IChainElement element=new LocalChainElement(localName,localType);
    accessibleLocals.add(element);
  }
}
Program: 93500
Project: 93500
Buggy source:
private boolean findReceiverClass(){
  if (ctx.isReceiverImplicitThis()) {
    receiverType=enclosingType;
  }
 else {
    final ITypeName receiverTypeName=ctx.getReceiverType();
    receiverType=toWalaClass(receiverTypeName);
  }
  return receiverType != null;
}

Fixed version (ground truth):
private boolean findReceiverClass(){
  if (ctx.isReceiverImplicitThis()) {
    receiverType=enclosingType;
  }
 else {
    final ITypeName receiverTypeName=ctx.getReceiverType();
    if (receiverType != null) {
      receiverType=toWalaClass(receiverTypeName);
    }
  }
  return receiverType != null;
}
Program: 93501
Project: 93501
Buggy source:
public ChainingAlgorithm(){
  expectedType=null;
  proposals=Collections.synchronizedList(new LinkedList<ChainProposal>());
  walaService=InjectionService.getInstance().requestInstance(IClassHierarchyService.class);
  javaelementResolver=InjectionService.getInstance().requestInstance(JavaElementResolver.class);
  searchMap=Collections.synchronizedMap(new HashMap<IClass,Map<IMember,IClass>>());
}

Fixed version (ground truth):
public ChainingAlgorithm(){
  expectedType=null;
  proposals=Collections.synchronizedList(new LinkedList<ChainTemplateProposal>());
  walaService=InjectionService.getInstance().requestInstance(IClassHierarchyService.class);
  javaelementResolver=InjectionService.getInstance().requestInstance(JavaElementResolver.class);
  searchMap=Collections.synchronizedMap(new HashMap<IClass,Map<IMember,IClass>>());
}
Program: 93502
Project: 93502
Buggy source:
public List<ChainProposal> getProposals(){
  return proposals;
}

Fixed version (ground truth):
public List<ChainTemplateProposal> getProposals(){
  return proposals;
}
Program: 93503
Project: 93503
Buggy source:
public void addProposal(final LinkedList<IChainElement> workingChain){
synchronized (proposals) {
    proposals.add(new ChainProposal(workingChain));
  }
}

Fixed version (ground truth):
public void addProposal(final LinkedList<IChainElement> workingChain){
synchronized (proposals) {
    proposals.add(new ChainTemplateProposal(workingChain));
  }
}
Program: 93504
Project: 93504
Buggy source:
public void addCastedProposal(final LinkedList<IChainElement> workingChain,final IClass expectedType){
synchronized (proposals) {
    proposals.add(new ChainProposal(workingChain,expectedType));
  }
}

Fixed version (ground truth):
public void addCastedProposal(final LinkedList<IChainElement> workingChain,final IClass expectedType){
synchronized (proposals) {
    proposals.add(new ChainTemplateProposal(workingChain,expectedType));
  }
}
Program: 93505
Project: 93505
Buggy source:
private boolean storeForProposal(final IClass typeToCheck) throws JavaModelException {
  if (typeToCheck == null) {
    return true;
  }
  final int testResult=WalaCache.equalityTest(typeToCheck,expectedType);
  if ((testResult & WalaCache.RESULT_EQUAL) > 0) {
    if (!checkRedundancy()) {
      internalProposalStore.addProposal(workingChain);
      return false;
    }
 else {
      return true;
    }
  }
  if ((testResult & WalaCache.RESULT_PRIMITIVE) > 0) {
    return true;
  }
  if (WalaCache.isSubtype(typeToCheck,expectedType) && !((testResult & WalaCache.RESULT_EQUAL) > 0)) {
    if (!checkRedundancy()) {
      internalProposalStore.addCastedProposal(workingChain,expectedType);
      return false;
    }
 else {
      return true;
    }
  }
  if (WalaCache.isSupertype(typeToCheck,expectedType) && !((testResult & WalaCache.RESULT_EQUAL) > 0)) {
    if (!checkRedundancy()) {
      internalProposalStore.addProposal(workingChain);
      return false;
    }
 else {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean storeForProposal(final IClass typeToCheck) throws JavaModelException {
  if (typeToCheck == null) {
    return true;
  }
  final int testResult=InheritanceHierarchyCache.equalityTest(typeToCheck,expectedType);
  if ((testResult & InheritanceHierarchyCache.RESULT_EQUAL) > 0) {
    if (!checkRedundancy()) {
      internalProposalStore.addProposal(workingChain);
      return false;
    }
 else {
      return true;
    }
  }
  if ((testResult & InheritanceHierarchyCache.RESULT_PRIMITIVE) > 0) {
    return true;
  }
  if (InheritanceHierarchyCache.isSubtype(typeToCheck,expectedType) && !((testResult & InheritanceHierarchyCache.RESULT_EQUAL) > 0)) {
    if (!checkRedundancy()) {
      internalProposalStore.addCastedProposal(workingChain,expectedType);
      return false;
    }
 else {
      return true;
    }
  }
  if (InheritanceHierarchyCache.isSupertype(typeToCheck,expectedType) && !((testResult & InheritanceHierarchyCache.RESULT_EQUAL) > 0)) {
    if (!checkRedundancy()) {
      internalProposalStore.addProposal(workingChain);
      return false;
    }
 else {
      return true;
    }
  }
  return false;
}