@@ -9,24 +9,40 @@ private class AndroidLayoutXmlFile extends XmlFile {
99 AndroidLayoutXmlFile ( ) { this .getRelativePath ( ) .matches ( "%/res/layout/%.xml" ) }
1010}
1111
12- /** An XML element that represents an editable text field. */
13- class AndroidEditableXmlElement extends XmlElement {
14- AndroidXmlAttribute inputType ;
12+ /** A component declared in an Android layout file. */
13+ class AndroidLayoutXmlElement extends XmlElement {
1514 AndroidXmlAttribute id ;
1615
17- AndroidEditableXmlElement ( ) {
16+ AndroidLayoutXmlElement ( ) {
1817 this .getFile ( ) instanceof AndroidLayoutXmlFile and
19- inputType = this .getAnAttribute ( ) and
20- inputType .getName ( ) = "inputType" and
21- id = this .getAnAttribute ( ) and
22- id .getName ( ) = "id"
18+ id = this .getAttribute ( "id" )
2319 }
2420
25- /** Gets the input type of this field. */
26- string getInputType ( ) { result = inputType .getValue ( ) }
27-
28- /** Gets the ID of this field. */
21+ /** Gets the ID of this component. */
2922 string getId ( ) { result = id .getValue ( ) }
23+
24+ /** Gets the class of this component. */
25+ Class getClass ( ) {
26+ this .getName ( ) = "view" and
27+ this .getAttribute ( "class" ) .getValue ( ) = result .getQualifiedName ( )
28+ or
29+ this .getName ( ) = result .getQualifiedName ( )
30+ or
31+ result .hasQualifiedName ( [ "android.widget" , "android.view" ] , this .getName ( ) )
32+ }
33+ }
34+
35+ /** An XML element that represents an editable text field. */
36+ class AndroidEditableXmlElement extends AndroidLayoutXmlElement {
37+ AndroidEditableXmlElement ( ) {
38+ exists ( Class editText |
39+ editText .hasQualifiedName ( "android.widget" , "EditText" ) and
40+ editText = this .getClass ( ) .getASourceSupertype * ( )
41+ )
42+ }
43+
44+ /** Gets the input type of this field, if any. */
45+ string getInputType ( ) { result = this .getAttribute ( "inputType" ) .( AndroidXmlAttribute ) .getValue ( ) }
3046}
3147
3248/** Gets a regex indicating that an input field may contain sensitive data. */
0 commit comments