mirror of
https://github.com/revanced/smali.git
synced 2025-05-02 07:34:28 +02:00
Improve parsing of an invalid SmaliMethod with no .end method
This ensures that we still generate a SmaliMethod in this case, instead of erroring out when not matching the END_METHOD_DIRECTIVE and aborting the main SmaliMethod mark.
This commit is contained in:
parent
4a9e7df53e
commit
aa06a4c782
@ -308,13 +308,17 @@ method
|
|||||||
mark().done(SmaliElementTypes.MODIFIER_LIST);
|
mark().done(SmaliElementTypes.MODIFIER_LIST);
|
||||||
}
|
}
|
||||||
: METHOD_DIRECTIVE access_list member_name method_prototype statements_and_directives
|
: METHOD_DIRECTIVE access_list member_name method_prototype statements_and_directives
|
||||||
END_METHOD_DIRECTIVE
|
end_method_directive
|
||||||
{ marker.done(SmaliElementTypes.METHOD); };
|
{ marker.done(SmaliElementTypes.METHOD); };
|
||||||
catch [RecognitionException re] {
|
catch [RecognitionException re] {
|
||||||
recover(input, re);
|
recover(input, re);
|
||||||
reportError(marker, re, false);
|
reportError(marker, re, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end_method_directive
|
||||||
|
: END_METHOD_DIRECTIVE;
|
||||||
|
|
||||||
|
|
||||||
statements_and_directives
|
statements_and_directives
|
||||||
: (
|
: (
|
||||||
( ordered_method_item
|
( ordered_method_item
|
||||||
|
@ -101,4 +101,5 @@ public class ParserTest extends ParsingTestCase {
|
|||||||
public void testParamListInvalidParameter() throws Exception { doTest(true); }
|
public void testParamListInvalidParameter() throws Exception { doTest(true); }
|
||||||
public void testSuperClassInvalidSyntax() throws Exception { doTest(true); }
|
public void testSuperClassInvalidSyntax() throws Exception { doTest(true); }
|
||||||
public void testSuperClassInvalidSyntax2() throws Exception { doTest(true); }
|
public void testSuperClassInvalidSyntax2() throws Exception { doTest(true); }
|
||||||
|
public void testInvalidMethod() throws Exception { doTest(true); }
|
||||||
}
|
}
|
||||||
|
4
smalidea/testData/InvalidMethod.smalidea
Normal file
4
smalidea/testData/InvalidMethod.smalidea
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.class Ltest;
|
||||||
|
.super Ljava/lang/Object;
|
||||||
|
|
||||||
|
.method .blah
|
33
smalidea/testData/InvalidMethod.txt
Normal file
33
smalidea/testData/InvalidMethod.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
smali.FILE
|
||||||
|
SmaliClass(CLASS)
|
||||||
|
SmaliModifierList(MODIFIER_LIST)
|
||||||
|
<empty list>
|
||||||
|
SmaliExtendsList(EXTENDS_LIST)
|
||||||
|
<empty list>
|
||||||
|
SmaliImplementsList(IMPLEMENTS_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(CLASS_STATEMENT)
|
||||||
|
PsiElement(CLASS_DIRECTIVE)('.class')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(ACCESS_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(CLASS_TYPE)
|
||||||
|
PsiElement(CLASS_DESCRIPTOR)('Ltest;')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
PsiElement(SUPER_STATEMENT)
|
||||||
|
PsiElement(SUPER_DIRECTIVE)('.super')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(CLASS_TYPE)
|
||||||
|
PsiElement(CLASS_DESCRIPTOR)('Ljava/lang/Object;')
|
||||||
|
PsiWhiteSpace('\n\n')
|
||||||
|
SmaliMethod(METHOD)
|
||||||
|
SmaliModifierList(MODIFIER_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiElement(METHOD_DIRECTIVE)('.method')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(ACCESS_LIST)
|
||||||
|
<empty list>
|
||||||
|
PsiErrorElement:no viable alternative at input '.blah'
|
||||||
|
PsiElement(BAD_CHARACTER)('.blah')
|
||||||
|
SmaliMethodPrototype(METHOD_PROTOTYPE)
|
||||||
|
<empty list>
|
Loading…
x
Reference in New Issue
Block a user