Kotlin: Performance tweak

This commit is contained in:
Ian Lynagh
2022-04-25 16:54:56 +01:00
parent b9be79473a
commit 653e74d181

View File

@@ -46,17 +46,24 @@ abstract class GeneratedFile extends File { }
*/
library class MarkerCommentGeneratedFile extends GeneratedFile {
MarkerCommentGeneratedFile() {
exists(JavadocElement t | t.getFile() = this |
exists(string msg | msg = t.getText() |
msg.regexpMatch("(?i).*\\bGenerated By\\b.*\\bDo not edit\\b.*") or
msg.regexpMatch("(?i).*\\bThis (file|class|interface|art[ei]fact) (was|is|(has been)) (?:auto[ -]?)?gener(e?)ated.*") or
msg.regexpMatch("(?i).*\\bAny modifications to this file will be lost\\b.*") or
msg.regexpMatch("(?i).*\\bThis (file|class|interface|art[ei]fact) (was|is) (?:mechanically|automatically) generated\\b.*") or
msg.regexpMatch("(?i).*\\bThe following code was (?:auto[ -]?)?generated (?:by|from)\\b.*") or
msg.regexpMatch("(?i).*\\bAutogenerated by Thrift.*") or
msg.regexpMatch("(?i).*\\bGenerated By.*JavaCC.*") or
msg.regexpMatch("(?i).*\\bGenerated from .* by ANTLR.*")
)
any(GeneratedFileMarker t).getFile() = this
}
}
/**
* A marker comment that indicates that it is in a generated file.
*/
private class GeneratedFileMarker extends Top {
GeneratedFileMarker() {
exists(string msg | msg = this.(JavadocElement).getText() |
msg.regexpMatch("(?i).*\\bGenerated By\\b.*\\bDo not edit\\b.*") or
msg.regexpMatch("(?i).*\\bThis (file|class|interface|art[ei]fact) (was|is|(has been)) (?:auto[ -]?)?gener(e?)ated.*") or
msg.regexpMatch("(?i).*\\bAny modifications to this file will be lost\\b.*") or
msg.regexpMatch("(?i).*\\bThis (file|class|interface|art[ei]fact) (was|is) (?:mechanically|automatically) generated\\b.*") or
msg.regexpMatch("(?i).*\\bThe following code was (?:auto[ -]?)?generated (?:by|from)\\b.*") or
msg.regexpMatch("(?i).*\\bAutogenerated by Thrift.*") or
msg.regexpMatch("(?i).*\\bGenerated By.*JavaCC.*") or
msg.regexpMatch("(?i).*\\bGenerated from .* by ANTLR.*")
)
}
}