mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[r=nik] no comma/semicolon/whatever when no closing bracket is inserted (IDEA-62725, IDEA-58920)
This commit is contained in:
+8
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.CodeInsightUtilBase;
|
||||
import com.intellij.codeInsight.ExpectedTypeInfo;
|
||||
import com.intellij.codeInsight.TailType;
|
||||
@@ -57,10 +58,15 @@ public class SmartCompletionDecorator extends TailTypeDecorator<LookupElement> {
|
||||
return defType;
|
||||
}
|
||||
|
||||
final PsiExpression enclosing = PsiTreeUtil.getContextOfType(myPosition, PsiExpression.class, true);
|
||||
LookupElement item = getDelegate();
|
||||
Object object = item.getObject();
|
||||
if (!CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET && (object instanceof PsiMethod || object instanceof PsiClass)) {
|
||||
return TailType.NONE;
|
||||
}
|
||||
|
||||
if (enclosing != null && item.getObject() instanceof PsiElement) {
|
||||
final PsiExpression enclosing = PsiTreeUtil.getContextOfType(myPosition, PsiExpression.class, true);
|
||||
|
||||
if (enclosing != null && object instanceof PsiElement) {
|
||||
final PsiType type = getItemType(item);
|
||||
final TailType itemType = item instanceof LookupItem ? ((LookupItem)item).getTailType() : TailType.NONE;
|
||||
TailType cached = itemType;
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
{
|
||||
String c = new String(<caret>
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A {
|
||||
{
|
||||
String c = new Stri<caret>
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class A {
|
||||
{
|
||||
String x;
|
||||
Class c = x.getClass(<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class A {
|
||||
{
|
||||
String x;
|
||||
Class c = x.getCl<caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
{
|
||||
Class c = this.xxxxx(<caret>
|
||||
}
|
||||
|
||||
Class xxxxx() {}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
{
|
||||
Class c = this.xx<caret>
|
||||
}
|
||||
|
||||
Class xxxxx() {}
|
||||
}
|
||||
+23
@@ -477,6 +477,29 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
public void testSameNamedFieldAndLocal() throws Throwable { doTest(); }
|
||||
|
||||
public void testNoTailWhenNoPairBracket() throws Throwable {
|
||||
doTestNoPairBracket();
|
||||
}
|
||||
|
||||
public void testNoTailWhenNoPairBracket2() throws Throwable {
|
||||
doTestNoPairBracket();
|
||||
}
|
||||
|
||||
private void doTestNoPairBracket() throws Exception {
|
||||
boolean old = CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET;
|
||||
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = false;
|
||||
try {
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
CodeInsightSettings.getInstance().AUTOINSERT_PAIR_BRACKET = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void testNoConstructorTailWhenNoPairBracket() throws Throwable {
|
||||
doTestNoPairBracket();
|
||||
}
|
||||
|
||||
public void testAbstractClassTwice() throws Throwable {
|
||||
configureByTestName();
|
||||
assertOneElement(myItems);
|
||||
|
||||
Reference in New Issue
Block a user