Skip to content

Commit

Permalink
Adapted to IntelliJ 2017.2 breaking change
Browse files Browse the repository at this point in the history
issue #365
  • Loading branch information
mplushnikov committed Jan 7, 2018
1 parent 6b0a48d commit a0bf23e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
8 changes: 5 additions & 3 deletions .travis.yml
Expand Up @@ -13,9 +13,11 @@ cache:


env: env:
- IDEA_VERSION=LATEST-EAP-SNAPSHOT - IDEA_VERSION=LATEST-EAP-SNAPSHOT
- IDEA_VERSION=IC-2017.2.3 - IDEA_VERSION=IC-2017.3.2
- IDEA_VERSION=IC-2017.1.5 - IDEA_VERSION=IC-2017.2.6
- IDEA_VERSION=IC-2017.1 - IDEA_VERSION=IC-2017.2
#- IDEA_VERSION=IC-2017.1.5
#- IDEA_VERSION=IC-2017.1


before_install: before_install:
- chmod +x gradlew - chmod +x gradlew
Expand Down
5 changes: 3 additions & 2 deletions gradle.properties
Expand Up @@ -3,8 +3,9 @@
# https://www.jetbrains.com/intellij-repository/snapshots # https://www.jetbrains.com/intellij-repository/snapshots
# #
#ideaVersion=2017.1 #ideaVersion=2017.1
ideaVersion=2017.1.5 #ideaVersion=2017.1.5
#ideaVersion=2017.2.3 #ideaVersion=2017.2.6
ideaVersion=2017.3.2
#ideaVersion = LATEST-EAP-SNAPSHOT #ideaVersion = LATEST-EAP-SNAPSHOT
#ideaVersion = LATEST-TRUNK-SNAPSHOT #ideaVersion = LATEST-TRUNK-SNAPSHOT
# #
Expand Down
Expand Up @@ -8,7 +8,6 @@
import com.intellij.psi.PsiExpression; import com.intellij.psi.PsiExpression;
import com.intellij.psi.PsiType; import com.intellij.psi.PsiType;
import com.intellij.psi.search.GlobalSearchScope; import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.refactoring.introduce.inplace.OccurrencesChooser;
import com.intellij.refactoring.introduceVariable.InputValidator; import com.intellij.refactoring.introduceVariable.InputValidator;
import com.intellij.refactoring.introduceVariable.IntroduceVariableHandler; import com.intellij.refactoring.introduceVariable.IntroduceVariableHandler;
import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings; import com.intellij.refactoring.introduceVariable.IntroduceVariableSettings;
Expand All @@ -21,19 +20,27 @@ public class IntroduceLombokVariableHandler extends IntroduceVariableHandler {
this.selectedTypeFQN = selectedTypeFQN; this.selectedTypeFQN = selectedTypeFQN;
} }


/*
* This method with JavaReplaceChoice parameter exists from 2017.2
*/
@Override @Override
public final IntroduceVariableSettings getSettings(Project project, Editor editor, final PsiExpression expr, public IntroduceVariableSettings getSettings(Project project, Editor editor, PsiExpression expr,
PsiExpression[] occurrences, TypeSelectorManagerImpl typeSelectorManager, PsiExpression[] occurrences, TypeSelectorManagerImpl typeSelectorManager,
boolean declareFinalIfAll, boolean anyAssignmentLHS, InputValidator validator, boolean declareFinalIfAll, boolean anyAssignmentLHS, InputValidator validator,
PsiElement anchor, OccurrencesChooser.ReplaceChoice replaceChoice) { PsiElement anchor, JavaReplaceChoice replaceChoice) {
final IntroduceVariableSettings variableSettings; final IntroduceVariableSettings variableSettings;


if (ApplicationManager.getApplication().isUnitTestMode()) { if (ApplicationManager.getApplication().isUnitTestMode()) {
variableSettings = new UnitTestMockVariableSettings(expr); variableSettings = new UnitTestMockVariableSettings(expr);
} else { } else {
variableSettings = super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll, anyAssignmentLHS, validator, anchor, replaceChoice); variableSettings = super.getSettings(project, editor, expr, occurrences, typeSelectorManager, declareFinalIfAll,
anyAssignmentLHS, validator, anchor, replaceChoice);
} }


return getIntroduceVariableSettings(project, variableSettings);
}

private IntroduceVariableSettings getIntroduceVariableSettings(Project project, IntroduceVariableSettings variableSettings) {
final PsiClassType psiClassType = PsiType.getTypeByName(selectedTypeFQN, project, GlobalSearchScope.projectScope(project)); final PsiClassType psiClassType = PsiType.getTypeByName(selectedTypeFQN, project, GlobalSearchScope.projectScope(project));
if (null != psiClassType) { if (null != psiClassType) {
return new IntroduceVariableSettingsDelegate(variableSettings, psiClassType); return new IntroduceVariableSettingsDelegate(variableSettings, psiClassType);
Expand Down

0 comments on commit a0bf23e

Please sign in to comment.