Skip to content

Commit

Permalink
Resolve test failures.
Browse files Browse the repository at this point in the history
  • Loading branch information
yaohaizh committed Nov 21, 2018
1 parent 2f7ad52 commit cbf60d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class RenameNodeCorrectionProposal extends CUCorrectionProposal {
private int fLength;

public RenameNodeCorrectionProposal(String name, ICompilationUnit cu, int offset, int length, String newName, int relevance) {
super(name, CodeActionKind.Refactor, cu, null, relevance);
super(name, CodeActionKind.QuickFix, cu, null, relevance);
fOffset= offset;
fLength= length;
fNewName= newName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Comparator;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
Expand Down Expand Up @@ -83,24 +84,23 @@ public List<Either<Command, CodeAction>> getCodeActionCommands(CodeActionParams
List<CUCorrectionProposal> candidates = new ArrayList<>();
try {
List<CUCorrectionProposal> corrections = this.quickFixProcessor.getCorrections(context, locations);
corrections.sort(new CUCorrectionProposalComparator());
candidates.addAll(corrections);
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem resolving quick fix code actions", e);
}

try {
List<CUCorrectionProposal> corrections = this.quickAssistProcessor.getAssists(context, locations);
corrections.sort(new CUCorrectionProposalComparator());
candidates.addAll(corrections);
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem resolving quick assist code actions", e);
}

List<CUCorrectionProposal> corrections = this.sourceAssistProcessor.getAssists(context, locations);
corrections.sort(new CUCorrectionProposalComparator());
candidates.addAll(corrections);

candidates.sort(new CUCorrectionProposalComparator());

if (params.getContext().getOnly() != null && !params.getContext().getOnly().isEmpty()) {
List<CUCorrectionProposal> resultList = new ArrayList<>();
List<String> acceptedActionKinds = params.getContext().getOnly();
Expand Down Expand Up @@ -189,6 +189,12 @@ private static class CUCorrectionProposalComparator implements Comparator<CUCorr

@Override
public int compare(CUCorrectionProposal p1, CUCorrectionProposal p2) {
String k1 = p1.getKind();
String k2 = p2.getKind();
if (!StringUtils.isBlank(k1) && !StringUtils.isBlank(k2) && !k1.equals(k2)) {
return k1.compareTo(k2);
}

int r1 = p1.getRelevance();
int r2 = p2.getRelevance();
int relevanceDif = r2 - r1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ protected List<Either<Command, CodeAction>> evaluateCodeActions(ICompilationUnit
List<Either<Command, CodeAction>> filteredList = codeActions.stream().filter(Either::isRight).filter(codeAction -> {
for (String str : this.ignoredKinds) {
if (codeAction.getRight().getKind().matches(str)) {
return false;
return true;
}
}
return true;
return false;
}).collect(Collectors.toList());
codeActions.removeAll(filteredList);
}
Expand Down

0 comments on commit cbf60d8

Please sign in to comment.