nus-yam/ex-repair huggingface dataset:
Program: 17050
Project: 17050
Buggy source:
/** 
 * @param testFolderName
 * @param checkedFilePack
 * @param checkedFileName
 * @param currentClass
 * @return
 */
public List<VjoSemanticProblem> getVjoSemanticProblem(String testFolderName,String checkedFilePack,String checkedFileName,Class<? extends VjoValidationBaseTester> currentClass){
  if (isOnDemand()) {
    return new VjoValidationTesterHelper().getVjoSemanticProblemOnDemand(testFolderName,checkedFilePack,checkedFileName,currentClass);
  }
  judgeLoadCustomType();
  return new VjoValidationTesterHelper().getVjoSemanticProblem(testFolderName,checkedFilePack,checkedFileName,currentClass);
}

Fixed version (ground truth):
/** 
 * @param testFolderName
 * @param checkedFilePack
 * @param checkedFileName
 * @param currentClass
 * @return
 */
public List<VjoSemanticProblem> getVjoSemanticProblem(String testFolderName,String checkedFilePack,String checkedFileName,Class<? extends VjoValidationBaseTester> currentClass,String groupName,boolean printTree){
  if (isOnDemand()) {
    return new VjoValidationTesterHelper().getVjoSemanticProblemOnDemand(testFolderName,checkedFilePack,checkedFileName,currentClass,groupName,printTree);
  }
  judgeLoadCustomType();
  return new VjoValidationTesterHelper().getVjoSemanticProblem(testFolderName,checkedFilePack,checkedFileName,currentClass);
}
Program: 17051
Project: 17051
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public void onUpdated(TypeSpaceEvent event,EventListenerStatus status){
  if (!done && EventId.Updated == event.getId()) {
    final Object trigger=event.getTrigger();
    if (trigger instanceof AddGroupEvent) {
      final AddGroupEvent addGroupEvt=(AddGroupEvent)trigger;
      final String groupName=addGroupEvt.getGroupName();
      final Group<IJstType> group=(Group<IJstType>)mgr.getTypeSpace().getGroup(groupName);
      if (group != null && ONDEMAND.equals(group.getName())) {
        final String[] libraries={JstTypeSpaceMgr.JAVA_PRIMITIVE_GRP,JstTypeSpaceMgr.JS_BROWSER_GRP,JstTypeSpaceMgr.JS_NATIVE_GRP,JstTypeSpaceMgr.VJO_BASE_LIB_NAME,JstTypeSpaceMgr.VJO_SELF_DESCRIBED};
        for (        String lib : libraries) {
          final IGroup<IJstType> libGroup=mgr.getTypeSpace().getGroup(lib);
          if (lib != null) {
            group.addGroupDependency(libGroup);
          }
        }
        done=true;
      }
    }
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public void onUpdated(TypeSpaceEvent event,EventListenerStatus status){
  if (!done && EventId.Updated == event.getId()) {
    final Object trigger=event.getTrigger();
    if (trigger instanceof AddGroupEvent) {
      final AddGroupEvent addGroupEvt=(AddGroupEvent)trigger;
      final String groupName=addGroupEvt.getGroupName();
      final Group<IJstType> group=(Group<IJstType>)mgr.getTypeSpace().getGroup(groupName);
      if (group != null && grpName.equals(group.getName())) {
        final String[] libraries={JstTypeSpaceMgr.JAVA_PRIMITIVE_GRP,JstTypeSpaceMgr.JS_BROWSER_GRP,JstTypeSpaceMgr.JS_NATIVE_GRP,JstTypeSpaceMgr.VJO_BASE_LIB_NAME,JstTypeSpaceMgr.VJO_SELF_DESCRIBED};
        for (        String lib : libraries) {
          final IGroup<IJstType> libGroup=mgr.getTypeSpace().getGroup(lib);
          if (lib != null) {
            group.addGroupDependency(libGroup);
          }
        }
        done=true;
      }
    }
  }
}
Program: 17053
Project: 17053
Buggy source:
@Before public void setUp(){
  expectProblems.clear();
  expectProblems.add(createNewProblem(MethodProbIds.UndefinedMethod,7,0));
  expectProblems.add(createNewProblem(MethodProbIds.UndefinedMethod,10,0));
  expectProblems.add(createNewProblem(VjoSyntaxProbIds.TypeUnknownNotInTypeSpace,2,0));
}

Fixed version (ground truth):
@Before public void setUp(){
  expectProblems.clear();
  expectProblems.add(createNewProblem(MethodProbIds.UndefinedMethod,7,0));
  expectProblems.add(createNewProblem(VarProbIds.UndefinedName,10,0));
  expectProblems.add(createNewProblem(VjoSyntaxProbIds.TypeUnknownNotInTypeSpace,2,0));
}
Program: 17054
Project: 17054
Buggy source:
@BeforeClass public static void beforeClass(){
  JstCache.getInstance().clear();
  LibManager.getInstance().clear();
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass(){
}
Program: 17055
Project: 17055
Buggy source:
@BeforeClass public static void beforeClass(){
  JstCache.getInstance().clear();
  LibManager.getInstance().clear();
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass(){
}
Program: 17056
Project: 17056
Buggy source:
@BeforeClass public static void beforeClass(){
  JstCache.getInstance().clear();
  LibManager.getInstance().clear();
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass(){
}
Program: 17057
Project: 17057
Buggy source:
@Test @Category({P3,FAST,UNIT}) @Description("String_Node_Str") public void testHTMLandDomEx5(){
  List<VjoSemanticProblem> problems=getVjoSemanticProblem(VjoValidationBaseTester.VJLIB_FOLDER,"String_Node_Str","String_Node_Str",this.getClass());
  assertProblemEquals(expectProblems,problems);
}

Fixed version (ground truth):
@Test @Category({P3,FAST,UNIT}) @Description("String_Node_Str") public void testHTMLandDomEx5(){
  List<VjoSemanticProblem> problems=getVjoSemanticProblem(VjoValidationBaseTester.VJLIB_FOLDER,"String_Node_Str","String_Node_Str",this.getClass(),"String_Node_Str",false);
  assertProblemEquals(expectProblems,problems);
}
Program: 17058
Project: 17058
Buggy source:
@BeforeClass public static void beforeClass(){
  JstCache.getInstance().clear();
  LibManager.getInstance().clear();
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass(){
}
Program: 17059
Project: 17059
Buggy source:
@BeforeClass public static void beforeClass(){
  JstCache.getInstance().clear();
  LibManager.getInstance().clear();
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass(){
}
Program: 17060
Project: 17060
Buggy source:
@Before public void setUp(){
  expectProblems.clear();
  expectProblems.add(createNewProblem(VjoSyntaxProbIds.TypeUnknownMissingImport,13,0));
  expectProblems.add(createNewProblem(VjoSyntaxProbIds.TypeUnknownNotInTypeSpace,2,0));
  expectProblems.add(createNewProblem(VarProbIds.UndefinedName,17,0));
  expectProblems.add(createNewProblem(MethodProbIds.UndefinedMethod,15,0));
  expectProblems.add(createNewProblem(MethodProbIds.UndefinedMethod,28,0));
}

Fixed version (ground truth):
@Before public void setUp(){
  expectProblems.clear();
  expectProblems.add(createNewProblem(VjoSyntaxProbIds.TypeUnknownMissingImport,13,0));
  expectProblems.add(createNewProblem(TypeProbIds.UnusedActiveNeeds,1,0));
  expectProblems.add(createNewProblem(VarProbIds.UndefinedName,14,0));
  expectProblems.add(createNewProblem(VarProbIds.UndefinedName,27,0));
  expectProblems.add(createNewProblem(VjoSyntaxProbIds.TypeUnknownNotInTypeSpace,2,0));
  expectProblems.add(createNewProblem(VarProbIds.UndefinedName,17,0));
}
Program: 17061
Project: 17061
Buggy source:
@Test @Category({P3,FAST,UNIT}) @Description("String_Node_Str") public void testJsOnlyEx2(){
  List<VjoSemanticProblem> problems=getVjoSemanticProblem(VjoValidationBaseTester.VJLIB_FOLDER,"String_Node_Str","String_Node_Str",this.getClass());
  assertProblemEquals(expectProblems,problems);
}

Fixed version (ground truth):
@Test @Category({P3,FAST,UNIT}) @Description("String_Node_Str") public void testJsOnlyEx2(){
  List<VjoSemanticProblem> problems=getVjoSemanticProblem(VjoValidationBaseTester.VJLIB_FOLDER,"String_Node_Str","String_Node_Str",this.getClass(),"String_Node_Str",false);
  assertProblemEquals(expectProblems,problems);
}
Program: 17062
Project: 17062
Buggy source:
@BeforeClass public static void beforeClass(){
  JstCache.getInstance().clear();
  LibManager.getInstance().clear();
}

Fixed version (ground truth):
@BeforeClass public static void beforeClass(){
}
Program: 17064
Project: 17064
Buggy source:
@Test public void testAttributedMethodAsFunctionParam() throws Exception {
  expectProblems.clear();
  expectProblems.add(createNewProblem(MethodProbIds.ParameterMismatch,21,0));
  expectProblems.add(createNewProblem(TypeProbIds.IncompatibleTypesInEqualityOperator,21,0));
  actualProblems=getVjoSemanticProblem("String_Node_Str","String_Node_Str",this.getClass());
  assertProblemEquals(expectProblems,actualProblems);
}

Fixed version (ground truth):
@Test @Ignore public void testAttributedMethodAsFunctionParam() throws Exception {
  expectProblems.clear();
  expectProblems.add(createNewProblem(MethodProbIds.ParameterMismatch,21,0));
  expectProblems.add(createNewProblem(TypeProbIds.IncompatibleTypesInEqualityOperator,21,0));
  actualProblems=getVjoSemanticProblem("String_Node_Str","String_Node_Str",this.getClass());
  assertProblemEquals(expectProblems,actualProblems);
}
Program: 17065
Project: 17065
Buggy source:
private void processLocalVarDecl(JstVars jstVars){
  List<AssignExpr> inits=jstVars.getAssignments();
  for (int i=0; i < inits.size(); i++) {
    AssignExpr assignExpr=inits.get(i);
    JstIdentifier localVar=(JstIdentifier)assignExpr.getLHS();
    IJstType type=jstVars.getType();
    JstSource source=localVar.getSource();
    IJSSourceElementRequestor.JSFieldInfo fieldInfo=new IJSSourceElementRequestor.JSFieldInfo();
    fieldInfo.name=localVar.getName();
    fieldInfo.declarationStart=source.getStartOffSet();
    fieldInfo.nameSourceStart=source.getStartOffSet();
    fieldInfo.nameSourceEnd=source.getEndOffSet();
    String typeName="String_Node_Str";
    if (type != null) {
      typeName=type.getName();
    }
    fieldInfo.m_type=typeName;
    fRequestor.enterField(fieldInfo);
    processExpression(assignExpr.getExpr());
    fRequestor.exitField(assignExpr.getSource().getEndOffSet());
  }
}

Fixed version (ground truth):
private void processLocalVarDecl(JstVars jstVars){
  List<AssignExpr> inits=jstVars.getAssignments();
  for (int i=0; i < inits.size(); i++) {
    AssignExpr assignExpr=inits.get(i);
    JstIdentifier localVar=(JstIdentifier)assignExpr.getLHS();
    IJstType type=jstVars.getType();
    JstSource source=localVar.getSource();
    IJSSourceElementRequestor.JSFieldInfo fieldInfo=new IJSSourceElementRequestor.JSFieldInfo();
    fieldInfo.name=localVar.getName();
    fieldInfo.declarationStart=source.getStartOffSet();
    fieldInfo.nameSourceStart=source.getStartOffSet();
    fieldInfo.nameSourceEnd=source.getEndOffSet();
    String typeName="String_Node_Str";
    if (type != null) {
      if (type instanceof JstFuncType) {
        typeName=getFullMethodString(localVar.getName(),((JstFuncType)type).getFunction(),jstVars.getOwnerType(),false);
      }
 else       if (type instanceof JstFunctionRefType) {
        typeName=getFullMethodString(localVar.getName(),((JstFunctionRefType)type).getMethodRef(),jstVars.getOwnerType(),false);
      }
 else {
        typeName=type.getName();
      }
    }
    fieldInfo.m_type=typeName;
    fRequestor.enterField(fieldInfo);
    processExpression(assignExpr.getExpr());
    fRequestor.exitField(assignExpr.getSource().getEndOffSet());
  }
}
Program: 17067
Project: 17067
Buggy source:
@Override protected JstArg doTranslate(IArgument astNode){
  throw new DsfRuntimeException("String_Node_Str");
}

Fixed version (ground truth):
@Override protected JstArg doTranslate(IArgument astNode){
  return null;
}
Program: 17068
Project: 17068
Buggy source:
public void testProposalsOrder() throws Exception {
  String js="String_Node_Str";
  FixtureManager m_fixtureManager=FixtureUtils.setUpFixture(this,js);
  try {
    String[] names={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
    VjoSourceModule module=(VjoSourceModule)getSourceModule(TestConstants.PROJECT_NAME_VJETPROJECT,"String_Node_Str",new Path(js));
    int position=lastPositionInFile("String_Node_Str",module);
    IVjoCcEngine engine=new VjoCcEngine(TypeSpaceMgr.parser());
    List<IVjoCcProposalData> list=engine.complete(module.getGroupName(),new String(module.getFileName()),module.getSourceContents(),position);
    VjoCcCtx ctx=engine.getContext();
    VjoProposalEclipsePresenter presenter=new VjoProposalEclipsePresenter(ctx,position,null,null);
    List<ICompletionProposal> pList=presenter.doPresenter(list);
    for (int i=0; i < names.length; i++) {
      CompletionProposal completionProp=(CompletionProposal)pList.get(i);
      assertEquals(names[i],completionProp.getDisplayString());
    }
  }
  finally {
    FixtureUtils.tearDownFixture(m_fixtureManager);
  }
}

Fixed version (ground truth):
@Ignore("String_Node_Str") public void testProposalsOrder() throws Exception {
  String js="String_Node_Str";
  FixtureManager m_fixtureManager=FixtureUtils.setUpFixture(this,js);
  try {
    String[] names={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
    VjoSourceModule module=(VjoSourceModule)getSourceModule(TestConstants.PROJECT_NAME_VJETPROJECT,"String_Node_Str",new Path(js));
    int position=lastPositionInFile("String_Node_Str",module);
    IVjoCcEngine engine=new VjoCcEngine(TypeSpaceMgr.parser());
    List<IVjoCcProposalData> list=engine.complete(module.getGroupName(),new String(module.getFileName()),module.getSourceContents(),position);
    VjoCcCtx ctx=engine.getContext();
    VjoProposalEclipsePresenter presenter=new VjoProposalEclipsePresenter(ctx,position,null,null);
    List<ICompletionProposal> pList=presenter.doPresenter(list);
    for (int i=0; i < names.length; i++) {
      CompletionProposal completionProp=(CompletionProposal)pList.get(i);
      assertEquals(names[i],completionProp.getDisplayString());
    }
  }
  finally {
    FixtureUtils.tearDownFixture(m_fixtureManager);
  }
}
Program: 17069
Project: 17069
Buggy source:
public static boolean isArbitary(IJstType exprValue){
  return exprValue != null && (VjoConstants.ARBITARY.equals(exprValue) || "String_Node_Str".equals(exprValue.getName()) || SynthOlType.TYPE_NAME.equals(exprValue.getName()));
}

Fixed version (ground truth):
public static boolean isArbitary(IJstType exprValue){
  return exprValue != null && (VjoConstants.ARBITARY.equals(exprValue) || "String_Node_Str".equals(exprValue.getName()));
}
Program: 17070
Project: 17070
Buggy source:
public static String getFullMethodString(IJstMethod method,final IJstType ownerType,final boolean optional){
  return JstDisplayUtils.getFullMethodString(method,ownerType,false);
}

Fixed version (ground truth):
public static String getFullMethodString(IJstMethod method,final IJstType ownerType,final boolean optional){
  return JstDisplayUtils.getFullMethodString(method,ownerType,optional);
}
Program: 17071
Project: 17071
Buggy source:
private String getSemanticTypeName(final IJstType parameterType){
  if (parameterType == null) {
    return "String_Node_Str";
  }
  if (parameterType instanceof JstFuncType) {
    final IJstMethod function=((JstFuncType)parameterType).getFunction();
    if (!function.isDispatcher()) {
      return JstDisplayUtils.getFullMethodString(function,function.getOwnerType(),false);
    }
 else {
      return parameterType.getName();
    }
  }
 else {
    return parameterType.getName();
  }
}

Fixed version (ground truth):
private String getSemanticTypeName(final IJstType parameterType){
  if (parameterType == null) {
    return "String_Node_Str";
  }
  if (parameterType instanceof JstFuncType) {
    final IJstMethod function=((JstFuncType)parameterType).getFunction();
    if (!function.isDispatcher()) {
      return JstDisplayUtils.getFullMethodString(function,function.getOwnerType(),false);
    }
 else {
      return "String_Node_Str";
    }
  }
 else {
    return parameterType.getName();
  }
}
Program: 17072
Project: 17072
Buggy source:
@Override public void visit(BaseJsCommentMetaNode<?> node){
}

Fixed version (ground truth):
public void visit(JstInferredType node){
}
Program: 17073
Project: 17073
Buggy source:
private void promoteGlobals(IJstType type,JstTypeSpaceMgr mgr,ResolutionResult rr){
  if (type.hasGlobalVars()) {
    ITypeSpace<IJstType,IJstNode> typeSpace=mgr.getTypeSpace();
    boolean error=false;
    if (type instanceof JstType) {
      JstType type2=(JstType)type;
      if (!type2.getStatus().areGlobalsPromoted()) {
        typeSpace.removeGlobalsFromType(type.getPackage().getGroupName(),type.getName());
        error=validateGlobal(type,mgr,rr,error);
        if (!error) {
          for (          IJstGlobalVar gvar : type.getGlobalVars()) {
            final String groupName=type.getPackage().getGroupName();
            JstExpressionTypeLinkerHelper.look4ActualBinding(this,gvar.getType(),new GroupInfo(groupName,null));
            typeSpace.addToGlobalSymbolMap(groupName,gvar.getName().getName(),gvar.getOwnerType().getName(),gvar);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void promoteGlobals(IJstType type,JstTypeSpaceMgr mgr,ResolutionResult rr){
  if (type.hasGlobalVars()) {
    ITypeSpace<IJstType,IJstNode> typeSpace=mgr.getTypeSpace();
    boolean error=false;
    if (type instanceof JstType) {
      JstType type2=(JstType)type;
      if (!type2.getStatus().areGlobalsPromoted()) {
        typeSpace.removeGlobalsFromType(type.getPackage().getGroupName(),type.getName());
        error=validateGlobal(type,mgr,rr,error);
        if (!error) {
          for (          IJstGlobalVar gvar : type.getGlobalVars()) {
            final String groupName=type.getPackage().getGroupName();
            final IJstNode globalBinding=JstExpressionTypeLinkerHelper.look4ActualBinding(this,gvar.getType(),new GroupInfo(groupName,null));
            if (gvar.getType() instanceof JstAttributedType) {
              if (!gvar.isFunc()) {
                final IJstGlobalProp globalPty=gvar.getProperty();
                if (globalBinding instanceof IJstProperty && globalPty instanceof JstGlobalProp) {
                  ((JstGlobalProp)globalPty).setProperty(new RenameableSynthJstProxyProp((IJstProperty)globalBinding,globalPty.getName().getName()));
                }
              }
            }
            typeSpace.addToGlobalSymbolMap(groupName,gvar.getName().getName(),gvar.getOwnerType().getName(),gvar);
          }
        }
      }
    }
  }
}
Program: 17074
Project: 17074
Buggy source:
public static void fixPropertyTypeRef(final JstExpressionBindingResolver resolver,JstProperty pty,GroupInfo groupInfo){
  IJstType ptyType=pty.getType();
  if (ptyType instanceof JstAttributedType) {
    final IJstNode rtnBinding=look4ActualBinding(resolver,ptyType,groupInfo);
    if (rtnBinding instanceof IJstOType && rtnBinding != ptyType) {
      ptyType=(IJstOType)rtnBinding;
      pty.setType(ptyType);
    }
  }
  IJstType correctType=getCorrectType(resolver,ptyType,groupInfo);
  if (correctType != ptyType) {
    pty.setType(correctType);
  }
}

Fixed version (ground truth):
public static void fixPropertyTypeRef(final JstExpressionBindingResolver resolver,JstProperty pty,GroupInfo groupInfo){
  final IJstType ptyType=pty.getType();
  final IJstType correctType=getCorrectType(resolver,ptyType,groupInfo);
  if (correctType != ptyType) {
    pty.setType(correctType);
  }
}
Program: 17075
Project: 17075
Buggy source:
public static IJstType getCorrectType(final JstExpressionBindingResolver resolver,final IJstType type,final GroupInfo groupInfo){
  if (type == null || !(type instanceof JstType)) {
    if (type instanceof JstTypeRefType) {
      IJstType target=((JstTypeRefType)type).getReferencedNode();
      IJstType extended=getExtendedType(target,groupInfo);
      if (extended != target) {
        return new JstTypeRefType(extended);
      }
    }
 else     if (type instanceof JstFuncType) {
      updateFunctionType((JstFuncType)type,groupInfo);
    }
    return type;
  }
  JstType jstType=(JstType)type;
  if (!jstType.getStatus().isPhantom()) {
    if (jstType instanceof JstArray) {
      updateArrayType((JstArray)jstType,groupInfo);
    }
 else     if (jstType.isFType() || jstType instanceof JstFunctionRefType) {
      updateFunctionType(jstType,groupInfo);
    }
    return getExtendedType(jstType,groupInfo);
  }
  JstType typeInCache=JstCache.getInstance().getType(jstType.getName());
  if (typeInCache != null) {
    if (typeInCache instanceof JstArray) {
      updateArrayType((JstArray)typeInCache,groupInfo);
    }
 else     if (jstType.isFType() || jstType instanceof JstFunctionRefType) {
      updateFunctionType(jstType,groupInfo);
    }
    return getExtendedType(typeInCache,groupInfo);
  }
  return getExtendedType(jstType,groupInfo);
}

Fixed version (ground truth):
public static IJstType getCorrectType(final JstExpressionBindingResolver resolver,final IJstType type,final GroupInfo groupInfo){
  if (type == null) {
    return null;
  }
 else   if (type instanceof JstAttributedType) {
    final IJstNode rtnBinding=look4ActualBinding(resolver,type,groupInfo);
    if (rtnBinding instanceof IJstOType && rtnBinding != type) {
      return (IJstOType)rtnBinding;
    }
  }
 else   if (type instanceof JstTypeRefType) {
    IJstType target=((JstTypeRefType)type).getReferencedNode();
    IJstType extended=getExtendedType(target,groupInfo);
    if (extended != target) {
      return new JstTypeRefType(extended);
    }
  }
 else   if (type instanceof JstFuncType) {
    updateFunctionType((JstFuncType)type,groupInfo);
  }
  if (!(type instanceof JstType)) {
    return type;
  }
  JstType jstType=(JstType)type;
  if (!jstType.getStatus().isPhantom()) {
    if (jstType instanceof JstArray) {
      updateArrayType((JstArray)jstType,groupInfo);
    }
 else     if (jstType.isFType() || jstType instanceof JstFunctionRefType) {
      updateFunctionType(jstType,groupInfo);
    }
    return getExtendedType(jstType,groupInfo);
  }
  JstType typeInCache=JstCache.getInstance().getType(jstType.getName());
  if (typeInCache != null) {
    if (typeInCache instanceof JstArray) {
      updateArrayType((JstArray)typeInCache,groupInfo);
    }
 else     if (jstType.isFType() || jstType instanceof JstFunctionRefType) {
      updateFunctionType(jstType,groupInfo);
    }
    return getExtendedType(typeInCache,groupInfo);
  }
  return getExtendedType(jstType,groupInfo);
}
Program: 17077
Project: 17077
Buggy source:
private void promoteGlobals(IJstType type,JstTypeSpaceMgr mgr,ResolutionResult rr){
  if (type.hasGlobalVars()) {
    ITypeSpace<IJstType,IJstNode> typeSpace=mgr.getTypeSpace();
    boolean error=false;
    if (type instanceof JstType) {
      JstType type2=(JstType)type;
      if (!type2.getStatus().areGlobalsPromoted()) {
        typeSpace.removeGlobalsFromType(type.getPackage().getGroupName(),type.getName());
        error=validateGlobal(type,mgr,rr,error);
        if (!error) {
          for (          IJstGlobalVar gvar : type.getGlobalVars()) {
            final String groupName=type.getPackage().getGroupName();
            final IJstNode globalBinding=JstExpressionTypeLinkerHelper.look4ActualBinding(this,gvar.getType(),new GroupInfo(groupName,null));
            if (gvar.getType() instanceof JstAttributedType) {
              if (!gvar.isFunc()) {
                final IJstGlobalProp globalPty=gvar.getProperty();
                if (globalBinding instanceof IJstProperty && globalPty instanceof JstGlobalProp) {
                  ((JstGlobalProp)globalPty).setProperty(new RenameableSynthJstProxyProp((IJstProperty)globalBinding,globalPty.getName().getName()));
                }
              }
            }
            typeSpace.addToGlobalSymbolMap(groupName,gvar.getName().getName(),gvar.getOwnerType().getName(),gvar);
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void promoteGlobals(IJstType type,JstTypeSpaceMgr mgr,ResolutionResult rr){
  if (type.hasGlobalVars()) {
    ITypeSpace<IJstType,IJstNode> typeSpace=mgr.getTypeSpace();
    boolean error=false;
    if (type instanceof JstType) {
      JstType type2=(JstType)type;
      if (!type2.getStatus().areGlobalsPromoted()) {
        typeSpace.removeGlobalsFromType(type.getPackage().getGroupName(),type.getName());
        error=validateGlobal(type,mgr,rr,error);
        if (!error) {
          for (          IJstGlobalVar gvar : type.getGlobalVars()) {
            final String groupName=type.getPackage().getGroupName();
            final IJstNode globalBinding=JstExpressionTypeLinkerHelper.look4ActualBinding(this,gvar.getType(),new GroupInfo(groupName,null));
            if (gvar.getType() instanceof JstAttributedType) {
              if (!gvar.isFunc()) {
                final IJstGlobalProp globalPty=gvar.getProperty();
                if (globalPty instanceof JstGlobalProp) {
                  if (globalBinding instanceof IJstProperty) {
                    ((JstGlobalProp)globalPty).setProperty(new RenameableSynthJstProxyProp((IJstProperty)globalBinding,globalPty.getName().getName()));
                  }
 else                   if (globalBinding instanceof IJstMethod) {
                    ((JstGlobalProp)globalPty).setProperty(new JstSynthesizedProperty(new JstFuncType((IJstMethod)globalBinding),globalPty.getName().getName(),null,null));
                  }
                }
              }
            }
            typeSpace.addToGlobalSymbolMap(groupName,gvar.getName().getName(),gvar.getOwnerType().getName(),gvar);
          }
        }
      }
    }
  }
}
Program: 17078
Project: 17078
Buggy source:
public static IJstNode look4ActualBinding(final JstExpressionBindingResolver resolver,final IJstType type,final GroupInfo groupInfo){
  if (type == null) {
    return null;
  }
 else   if (type instanceof JstArray) {
    look4ActualBinding(resolver,((JstArray)type).getComponentType(),groupInfo);
    return null;
  }
 else   if (type instanceof JstTypeWithArgs) {
    for (    IJstType argType : ((JstTypeWithArgs)type).getArgTypes()) {
      look4ActualBinding(resolver,argType);
    }
    return null;
  }
 else   if (type instanceof JstWildcardType) {
    look4ActualBinding(resolver,((JstWildcardType)type).getType(),groupInfo);
    return null;
  }
 else   if (type instanceof JstFuncType) {
    final IJstMethod func=((JstFuncType)type).getFunction();
    return bindAttributedType(resolver,func,groupInfo);
  }
 else   if (type instanceof JstAttributedType) {
    return doAttributedTypeBindings(resolver,(JstAttributedType)type,groupInfo);
  }
 else   if (type instanceof JstInferredType) {
    return look4ActualBinding(resolver,((JstInferredType)type).getType(),groupInfo);
  }
 else   if (type.isFType()) {
    return type;
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
public static IJstNode look4ActualBinding(final JstExpressionBindingResolver resolver,final IJstType type,final GroupInfo groupInfo){
  if (type == null) {
    return null;
  }
 else   if (type instanceof JstArray) {
    look4ActualBinding(resolver,((JstArray)type).getComponentType(),groupInfo);
    return null;
  }
 else   if (type instanceof JstTypeWithArgs) {
    for (    IJstType argType : ((JstTypeWithArgs)type).getArgTypes()) {
      look4ActualBinding(resolver,argType);
    }
    return null;
  }
 else   if (type instanceof JstWildcardType) {
    look4ActualBinding(resolver,((JstWildcardType)type).getType(),groupInfo);
    return null;
  }
 else   if (type instanceof JstFuncType) {
    final IJstMethod func=((JstFuncType)type).getFunction();
    bindAttributedType(resolver,func,groupInfo);
    return null;
  }
 else   if (type instanceof JstAttributedType) {
    return doAttributedTypeBindings(resolver,(JstAttributedType)type,groupInfo);
  }
 else   if (type instanceof JstInferredType) {
    return look4ActualBinding(resolver,((JstInferredType)type).getType(),groupInfo);
  }
 else   if (type.isFType()) {
    return type;
  }
 else {
    return null;
  }
}
Program: 17079
Project: 17079
Buggy source:
@Before public void setUp(){
  expectProblems.clear();
  expectProblems.add(createNewProblem(VarProbIds.LooseVarDecl,60,0));
  expectProblems.add(createNewProblem(VarProbIds.UndefinedName,60,0));
  expectProblems.add(createNewProblem(FieldProbIds.UndefinedField,190,0));
  expectProblems.add(createNewProblem(FieldProbIds.UndefinedField,195,0));
  expectProblems.add(createNewProblem(FieldProbIds.UndefinedField,200,0));
  expectProblems.add(createNewProblem(FieldProbIds.UndefinedField,296,0));
  expectProblems.add(createNewProblem(FieldProbIds.UndefinedField,297,0));
  expectProblems.add(createNewProblem(VarProbIds.LooseVarDecl,303,0));
}

Fixed version (ground truth):
@Before public void setUp(){
  expectProblems.clear();
  expectProblems.add(createNewProblem(VarProbIds.LooseVarDecl,60,0));
  expectProblems.add(createNewProblem(VarProbIds.UndefinedName,60,0));
  expectProblems.add(createNewProblem(FieldProbIds.UndefinedField,190,0));
  expectProblems.add(createNewProblem(FieldProbIds.UndefinedField,195,0));
  expectProblems.add(createNewProblem(FieldProbIds.UndefinedField,200,0));
  expectProblems.add(createNewProblem(VarProbIds.LooseVarDecl,303,0));
}
Program: 17080
Project: 17080
Buggy source:
public IJstNode findGlobalVar(final String groupName,final String ptyName){
  return m_ts.getGlobalVar(groupName,ptyName);
}

Fixed version (ground truth):
public IJstNode findGlobalVar(final String groupName,final String ptyName,final boolean recursive){
  IJstNode var=m_ts.getGlobalVar(groupName,ptyName);
  if (var != null) {
    return var;
  }
  if (!recursive) {
    return null;
  }
  IGroup<IJstType> group=m_ts.getGroup(groupName);
  for (  IGroup<IJstType> depGrp : group.getGroupDependency()) {
    var=m_ts.getGlobalVar(depGrp.getName(),ptyName);
    if (var != null) {
      return var;
    }
  }
  return null;
}
Program: 17081
Project: 17081
Buggy source:
private boolean validateGlobal(IJstType type,JstTypeSpaceMgr mgr,ResolutionResult rr,boolean error){
  for (  IJstGlobalVar vars : type.getGlobalVars()) {
    String name=vars.getName().getName();
    String groupName=type.getPackage().getGroupName();
    IJstNode findGlobal=mgr.getQueryExecutor().findGlobal(groupName,name);
    List<IJstType> list=mgr.getTypeSpace().getType(name);
    if (!list.isEmpty()) {
      IScriptProblem prblm=reportError(type,vars,name,findGlobal,"String_Node_Str" + name + "String_Node_Str"+ list.get(0).getName());
      rr.addProblem(prblm);
      error=true;
      continue;
    }
    if (findGlobal != null && (findGlobal instanceof IJstGlobalProp || findGlobal instanceof IJstGlobalFunc) && !findGlobal.getOwnerType().equals(type)) {
      IScriptProblem prblm=reportError(type,vars,name,findGlobal,"String_Node_Str" + name + "String_Node_Str"+ type.getName());
      rr.addProblem(prblm);
      error=true;
      continue;
    }
    List<IJstType> windowTypeList=mgr.getTypeSpace().getVisibleType("String_Node_Str",getController().getJstTypeSpaceMgr().getTypeSpace().getGroup(groupName));
    if (windowTypeList.size() == 0) {
      continue;
    }
    IJstType window=windowTypeList.get(0);
    IJstMethod method=window.getMethod(name,false);
    if (method != null) {
      IScriptProblem prblm=reportError(type,vars,name,method,"String_Node_Str" + name + "String_Node_Str");
      rr.addProblem(prblm);
      error=true;
      continue;
    }
    IJstProperty property=window.getProperty(name);
    if (property != null) {
      IScriptProblem prblm=reportError(type,vars,name,property,"String_Node_Str" + name + "String_Node_Str");
      rr.addProblem(prblm);
      error=true;
      continue;
    }
  }
  return error;
}

Fixed version (ground truth):
private boolean validateGlobal(IJstType type,JstTypeSpaceMgr mgr,ResolutionResult rr,boolean error){
  for (  IJstGlobalVar var : type.getGlobalVars()) {
    String glbScope=var.getScopeForGlobal();
    if (glbScope != null) {
      continue;
    }
    String name=var.getName().getName();
    String groupName=type.getPackage().getGroupName();
    IJstNode findGlobal=mgr.getQueryExecutor().findGlobalVar(groupName,name,true);
    if (findGlobal == null) {
      continue;
    }
    List<IJstType> list=mgr.getTypeSpace().getType(name);
    if (!list.isEmpty()) {
      IScriptProblem prblm=reportError(type,var,name,findGlobal,"String_Node_Str" + name + "String_Node_Str"+ list.get(0).getName());
      rr.addProblem(prblm);
      error=true;
      continue;
    }
    if ((findGlobal instanceof IJstGlobalProp || findGlobal instanceof IJstGlobalFunc) && !findGlobal.getOwnerType().equals(type)) {
      IScriptProblem prblm=reportError(type,var,name,findGlobal,"String_Node_Str" + name + "String_Node_Str"+ type.getName());
      rr.addProblem(prblm);
      error=true;
      continue;
    }
  }
  return error;
}
Program: 17082
Project: 17082
Buggy source:
/** 
 * Write a carriage return if PRETTY style is selected
 * @return SourceWriter
 */
public SourceGenerator writeNewline(){
  if (m_style == CodeStyle.PRETTY) {
    m_writer.append(NEWLINE);
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Write a carriage return if PRETTY style is selected
 * @return SourceWriter
 */
public SourceGenerator writeNewline(){
  if (m_style == CodeStyle.PRETTY) {
    m_writer.append(m_newline);
  }
  return this;
}
Program: 17083
Project: 17083
Buggy source:
/** 
 * Force a carriage return
 * @return
 */
public SourceGenerator forceNewline(){
  m_writer.append(NEWLINE);
  return this;
}

Fixed version (ground truth):
/** 
 * Force a carriage return
 * @return
 */
public SourceGenerator forceNewline(){
  m_writer.append(m_newline);
  return this;
}
Program: 17084
Project: 17084
Buggy source:
public VjoGenerator writeSatisfies(final List<? extends IJstType> needs){
  if (needs == null || needs.size() == 0) {
    return this;
  }
 else   if (needs.size() == 0) {
    writeSatisfies(needs.get(0));
    return this;
  }
  StringBuffer sb=new StringBuffer();
  int i=0;
  for (  IJstType need : needs) {
    if (i > 0) {
      sb.append("String_Node_Str");
      if (i % 2 == 0) {
        sb.append(NEWLINE).append(Indenter.TAB);
      }
    }
    sb.append("String_Node_Str").append(need.getName()).append("String_Node_Str");
    i++;
  }
  if (sb.length() > 0) {
    writeNewline();
    getWriter().append("String_Node_Str").append(VjoKeywords.SATISFIES).append("String_Node_Str").append(sb.toString()).append("String_Node_Str");
  }
  return this;
}

Fixed version (ground truth):
public VjoGenerator writeSatisfies(final List<? extends IJstType> needs){
  if (needs == null || needs.size() == 0) {
    return this;
  }
 else   if (needs.size() == 0) {
    writeSatisfies(needs.get(0));
    return this;
  }
  StringBuffer sb=new StringBuffer();
  int i=0;
  for (  IJstType need : needs) {
    if (i > 0) {
      sb.append("String_Node_Str");
      if (i % 2 == 0) {
        sb.append(getNewline()).append(Indenter.TAB);
      }
    }
    sb.append("String_Node_Str").append(need.getName()).append("String_Node_Str");
    i++;
  }
  if (sb.length() > 0) {
    writeNewline();
    getWriter().append("String_Node_Str").append(VjoKeywords.SATISFIES).append("String_Node_Str").append(sb.toString()).append("String_Node_Str");
  }
  return this;
}
Program: 17085
Project: 17085
Buggy source:
public VjoGenerator writeNeeds(final List<? extends IJstType> needs,final IJstType type){
  if (needs == null || needs.size() == 0) {
    return this;
  }
 else   if (needs.size() == 1) {
    if (!shouldExcludeNeed(type,needs.get(0))) {
      writeNeeds(needs.get(0).getName(),needs.get(0).getAlias());
    }
    return this;
  }
  IJstType first=null;
  List<IJstType> alias=new ArrayList<IJstType>();
  StringBuffer sb=new StringBuffer();
  int i=0;
  for (  IJstType need : needs) {
    if (!shouldExcludeNeed(type,need)) {
      if (need.getAlias() != null && (!need.getAlias().equals(need.getName()) || type.getImportsMap().get(need.getName()) != null)) {
        alias.add(need);
      }
 else {
        if (i > 0) {
          sb.append("String_Node_Str");
          if (i % 2 == 0) {
            sb.append(NEWLINE).append(Indenter.TAB);
          }
          first=null;
        }
 else {
          first=need;
        }
        sb.append("String_Node_Str").append(need.getName()).append("String_Node_Str");
        i++;
      }
    }
  }
  if (first != null) {
    writeNeeds(first.getName(),first.getAlias());
  }
 else   if (sb.length() > 0) {
    writeNewline();
    getWriter().append("String_Node_Str").append(VjoKeywords.NEEDS).append("String_Node_Str").append(sb.toString()).append("String_Node_Str");
  }
  for (  IJstType need : alias) {
    String als="String_Node_Str";
    if (type.getImportsMap().get(need.getName()) == null) {
      als=need.getAlias();
    }
    writeNeeds(need.getName(),als);
  }
  return this;
}

Fixed version (ground truth):
public VjoGenerator writeNeeds(final List<? extends IJstType> needs,final IJstType type){
  if (needs == null || needs.size() == 0) {
    return this;
  }
 else   if (needs.size() == 1) {
    if (!shouldExcludeNeed(type,needs.get(0))) {
      writeNeeds(needs.get(0).getName(),needs.get(0).getAlias());
    }
    return this;
  }
  IJstType first=null;
  List<IJstType> alias=new ArrayList<IJstType>();
  StringBuffer sb=new StringBuffer();
  int i=0;
  for (  IJstType need : needs) {
    if (!shouldExcludeNeed(type,need)) {
      if (need.getAlias() != null && (!need.getAlias().equals(need.getName()) || type.getImportsMap().get(need.getName()) != null)) {
        alias.add(need);
      }
 else {
        if (i > 0) {
          sb.append("String_Node_Str");
          if (i % 2 == 0) {
            sb.append(getNewline()).append(Indenter.TAB);
          }
          first=null;
        }
 else {
          first=need;
        }
        sb.append("String_Node_Str").append(need.getName()).append("String_Node_Str");
        i++;
      }
    }
  }
  if (first != null) {
    writeNeeds(first.getName(),first.getAlias());
  }
 else   if (sb.length() > 0) {
    writeNewline();
    getWriter().append("String_Node_Str").append(VjoKeywords.NEEDS).append("String_Node_Str").append(sb.toString()).append("String_Node_Str");
  }
  for (  IJstType need : alias) {
    String als="String_Node_Str";
    if (type.getImportsMap().get(need.getName()) == null) {
      als=need.getAlias();
    }
    writeNeeds(need.getName(),als);
  }
  return this;
}
Program: 17086
Project: 17086
Buggy source:
public TestHelper(Class javaClass,final ITranslationInitializer initializer){
  m_initializer=initializer;
  m_javaCls=javaClass;
  m_generatorCtx=new GeneratorCtx(CodeStyle.PRETTY);
}

Fixed version (ground truth):
public TestHelper(Class javaClass,final ITranslationInitializer initializer){
  m_initializer=initializer;
  m_javaCls=javaClass;
  m_generatorCtx=new GeneratorCtx(CodeStyle.PRETTY);
  m_generatorCtx.setNewline(NEWLINE);
}
Program: 17087
Project: 17087
Buggy source:
protected JsrGenerator getJsrGenerator(final StringWriter buffer,final CodeStyle style){
  JsrGenerator writer=new JsrGenerator(new PrintWriter(buffer),style);
  return writer;
}

Fixed version (ground truth):
protected JsrGenerator getJsrGenerator(final StringWriter buffer,final CodeStyle style){
  JsrGenerator writer=new JsrGenerator(new PrintWriter(buffer),style);
  writer.setNewline(NEWLINE);
  return writer;
}
Program: 17088
Project: 17088
Buggy source:
public static void fixPropertyTypeRef(final JstExpressionBindingResolver resolver,JstProperty pty,GroupInfo groupInfo){
  IJstType ptyType=pty.getType();
  IJstType correctType=getCorrectType(resolver,ptyType,groupInfo);
  if (correctType != ptyType) {
    pty.setType(correctType);
  }
}

Fixed version (ground truth):
public static void fixPropertyTypeRef(final JstExpressionBindingResolver resolver,JstProperty pty,GroupInfo groupInfo){
  IJstType ptyType=pty.getType();
  if (ptyType instanceof JstAttributedType) {
    final IJstNode rtnBinding=look4ActualBinding(resolver,ptyType,groupInfo);
    if (rtnBinding instanceof IJstOType && rtnBinding != ptyType) {
      ptyType=(IJstOType)rtnBinding;
    }
  }
  IJstType correctType=getCorrectType(resolver,ptyType,groupInfo);
  if (correctType != ptyType) {
    pty.setType(correctType);
  }
}
Program: 17090
Project: 17090
Buggy source:
public void advise(final VjoCcCtx ctx){
  final Object valueOfInfoKeyArgument=ctx.getInfo(VjoCcCtx.INFO_KEY_ARGUMENT);
  if (!(valueOfInfoKeyArgument instanceof IExpr)) {
    return;
  }
  final IExpr argument=(IExpr)valueOfInfoKeyArgument;
  if (!(argument.getParentNode() instanceof MtdInvocationExpr)) {
    return;
  }
  final MtdInvocationExpr mtdInvocationExpr=(MtdInvocationExpr)argument.getParentNode();
  final int position=mtdInvocationExpr.getArgs().indexOf(argument);
  final IJstNode node=mtdInvocationExpr.getMethod();
  if (node == null || !(node instanceof IJstMethod)) {
    return;
  }
  final IJstMethod method=(IJstMethod)node;
  IJstType calledType=method.getOwnerType();
  if (calledType == null) {
    return;
  }
  final List<JstArg> parameters=method.getArgs();
  if (parameters.size() <= position) {
    return;
  }
  final JstArg parameterAtPos=parameters.get(position);
  final IJstType parameterType=parameterAtPos.getType();
  if (parameterType instanceof JstFuncType) {
    appendData(ctx,((JstFuncType)parameterType).getFunction(),true);
  }
 else   if (parameterType instanceof JstFunctionRefType) {
    appendData(ctx,((JstFunctionRefType)parameterType).getMethodRef(),true);
  }
}

Fixed version (ground truth):
public void advise(final VjoCcCtx ctx){
  final Object valueOfInfoKeyArgument=ctx.getInfo(VjoCcCtx.INFO_KEY_ARGUMENT);
  if (!(valueOfInfoKeyArgument instanceof IExpr)) {
    return;
  }
  final IExpr argument=(IExpr)valueOfInfoKeyArgument;
  if (!(argument.getParentNode() instanceof MtdInvocationExpr)) {
    return;
  }
  final MtdInvocationExpr mtdInvocationExpr=(MtdInvocationExpr)argument.getParentNode();
  final int position=mtdInvocationExpr.getArgs().indexOf(argument);
  final IJstNode node=mtdInvocationExpr.getMethod();
  if (node == null || !(node instanceof IJstMethod)) {
    return;
  }
  final IJstMethod method=(IJstMethod)node;
  IJstType calledType=method.getOwnerType();
  if (calledType == null) {
    return;
  }
  final List<JstArg> parameters=method.getArgs();
  if (parameters.size() <= position) {
    return;
  }
  final JstArg parameterAtPos=parameters.get(position);
  final IJstType parameterType=parameterAtPos.getType();
  if (parameterType instanceof JstFuncType) {
    appendData(ctx,getParamNamedMethodProposal(parameterAtPos,((JstFuncType)parameterType).getFunction()),true);
  }
 else   if (parameterType instanceof JstFunctionRefType) {
    appendData(ctx,getParamNamedMethodProposal(parameterAtPos,((JstFunctionRefType)parameterType).getMethodRef()),true);
  }
}
Program: 17092
Project: 17092
Buggy source:
@Override public void start(BundleContext context) throws Exception {
  super.start(context);
  IPerspectiveDescriptor[] allSets=PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
  for (  IPerspectiveDescriptor iPerspectiveDescriptor : allSets) {
    if (iPerspectiveDescriptor.getId().contains("String_Node_Str")) {
      PlatformUI.getWorkbench().getPerspectiveRegistry().deletePerspective(iPerspectiveDescriptor);
    }
  }
  setPluginInstance(this);
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
      window.getPartService().addPartListener(partListener);
      registryAdvisor();
      reloadFont();
    }
  }
);
  IEditorRegistry editorRegistry=VjetUIPlugin.getDefault().getWorkbench().getEditorRegistry();
  editorRegistry.setDefaultEditor(getExtentionPattern(),VjoEditor.EDITOR_ID);
}

Fixed version (ground truth):
@Override public void start(BundleContext context) throws Exception {
  super.start(context);
  IPerspectiveDescriptor[] allSets=PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives();
  for (  IPerspectiveDescriptor iPerspectiveDescriptor : allSets) {
    if (iPerspectiveDescriptor.getId().contains("String_Node_Str")) {
      PlatformUI.getWorkbench().getPerspectiveRegistry().deletePerspective(iPerspectiveDescriptor);
    }
  }
  setPluginInstance(this);
  new WorkbenchJob("String_Node_Str"){
    @Override public IStatus runInUIThread(    IProgressMonitor arg0){
      IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
      window.getPartService().addPartListener(partListener);
      registryAdvisor();
      reloadFont();
      return new Status(IStatus.OK,PLUGIN_ID,IStatus.OK,"String_Node_Str",null);
    }
  }
.schedule();
  IEditorRegistry editorRegistry=VjetUIPlugin.getDefault().getWorkbench().getEditorRegistry();
  editorRegistry.setDefaultEditor(getExtentionPattern(),VjoEditor.EDITOR_ID);
}
Program: 17093
Project: 17093
Buggy source:
/** 
 * Returns item's name, with a maximum length
 * @param itemStack ItemStack to name
 * @param maxLength The max length that the name should have; 0 or below if it should be unlimited
 * @return ItemStack's name
 */
public static String getName(ItemStack itemStack,int maxLength){
  String alias=Odd.getAlias(itemStack);
  String itemName=alias != null ? alias : itemStack.getType().toString();
  String data=DataValue.name(itemStack);
  String durability="String_Node_Str";
  if (data == null) {
    if (itemStack.getDurability() != 0) {
      durability="String_Node_Str" + itemStack.getDurability();
    }
  }
  data=data != null ? data + "String_Node_Str" : "String_Node_Str";
  String metaData="String_Node_Str";
  if (itemStack.hasItemMeta()) {
    metaData="String_Node_Str" + Metadata.getItemCode(itemStack);
  }
  int codeLength=(data + itemName + durability+ metaData).length();
  String code=data + itemName;
  if (maxLength > 0 && codeLength > maxLength) {
    int exceeding=codeLength - maxLength;
    code=getShortenedName(code,code.length() - exceeding);
  }
  code=StringUtil.capitalizeFirstLetter(code,'_') + durability + metaData;
  ItemStack codeItem=getItem(code);
  if (!equals(itemStack,codeItem)) {
    throw new IllegalArgumentException("String_Node_Str" + itemStack + "String_Node_Str"+ maxLength+ "String_Node_Str"+ code+ "String_Node_Str"+ codeItem+ "String_Node_Str");
  }
  return code;
}

Fixed version (ground truth):
/** 
 * Returns item's name, with a maximum length
 * @param itemStack ItemStack to name
 * @param maxLength The max length that the name should have; 0 or below if it should be unlimited
 * @return ItemStack's name
 */
public static String getName(ItemStack itemStack,int maxLength){
  String alias=Odd.getAlias(itemStack);
  String itemName=alias != null ? alias : itemStack.getType().toString();
  if (itemStack.getType() != Material.HUGE_MUSHROOM_2 && itemName.endsWith("String_Node_Str")) {
    itemName=itemName.substring(0,itemName.length() - 2);
  }
  String data=DataValue.name(itemStack);
  String durability="String_Node_Str";
  if (data == null) {
    if (itemStack.getDurability() != 0) {
      durability="String_Node_Str" + itemStack.getDurability();
    }
  }
  data=data != null ? data + "String_Node_Str" : "String_Node_Str";
  String metaData="String_Node_Str";
  if (itemStack.hasItemMeta()) {
    metaData="String_Node_Str" + Metadata.getItemCode(itemStack);
  }
  int codeLength=(data + itemName + durability+ metaData).length();
  String code=data + itemName;
  if (maxLength > 0 && codeLength > maxLength) {
    int exceeding=codeLength - maxLength;
    code=getShortenedName(code,code.length() - exceeding);
  }
  code=StringUtil.capitalizeFirstLetter(code,'_') + durability + metaData;
  ItemStack codeItem=getItem(code);
  if (!equals(itemStack,codeItem)) {
    throw new IllegalArgumentException("String_Node_Str" + itemStack + "String_Node_Str"+ maxLength+ "String_Node_Str"+ code+ "String_Node_Str"+ codeItem+ "String_Node_Str");
  }
  return code;
}