mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Add support for XML InlineExpectationsTest
This commit is contained in:
@@ -20,3 +20,15 @@ private class KtExpectationComment extends KtComment, ExpectationComment {
|
||||
|
||||
override string getContents() { result = this.getText().suffix(2).trim() }
|
||||
}
|
||||
|
||||
private class XMLExpectationComment extends ExpectationComment instanceof XMLComment {
|
||||
override string getContents() { result = this.(XMLComment).getText().trim() }
|
||||
|
||||
override Location getLocation() { result = this.(XMLComment).getLocation() }
|
||||
|
||||
override predicate hasLocationInfo(string path, int sl, int sc, int el, int ec) {
|
||||
this.(XMLComment).hasLocationInfo(path, sl, sc, el, ec)
|
||||
}
|
||||
|
||||
override string toString() { result = this.(XMLComment).toString() }
|
||||
}
|
||||
|
||||
3
java/ql/test/library-tests/xml/Test.java
Normal file
3
java/ql/test/library-tests/xml/Test.java
Normal file
@@ -0,0 +1,3 @@
|
||||
public class Test {
|
||||
|
||||
}
|
||||
0
java/ql/test/library-tests/xml/XMLTest.expected
Normal file
0
java/ql/test/library-tests/xml/XMLTest.expected
Normal file
17
java/ql/test/library-tests/xml/XMLTest.ql
Normal file
17
java/ql/test/library-tests/xml/XMLTest.ql
Normal file
@@ -0,0 +1,17 @@
|
||||
import semmle.code.xml.XML
|
||||
import TestUtilities.InlineExpectationsTest
|
||||
|
||||
class XMLTest extends InlineExpectationsTest {
|
||||
XMLTest() { this = "XMLTest" }
|
||||
|
||||
override string getARelevantTag() { result = "hasXmlResult" }
|
||||
|
||||
override predicate hasActualResult(Location location, string element, string tag, string value) {
|
||||
tag = "hasXmlResult" and
|
||||
exists(XMLAttribute a |
|
||||
a.getLocation() = location and
|
||||
element = a.toString() and
|
||||
value = ""
|
||||
)
|
||||
}
|
||||
}
|
||||
4
java/ql/test/library-tests/xml/test.xml
Normal file
4
java/ql/test/library-tests/xml/test.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document>
|
||||
<element attribute="value">Text</element> <!-- $ hasXmlResult -->
|
||||
</document>
|
||||
Reference in New Issue
Block a user