mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Java: Rename Annotation value predicates
This commit is contained in:
committed by
Chris Smowton
parent
c226758889
commit
b96061aa7e
@@ -61,14 +61,14 @@ class Annotation extends @annotation, Expr {
|
||||
* gets the enum constant used as value for that element. This includes default values in
|
||||
* case no explicit value is specified.
|
||||
*/
|
||||
EnumConstant getValueEnumConstant(string name) { result = getValue(name).(FieldRead).getField() }
|
||||
EnumConstant getEnumConstantValue(string name) { result = getValue(name).(FieldRead).getField() }
|
||||
|
||||
/**
|
||||
* If the value type of the annotation element with the specified `name` is `String`,
|
||||
* gets the string value used for that element. This includes default values in case no
|
||||
* explicit value is specified.
|
||||
*/
|
||||
string getValueString(string name) {
|
||||
string getStringValue(string name) {
|
||||
// Uses CompileTimeConstantExpr instead of StringLiteral because value can
|
||||
// be read of final variable as well
|
||||
result = getValue(name).(CompileTimeConstantExpr).getStringValue()
|
||||
@@ -79,7 +79,7 @@ class Annotation extends @annotation, Expr {
|
||||
* gets the int value used for that element. This includes default values in case no
|
||||
* explicit value is specified.
|
||||
*/
|
||||
int getValueInt(string name) {
|
||||
int getIntValue(string name) {
|
||||
// Uses CompileTimeConstantExpr instead of IntegerLiteral because value can
|
||||
// be read of final variable as well
|
||||
result = getValue(name).(CompileTimeConstantExpr).getIntValue()
|
||||
@@ -90,7 +90,7 @@ class Annotation extends @annotation, Expr {
|
||||
* gets the boolean value used for that element. This includes default values in case
|
||||
* no explicit value is specified.
|
||||
*/
|
||||
boolean getValueBoolean(string name) {
|
||||
boolean getBooleanValue(string name) {
|
||||
// Uses CompileTimeConstantExpr instead of BooleanLiteral because value can
|
||||
// be read of final variable as well
|
||||
result = getValue(name).(CompileTimeConstantExpr).getBooleanValue()
|
||||
@@ -101,7 +101,7 @@ class Annotation extends @annotation, Expr {
|
||||
* gets the referenced type used as value for that element. This includes default values
|
||||
* in case no explicit value is specified.
|
||||
*/
|
||||
Type getValueClass(string name) { result = getValue(name).(TypeLiteral).getReferencedType() }
|
||||
Type getTypeValue(string name) { result = getValue(name).(TypeLiteral).getReferencedType() }
|
||||
|
||||
/** Gets the element being annotated. */
|
||||
Element getTarget() { result = this.getAnnotatedElement() }
|
||||
|
||||
@@ -99,7 +99,7 @@ class RepeatableAnnotation extends Annotation {
|
||||
* Gets the annotation type which acts as _containing type_, grouping multiple
|
||||
* repeatable annotations together.
|
||||
*/
|
||||
AnnotationType getContainingType() { result = getValueClass("value") }
|
||||
AnnotationType getContainingType() { result = getTypeValue("value") }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -161,13 +161,13 @@ class TestNGTestMethod extends Method {
|
||||
exists(TestNGTestAnnotation testAnnotation |
|
||||
testAnnotation = this.getAnAnnotation() and
|
||||
// The data provider must have the same name as the referenced data provider
|
||||
result.getDataProviderName() = testAnnotation.getValueString("dataProvider")
|
||||
result.getDataProviderName() = testAnnotation.getStringValue("dataProvider")
|
||||
|
|
||||
// Either the data provider should be on the current class, or a supertype
|
||||
this.getDeclaringType().getAnAncestor() = result.getDeclaringType()
|
||||
or
|
||||
// Or the data provider class should be declared
|
||||
result.getDeclaringType() = testAnnotation.getValueClass("dataProviderClass")
|
||||
result.getDeclaringType() = testAnnotation.getTypeValue("dataProviderClass")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class JaxbType extends Class {
|
||||
this.getAnAnnotation() = a and
|
||||
a.getType().(JaxbAnnotationType).hasName("XmlAccessorType")
|
||||
|
|
||||
result = a.getValueEnumConstant("value")
|
||||
result = a.getEnumConstantValue("value")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -64,5 +64,5 @@ class RunWithAnnotation extends Annotation {
|
||||
/**
|
||||
* Gets the runner that will be used.
|
||||
*/
|
||||
Type getRunner() { result = this.getValueClass("value") }
|
||||
Type getRunner() { result = this.getTypeValue("value") }
|
||||
}
|
||||
|
||||
@@ -33,11 +33,12 @@ class PersistentEntity extends RefType {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the access type for this entity as defined by a `@javax.persistence.Access` annotation, if any.
|
||||
* Gets the access type for this entity as defined by a `@javax.persistence.Access` annotation,
|
||||
* if any, in lower case.
|
||||
*/
|
||||
string getAccessTypeFromAnnotation() {
|
||||
exists(AccessAnnotation accessType | accessType = this.getAnAnnotation() |
|
||||
result = accessType.getValueEnumConstant("value").getName().toLowerCase()
|
||||
result = accessType.getEnumConstantValue("value").getName().toLowerCase()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ class SpringQualifierDefinitionAnnotation extends Annotation {
|
||||
/**
|
||||
* Gets the value of the qualifier field for this qualifier.
|
||||
*/
|
||||
string getQualifierValue() { result = this.getValueString("value") }
|
||||
string getQualifierValue() { result = this.getStringValue("value") }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -323,7 +323,7 @@ class SpringQualifierAnnotation extends Annotation {
|
||||
/**
|
||||
* Gets the value of the qualifier field for this qualifier.
|
||||
*/
|
||||
string getQualifierValue() { result = getValueString("value") }
|
||||
string getQualifierValue() { result = getStringValue("value") }
|
||||
|
||||
/**
|
||||
* Gets the bean definition in an XML file that this qualifier resolves to, if any.
|
||||
@@ -346,7 +346,7 @@ class SpringResourceAnnotation extends Annotation {
|
||||
/**
|
||||
* Gets the specified name value, if any.
|
||||
*/
|
||||
string getNameValue() { result = getValueString("name") }
|
||||
string getNameValue() { result = getStringValue("name") }
|
||||
|
||||
/**
|
||||
* Gets the bean definition in an XML file that the resource resolves to, if any.
|
||||
|
||||
@@ -144,7 +144,7 @@ class SpringComponent extends RefType {
|
||||
if exists(this.getComponentAnnotation().getValue("value"))
|
||||
then
|
||||
// If the name has been specified in the component annotation, use that.
|
||||
result = getComponentAnnotation().getValueString("value")
|
||||
result = getComponentAnnotation().getStringValue("value")
|
||||
else
|
||||
// Otherwise use the name of the class, with the initial letter lower cased.
|
||||
exists(string name | name = this.getName() |
|
||||
|
||||
@@ -155,7 +155,7 @@ class SpringRequestMappingMethod extends SpringControllerMethod {
|
||||
|
||||
/** Gets the "value" @RequestMapping annotation value, if present. */
|
||||
string getValue() {
|
||||
result = requestMappingAnnotation.getValueString("value")
|
||||
result = requestMappingAnnotation.getStringValue("value")
|
||||
}
|
||||
|
||||
/** Holds if this is considered an `@ResponseBody` method. */
|
||||
|
||||
Reference in New Issue
Block a user