diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java index 47e48e99547d..a2bce4d119d5 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java @@ -83,12 +83,13 @@ public class StatementParser { while (true) { final IElementType type = builder.getTokenType(); if (ElementType.PRIMITIVE_TYPE_BIT_SET.contains(type) || ElementType.MODIFIER_BIT_SET.contains(type) || - type == JavaTokenType.IDENTIFIER || type == JavaTokenType.LT || type == JavaTokenType.GT || + (type == JavaTokenType.IDENTIFIER && list.size() > 0) || type == JavaTokenType.LT || type == JavaTokenType.GT || type == JavaTokenType.GTGT || type == JavaTokenType.GTGTGT || type == JavaTokenType.COMMA || type == JavaTokenType.DOT || type == JavaTokenType.EXTENDS_KEYWORD || type == JavaTokenType.IMPLEMENTS_KEYWORD) { list.add(type); builder.advanceLexer(); - } else { + } + else { break; } } diff --git a/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors5.java b/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors5.java new file mode 100644 index 000000000000..a88db6b0fa53 --- /dev/null +++ b/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors5.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +private static class My extends JComponent { + private My(Map> param) { + setBorder(null); + param + list(); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors5.txt b/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors5.txt new file mode 100644 index 000000000000..93ee5111a400 --- /dev/null +++ b/java/java-tests/testData/psi/parser-full/declarationParsing/class/Errors5.txt @@ -0,0 +1,109 @@ +PsiJavaFile:Errors5.java + PsiImportList + + PsiClass:My + PsiComment(C_STYLE_COMMENT)('/*\n * Copyright 2000-2012 JetBrains s.r.o.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */') + PsiWhiteSpace('\n') + PsiModifierList:private static + PsiKeyword:private('private') + PsiWhiteSpace(' ') + PsiKeyword:static('static') + PsiWhiteSpace(' ') + PsiKeyword:class('class') + PsiWhiteSpace(' ') + PsiIdentifier:My('My') + PsiTypeParameterList + + PsiWhiteSpace(' ') + PsiReferenceList + PsiKeyword:extends('extends') + PsiWhiteSpace(' ') + PsiJavaCodeReferenceElement:JComponent + PsiIdentifier:JComponent('JComponent') + PsiReferenceParameterList + + PsiReferenceList + + PsiWhiteSpace(' ') + PsiJavaToken:LBRACE('{') + PsiWhiteSpace('\n ') + PsiMethod:My + PsiModifierList:private + PsiKeyword:private('private') + PsiTypeParameterList + + PsiWhiteSpace(' ') + PsiIdentifier:My('My') + PsiParameterList:(Map> param) + PsiJavaToken:LPARENTH('(') + PsiParameter:param + PsiModifierList: + + PsiTypeElement:Map> + PsiJavaCodeReferenceElement:Map> + PsiIdentifier:Map('Map') + PsiReferenceParameterList + PsiJavaToken:LT('<') + PsiTypeElement:String + PsiJavaCodeReferenceElement:String + PsiIdentifier:String('String') + PsiReferenceParameterList + + PsiJavaToken:COMMA(',') + PsiWhiteSpace(' ') + PsiTypeElement:List + PsiJavaCodeReferenceElement:List + PsiIdentifier:List('List') + PsiReferenceParameterList + PsiJavaToken:LT('<') + PsiTypeElement:Object + PsiJavaCodeReferenceElement:Object + PsiIdentifier:Object('Object') + PsiReferenceParameterList + + PsiJavaToken:GT('>') + PsiJavaToken:GT('>') + PsiWhiteSpace(' ') + PsiIdentifier:param('param') + PsiJavaToken:RPARENTH(')') + PsiReferenceList + + PsiWhiteSpace(' ') + PsiCodeBlock + PsiJavaToken:LBRACE('{') + PsiWhiteSpace('\n ') + PsiExpressionStatement + PsiMethodCallExpression:setBorder(null) + PsiReferenceExpression:setBorder + PsiReferenceParameterList + + PsiIdentifier:setBorder('setBorder') + PsiExpressionList + PsiJavaToken:LPARENTH('(') + PsiLiteralExpression:null + PsiJavaToken:NULL_KEYWORD('null') + PsiJavaToken:RPARENTH(')') + PsiJavaToken:SEMICOLON(';') + PsiWhiteSpace('\n ') + PsiExpressionStatement + PsiReferenceExpression:param + PsiReferenceParameterList + + PsiIdentifier:param('param') + PsiErrorElement:';' expected + + PsiWhiteSpace('\n ') + PsiExpressionStatement + PsiMethodCallExpression:list() + PsiReferenceExpression:list + PsiReferenceParameterList + + PsiIdentifier:list('list') + PsiExpressionList + PsiJavaToken:LPARENTH('(') + PsiJavaToken:RPARENTH(')') + PsiJavaToken:SEMICOLON(';') + PsiWhiteSpace('\n ') + PsiJavaToken:RBRACE('}') + PsiWhiteSpace('\n') + PsiJavaToken:RBRACE('}') \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/lang/java/parser/declarationParsing/ClassParsingTest.java b/java/java-tests/testSrc/com/intellij/lang/java/parser/declarationParsing/ClassParsingTest.java index ac6538d31d9c..bcc3b2504c01 100644 --- a/java/java-tests/testSrc/com/intellij/lang/java/parser/declarationParsing/ClassParsingTest.java +++ b/java/java-tests/testSrc/com/intellij/lang/java/parser/declarationParsing/ClassParsingTest.java @@ -1,9 +1,22 @@ - +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.lang.java.parser.declarationParsing; import com.intellij.lang.java.parser.JavaParsingTestCase; - public class ClassParsingTest extends JavaParsingTestCase { public ClassParsingTest() { super("parser-full/declarationParsing/class"); @@ -52,4 +65,6 @@ public class ClassParsingTest extends JavaParsingTestCase { myFileExt = ext; } } + + public void testErrors5() { doTest(true); } }