mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: avoid IAE on Introduce Variable (IDEA-369326)
GitOrigin-RevId: 9fa79fc70578d8ff14bda2051341b6d22ece6677
This commit is contained in:
committed by
intellij-monorepo-bot
parent
33d037c1fd
commit
35aab21776
+13
@@ -35,6 +35,7 @@ import com.intellij.psi.util.TypeConversionUtil;
|
||||
import com.intellij.refactoring.AbstractJavaInplaceIntroducer;
|
||||
import com.intellij.refactoring.IntroduceVariableUtil;
|
||||
import com.intellij.refactoring.RefactoringActionHandler;
|
||||
import com.intellij.refactoring.introduceField.ElementToWorkOn;
|
||||
import com.intellij.refactoring.rename.ResolveSnapshotProvider;
|
||||
import com.intellij.refactoring.rename.inplace.SelectableInlayPresentation;
|
||||
import com.intellij.refactoring.rename.inplace.TemplateInlayUtil;
|
||||
@@ -138,6 +139,18 @@ public class JavaVariableInplaceIntroducer extends AbstractJavaInplaceIntroducer
|
||||
super.restoreState(psiField);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RangeMarker createMarker(PsiElement element) {
|
||||
int length = myEditor.getDocument().getTextLength();
|
||||
if (element.getTextRange().getEndOffset() > length) {
|
||||
RangeMarker marker = ElementToWorkOn.TEXT_RANGE.get(element);
|
||||
if (marker != null) {
|
||||
return marker;
|
||||
}
|
||||
}
|
||||
return super.createMarker(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean ensureValid() {
|
||||
final PsiVariable variable = getVariable();
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
public class GraphQLIntrospectionQuery {
|
||||
|
||||
String INTROSPECTION_QUERY = <selection>"fragment TypeRef on __Type {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n"</selection>;}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
public class GraphQLIntrospectionQuery {
|
||||
|
||||
String INTROSPECTION_QUERY;
|
||||
|
||||
{
|
||||
String s = "fragment TypeRef on __Type {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" ofType {\n" +
|
||||
" kind\n" +
|
||||
" name\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"\n";
|
||||
INTROSPECTION_QUERY = s;
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.refactoring;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
@@ -348,6 +348,10 @@ public class InplaceIntroduceVariableTest extends AbstractJavaInplaceIntroduceTe
|
||||
public void testNoExternalTypeAnnotations() {
|
||||
doTest(null);
|
||||
}
|
||||
|
||||
public void testNoIllegalArgumentException() {
|
||||
doTest(null);
|
||||
}
|
||||
|
||||
public void testSplitMutuallyExclusiveIf() { doTestReplaceChoice("Replace all 0 occurrences"); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user