mirror of
https://github.com/revanced/smali.git
synced 2025-06-13 12:37:37 +02:00
Improve parsing error recovery for the end method directive
This commit is contained in:
@ -331,6 +331,11 @@ method
|
|||||||
|
|
||||||
end_method_directive
|
end_method_directive
|
||||||
: END_METHOD_DIRECTIVE;
|
: END_METHOD_DIRECTIVE;
|
||||||
|
catch [RecognitionException re] {
|
||||||
|
Marker errorMarker = mark();
|
||||||
|
recover(input, re);
|
||||||
|
reportError(errorMarker, re, false);
|
||||||
|
}
|
||||||
|
|
||||||
statements_and_directives
|
statements_and_directives
|
||||||
: (
|
: (
|
||||||
|
@ -56,4 +56,5 @@ public class ParserTest extends LightCodeInsightParsingTestCase {
|
|||||||
public void testSuperClassInvalidSyntax2() throws Exception { doTest(true); }
|
public void testSuperClassInvalidSyntax2() throws Exception { doTest(true); }
|
||||||
public void testInvalidMethod() throws Exception { doTest(true); }
|
public void testInvalidMethod() throws Exception { doTest(true); }
|
||||||
public void testInvalidMethod2() throws Exception { doTest(true); }
|
public void testInvalidMethod2() throws Exception { doTest(true); }
|
||||||
|
public void testInvalidMethod3() throws Exception { doTest(true); }
|
||||||
}
|
}
|
||||||
|
11
smalidea/testData/InvalidMethod3.smalidea
Normal file
11
smalidea/testData/InvalidMethod3.smalidea
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
.method blah()V
|
||||||
|
.end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.method return-object()V
|
||||||
|
.registers 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.method
|
63
smalidea/testData/InvalidMethod3.txt
Normal file
63
smalidea/testData/InvalidMethod3.txt
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
smali.FILE
|
||||||
|
SmaliClass(CLASS)
|
||||||
|
SmaliExtendsList(EXTENDS_LIST)
|
||||||
|
<empty list>
|
||||||
|
SmaliImplementsList(IMPLEMENTS_LIST)
|
||||||
|
<empty list>
|
||||||
|
SmaliMethod(METHOD)
|
||||||
|
SmaliThrowsList(THROWS_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(METHOD_DIRECTIVE)('.method')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
SmaliModifierList(MODIFIER_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(MEMBER_NAME)
|
||||||
|
PsiElement(SIMPLE_NAME)('blah')
|
||||||
|
SmaliMethodPrototype(METHOD_PROTOTYPE)
|
||||||
|
PsiElement(OPEN_PAREN)('(')
|
||||||
|
SmaliMethodParamList(METHOD_PARAM_LIST)
|
||||||
|
<empty 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)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(METHOD_DIRECTIVE)('.method')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
SmaliModifierList(MODIFIER_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(MEMBER_NAME)
|
||||||
|
PsiElement(INSTRUCTION_FORMAT11x)('return-object')
|
||||||
|
SmaliMethodPrototype(METHOD_PROTOTYPE)
|
||||||
|
PsiElement(OPEN_PAREN)('(')
|
||||||
|
SmaliMethodParamList(METHOD_PARAM_LIST)
|
||||||
|
<empty 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'
|
||||||
|
<empty list>
|
||||||
|
PsiWhiteSpace('\n\n\n\n')
|
||||||
|
SmaliMethod(METHOD)
|
||||||
|
SmaliThrowsList(THROWS_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(METHOD_DIRECTIVE)('.method')
|
||||||
|
SmaliModifierList(MODIFIER_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(MEMBER_NAME)
|
||||||
|
PsiErrorElement:no viable alternative at input '<EOF>'
|
||||||
|
<empty list>
|
||||||
|
SmaliMethodPrototype(METHOD_PROTOTYPE)
|
||||||
|
SmaliMethodParamList(METHOD_PARAM_LIST)
|
||||||
|
<empty list>
|
Reference in New Issue
Block a user