Program: 119130
Project: 119130
Buggy source:
@Override protected List<ICompletionProposal> sortProposals(List<ICompletionProposal> proposals,IProgressMonitor monitor,ContentAssistInvocationContext context){
  List<ICompletionProposal> newProposals=super.sortProposals(proposals,monitor,context);
  List<ICompletionProposal> toRemove=new ArrayList<ICompletionProposal>();
  boolean globalFieldsDone=false;
  for (  Object o : newProposals) {
    ICompletionProposal proposal=(ICompletionProposal)o;
    String longna=proposal.getDisplayString();
    int indexna=longna.indexOf("String_Node_Str");
    if (indexna > 0) {
      if (longna.substring(indexna + 2,longna.length()).equals(TalendJavaSourceViewer.getClassName())) {
        toRemove.add(proposal);
      }
    }
    if (proposal instanceof JavaCompletionProposal) {
      JavaCompletionProposal javaProposal=((JavaCompletionProposal)proposal);
      if (javaProposal.getJavaElement() instanceof SourceField) {
        globalFieldsDone=true;
      }
      if (javaProposal.getJavaElement() == null && globalFieldsDone) {
        toRemove.add(proposal);
      }
    }
    if (proposal.getDisplayString().startsWith(TalendJavaSourceViewer.VIEWER_CLASS_NAME)) {
      toRemove.add(proposal);
    }
  }
  newProposals.removeAll(toRemove);
  Collections.sort(newProposals,new Comparator<ICompletionProposal>(){
    @Override public int compare(    ICompletionProposal arg0,    ICompletionProposal arg1){
      if (arg1 instanceof TalendCompletionProposal && (!(arg0 instanceof TalendCompletionProposal))) {
        return 1;
      }
 else       if (arg1 instanceof TalendCompletionProposal && (arg0 instanceof TalendCompletionProposal)) {
        TalendCompletionProposal a=(TalendCompletionProposal)arg0;
        TalendCompletionProposal b=(TalendCompletionProposal)arg1;
        return a.getType().compareTo(b.getType());
      }
      return 0;
    }
  }
);
  return newProposals;
}

Fixed version (ground truth):
@Override protected List<ICompletionProposal> sortProposals(List<ICompletionProposal> proposals,IProgressMonitor monitor,ContentAssistInvocationContext context){
  proposals=super.sortProposals(proposals,monitor,context);
  Map<String,ICompletionProposal> completionProposalMap=new HashMap<String,ICompletionProposal>();
  boolean globalFieldsDone=false;
  for (  Object o : proposals) {
    ICompletionProposal proposal=(ICompletionProposal)o;
    String longna=proposal.getDisplayString();
    int indexna=longna.indexOf("String_Node_Str");
    boolean shouldRemove=false;
    if (indexna > 0) {
      if (longna.substring(indexna + 2,longna.length()).equals(TalendJavaSourceViewer.getClassName())) {
        shouldRemove=true;
      }
    }
    if (proposal instanceof JavaCompletionProposal) {
      JavaCompletionProposal javaProposal=((JavaCompletionProposal)proposal);
      if (javaProposal.getJavaElement() instanceof SourceField) {
        globalFieldsDone=true;
      }
      if (javaProposal.getJavaElement() == null && globalFieldsDone) {
        shouldRemove=true;
      }
    }
    if (proposal.getDisplayString().startsWith(TalendJavaSourceViewer.VIEWER_CLASS_NAME)) {
      shouldRemove=true;
    }
    if (!shouldRemove) {
      completionProposalMap.put(longna,proposal);
    }
  }
  List<ICompletionProposal> newProposals=new ArrayList<ICompletionProposal>(completionProposalMap.values());
  Collections.sort(newProposals,new Comparator<ICompletionProposal>(){
    @Override public int compare(    ICompletionProposal arg0,    ICompletionProposal arg1){
      if (arg1 instanceof TalendCompletionProposal && (!(arg0 instanceof TalendCompletionProposal))) {
        return 1;
      }
 else       if (arg1 instanceof TalendCompletionProposal && (arg0 instanceof TalendCompletionProposal)) {
        TalendCompletionProposal a=(TalendCompletionProposal)arg0;
        TalendCompletionProposal b=(TalendCompletionProposal)arg1;
        return a.getType().compareTo(b.getType());
      }
      return 0;
    }
  }
);
  return newProposals;
}