@@ -7,15 +7,11 @@ import semmle.code.Location
77
88/** Each element in a configuration file has a location. */
99abstract class ConfigLocatable extends @configLocatable {
10- /** Retrieve the source location for this element. */
11- Location getLocation ( ) {
12- configLocations ( this , result )
13- }
10+ /** Gets the source location for this element. */
11+ Location getLocation ( ) { configLocations ( this , result ) }
1412
15- /** The file associated with this element. */
16- File getFile ( ) {
17- result = getLocation ( ) .getFile ( )
18- }
13+ /** Gets the file associated with this element. */
14+ File getFile ( ) { result = getLocation ( ) .getFile ( ) }
1915
2016 /** Gets a textual representation of this element. */
2117 abstract string toString ( ) ;
@@ -26,76 +22,49 @@ abstract class ConfigLocatable extends @configLocatable {
2622 * for applications, such as the port, name or address of a database.
2723 */
2824class ConfigPair extends @config, ConfigLocatable {
25+ /** Gets the name of this ConfigPair, if any. */
26+ ConfigName getNameElement ( ) { configNames ( result , this , _) }
2927
30- /** If this ConfigPair has a name element, return it. */
31- ConfigName getNameElement ( ) {
32- configNames ( result , this , _)
33- }
34-
35- /** If this ConfigPair has a value element, return it. */
36- ConfigValue getValueElement ( ) {
37- configValues ( result , this , _)
38- }
28+ /** Gets the value of this ConfigPair, if any. */
29+ ConfigValue getValueElement ( ) { configValues ( result , this , _) }
3930
4031 /**
41- * If this ConfigPair has a name element, return its string value.
42- * Otherwise return the empty string.
32+ * Gets the string value of the name of this ConfigPair if
33+ * it exists and the empty string if it doesn't .
4334 */
4435 string getEffectiveName ( ) {
45- if exists ( getNameElement ( ) ) then
46- result = getNameElement ( ) .getName ( )
47- else
48- result = ""
36+ if exists ( getNameElement ( ) ) then result = getNameElement ( ) .getName ( ) else result = ""
4937 }
5038
5139 /**
52- * If this ConfigPair has a value element, return its string value.
53- * Otherwise return the empty string.
40+ * Gets the string value of the value of this ConfigPair if
41+ * it exists and the empty string if it doesn't .
5442 */
5543 string getEffectiveValue ( ) {
56- if exists ( getValueElement ( ) ) then
57- result = getValueElement ( ) .getValue ( )
58- else
59- result = ""
44+ if exists ( getValueElement ( ) ) then result = getValueElement ( ) .getValue ( ) else result = ""
6045 }
6146
62- /** A printable representation of this ConfigPair. */
63- override string toString ( ) {
64- result = getEffectiveName ( ) + "=" + getEffectiveValue ( )
65- }
47+ /** Gets a printable representation of this ConfigPair. */
48+ override string toString ( ) { result = getEffectiveName ( ) + "=" + getEffectiveValue ( ) }
6649}
6750
6851/** The name element of a ConfigPair. */
6952class ConfigName extends @configName, ConfigLocatable {
53+ /** Gets the name as a string. */
54+ string getName ( ) { configNames ( this , _, result ) }
7055
71- /** Returns the name as a string. */
72- string getName ( ) {
73- configNames ( this , _, result )
74- }
75-
76- /** A printable representation of this ConfigName. */
77- override string toString ( ) {
78- result = getName ( )
79- }
56+ /** Gets a printable representation of this ConfigName. */
57+ override string toString ( ) { result = getName ( ) }
8058}
8159
8260/** The value element of a ConfigPair. */
8361class ConfigValue extends @configValue, ConfigLocatable {
62+ /** Gets the value as a string. */
63+ string getValue ( ) { configValues ( this , _, result ) }
8464
85- /** Returns the value as a string. */
86- string getValue ( ) {
87- configValues ( this , _, result )
88- }
89-
90- /** A printable representation of this ConfigValue. */
91- override string toString ( ) {
92- result = getValue ( )
93- }
65+ /** Gets a printable representation of this ConfigValue. */
66+ override string toString ( ) { result = getValue ( ) }
9467}
9568
9669/** A Java property is a name-value pair in a .properties file. */
97- class JavaProperty extends ConfigPair {
98- JavaProperty ( ) {
99- getFile ( ) .getExtension ( ) = "properties"
100- }
101- }
70+ class JavaProperty extends ConfigPair { JavaProperty ( ) { getFile ( ) .getExtension ( ) = "properties" } }
0 commit comments