From 1041bea5f794fd01ac2d01bebf1f3f2f98a4b27e Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Wed, 18 Sep 2019 12:52:21 +0800 Subject: [PATCH] Use sequence rank to get the first element in position group Signed-off-by: Sheng Chen --- .../code/ExtractMethodRefactoring.java | 2 +- .../handlers/GetRefactorEditHandler.java | 20 +------------------ 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corext/refactoring/code/ExtractMethodRefactoring.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corext/refactoring/code/ExtractMethodRefactoring.java index 1e83785d2e..be787e4eea 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corext/refactoring/code/ExtractMethodRefactoring.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corext/refactoring/code/ExtractMethodRefactoring.java @@ -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; diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/GetRefactorEditHandler.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/GetRefactorEditHandler.java index e5498cc1b5..95d32e82c7 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/GetRefactorEditHandler.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/GetRefactorEditHandler.java @@ -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(); @@ -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;