Skip to content

Commit

Permalink
Use sequence rank to get the first element in position group
Browse files Browse the repository at this point in the history
Signed-off-by: Sheng Chen <[email protected]>
  • Loading branch information
jdneo authored and fbricon committed Sep 25, 2019
1 parent e19a96a commit 1041bea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ private ASTNode[] createCallNodes(SnippetFinder.Match duplicate, int modifiers)
}
if (fLinkedProposalModel != null) {
LinkedProposalPositionGroupCore nameGroup = fLinkedProposalModel.getPositionGroup(KEY_NAME, true);
nameGroup.addPosition(fRewriter.track(invocation.getName()), false);
nameGroup.addPosition(fRewriter.track(invocation.getName()), true);
}

ASTNode call;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,7 @@ public static RefactorWorkspaceEdit getEditsForRefactor(GetRefactorEditParams pa
Command additionalCommand = null;
if (linkedProposalModel != null) {
LinkedProposalPositionGroupCore linkedPositionGroup = linkedProposalModel.getPositionGroup(positionKey, false);
PositionInformation highlightPosition;
if (QuickAssistProcessor.CONVERT_ANONYMOUS_CLASS_TO_NESTED_COMMAND.equals(params.command)) {
highlightPosition = getFirstTrackedNodePositionBySequenceRank(linkedPositionGroup);
} else {
highlightPosition = getFirstTrackedNodePosition(linkedPositionGroup);
}
PositionInformation highlightPosition = getFirstTrackedNodePositionBySequenceRank(linkedPositionGroup);
if (highlightPosition != null) {
int offset = highlightPosition.getOffset();
int length = highlightPosition.getLength();
Expand All @@ -109,19 +104,6 @@ public static RefactorWorkspaceEdit getEditsForRefactor(GetRefactorEditParams pa
return null;
}

private static PositionInformation getFirstTrackedNodePosition(LinkedProposalPositionGroupCore positionGroup) {
if (positionGroup == null) {
return null;
}

PositionInformation[] positions = positionGroup.getPositions();
if (positions == null || positions.length == 0) {
return null;
}

return positions[0];
}

private static PositionInformation getFirstTrackedNodePositionBySequenceRank(LinkedProposalPositionGroupCore positionGroup) {
if (positionGroup == null) {
return null;
Expand Down

0 comments on commit 1041bea

Please sign in to comment.