diff --git a/smalidea/src/main/antlr3/smalideaParser.g b/smalidea/src/main/antlr3/smalideaParser.g index f6695bd3..2501f5f0 100644 --- a/smalidea/src/main/antlr3/smalideaParser.g +++ b/smalidea/src/main/antlr3/smalideaParser.g @@ -331,6 +331,11 @@ method end_method_directive : END_METHOD_DIRECTIVE; +catch [RecognitionException re] { + Marker errorMarker = mark(); + recover(input, re); + reportError(errorMarker, re, false); + } statements_and_directives : ( diff --git a/smalidea/src/test/java/org/jf/smalidea/ParserTest.java b/smalidea/src/test/java/org/jf/smalidea/ParserTest.java index 225cc8b9..5d584c55 100644 --- a/smalidea/src/test/java/org/jf/smalidea/ParserTest.java +++ b/smalidea/src/test/java/org/jf/smalidea/ParserTest.java @@ -56,4 +56,5 @@ public class ParserTest extends LightCodeInsightParsingTestCase { public void testSuperClassInvalidSyntax2() throws Exception { doTest(true); } public void testInvalidMethod() throws Exception { doTest(true); } public void testInvalidMethod2() throws Exception { doTest(true); } + public void testInvalidMethod3() throws Exception { doTest(true); } } diff --git a/smalidea/testData/InvalidMethod3.smalidea b/smalidea/testData/InvalidMethod3.smalidea new file mode 100644 index 00000000..24e66b6f --- /dev/null +++ b/smalidea/testData/InvalidMethod3.smalidea @@ -0,0 +1,11 @@ +.method blah()V +.end + + + +.method return-object()V +.registers 0 + + + +.method \ No newline at end of file diff --git a/smalidea/testData/InvalidMethod3.txt b/smalidea/testData/InvalidMethod3.txt new file mode 100644 index 00000000..ce143718 --- /dev/null +++ b/smalidea/testData/InvalidMethod3.txt @@ -0,0 +1,63 @@ +smali.FILE + SmaliClass(CLASS) + SmaliExtendsList(EXTENDS_LIST) + + SmaliImplementsList(IMPLEMENTS_LIST) + + SmaliMethod(METHOD) + SmaliThrowsList(THROWS_LIST) + + PsiElement(METHOD_DIRECTIVE)('.method') + PsiWhiteSpace(' ') + SmaliModifierList(MODIFIER_LIST) + + PsiElement(MEMBER_NAME) + PsiElement(SIMPLE_NAME)('blah') + SmaliMethodPrototype(METHOD_PROTOTYPE) + PsiElement(OPEN_PAREN)('(') + SmaliMethodParamList(METHOD_PARAM_LIST) + + PsiElement(CLOSE_PAREN)(')') + PsiElement(VOID_TYPE) + PsiElement(VOID_TYPE)('V') + PsiWhiteSpace('\n') + PsiErrorElement:mismatched input '.end' expecting END_METHOD_DIRECTIVE + PsiElement(BAD_CHARACTER)('.end') + PsiWhiteSpace('\n\n\n\n') + SmaliMethod(METHOD) + SmaliThrowsList(THROWS_LIST) + + PsiElement(METHOD_DIRECTIVE)('.method') + PsiWhiteSpace(' ') + SmaliModifierList(MODIFIER_LIST) + + PsiElement(MEMBER_NAME) + PsiElement(INSTRUCTION_FORMAT11x)('return-object') + SmaliMethodPrototype(METHOD_PROTOTYPE) + PsiElement(OPEN_PAREN)('(') + SmaliMethodParamList(METHOD_PARAM_LIST) + + PsiElement(CLOSE_PAREN)(')') + PsiElement(VOID_TYPE) + PsiElement(VOID_TYPE)('V') + PsiWhiteSpace('\n') + PsiElement(REGISTERS_STATEMENT) + PsiElement(REGISTERS_DIRECTIVE)('.registers') + PsiWhiteSpace(' ') + PsiElement(LITERAL) + PsiElement(POSITIVE_INTEGER_LITERAL)('0') + PsiErrorElement:missing END_METHOD_DIRECTIVE at '.method' + + PsiWhiteSpace('\n\n\n\n') + SmaliMethod(METHOD) + SmaliThrowsList(THROWS_LIST) + + PsiElement(METHOD_DIRECTIVE)('.method') + SmaliModifierList(MODIFIER_LIST) + + PsiElement(MEMBER_NAME) + PsiErrorElement:no viable alternative at input '' + + SmaliMethodPrototype(METHOD_PROTOTYPE) + SmaliMethodParamList(METHOD_PARAM_LIST) + \ No newline at end of file