mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
select a literal if its whole content is selected but quotes are skipped
This commit is contained in:
+20
-1
@@ -53,6 +53,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrContinueSta
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnStatement;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrCaseSection;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter;
|
||||
@@ -65,6 +66,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeArgumentList;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.util.GrStatementOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.api.util.GrVariableDeclarationOwner;
|
||||
import org.jetbrains.plugins.groovy.lang.psi.impl.PsiImplUtil;
|
||||
import org.jetbrains.plugins.groovy.refactoring.introduce.StringPartInfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -105,12 +107,29 @@ public abstract class GroovyRefactoringUtil {
|
||||
final PsiElement commonParent = PsiTreeUtil.findCommonParent(element1, element2);
|
||||
assert commonParent != null;
|
||||
final T element = ReflectionUtil.isAssignable(klass, commonParent.getClass()) ? (T) commonParent : PsiTreeUtil.getParentOfType(commonParent, klass);
|
||||
if (element == null || element.getTextRange().getStartOffset() != startOffset) {
|
||||
if (element == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!checkRanges(element, startOffset, endOffset)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private static boolean checkRanges(@NotNull PsiElement element, int startOffset, int endOffset) {
|
||||
if (element instanceof GrLiteral && StringPartInfo.isWholeLiteralContentSelected((GrLiteral)element, startOffset, endOffset)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (element.getTextRange().getStartOffset() == startOffset) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static PsiElement[] getExpressionOccurrences(@NotNull PsiElement expr, @NotNull PsiElement scope) {
|
||||
ArrayList<PsiElement> occurrences = new ArrayList<PsiElement>();
|
||||
Comparator<PsiElement> comparator = new Comparator<PsiElement>() {
|
||||
|
||||
Reference in New Issue
Block a user