@@ -1399,7 +1399,7 @@ public void run() {
13991399 }
14001400 }
14011401 }
1402- if (searchInAnnotations (classDef .getAnnotations (), className , snippets )) match = true ;
1402+ if (searchInAnnotations (classDef .getAnnotations (), className , snippets , smali , classDef )) match = true ;
14031403 }
14041404 break ;
14051405 case "Integer" :
@@ -1666,39 +1666,42 @@ private int findLineOfText(String smali, String searchText) {
16661666 return countLinesBefore (smali , pos );
16671667 }
16681668
1669- private boolean searchInAnnotations (java .util .Set <? extends com .android .tools .smali .dexlib2 .iface .Annotation > annotations , String className , List <TreeNode > snippets ) {
1669+ private boolean searchInAnnotations (java .util .Set <? extends com .android .tools .smali .dexlib2 .iface .Annotation > annotations , String className , List <TreeNode > snippets , String smali , ClassDef classDef ) {
16701670 if (annotations == null ) return false ;
16711671 boolean matched = false ;
16721672 for (com .android .tools .smali .dexlib2 .iface .Annotation annotation : annotations ) {
16731673 for (com .android .tools .smali .dexlib2 .iface .AnnotationElement element : annotation .getElements ()) {
1674- if (collectAnnotationMatches (element .getName (), element .getValue (), className , snippets ))
1674+ if (collectAnnotationMatches (element .getName (), element .getValue (), className , snippets , smali , classDef ))
16751675 matched = true ;
16761676 }
16771677 }
16781678 return matched ;
16791679 }
16801680
1681- private boolean collectAnnotationMatches (String name , com .android .tools .smali .dexlib2 .iface .value .EncodedValue value , String className , List <TreeNode > snippets ) {
1681+ private boolean collectAnnotationMatches (String name , com .android .tools .smali .dexlib2 .iface .value .EncodedValue value , String className , List <TreeNode > snippets , String smali , ClassDef classDef ) {
16821682 boolean matched = false ;
16831683 if (value instanceof com .android .tools .smali .dexlib2 .iface .value .StringEncodedValue ) {
16841684 String str = ((com .android .tools .smali .dexlib2 .iface .value .StringEncodedValue ) value ).getValue ();
16851685 if (checkMatch (str )) {
16861686 if (foundCount .incrementAndGet () >= 250000 ) return true ;
1687- TreeNode snippet = new TreeNode ("Annotation: " + name + " = \" " + str + "\" " , className , 0 , false );
1687+ String currentSmali = smali ;
1688+ if (currentSmali == null ) currentSmali = generateSmaliSafe (classDef );
1689+ int lineIdx = findLineOfText (currentSmali , "\" " + str + "\" " );
1690+ TreeNode snippet = new TreeNode (name + " = \" " + str + "\" " , className , 0 , false );
16881691 snippet .setSnippet (true );
1689- snippet .setLineNumber (1 );
1692+ snippet .setLineNumber (lineIdx != - 1 ? lineIdx : 0 );
16901693 preHighlightSnippet (snippet , highlightQuery );
16911694 snippets .add (snippet );
16921695 matched = true ;
16931696 }
16941697 } else if (value instanceof com .android .tools .smali .dexlib2 .iface .value .AnnotationEncodedValue ) {
16951698 for (com .android .tools .smali .dexlib2 .iface .AnnotationElement element : ((com .android .tools .smali .dexlib2 .iface .value .AnnotationEncodedValue ) value ).getElements ()) {
1696- if (collectAnnotationMatches (element .getName (), element .getValue (), className , snippets ))
1699+ if (collectAnnotationMatches (element .getName (), element .getValue (), className , snippets , smali , classDef ))
16971700 matched = true ;
16981701 }
16991702 } else if (value instanceof com .android .tools .smali .dexlib2 .iface .value .ArrayEncodedValue ) {
17001703 for (com .android .tools .smali .dexlib2 .iface .value .EncodedValue subValue : ((com .android .tools .smali .dexlib2 .iface .value .ArrayEncodedValue ) value ).getValue ()) {
1701- if (collectAnnotationMatches (name , subValue , className , snippets ))
1704+ if (collectAnnotationMatches (name , subValue , className , snippets , smali , classDef ))
17021705 matched = true ;
17031706 }
17041707 }
0 commit comments