Skip to content

Commit ad4b2be

Browse files
authored
Merge pull request github#4727 from criemen/remove-abstract-classes
C++/C#/JS/Python/Java XML.qll: Remove abstract from class hierarchy.
2 parents 301f49a + 3bfb398 commit ad4b2be

File tree

5 files changed

+30
-15
lines changed
  • cpp/ql/src/semmle/code/cpp
  • csharp/ql/src/semmle/code/csharp
  • javascript/ql/src/semmle/javascript
  • java/ql/src/semmle/code/xml
  • python/ql/src/semmle/python/xml

5 files changed

+30
-15
lines changed

cpp/ql/src/semmle/code/cpp/XML.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
import semmle.files.FileSystem
66

7+
private class TXMLLocatable =
8+
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
9+
710
/** An XML element that has a ___location. */
8-
abstract class XMLLocatable extends @xmllocatable {
11+
class XMLLocatable extends @xmllocatable, TXMLLocatable {
912
/** Gets the source ___location for this element. */
1013
Location getLocation() { xmllocations(this, result) }
1114

@@ -33,7 +36,7 @@ abstract class XMLLocatable extends @xmllocatable {
3336
}
3437

3538
/** Gets a textual representation of this element. */
36-
abstract string toString();
39+
string toString() { none() } // overridden in subclasses
3740
}
3841

3942
/**
@@ -51,7 +54,7 @@ class XMLParent extends @xmlparent {
5154
* Gets a printable representation of this XML parent.
5255
* (Intended to be overridden in subclasses.)
5356
*/
54-
abstract string getName();
57+
string getName() { none() } // overridden in subclasses
5558

5659
/** Gets the file to which this XML parent belongs. */
5760
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) }

csharp/ql/src/semmle/code/csharp/XML.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
import semmle.files.FileSystem
66

7+
private class TXMLLocatable =
8+
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
9+
710
/** An XML element that has a ___location. */
8-
abstract class XMLLocatable extends @xmllocatable {
11+
class XMLLocatable extends @xmllocatable, TXMLLocatable {
912
/** Gets the source ___location for this element. */
1013
Location getLocation() { xmllocations(this, result) }
1114

@@ -33,7 +36,7 @@ abstract class XMLLocatable extends @xmllocatable {
3336
}
3437

3538
/** Gets a textual representation of this element. */
36-
abstract string toString();
39+
string toString() { none() } // overridden in subclasses
3740
}
3841

3942
/**
@@ -51,7 +54,7 @@ class XMLParent extends @xmlparent {
5154
* Gets a printable representation of this XML parent.
5255
* (Intended to be overridden in subclasses.)
5356
*/
54-
abstract string getName();
57+
string getName() { none() } // overridden in subclasses
5558

5659
/** Gets the file to which this XML parent belongs. */
5760
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) }

java/ql/src/semmle/code/xml/XML.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
import semmle.files.FileSystem
66

7+
private class TXMLLocatable =
8+
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
9+
710
/** An XML element that has a ___location. */
8-
abstract class XMLLocatable extends @xmllocatable {
11+
class XMLLocatable extends @xmllocatable, TXMLLocatable {
912
/** Gets the source ___location for this element. */
1013
Location getLocation() { xmllocations(this, result) }
1114

@@ -33,7 +36,7 @@ abstract class XMLLocatable extends @xmllocatable {
3336
}
3437

3538
/** Gets a textual representation of this element. */
36-
abstract string toString();
39+
string toString() { none() } // overridden in subclasses
3740
}
3841

3942
/**
@@ -51,7 +54,7 @@ class XMLParent extends @xmlparent {
5154
* Gets a printable representation of this XML parent.
5255
* (Intended to be overridden in subclasses.)
5356
*/
54-
abstract string getName();
57+
string getName() { none() } // overridden in subclasses
5558

5659
/** Gets the file to which this XML parent belongs. */
5760
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) }

javascript/ql/src/semmle/javascript/XML.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
import semmle.files.FileSystem
66

7+
private class TXMLLocatable =
8+
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
9+
710
/** An XML element that has a ___location. */
8-
abstract class XMLLocatable extends @xmllocatable {
11+
class XMLLocatable extends @xmllocatable, TXMLLocatable {
912
/** Gets the source ___location for this element. */
1013
Location getLocation() { xmllocations(this, result) }
1114

@@ -33,7 +36,7 @@ abstract class XMLLocatable extends @xmllocatable {
3336
}
3437

3538
/** Gets a textual representation of this element. */
36-
abstract string toString();
39+
string toString() { none() } // overridden in subclasses
3740
}
3841

3942
/**
@@ -51,7 +54,7 @@ class XMLParent extends @xmlparent {
5154
* Gets a printable representation of this XML parent.
5255
* (Intended to be overridden in subclasses.)
5356
*/
54-
abstract string getName();
57+
string getName() { none() } // overridden in subclasses
5558

5659
/** Gets the file to which this XML parent belongs. */
5760
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) }

python/ql/src/semmle/python/xml/XML.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
import semmle.files.FileSystem
66

7+
private class TXMLLocatable =
8+
@xmldtd or @xmlelement or @xmlattribute or @xmlnamespace or @xmlcomment or @xmlcharacters;
9+
710
/** An XML element that has a ___location. */
8-
abstract class XMLLocatable extends @xmllocatable {
11+
class XMLLocatable extends @xmllocatable, TXMLLocatable {
912
/** Gets the source ___location for this element. */
1013
Location getLocation() { xmllocations(this, result) }
1114

@@ -33,7 +36,7 @@ abstract class XMLLocatable extends @xmllocatable {
3336
}
3437

3538
/** Gets a textual representation of this element. */
36-
abstract string toString();
39+
string toString() { none() } // overridden in subclasses
3740
}
3841

3942
/**
@@ -51,7 +54,7 @@ class XMLParent extends @xmlparent {
5154
* Gets a printable representation of this XML parent.
5255
* (Intended to be overridden in subclasses.)
5356
*/
54-
abstract string getName();
57+
string getName() { none() } // overridden in subclasses
5558

5659
/** Gets the file to which this XML parent belongs. */
5760
XMLFile getFile() { result = this or xmlElements(this, _, _, _, result) }

0 commit comments

Comments
 (0)