mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
util
This commit is contained in:
+2
-2
@@ -197,8 +197,8 @@ public abstract class GroovyRefactoringUtil {
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isLocalVariable(GrVariable variable) {
|
||||
return !(variable instanceof GrField || variable instanceof GrParameter);
|
||||
public static boolean isLocalVariable(PsiElement variable) {
|
||||
return variable instanceof GrVariable && !(variable instanceof GrField || variable instanceof GrParameter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-2
@@ -210,8 +210,7 @@ public class ExtractUtil {
|
||||
@Override
|
||||
public void visitReferenceExpression(GrReferenceExpression ref) {
|
||||
final PsiElement resolved = ref.resolve();
|
||||
if ((resolved instanceof GrParameter ||
|
||||
resolved instanceof GrVariable && GroovyRefactoringUtil.isLocalVariable((GrVariable)resolved)) && resolved.isPhysical()) {
|
||||
if ((resolved instanceof GrParameter || GroovyRefactoringUtil.isLocalVariable(resolved)) && resolved.isPhysical()) {
|
||||
final int offset = resolved.getTextRange().getStartOffset();
|
||||
//var is declared outside of selected code
|
||||
if (offset < start || end <= offset) {
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class GroovyInlineLocalHandler extends InlineActionHandler {
|
||||
|
||||
@Override
|
||||
public boolean canInlineElement(PsiElement element) {
|
||||
return element instanceof GrVariable && GroovyRefactoringUtil.isLocalVariable((GrVariable)element);
|
||||
return GroovyRefactoringUtil.isLocalVariable(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+5
-9
@@ -332,10 +332,8 @@ public class GrIntroduceFieldDialog extends DialogWrapper implements GrIntroduce
|
||||
private static String getInvokedOnLocalVar(GrExpression expression) {
|
||||
if (expression instanceof GrReferenceExpression) {
|
||||
final PsiElement resolved = ((GrReferenceExpression)expression).resolve();
|
||||
if (resolved instanceof GrVariable) {
|
||||
if (GroovyRefactoringUtil.isLocalVariable((GrVariable)resolved)) {
|
||||
return ((GrVariable)resolved).getName();
|
||||
}
|
||||
if (GroovyRefactoringUtil.isLocalVariable(resolved)) {
|
||||
return ((GrVariable)resolved).getName();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -348,11 +346,9 @@ public class GrIntroduceFieldDialog extends DialogWrapper implements GrIntroduce
|
||||
|
||||
if (expression instanceof GrReferenceExpression) {
|
||||
final PsiElement resolved = ((GrReferenceExpression)expression).resolve();
|
||||
if (resolved instanceof GrVariable) {
|
||||
if (GroovyRefactoringUtil.isLocalVariable((GrVariable)resolved)) {
|
||||
expression = ((GrVariable)resolved).getInitializerGroovy();
|
||||
if (expression == null) return false;
|
||||
}
|
||||
if (GroovyRefactoringUtil.isLocalVariable(resolved)) {
|
||||
expression = ((GrVariable)resolved).getInitializerGroovy();
|
||||
if (expression == null) return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user