mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
postfix template fix ternary operator + test
This commit is contained in:
+11
-5
@@ -426,7 +426,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
if (JavaCompletionData.isAfterPrimitiveOrArrayType(position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -466,11 +466,11 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
|
||||
methods: for (PsiMethod method : annoClass.getMethods()) {
|
||||
if (!(method instanceof PsiAnnotationMethod)) continue;
|
||||
|
||||
|
||||
final String attrName = method.getName();
|
||||
for (PsiNameValuePair existingAttr : existingPairs) {
|
||||
if (PsiTreeUtil.isAncestor(existingAttr, insertedElement, false)) break;
|
||||
if (Comparing.equal(existingAttr.getName(), attrName) ||
|
||||
if (Comparing.equal(existingAttr.getName(), attrName) ||
|
||||
PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME.equals(attrName) && existingAttr.getName() == null) continue methods;
|
||||
}
|
||||
LookupElementBuilder element = LookupElementBuilder.createWithIcon(method).withInsertHandler(new InsertHandler<LookupElement>() {
|
||||
@@ -479,7 +479,7 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
final Editor editor = context.getEditor();
|
||||
TailType.EQ.processTail(editor, editor.getCaretModel().getOffset());
|
||||
context.setAddCompletionChar(false);
|
||||
|
||||
|
||||
context.commitDocument();
|
||||
PsiAnnotationParameterList paramList =
|
||||
PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), context.getStartOffset(), PsiAnnotationParameterList.class, false);
|
||||
@@ -702,7 +702,13 @@ public class JavaCompletionContributor extends CompletionContributor {
|
||||
iterator.advance();
|
||||
}
|
||||
|
||||
if (!iterator.atEnd() && (iterator.getTokenType() == JavaTokenType.LPARENTH || iterator.getTokenType() == JavaTokenType.COLON)) {
|
||||
if (!iterator.atEnd() && (iterator.getTokenType() == JavaTokenType.LPARENTH)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!iterator.atEnd()
|
||||
&& (iterator.getTokenType() == JavaTokenType.COLON)
|
||||
&& null == PsiTreeUtil.findElementOfClassAtOffset(file, startOffset, PsiConditionalExpression.class, false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m(String s) {
|
||||
Object o = s.isEmpty() ? s.concat("a").cast<caret> : s.concat("b");
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
void m(String s) {
|
||||
Object o = s.isEmpty() ? (() s.concat("a")) : s.concat("b");
|
||||
}
|
||||
}
|
||||
+3
@@ -43,4 +43,7 @@ public class CastPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
public void testChainCall() {
|
||||
doTest();
|
||||
}
|
||||
public void testTernary() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user