Program: 135935
Project: 135935
Buggy source:
private static void setUseMarkers(OpApplNode[] uses,String moduleName,Spec spec){
  Location[] locations=new Location[uses.length];
  for (int i=0; i < locations.length; i++) {
    SyntaxTreeNode stn=(SyntaxTreeNode)uses[i].stn;
switch (stn.getKind()) {
case N_OpApplication:
      stn=(SyntaxTreeNode)stn.heirs()[0];
    break;
case N_InfixExpr:
case N_PostfixExpr:
  stn=(SyntaxTreeNode)stn.heirs()[1];
break;
case N_GeneralId:
if (uses[i].subExpressionOf != null) {
while (stn.getKind() > NULL_ID && stn.heirs() != null && stn.heirs().length > 0) {
  stn=(SyntaxTreeNode)stn.heirs()[0];
}
}
break;
default :
System.out.println("String_Node_Str" + stn.getKind() + "String_Node_Str");
}
locations[i]=stn.getLocation();
}
Arrays.sort(locations,new LocationComparator());
UIHelper.jumpToLocation(locations[0]);
spec.setCurrentSelection(0);
IResource resource=ResourceHelper.getResourceByModuleName(spec.getModuleToShow());
if (resource == null) {
System.out.println("String_Node_Str");
return;
}
try {
resource.deleteMarkers(SHOW_USE_MARKER_TYPE,false,99);
spec.setMarkersToShow(null);
IMarker[] markersToShow=new IMarker[locations.length];
for (int i=0; i < markersToShow.length; i++) {
IRegion iregion=AdapterFactory.locationToRegion(locations[i]);
IMarker marker;
marker=resource.createMarker(SHOW_USE_MARKER_TYPE);
Map markerAttributes=new HashMap(2);
markerAttributes.put(IMarker.CHAR_START,new Integer(iregion.getOffset()));
markerAttributes.put(IMarker.CHAR_END,new Integer(iregion.getOffset() + iregion.getLength()));
marker.setAttributes(markerAttributes);
markersToShow[i]=marker;
}
spec.setMarkersToShow(markersToShow);
}
 catch (CoreException e) {
e.printStackTrace();
}
}

Fixed version (ground truth):
/** 
 * TODO: This method has the following minor bug.  When Foo is defined in module M, which is instantiated by  I == INSTANCE M, then when one of the OpApplNodes in uses represents a subexpression name like I!Foo!2, then just the "I" rather than the "I!Foo" is marked.  This is pretty harmless and is probably not worth fixing.
 * @param uses
 * @param moduleName
 * @param spec
 */
private static void setUseMarkers(OpApplNode[] uses,String moduleName,Spec spec){
  Location[] locations=new Location[uses.length];
  for (int i=0; i < locations.length; i++) {
    SyntaxTreeNode stn=(SyntaxTreeNode)uses[i].stn;
switch (stn.getKind()) {
case N_OpApplication:
      stn=(SyntaxTreeNode)stn.heirs()[0];
    break;
case N_InfixExpr:
case N_PostfixExpr:
  stn=(SyntaxTreeNode)stn.heirs()[1];
break;
case N_GeneralId:
if (uses[i].subExpressionOf != null && uses[i].subExpressionOf != uses[i].getOperator()) {
while (stn.getKind() > NULL_ID && stn.heirs() != null && stn.heirs().length > 0) {
  stn=(SyntaxTreeNode)stn.heirs()[0];
}
}
break;
default :
System.out.println("String_Node_Str" + stn.getKind() + "String_Node_Str");
}
locations[i]=stn.getLocation();
}
Arrays.sort(locations,new LocationComparator());
UIHelper.jumpToLocation(locations[0]);
spec.setCurrentSelection(0);
IResource resource=ResourceHelper.getResourceByModuleName(spec.getModuleToShow());
if (resource == null) {
System.out.println("String_Node_Str");
return;
}
try {
resource.deleteMarkers(SHOW_USE_MARKER_TYPE,false,99);
spec.setMarkersToShow(null);
IMarker[] markersToShow=new IMarker[locations.length];
for (int i=0; i < markersToShow.length; i++) {
IRegion iregion=AdapterFactory.locationToRegion(locations[i]);
IMarker marker;
marker=resource.createMarker(SHOW_USE_MARKER_TYPE);
Map markerAttributes=new HashMap(2);
markerAttributes.put(IMarker.CHAR_START,new Integer(iregion.getOffset()));
markerAttributes.put(IMarker.CHAR_END,new Integer(iregion.getOffset() + iregion.getLength()));
marker.setAttributes(markerAttributes);
markersToShow[i]=marker;
}
spec.setMarkersToShow(markersToShow);
}
 catch (CoreException e) {
e.printStackTrace();
}
}