@@ -31,13 +31,10 @@ string getMessage(Select sel) {
31
31
* This fingerprint avoid false positives where two queries with the same ID behave differently (which is OK).
32
32
*/
33
33
string getSelectFingerPrint ( Select sel ) {
34
- exists ( File file , QLDoc doc |
35
- sel .getLocation ( ) .getFile ( ) = file and
36
- any ( TopLevel top | top .getLocation ( ) .getFile ( ) = file ) .getQLDoc ( ) = doc
37
- |
34
+ exists ( QueryDoc doc | doc = sel .getQueryDoc ( ) |
38
35
result =
39
- doc .getContents ( ) . regexpCapture ( "(?s).*@id (\\w+)/([\\w\\-]+)\\s.*" , 2 ) // query ID (without lang)
40
- + "-" + doc .getContents ( ) . regexpCapture ( "(?s).*@kind (\\w+)\\s.*" , 1 ) // @kind
36
+ doc .getQueryId ( ) // query ID (without lang)
37
+ + "-" + doc .getQueryKind ( ) // @kind
41
38
+ "-" +
42
39
strictcount ( String e | e .getParent * ( ) = sel .getExpr ( any ( int i | i % 2 = 1 ) ) ) // the number of string constants in the select
43
40
+ "-" + count ( sel .getExpr ( _) ) // and the total number of expressions in the select
@@ -49,10 +46,10 @@ string getSelectFingerPrint(Select sel) {
49
46
* The query-id (without language), the language, the message from the select, and a language agnostic fingerprint.
50
47
*/
51
48
Select parseSelect ( string id , string lang , string msg , string fingerPrint ) {
52
- exists ( File file , QLDoc doc | result . getLocation ( ) . getFile ( ) = file |
53
- any ( TopLevel top | top . getLocation ( ) . getFile ( ) = file ) . getQLDoc ( ) = doc and
54
- id = doc .getContents ( ) . regexpCapture ( "(?s).*@id (\\w+)/([\\w\\-]+)\\s.*" , 2 ) and
55
- lang = doc .getContents ( ) . regexpCapture ( "(?s).*@id (\\w+)/([\\w\\-]+)\\s.*" , 1 ) and
49
+ exists ( QueryDoc doc |
50
+ doc = result . getQueryDoc ( ) and
51
+ id = doc .getQueryId ( ) and
52
+ lang = doc .getQueryLanguage ( ) and
56
53
fingerPrint = getSelectFingerPrint ( result ) and
57
54
msg = getMessage ( result ) .toLowerCase ( ) // case normalize, because some languages upper-case methods.
58
55
) and
0 commit comments