mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+300
@@ -0,0 +1,300 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.FileModificationService;
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.refactoring.util.LambdaRefactoringUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.siyeh.ig.psiutils.ParenthesesUtils;
|
||||
import com.siyeh.ig.style.MethodRefCanBeReplacedWithLambdaInspection;
|
||||
import one.util.streamex.StreamEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class InlineStreamMapAction extends PsiElementBaseIntentionAction {
|
||||
private static final Logger LOG = Logger.getInstance(InlineStreamMapAction.class.getName());
|
||||
|
||||
private static final Set<String> MAP_METHODS =
|
||||
StreamEx.of("map", "mapToInt", "mapToLong", "mapToDouble", "mapToObj", "boxed", "asLongStream", "asDoubleStream").toSet();
|
||||
|
||||
private static final Set<String> NEXT_METHODS = StreamEx
|
||||
.of("flatMap", "flatMapToInt", "flatMapToLong", "flatMapToDouble", "forEach", "forEachOrdered", "anyMatch", "noneMatch", "allMatch")
|
||||
.append(MAP_METHODS).toSet();
|
||||
|
||||
@Override
|
||||
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull final PsiElement element) {
|
||||
if (!(element instanceof PsiIdentifier)) return false;
|
||||
final PsiElement parent = element.getParent();
|
||||
if (!(parent instanceof PsiReferenceExpression)) return false;
|
||||
final PsiElement gParent = parent.getParent();
|
||||
if (!(gParent instanceof PsiMethodCallExpression)) return false;
|
||||
PsiMethodCallExpression curCall = (PsiMethodCallExpression)gParent;
|
||||
if (!isMapCall(curCall)) return false;
|
||||
PsiMethodCallExpression nextCall = getNextExpressionToMerge(curCall);
|
||||
if(nextCall == null) return false;
|
||||
String key = curCall.getArgumentList().getExpressions().length == 0 || nextCall.getArgumentList().getExpressions().length == 0 ?
|
||||
"intention.inline.map.merge.text" : "intention.inline.map.inline.text";
|
||||
setText(CodeInsightBundle.message(key, element.getText(), nextCall.getMethodExpression().getReferenceName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean isMapCall(@NotNull PsiMethodCallExpression methodCallExpression) {
|
||||
String name = methodCallExpression.getMethodExpression().getReferenceName();
|
||||
if (name == null || !MAP_METHODS.contains(name)) return false;
|
||||
|
||||
final PsiExpressionList argumentList = methodCallExpression.getArgumentList();
|
||||
final PsiExpression[] expressions = argumentList.getExpressions();
|
||||
if (!name.startsWith("map") && expressions.length == 0) return true;
|
||||
if (expressions.length != 1) return false;
|
||||
if (!isSupportedForConversion(expressions[0], true)) return false;
|
||||
|
||||
final PsiMethod method = methodCallExpression.resolveMethod();
|
||||
if (method == null) return false;
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
return InheritanceUtil.isInheritor(containingClass, CommonClassNames.JAVA_UTIL_STREAM_BASE_STREAM);
|
||||
}
|
||||
|
||||
private static boolean isSupportedForConversion(PsiExpression expression, boolean requireExpressionLambda) {
|
||||
if(expression instanceof PsiLambdaExpression) {
|
||||
PsiLambdaExpression lambdaExpression = (PsiLambdaExpression)expression;
|
||||
return lambdaExpression.getParameterList().getParametersCount() == 1 &&
|
||||
(!requireExpressionLambda || LambdaUtil.extractSingleExpressionFromBody(lambdaExpression.getBody()) != null);
|
||||
} else if(expression instanceof PsiMethodReferenceExpression) {
|
||||
PsiMethodReferenceExpression methodReference = (PsiMethodReferenceExpression)expression;
|
||||
return !MethodRefCanBeReplacedWithLambdaInspection.isWithSideEffects(methodReference);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiMethodCallExpression getNextExpressionToMerge(PsiMethodCallExpression methodCallExpression) {
|
||||
PsiElement parent = methodCallExpression.getParent();
|
||||
if(!(parent instanceof PsiReferenceExpression)) return null;
|
||||
PsiElement gParent = parent.getParent();
|
||||
if(!(gParent instanceof PsiMethodCallExpression)) return null;
|
||||
String nextName = ((PsiReferenceExpression)parent).getReferenceName();
|
||||
PsiMethodCallExpression nextCall = (PsiMethodCallExpression)gParent;
|
||||
if(nextName == null || !NEXT_METHODS.contains(nextName) || translateName(methodCallExpression, nextCall) == null) return null;
|
||||
PsiExpressionList argumentList = (nextCall).getArgumentList();
|
||||
PsiExpression[] expressions = argumentList.getExpressions();
|
||||
if(expressions.length == 0) {
|
||||
if (!nextName.equals("boxed") && !nextName.equals("asLongStream") && !nextName.equals("asDoubleStream")) return null;
|
||||
return nextCall;
|
||||
}
|
||||
if (expressions.length != 1 || !isSupportedForConversion(expressions[0], false)) return null;
|
||||
|
||||
return nextCall;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate name of joint method call which combines two given calls
|
||||
*
|
||||
* @param prevCall previous call (assumed to be in MAP_METHODS)
|
||||
* @param nextCall next call (assumed to be in NEXT_METHODS)
|
||||
* @return a name of the resulting method
|
||||
*/
|
||||
@Nullable
|
||||
private static String translateName(@NotNull PsiMethodCallExpression prevCall, @NotNull PsiMethodCallExpression nextCall) {
|
||||
PsiMethod nextMethod = nextCall.resolveMethod();
|
||||
if (nextMethod == null) return null;
|
||||
String nextName = nextMethod.getName();
|
||||
PsiMethod method = prevCall.resolveMethod();
|
||||
if (method == null) return null;
|
||||
PsiClass prevClass = method.getContainingClass();
|
||||
if (prevClass == null) return null;
|
||||
String prevClassName = prevClass.getQualifiedName();
|
||||
if (prevClassName == null) return null;
|
||||
String prevName = method.getName();
|
||||
if (nextName.endsWith("Match") || nextName.startsWith("forEach")) return nextName;
|
||||
if (nextName.equals("map")) {
|
||||
return translateMap(prevName);
|
||||
}
|
||||
if (prevName.equals("map")) {
|
||||
return translateMap(nextName);
|
||||
}
|
||||
if(MAP_METHODS.contains(nextName)) {
|
||||
PsiType type = nextMethod.getReturnType();
|
||||
if(!(type instanceof PsiClassType)) return null;
|
||||
PsiClass nextClass = ((PsiClassType)type).resolve();
|
||||
if(nextClass == null) return null;
|
||||
String nextClassName = nextClass.getQualifiedName();
|
||||
if(nextClassName == null) return null;
|
||||
if(prevClassName.equals(nextClassName)) return "map";
|
||||
switch(nextClassName) {
|
||||
case CommonClassNames.JAVA_UTIL_STREAM_INT_STREAM:
|
||||
return "mapToInt";
|
||||
case CommonClassNames.JAVA_UTIL_STREAM_LONG_STREAM:
|
||||
return "mapToLong";
|
||||
case CommonClassNames.JAVA_UTIL_STREAM_DOUBLE_STREAM:
|
||||
return "mapToDouble";
|
||||
case CommonClassNames.JAVA_UTIL_STREAM_STREAM:
|
||||
return "mapToObj";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if(nextName.equals("flatMap") && prevClassName.equals(CommonClassNames.JAVA_UTIL_STREAM_STREAM)) {
|
||||
String mapMethod = translateMap(prevName);
|
||||
return "flatM"+mapMethod.substring(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String translateMap(String nextMethod) {
|
||||
switch (nextMethod) {
|
||||
case "boxed":
|
||||
return "mapToObj";
|
||||
case "asLongStream":
|
||||
return "mapToLong";
|
||||
case "asDoubleStream":
|
||||
return "mapToDouble";
|
||||
default:
|
||||
return nextMethod;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getFamilyName() {
|
||||
return CodeInsightBundle.message("intention.inline.map.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
|
||||
PsiMethodCallExpression mapCall = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class);
|
||||
if(mapCall == null) return;
|
||||
|
||||
PsiMethodCallExpression nextCall = getNextExpressionToMerge(mapCall);
|
||||
if(nextCall == null) return;
|
||||
|
||||
PsiExpression nextQualifier = nextCall.getMethodExpression().getQualifierExpression();
|
||||
if(nextQualifier == null) return;
|
||||
|
||||
String newName = translateName(mapCall, nextCall);
|
||||
if(newName == null) return;
|
||||
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(element)) return;
|
||||
|
||||
PsiLambdaExpression previousLambda = getLambda(mapCall);
|
||||
|
||||
LOG.assertTrue(previousLambda != null);
|
||||
PsiExpression previousBody = LambdaUtil.extractSingleExpressionFromBody(previousLambda.getBody());
|
||||
LOG.assertTrue(previousBody != null);
|
||||
|
||||
PsiLambdaExpression lambda = getLambda(nextCall);
|
||||
LOG.assertTrue(lambda != null);
|
||||
|
||||
if(!lambda.isPhysical()) {
|
||||
lambda = (PsiLambdaExpression)nextCall.getArgumentList().add(lambda);
|
||||
}
|
||||
PsiElement body = lambda.getBody();
|
||||
LOG.assertTrue(body != null);
|
||||
|
||||
PsiParameter[] nextParameters = lambda.getParameterList().getParameters();
|
||||
LOG.assertTrue(nextParameters.length == 1);
|
||||
PsiParameter[] prevParameters = previousLambda.getParameterList().getParameters();
|
||||
LOG.assertTrue(prevParameters.length == 1);
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
|
||||
for(PsiReference ref : ReferencesSearch.search(nextParameters[0], new LocalSearchScope(body)).findAll()) {
|
||||
PsiElement e = ref.getElement();
|
||||
PsiExpression replacement = previousBody;
|
||||
if (e.getParent() instanceof PsiExpression &&
|
||||
ParenthesesUtils.areParenthesesNeeded(previousBody, (PsiExpression)e.getParent(), false)) {
|
||||
replacement = factory.createExpressionFromText("(a)", e);
|
||||
PsiExpression parenthesized = ((PsiParenthesizedExpression)replacement).getExpression();
|
||||
LOG.assertTrue(parenthesized != null);
|
||||
parenthesized.replace(previousBody);
|
||||
}
|
||||
e.replace(replacement);
|
||||
}
|
||||
nextParameters[0].replace(prevParameters[0]);
|
||||
PsiElement nameElement = nextCall.getMethodExpression().getReferenceNameElement();
|
||||
if(nameElement != null && !nameElement.getText().equals(newName)) {
|
||||
nameElement.replace(factory.createIdentifier(newName));
|
||||
}
|
||||
PsiExpression prevQualifier = mapCall.getMethodExpression().getQualifierExpression();
|
||||
if(prevQualifier == null) {
|
||||
nextQualifier.delete();
|
||||
} else {
|
||||
nextQualifier.replace(prevQualifier);
|
||||
}
|
||||
CodeStyleManager.getInstance(project).reformat(lambda);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PsiLambdaExpression getLambda(PsiMethodCallExpression call) {
|
||||
PsiExpression[] expressions = call.getArgumentList().getExpressions();
|
||||
if(expressions.length == 1) {
|
||||
PsiExpression expression = expressions[0];
|
||||
if(expression instanceof PsiLambdaExpression) return (PsiLambdaExpression)expression;
|
||||
if(expression instanceof PsiMethodReferenceExpression) {
|
||||
return LambdaRefactoringUtil.convertMethodReferenceToLambda((PsiMethodReferenceExpression)expression, false, true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if(expressions.length != 0) return null;
|
||||
PsiMethod method = call.resolveMethod();
|
||||
if(method == null) return null;
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
if(containingClass == null) return null;
|
||||
String className = containingClass.getQualifiedName();
|
||||
if(className == null) return null;
|
||||
String varName;
|
||||
String type;
|
||||
switch (className) {
|
||||
case CommonClassNames.JAVA_UTIL_STREAM_INT_STREAM:
|
||||
varName = "i";
|
||||
type = CommonClassNames.JAVA_LANG_INTEGER;
|
||||
break;
|
||||
case CommonClassNames.JAVA_UTIL_STREAM_LONG_STREAM:
|
||||
varName = "l";
|
||||
type = CommonClassNames.JAVA_LANG_LONG;
|
||||
break;
|
||||
case CommonClassNames.JAVA_UTIL_STREAM_DOUBLE_STREAM:
|
||||
varName = "d";
|
||||
type = CommonClassNames.JAVA_LANG_DOUBLE;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
varName = JavaCodeStyleManager.getInstance(call.getProject()).suggestUniqueVariableName(varName, call, true);
|
||||
String expression;
|
||||
if("boxed".equals(method.getName())) {
|
||||
expression = varName+" -> ("+type+")"+varName;
|
||||
} else if("asLongStream".equals(method.getName())) {
|
||||
expression = varName+" -> (long)"+varName;
|
||||
} else if("asDoubleStream".equals(method.getName())) {
|
||||
expression = varName+" -> (double)"+varName;
|
||||
} else return null;
|
||||
PsiElementFactory factory = JavaPsiFacade.getElementFactory(call.getProject());
|
||||
return (PsiLambdaExpression)factory.createExpressionFromText(expression, call);
|
||||
}
|
||||
}
|
||||
@@ -219,30 +219,27 @@ public class JavaQualifiedNameProvider implements QualifiedNameProvider {
|
||||
final PsiExpression expression;
|
||||
try {
|
||||
expression = factory.createExpressionFromText(toInsert + suffix, elementAtCaret);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
return;
|
||||
}
|
||||
final PsiReferenceExpression referenceExpression = expression instanceof PsiMethodCallExpression
|
||||
? ((PsiMethodCallExpression)expression).getMethodExpression()
|
||||
: expression instanceof PsiReferenceExpression
|
||||
? (PsiReferenceExpression)expression
|
||||
: null;
|
||||
if (referenceExpression == null || !referenceExpression.isValid()) {
|
||||
toInsert = fqn;
|
||||
}
|
||||
else if (!isReferencedTo(referenceExpression, targetElement)) {
|
||||
try {
|
||||
referenceExpression.bindToElement(targetElement);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
// failed to bind
|
||||
}
|
||||
if (!referenceExpression.isValid() || !isReferencedTo(referenceExpression, targetElement)) {
|
||||
final PsiReferenceExpression referenceExpression = expression instanceof PsiMethodCallExpression
|
||||
? ((PsiMethodCallExpression)expression).getMethodExpression()
|
||||
: expression instanceof PsiReferenceExpression
|
||||
? (PsiReferenceExpression)expression
|
||||
: null;
|
||||
if (referenceExpression == null || !referenceExpression.isValid()) {
|
||||
toInsert = fqn;
|
||||
}
|
||||
else if (!isReferencedTo(referenceExpression, targetElement)) {
|
||||
try {
|
||||
referenceExpression.bindToElement(targetElement);
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
// failed to bind
|
||||
}
|
||||
if (!referenceExpression.isValid() || !isReferencedTo(referenceExpression, targetElement)) {
|
||||
toInsert = fqn;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IncorrectOperationException ignored) {}
|
||||
}
|
||||
if (toInsert == null) toInsert = "";
|
||||
|
||||
|
||||
+12
-12
@@ -699,8 +699,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
final PsiElement chosenAnchor =
|
||||
chooseAnchor(settings.isReplaceAllOccurrences(), hasWriteAccess, nonWrite, anchorStatementIfAll, anchorStatement);
|
||||
|
||||
variable = ApplicationManager.getApplication().runWriteAction(
|
||||
introduce(project, expr, topLevelEditor, chosenAnchor, occurrences, settings));
|
||||
variable = introduce(project, expr, topLevelEditor, chosenAnchor, occurrences, settings);
|
||||
}
|
||||
finally {
|
||||
final RefactoringEventData afterData = new RefactoringEventData();
|
||||
@@ -794,12 +793,12 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
return parent3 instanceof JspHolderMethod;
|
||||
}
|
||||
|
||||
public static Computable<PsiVariable> introduce(final Project project,
|
||||
final PsiExpression expr,
|
||||
final Editor editor,
|
||||
final PsiElement anchorStatement,
|
||||
final PsiExpression[] occurrences,
|
||||
final IntroduceVariableSettings settings) {
|
||||
public static PsiVariable introduce(final Project project,
|
||||
final PsiExpression expr,
|
||||
final Editor editor,
|
||||
final PsiElement anchorStatement,
|
||||
final PsiExpression[] occurrences,
|
||||
final IntroduceVariableSettings settings) {
|
||||
final PsiElement container = anchorStatement.getParent();
|
||||
PsiElement child = anchorStatement;
|
||||
final boolean isInsideLoop = RefactoringUtil.isLoopOrIf(container);
|
||||
@@ -841,9 +840,9 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
|
||||
final PsiCodeBlock newDeclarationScope = PsiTreeUtil.getParentOfType(container, PsiCodeBlock.class, false);
|
||||
final FieldConflictsResolver fieldConflictsResolver = new FieldConflictsResolver(settings.getEnteredName(), newDeclarationScope);
|
||||
return new Computable<PsiVariable>() {
|
||||
SmartPsiElementPointer<PsiVariable> pointer = ApplicationManager.getApplication().runWriteAction(new Computable<SmartPsiElementPointer<PsiVariable>> () {
|
||||
@Override
|
||||
public PsiVariable compute() {
|
||||
public SmartPsiElementPointer<PsiVariable> compute() {
|
||||
try {
|
||||
PsiStatement statement = null;
|
||||
if (!isInsideLoop && deleteSelf) {
|
||||
@@ -913,7 +912,7 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
PsiVariable var = (PsiVariable) declaration.getDeclaredElements()[0];
|
||||
PsiUtil.setModifierProperty(var, PsiModifier.FINAL, settings.isDeclareFinal());
|
||||
fieldConflictsResolver.fix();
|
||||
return var;
|
||||
return SmartPointerManager.getInstance(project).createSmartPsiElementPointer(var);
|
||||
} catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
@@ -945,7 +944,8 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
|
||||
}
|
||||
return (PsiDeclarationStatement) container.addBefore(declaration, anchor);
|
||||
}
|
||||
};
|
||||
});
|
||||
return pointer != null ? pointer.getElement() : null;
|
||||
}
|
||||
|
||||
private static PsiType stripNullabilityAnnotationsFromTargetType(SmartTypePointer selectedType, final Project project) {
|
||||
|
||||
+11
-6
@@ -395,10 +395,19 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
|
||||
@Override
|
||||
protected PsiVariable createFieldToStartTemplateOn(String[] names, PsiType psiType) {
|
||||
final PsiVariable variable = ApplicationManager.getApplication().runWriteAction(
|
||||
IntroduceVariableBase.introduce(myProject, myExpr, myEditor, myChosenAnchor.getElement(), getOccurrences(), mySettings));
|
||||
PsiVariable variable = IntroduceVariableBase.introduce(myProject, myExpr, myEditor, myChosenAnchor.getElement(), getOccurrences(), mySettings);
|
||||
final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(variable, PsiDeclarationStatement.class);
|
||||
myPointer = declarationStatement != null ? SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(declarationStatement) : null;
|
||||
myEditor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
|
||||
setAdvertisementText(getAdvertisementText(declarationStatement, variable.getType(), myHasTypeSuggestion));
|
||||
|
||||
PsiDocumentManager.getInstance(myProject).doPostponedOperationsAndUnblockDocument(myEditor.getDocument());
|
||||
|
||||
final PsiVariable restoredVar = getVariable();
|
||||
if (restoredVar != null) {
|
||||
variable = restoredVar;
|
||||
}
|
||||
|
||||
if (isReplaceAllOccurrences()) {
|
||||
List<RangeMarker> occurrences = new ArrayList<>();
|
||||
ReferencesSearch.search(variable).forEach(reference -> {
|
||||
@@ -407,10 +416,6 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
setOccurrenceMarkers(occurrences);
|
||||
}
|
||||
|
||||
final PsiDeclarationStatement declarationStatement = PsiTreeUtil.getParentOfType(variable, PsiDeclarationStatement.class);
|
||||
myPointer = declarationStatement != null ? SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(declarationStatement) : null;
|
||||
myEditor.putUserData(ReassignVariableUtil.DECLARATION_KEY, myPointer);
|
||||
setAdvertisementText(getAdvertisementText(declarationStatement, variable.getType(), myHasTypeSuggestion));
|
||||
final PsiIdentifier identifier = variable.getNameIdentifier();
|
||||
if (identifier != null) {
|
||||
myEditor.getCaretModel().moveToOffset(identifier.getTextOffset());
|
||||
|
||||
Reference in New Issue
Block a user