@@ -19,32 +19,30 @@ string getMessage(Select sel) {
19
19
) .trim ( )
20
20
}
21
21
22
- Select getSelectForQuery ( string id , string lang , string msg , string kind ) {
22
+ int parts ( Select sel ) { result = strictcount ( String e | e .getParent * ( ) = sel .getExpr ( _) ) }
23
+
24
+ Select getSelectForQuery ( string id , string lang , string msg , string kind , int parts ) {
23
25
exists ( File file , QLDoc doc | result .getLocation ( ) .getFile ( ) = file |
24
26
any ( TopLevel top | top .getLocation ( ) .getFile ( ) = file ) .getQLDoc ( ) = doc and
25
27
id = doc .getContents ( ) .regexpCapture ( "(?s).*@id (\\w+)/([\\w\\-]+)\\s.*" , 2 ) and
26
28
lang = doc .getContents ( ) .regexpCapture ( "(?s).*@id (\\w+)/([\\w\\-]+)\\s.*" , 1 ) and
27
29
kind = doc .getContents ( ) .regexpCapture ( "(?s).*@kind (\\w+)\\s.*" , 1 ) and // enforcing the same kind.
28
- msg = getMessage ( result )
30
+ msg = getMessage ( result ) and
31
+ parts = parts ( result )
29
32
) and
30
33
// excluding experimetnal
31
34
not result .getLocation ( ) .getFile ( ) .getRelativePath ( ) .matches ( "%/experimental/%" )
32
35
}
33
36
34
- from
35
- string thisLang , string otherLang , string thisMsg , string otherMsg , Select thisSel ,
36
- Select otherSel , string id , string kind
37
+ from Select sel , string id , string lang , string msg , string kind , int parts , string badLangs
37
38
where
38
- thisLang != otherLang and
39
- thisMsg != otherMsg and
40
- thisSel = getSelectForQuery ( id , thisLang , thisMsg , kind ) and
41
- otherSel = getSelectForQuery ( id , otherLang , otherMsg , kind ) and
42
- thisLang = "js"
43
- // TODO: summarize the langs in the msg.
44
- // TODO: Also select on the number of string constants in the select, to remove queries that contain more/less info.
45
- select thisSel , id + " $@" , otherSel , otherLang // TODO: Tmp, makes bulk-fixing easier.
46
- /*
47
- * "The " + id + " query in " + thisLang + " does not have the same alert message as in $@.",
48
- * otherSel, otherLang
49
- */
50
-
39
+ sel = getSelectForQuery ( id , lang , msg , kind , parts ) and
40
+ badLangs =
41
+ strictconcat ( string bad |
42
+ bad != lang and
43
+ exists ( getSelectForQuery ( id , bad , any ( string otherMsg | otherMsg != msg ) , kind , parts ) )
44
+ |
45
+ bad , ", "
46
+ )
47
+ select sel ,
48
+ "The " + lang + "/" + id + " query does not have the same alert message as " + badLangs + "."
0 commit comments