mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
wildcards and arrays inside generics pairs (IDEA-COMMUNITY-CR-664)
This commit is contained in:
+8
-3
@@ -23,8 +23,15 @@ import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.impl.source.tree.StdTokenSets;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
|
||||
public class JavaPairedBraceMatcher extends PairedBraceMatcherAdapter {
|
||||
private static final TokenSet TYPE_TOKENS =
|
||||
TokenSet.orSet(StdTokenSets.WHITE_SPACE_OR_COMMENT_BIT_SET,
|
||||
TokenSet.create(JavaTokenType.IDENTIFIER, JavaTokenType.COMMA,
|
||||
JavaTokenType.RBRACKET, JavaTokenType.LBRACKET, //arrays
|
||||
JavaTokenType.QUEST, JavaTokenType.EXTENDS_KEYWORD, JavaTokenType.SUPER_KEYWORD));//wildcards
|
||||
|
||||
public JavaPairedBraceMatcher() {
|
||||
super(new JavaBraceMatcher(), JavaLanguage.INSTANCE);
|
||||
}
|
||||
@@ -75,9 +82,7 @@ public class JavaPairedBraceMatcher extends PairedBraceMatcherAdapter {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!StdTokenSets.WHITE_SPACE_OR_COMMENT_BIT_SET.contains(tokenType) &&
|
||||
tokenType != JavaTokenType.IDENTIFIER &&
|
||||
tokenType != JavaTokenType.COMMA) {
|
||||
if (!TYPE_TOKENS.contains(tokenType)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,10 +24,10 @@ public class JavaBraceMatcherTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testGenerics() {
|
||||
myFixture.configureByText("a.java", "import java.util.ArrayList;" +
|
||||
"class A {" +
|
||||
" ArrayList<caret><String> f;" +
|
||||
" ArrayList<caret><? extends String[]> f;" +
|
||||
"}");
|
||||
final int offset = BraceMatchingUtil.getMatchedBraceOffset(myFixture.getEditor(), true, myFixture.getFile());
|
||||
assertTrue(offset == 54);
|
||||
assertEquals(66, offset);
|
||||
}
|
||||
|
||||
public void testBrokenText() {
|
||||
|
||||
Reference in New Issue
Block a user