mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[^ann] IDEA-85010 Inner enum is completed incorrectly in method return type
This commit is contained in:
@@ -15,8 +15,10 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.lookup.*;
|
||||
import com.intellij.featureStatistics.FeatureUsageTracker;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupElementDecorator;
|
||||
import com.intellij.codeInsight.lookup.LookupElementPresentation;
|
||||
import com.intellij.codeInsight.lookup.TypedLookupItem;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.util.ClassConditionKey;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -97,8 +99,6 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.SECOND_SMART_COMPLETION_CHAIN);
|
||||
|
||||
final Document document = context.getEditor().getDocument();
|
||||
document.replaceString(context.getStartOffset(), context.getTailOffset(), ";");
|
||||
final InsertionContext qualifierContext = CompletionUtil.emulateInsertion(context, context.getStartOffset(), myQualifier);
|
||||
@@ -138,8 +138,11 @@ public class JavaChainLookupElement extends LookupElementDecorator<LookupElement
|
||||
last = element;
|
||||
element = element.getParent();
|
||||
}
|
||||
PsiExpression expr = PsiTreeUtil.getParentOfType(last, PsiExpression.class, false);
|
||||
if (expr == null || expr.getTextRange().getEndOffset() > endOffset) {
|
||||
PsiExpression expr = PsiTreeUtil.getParentOfType(last, PsiExpression.class, false, PsiClass.class);
|
||||
if (expr == null) {
|
||||
return false;
|
||||
}
|
||||
if (expr.getTextRange().getEndOffset() > endOffset) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -451,7 +451,13 @@ public class ReferenceExpressionCompletionContributor {
|
||||
final ElementFilter filter = getReferenceFilter(place, true);
|
||||
for (final LookupElement item : completeFinalReference(place, mockRef, filter, parameters)) {
|
||||
if (shouldChain(place, qualifierType, expectedType, item)) {
|
||||
result.consume(new JavaChainLookupElement(qualifierItem, item));
|
||||
result.consume(new JavaChainLookupElement(qualifierItem, item) {
|
||||
@Override
|
||||
public void handleInsert(InsertionContext context) {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed(JavaCompletionFeatures.SECOND_SMART_COMPLETION_CHAIN);
|
||||
super.handleInsert(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Bar3 {
|
||||
|
||||
protected abstract Response.Stat<caret>
|
||||
}
|
||||
class Goo {
|
||||
public static class Response {
|
||||
public enum Status {}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class Bar3 {
|
||||
{
|
||||
new Runnable() {
|
||||
protected abstract Response.Statu<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
class Goo {
|
||||
public static class Response {
|
||||
public enum Status {}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class Bar3 {
|
||||
{
|
||||
new Runnable() {
|
||||
protected abstract Goo.Response.Status<caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
class Goo {
|
||||
public static class Response {
|
||||
public enum Status {}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class Bar3 {
|
||||
|
||||
protected abstract Goo.Response.Status<caret>
|
||||
}
|
||||
class Goo {
|
||||
public static class Response {
|
||||
public enum Status {}
|
||||
}
|
||||
}
|
||||
+2
@@ -1320,6 +1320,7 @@ public class ListUtils {
|
||||
public void testListArrayListCast() { doTest('\n') }
|
||||
public void testInterfaceImplementationNoCast() { doTest() }
|
||||
public void testStaticallyImportedMethodsBeforeExpression() { doTest() }
|
||||
public void testInnerChainedReturnType() { doTest() }
|
||||
|
||||
private CommonCodeStyleSettings getCodeStyleSettings() {
|
||||
return CodeStyleSettingsManager.getSettings(getProject()).getCommonSettings(JavaLanguage.INSTANCE);
|
||||
@@ -1330,4 +1331,5 @@ public class ListUtils {
|
||||
assert myFixture.lookupElementStrings.containsAll(['foo', 'bar'])
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user