JS: support <meta name="generator"/> classification

This commit is contained in:
Esben Sparre Andreasen
2018-12-11 09:12:39 +01:00
parent a295dfd2c5
commit 3879e57f18
7 changed files with 67 additions and 2 deletions

View File

@@ -114,6 +114,17 @@ private predicate isData(File f) {
)
}
/**
* Holds if `f` is a generated HTML file.
*/
private predicate isGeneratedHtml(File f) {
exists(HTML::Element e |
e.getFile() = f and
e.getName() = "meta" and
e.getAttributeByName("name").getValue() = "generator"
)
}
/**
* Holds if `tl` looks like it contains generated code.
*/
@@ -124,12 +135,14 @@ predicate isGenerated(TopLevel tl) {
tl instanceof DartGeneratedTopLevel or
exists (GeneratedCodeMarkerComment gcmc | tl = gcmc.getTopLevel()) or
hasManyInvocations(tl) or
isData(tl.getFile())
isData(tl.getFile()) or
isGeneratedHtml(tl.getFile())
}
/**
* Holds if `file` look like it contains generated code.
*/
predicate isGeneratedCode(File file) {
isGenerated(file.getATopLevel())
isGenerated(file.getATopLevel()) or
isGeneratedHtml(file)
}