mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-39079 groovy Inline: current editor does not contain all usages
This commit is contained in:
+23
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -119,16 +119,15 @@ public class GroovyMethodInliner implements InlineHandler.Inliner {
|
||||
PsiElement element=usage.getElement();
|
||||
|
||||
assert element instanceof GrExpression && element.getParent() instanceof GrCallExpression;
|
||||
|
||||
final Editor editor = getCurrentEditorIfApplicable(element);
|
||||
|
||||
GrCallExpression call = (GrCallExpression) element.getParent();
|
||||
RangeMarker marker = inlineReferenceImpl(call, myMethod, isOnExpressionOrReturnPlace(call), GroovyInlineMethodUtil.isTailMethodCall(call));
|
||||
RangeMarker marker = inlineReferenceImpl(call, myMethod, isOnExpressionOrReturnPlace(call), GroovyInlineMethodUtil.isTailMethodCall(call), editor);
|
||||
|
||||
// highlight replaced result
|
||||
if (marker != null) {
|
||||
Project project = referenced.getProject();
|
||||
FileEditorManager manager = FileEditorManager.getInstance(project);
|
||||
Editor editor = manager.getSelectedTextEditor();
|
||||
|
||||
//GroovyRefactoringUtil.highlightOccurrences(myProject, editor, new PsiElement[]{pointer.getElement()});
|
||||
TextRange range = TextRange.create(marker);
|
||||
GroovyRefactoringUtil.highlightOccurrencesByRanges(project, editor, new TextRange[]{range});
|
||||
|
||||
@@ -139,14 +138,28 @@ public class GroovyMethodInliner implements InlineHandler.Inliner {
|
||||
}
|
||||
}
|
||||
|
||||
static RangeMarker inlineReferenceImpl(GrCallExpression call, GrMethod method, boolean resultOfCallExplicitlyUsed, boolean isTailMethodCall) {
|
||||
@Nullable
|
||||
private static Editor getCurrentEditorIfApplicable(PsiElement element) {
|
||||
final Project project = element.getProject();
|
||||
final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
|
||||
|
||||
if (editor != null &&
|
||||
editor.getDocument() == PsiDocumentManager.getInstance(project).getDocument(element.getContainingFile())) {
|
||||
return editor;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static RangeMarker inlineReferenceImpl(GrCallExpression call,
|
||||
GrMethod method,
|
||||
boolean resultOfCallExplicitlyUsed,
|
||||
boolean isTailMethodCall,
|
||||
Editor editor) {
|
||||
try {
|
||||
GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(call.getProject());
|
||||
final Project project = call.getProject();
|
||||
|
||||
FileEditorManager manager = FileEditorManager.getInstance(project);
|
||||
Editor editor = manager.getSelectedTextEditor();
|
||||
|
||||
// Variable declaration for qualifier expression
|
||||
GrVariableDeclaration qualifierDeclaration = null;
|
||||
GrReferenceExpression innerQualifier = null;
|
||||
|
||||
Reference in New Issue
Block a user