@@ -38,14 +38,10 @@ class Annotation extends @annotation, Expr {
3838 Expr getAValue ( ) { filteredAnnotValue ( this , _, result ) }
3939
4040 /** Gets the value of the annotation element with the specified `name`. */
41- Expr getValue ( string name ) {
42- filteredAnnotValue ( this , this .getAnnotationElement ( name ) , result )
43- }
41+ Expr getValue ( string name ) { filteredAnnotValue ( this , this .getAnnotationElement ( name ) , result ) }
4442
4543 /** Gets the element being annotated. */
46- Element getTarget ( ) {
47- exprs ( this , _, _, result , _)
48- }
44+ Element getTarget ( ) { exprs ( this , _, _, result , _) }
4945
5046 override string toString ( ) { result = this .getType ( ) .getName ( ) }
5147
@@ -63,35 +59,28 @@ class Annotation extends @annotation, Expr {
6359 Expr getAValue ( string name ) {
6460 getType ( ) .getAnnotationElement ( name ) .getType ( ) instanceof Array and
6561 exists ( Expr value | value = getValue ( name ) |
66- if value instanceof ArrayInit then
67- result = value .( ArrayInit ) .getAnInit ( )
68- else
69- result = value
62+ if value instanceof ArrayInit then result = value .( ArrayInit ) .getAnInit ( ) else result = value
7063 )
7164 }
7265}
7366
7467/** An `Annotation` that applies to a declaration. */
75- class DeclAnnotation extends @declannotation, Annotation {
76- }
68+ class DeclAnnotation extends @declannotation, Annotation { }
7769
7870/** An `Annotation` that applies to a type. */
79- class TypeAnnotation extends @typeannotation, Annotation {
80- }
71+ class TypeAnnotation extends @typeannotation, Annotation { }
8172
8273/**
8374 * There may be duplicate entries in annotValue(...) - one entry for
8475 * information populated from bytecode, and one for information populated
8576 * from source. This removes the duplication.
8677 */
87- private
88- predicate filteredAnnotValue ( Annotation a , Method m , Expr val ) {
78+ private predicate filteredAnnotValue ( Annotation a , Method m , Expr val ) {
8979 annotValue ( a , m , val ) and
9080 ( sourceAnnotValue ( a , m , val ) or not sourceAnnotValue ( a , m , _) )
9181}
9282
93- private
94- predicate sourceAnnotValue ( Annotation a , Method m , Expr val ) {
83+ private predicate sourceAnnotValue ( Annotation a , Method m , Expr val ) {
9584 annotValue ( a , m , val ) and
9685 val .getFile ( ) .getExtension ( ) = "java"
9786}
@@ -103,7 +92,9 @@ class Annotatable extends Element {
10392
10493 /** Holds if this element has the specified annotation. */
10594 predicate hasAnnotation ( string package , string name ) {
106- exists ( AnnotationType at | at = getAnAnnotation ( ) .getType ( ) | at .nestedName ( ) = name and at .getPackage ( ) .getName ( ) = package )
95+ exists ( AnnotationType at | at = getAnAnnotation ( ) .getType ( ) |
96+ at .nestedName ( ) = name and at .getPackage ( ) .getName ( ) = package
97+ )
10798 }
10899
109100 /** Gets an annotation that applies to this element. */
@@ -114,14 +105,20 @@ class Annotatable extends Element {
114105 * annotation attached to it for the specified `category`.
115106 */
116107 predicate suppressesWarningsAbout ( string category ) {
117- exists ( string withQuotes
118- | withQuotes = ( ( SuppressWarningsAnnotation ) getAnAnnotation ( ) ) .getASuppressedWarning ( )
119- | category = withQuotes .substring ( 1 , withQuotes .length ( ) - 1 )
120- ) or
121- this .( Member ) .getDeclaringType ( ) .suppressesWarningsAbout ( category ) or
122- this .( Expr ) .getEnclosingCallable ( ) .suppressesWarningsAbout ( category ) or
123- this .( Stmt ) .getEnclosingCallable ( ) .suppressesWarningsAbout ( category ) or
124- this .( NestedClass ) .getEnclosingType ( ) .suppressesWarningsAbout ( category ) or
108+ exists ( string withQuotes |
109+ withQuotes = ( getAnAnnotation ( ) .( SuppressWarningsAnnotation ) ) .getASuppressedWarning ( )
110+ |
111+ category = withQuotes .substring ( 1 , withQuotes .length ( ) - 1 )
112+ )
113+ or
114+ this .( Member ) .getDeclaringType ( ) .suppressesWarningsAbout ( category )
115+ or
116+ this .( Expr ) .getEnclosingCallable ( ) .suppressesWarningsAbout ( category )
117+ or
118+ this .( Stmt ) .getEnclosingCallable ( ) .suppressesWarningsAbout ( category )
119+ or
120+ this .( NestedClass ) .getEnclosingType ( ) .suppressesWarningsAbout ( category )
121+ or
125122 this .( LocalVariableDecl ) .getCallable ( ) .suppressesWarningsAbout ( category )
126123 }
127124}
@@ -132,13 +129,11 @@ class AnnotationType extends Interface {
132129
133130 /** Gets the annotation element with the specified `name`. */
134131 AnnotationElement getAnnotationElement ( string name ) {
135- methods ( result , _ , _ , _ , this , _) and result .hasName ( name )
132+ methods ( result , _ , _ , _ , this , _) and result .hasName ( name )
136133 }
137134
138135 /** Gets an annotation element that is a member of this annotation type. */
139- AnnotationElement getAnAnnotationElement ( ) {
140- methods ( result , _, _, _, this , _)
141- }
136+ AnnotationElement getAnAnnotationElement ( ) { methods ( result , _, _, _, this , _) }
142137
143138 /** Holds if this annotation type is annotated with the meta-annotation `@Inherited`. */
144139 predicate isInherited ( ) {
@@ -154,5 +149,5 @@ class AnnotationElement extends Member {
154149 AnnotationElement ( ) { isAnnotElem ( this ) }
155150
156151 /** Gets the type of this annotation element. */
157- Type getType ( ) { methods ( this , _ , _ , result , _ , _) }
152+ Type getType ( ) { methods ( this , _ , _ , result , _ , _) }
158153}
0 commit comments