void () { String s = """ class A { static String a = 1; static String s = "aaa"; static String s2; }"""; assertEquals("Literal", 2, findMatchesCount(s, "static String '_FieldName = '_Init?:[!regex( \".*\" )];")); assertEquals("Literal, 2", 1, findMatchesCount(s, "static String '_FieldName = '_Init:[!regex( \".*\" )];")); assertEquals("String literal", 1, findMatchesCount(s, "\"'String\"")); String source = """ @SuppressWarnings("test") class A { @SuppressWarnings({"other", "test"}) String field; }"""; assertEquals("String literal in annotation", 2, findMatchesCount(source, "\"test\"")); String s2 = """ class A { String a = "Alpha"; String b = "Bravo"; String c = "Charlie"; }"""; assertEquals("match literal contents", 1, findMatchesCount(s2, "\"'String:[regex( alpha )]\"")); assertEquals("negate match literal contents", 2, findMatchesCount(s2, "\"'String:[!regex( alpha )]\"")); assertEquals("match literal contents combined with other constraint", 1, findMatchesCount(s2, "\"'String:[regex( alpha ) && script( true )]\"")); String s3 = """ class A { int i = 0x20; char c = 'a'; char d = 'A'; char e = 'z'; }"""; assertEquals("match literal by value", 1, findMatchesCount(s3, "32")); assertEquals("match char with substitution", 3, findMatchesCount(s3, "\\''_x\\'")); assertEquals("string literal should not match char", 0, findMatchesCount(s3, "\"a\"")); String s4 = """ class X { String s = "\\n"; String t = " "; String u = " "; String v = ""; }"""; assertEquals("match empty string", 1, findMatchesCount(s4, "\"\"")); assertEquals("match space", 2, findMatchesCount(s4, "\" \"")); }