mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
don't add annotation attribute braces when typing comma inside string (IDEA-177182)
This commit is contained in:
@@ -194,7 +194,7 @@ public class JavaTypedHandler extends TypedHandlerDelegate {
|
||||
int caret = editor.getCaretModel().getOffset();
|
||||
if (mightBeInsideDefaultAnnotationAttribute(editor, caret - 2)) {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
PsiAnnotation anno = PsiTreeUtil.findElementOfClassAtOffset(file, caret, PsiAnnotation.class, false);
|
||||
PsiAnnotation anno = PsiTreeUtil.getParentOfType(file.findElementAt(caret), PsiAnnotation.class, false, PsiExpression.class, PsiComment.class);
|
||||
PsiNameValuePair attr = anno == null ? null : getTheOnlyDefaultAttribute(anno);
|
||||
if (attr != null && hasDefaultArrayMethod(anno) && !(attr.getValue() instanceof PsiArrayInitializerMemberValue)) {
|
||||
editor.getDocument().insertString(caret, "}");
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
public @interface Category {
|
||||
String[] value();
|
||||
}
|
||||
@Category("foo,<caret>")
|
||||
@@ -0,0 +1,4 @@
|
||||
public @interface Category {
|
||||
String[] value();
|
||||
}
|
||||
@Category("foo<caret>")
|
||||
@@ -114,6 +114,8 @@ public class JavaTypingTest extends LightPlatformCodeInsightFixtureTestCase {
|
||||
doTest(',');
|
||||
}
|
||||
|
||||
public void testCommaInDefaultAnnotationStringArgumentWhenArrayIsExpected() { doTest(','); }
|
||||
|
||||
private void doTest(char c) {
|
||||
myFixture.configureByFile(getTestName(true) + "_before.java");
|
||||
myFixture.type(c);
|
||||
|
||||
Reference in New Issue
Block a user