@@ -9,24 +9,40 @@ private class AndroidLayoutXmlFile extends XmlFile {
9
9
AndroidLayoutXmlFile ( ) { this .getRelativePath ( ) .matches ( "%/res/layout/%.xml" ) }
10
10
}
11
11
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 {
15
14
AndroidXmlAttribute id ;
16
15
17
- AndroidEditableXmlElement ( ) {
16
+ AndroidLayoutXmlElement ( ) {
18
17
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" )
23
19
}
24
20
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. */
29
22
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 ( ) }
30
46
}
31
47
32
48
/** Gets a regex indicating that an input field may contain sensitive data. */
0 commit comments