diff --git a/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl new file mode 100644 index 0000000..b29585f --- /dev/null +++ b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl @@ -0,0 +1,1339 @@ +// script +use coref::xml::* +use coref::java::* +@inline +pub fn trim(n: string, m: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__(), + i1 in int::__undetermined_all__(), + temp in string::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_0(n)) { + if (temp = n.substr(1,i - 2)) { + if (i1 = temp.len()) { + if (tmp_1(temp)) { + if (m = temp.substr(1,i1 - 2)) { + return true + } + } + if (!(tmp_1(temp))) { + if (tmp_2(temp)) { + if (m = temp.substr(2,i1 - 4)) { + return true + } + } + if (!(tmp_2(temp))) { + if (m = temp) { + return true + } + } + } + } + } + } + if (!(tmp_0(n))) { + if (tmp_3(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_3(n))) { + if (tmp_4(n)) { + if (m = n.substr(2,i - 4)) { + return true + } + } + if (!(tmp_4(n))) { + if (m = n) { + return true + } + } + } + } + } + } + } + } +} +@inline +pub fn contact(a: string, b: string, c: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__()) { + if (i = a.len()) { + if (tmp_5(i)) { + if (tmp_6(b, a)) { + if (c = b) { + return true + } + } + if (!(tmp_6(b, a))) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_5(i))) { + if (tmp_7(b, i, a)) { + if (temp = a.substr(1,i - 1)) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_7(b, i, a))) { + if (tmp_8(b, i, a)) { + if (c = a + "/" + b) { + return true + } + } + if (!(tmp_8(b, i, a))) { + if (c = a + b) { + return true + } + } + } + } + } + } + } + } +} +schema HttpMethodType extends AnnotationAccessArgument { + +} + +impl HttpMethodType { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *HttpMethodType { + for (tmp in AnnotationAccessArgument(db)) { + if (tmp.getAnnotationArgumentName() = "method") { + yield HttpMethodType { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (a in AnnotationArrayInitializer(__all_data__)) { + if (self.getArgumentValueHashId() = a.element_hash_id) { + for (i in Identifier(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (a.key_eq(r.getParent())) { + if (r.key_eq(i.getParent())) { + if (t = i.getName()) { + return t + } + } + } + } + } + } + for (i in Identifier(__all_data__)) { + if (self.getArgumentValueHashId() = i.getParent().id) { + if (t = i.getName()) { + return t + } + } + } + } + } + + +} + +pub fn getMethodType(a: Annotation, t: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (m in Method(java_db), + h in HttpMethodType(java_db)) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (tmp_9(a)) { + if (t = "POST") { + return true + } + } + if (!(tmp_9(a))) { + if (tmp_10(a)) { + if (t = "GET") { + return true + } + } + if (!(tmp_10(a))) { + if (tmp_11(a)) { + if (t = "PUT") { + return true + } + } + if (!(tmp_11(a))) { + if (tmp_12(a)) { + if (t = "DELETE") { + return true + } + } + if (!(tmp_12(a))) { + if (tmp_13(a)) { + if (t = "PATCH") { + return true + } + } + if (!(tmp_13(a))) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (h.key_eq(auto_tmp2)) { + if (t = h.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn existsValueArgument(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (temp in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in a.getAnnotationArgument()) { + if (temp = auto_tmp1) { + if (temp.getAnnotationArgumentName() = "value") { + return true + } + } + } + } + } + } +} +pub fn getSubUri(a: Annotation, sub: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (n in string::__undetermined_all__()) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (tmp_14(a)) { + for (s in string::__undetermined_all__()) { + for (temp in AnnotationAccessArgument(java_db), + e in Expression(java_db)) { + for (auto_tmp1 in a.getAnnotationArgument()) { + if (temp = auto_tmp1) { + if (temp.getAnnotationArgumentName() = "value") { + if (tmp_15(e, temp)) { + if (sub = connectStr(e)) { + return true + } + } + if (!(tmp_15(e, temp))) { + if (s = temp.getAnnotationArgumentValue()) { + if (trim(s, sub)) { + return true + } + } + } + } + } + } + } + } + } + if (!(tmp_14(a))) { + if (sub = "") { + return true + } + } + } + } + } + for (b in Annotation(java_db)) { + if (a.getAnnotatedMethod() = b.getAnnotatedMethod()) { + if (a.getName() = "POST") { + if (b.getName() = "Path") { + if (tmp_16(b)) { + for (s in string::__undetermined_all__()) { + for (temp in AnnotationAccessArgument(java_db), + e in Expression(java_db)) { + for (auto_tmp2 in b.getAnnotationArgument()) { + if (temp = auto_tmp2) { + if (temp.getAnnotationArgumentName() = "value") { + if (tmp_17(e, temp)) { + if (sub = connectStr(e)) { + return true + } + } + if (!(tmp_17(e, temp))) { + if (s = temp.getAnnotationArgumentValue()) { + if (trim(s, sub)) { + return true + } + } + } + } + } + } + } + } + } + if (!(tmp_16(b))) { + if (sub = "") { + return true + } + } + } + } + if (a.getName() = "GET") { + if (b.getName() = "Path") { + if (tmp_16(b)) { + for (s in string::__undetermined_all__()) { + for (temp in AnnotationAccessArgument(java_db), + e in Expression(java_db)) { + for (auto_tmp2 in b.getAnnotationArgument()) { + if (temp = auto_tmp2) { + if (temp.getAnnotationArgumentName() = "value") { + if (tmp_17(e, temp)) { + if (sub = connectStr(e)) { + return true + } + } + if (!(tmp_17(e, temp))) { + if (s = temp.getAnnotationArgumentValue()) { + if (trim(s, sub)) { + return true + } + } + } + } + } + } + } + } + } + if (!(tmp_16(b))) { + if (sub = "") { + return true + } + } + } + } + } + } + } + } +} +pub fn getSubUri1(a: Annotation, sub: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if ("Path" = a.getName()) { + if (tmp_18(a)) { + for (s in string::__undetermined_all__()) { + for (temp in AnnotationAccessArgument(java_db), + e in Expression(java_db)) { + for (auto_tmp1 in a.getAnnotationArgument()) { + if (temp = auto_tmp1) { + if (temp.getAnnotationArgumentName() = "value") { + if (tmp_19(e, temp)) { + if (sub = connectStr(e)) { + return true + } + } + if (!(tmp_19(e, temp))) { + if (s = temp.getAnnotationArgumentValue()) { + if (trim(s, sub)) { + return true + } + } + } + } + } + } + } + } + } + if (!(tmp_18(a))) { + if (sub = "") { + return true + } + } + } + } + } +} +pub fn getUri(c: ClassOrInterface, m: Method, uri1: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (l1 in string::__undetermined_all__(), + l2 in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (a in Annotation(java_db), + a1 in Annotation(java_db)) { + if (c = m.getParent()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + for (auto_tmp2 in c.getAnnotation()) { + if (a1 = auto_tmp2) { + if (n = a.getName()) { + if (tmp_21(c)) { + for (temp1 in string::__undetermined_all__(), + temp2 in string::__undetermined_all__()) { + if (getSubUri1(a1, temp1)) { + if (getSubUri(a, temp2)) { + if (contact(temp1, temp2, uri)) { + if (contactUri(uri, uri1)) { + return true + } + } + } + } + } + } + if (!(tmp_21(c))) { + if (tmp_23(c)) { + if (getSubUri(a, uri)) { + if (contactUri(uri, uri1)) { + return true + } + } + } + if (!(tmp_23(c))) { + if (tmp_25(a)) { + if (tmp_26(n)) { + if (getSubUri(a1, uri)) { + if (contactUri(uri, uri1)) { + return true + } + } + } + if (!(tmp_26(n))) { + if (getSubUri(a, l1)) { + if (getSubUri(a1, l2)) { + if (contact(l2, l1, uri)) { + if (contactUri(uri, uri1)) { + return true + } + } + } + } + } + } + if (!(tmp_25(a))) { + if (a1.getName() = "RequestMapping") { + if (getSubUri(a, l1)) { + if (getSubUri(a1, l2)) { + if (contact(l2, l1, uri)) { + if (contactUri(uri, uri1)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn resolve(r: ReferenceExpression, rr: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (e.getParent() = r.getDefinition()) { + if (temp = e.getPrintableText()) { + if (trim(temp, rr)) { + return true + } + } + } + } + } + } + } +} +pub fn facts(a: Expression, i: int, value: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (p in PolyadicExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_27(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_27(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_28(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_28(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in BinaryExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_27(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_27(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_28(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_28(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in ReferenceExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_27(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_27(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_28(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_28(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn connectStrBase(ID: Expression, index: int, res: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (total in int::__undetermined_all__(), + reStr in string::__undetermined_all__(), + currStr in string::__undetermined_all__()) { + if (total = tmp_29(ID).len()) { + if (tmp_31(index)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = currStr) { + return true + } + } + } + if (!(tmp_31(index))) { + if (index > 0) { + if (connectStrBase(ID, index - 1, reStr)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = reStr + currStr) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: Expression) -> string { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (c in int::__undetermined_all__(), + res in string::__undetermined_all__()) { + if (c = tmp_32(ID).len()) { + if (connectStrBase(ID, c - 1, res)) { + return res + } + } + } + } + } +} +pub fn findReleasedHttpAPI(m: Method, c: ClassOrInterface, path: string, uri: string, type: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (temp1 in string::__undetermined_all__(), + temp2 in string::__undetermined_all__(), + uri1 in string::__undetermined_all__(), + temp3 in string::__undetermined_all__()) { + for (w in Folder(java_db), + f in Folder(java_db)) { + if (findReleasedHttpAPI1(m, c, uri1, type)) { + if (tmp_34(w)) { + for (ww in WebFolder(java_db)) { + if (ww.key_eq(w)) { + if (path = ww.getRelativePath()) { + if (f = c.getLocation().getFile().getBelongedFolder()) { + if (temp1 = f.getRelativePath()) { + if (temp2 = path + "/") { + if (temp1.contains(temp2)) { + if (temp3 = ww.getModuleName()) { + if (uri = temp3 + uri1) { + return true + } + } + } + } + } + } + } + } + } + } + if (!(tmp_34(w))) { + if (path = "null") { + if (uri = uri1) { + return true + } + } + } + } + } + } + } + } +} +pub fn existsWebFolder(f: Folder) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (w in WebFolder(java_db)) { + if (f.key_eq(w)) { + return true + } + } + } + } +} +pub fn findReleasedHttpAPI1(m: Method, c: ClassOrInterface, uri1: string, type: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (n in string::__undetermined_all__()) { + for (a in Annotation(java_db)) { + if (getUri(c, m, uri1)) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (tmp_37(a)) { + if (type = "PUT") { + return true + } + if (type = "POST") { + return true + } + if (type = "OPTIONS") { + return true + } + if (type = "PATCH") { + return true + } + if (type = "HEAD") { + return true + } + if (type = "DELETE") { + return true + } + if (type = "GET") { + return true + } + } + if (!(tmp_37(a))) { + if (getMethodType(a, type)) { + return true + } + } + } + } + if (a.getName() = "POST") { + if (type = "POST") { + return true + } + } + if (a.getName() = "GET") { + if (type = "GET") { + return true + } + } + } + } + } + } + } + } + } +} +@inline +pub fn contactUri(n: string, m: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (temp in string::__undetermined_all__()) { + if (temp = n.substr(0,1)) { + if (tmp_38(temp)) { + if (m = n) { + return true + } + } + if (!(tmp_38(temp))) { + if (m = "/" + n) { + return true + } + } + } + } + } + } +} +schema WebFolder extends Folder { + +} + +impl WebFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebFolder { + for (tmp in Folder(db)) { + for (n in string::__undetermined_all__()) { + if (findReleasedArtifact(n, __all_data__)) { + if (tmp.getRelativePath() = n) { + yield WebFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + } + } + } + + pub fn getModuleName(self) -> string { + for (name in string::__undetermined_all__(), + temp1 in string::__undetermined_all__(), + temp2 in string::__undetermined_all__()) { + if (temp1 = self.getRelativePath()) { + if (tmp_39(temp1)) { + if (temp2 = self.getName()) { + if (name = "/" + temp2) { + return name + } + } + } + if (!(tmp_39(temp1))) { + if (name = "") { + return name + } + } + } + } + } + + +} + +pub fn findReleasedArtifact(moduleName: string, moduleId: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (f in PomFile(xml_db), + m in ModuleXmlElement(xml_db)) { + if (f.key_eq(m.getLocation().getFile())) { + for (auto_tmp1 in m.getCharacter()) { + if (moduleName = auto_tmp1.getText()) { + for (pa in string::__undetermined_all__(), + id in string::__undetermined_all__()) { + for (e in PomFile(xml_db), + a in ArtifactXmlElement(xml_db), + g in GroupXmlElement(xml_db), + r in RootXmlElement(xml_db)) { + if (moduleName + "/pom.xml" = e.getRelativePath()) { + if (e.key_eq(a.getLocation().getFile())) { + if (e.key_eq(g.getLocation().getFile())) { + if (r.key_eq(a.getParent())) { + for (auto_tmp2 in a.getCharacter()) { + if (id = auto_tmp2.getText()) { + if (g.getParent().getName() = "parent") { + for (auto_tmp3 in g.getCharacter()) { + if (pa = auto_tmp3.getText()) { + if (moduleId = pa + ":" + id) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(className: string, methodSignature: string, uri: string, type: string, moduleName: string, moduleId: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (c in ClassOrInterface(java_db), + m in Method(java_db)) { + if (tmp_40()) { + if (findReleasedArtifact(moduleName, moduleId)) { + if (findReleasedHttpAPI(m, c, moduleName, uri, type)) { + if (className = c.getName()) { + if (methodSignature = m.getName()) { + return true + } + } + } + } + } + if (!(tmp_40())) { + if (findReleasedHttpAPI(m, c, __all_data__, uri, type)) { + if (moduleName = "null") { + if (moduleId = "null") { + if (className = c.getName()) { + if (methodSignature = m.getName()) { + return true + } + } + } + } + } + } + } + } + } +} + + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn tmp_0(n: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (n.substr(0,1) = "{") { + return true + } + } + } +} + +fn tmp_1(temp: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (temp.substr(0,1) = "\"") { + return true + } + } + } +} + +fn tmp_2(temp: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (temp.substr(1,1) = "\"") { + return true + } + } + } +} + +fn tmp_3(n: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } + } +} + +fn tmp_4(n: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (n.substr(1,1) = "\"") { + return true + } + } + } +} + +fn tmp_5(i: int) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (i = 1) { + return true + } + } + } +} + +fn tmp_6(b: string, a: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (a.substr(0,1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } + } +} + +@inline +fn tmp_7(b: string, i: int, a: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (a.substr(i - 1,i - 1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } + } +} + +@inline +fn tmp_8(b: string, i: int, a: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { + return true + } + } + } + } +} + +fn tmp_9(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (a.getName() = "PostMapping") { + return true + } + } + } +} + +fn tmp_10(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (a.getName() = "GetMapping") { + return true + } + } + } +} + +fn tmp_11(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (a.getName() = "PutMapping") { + return true + } + } + } +} + +fn tmp_12(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (a.getName() = "DeleteMapping") { + return true + } + } + } +} + +fn tmp_13(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (a.getName() = "PatchMapping") { + return true + } + } + } +} + +fn tmp_14(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (existsValueArgument(a)) { + return true + } + } + } +} + +fn tmp_15(e: Expression, temp: AnnotationAccessArgument) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (temp.key_eq(e.getParent())) { + if (facts(e, __all_data__, __all_data__)) { + return true + } + } + } + } +} + +fn tmp_16(b: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (existsValueArgument(b)) { + return true + } + } + } +} + +fn tmp_17(e: Expression, temp: AnnotationAccessArgument) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (temp.key_eq(e.getParent())) { + if (facts(e, __all_data__, __all_data__)) { + return true + } + } + } + } +} + +fn tmp_18(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (existsValueArgument(a)) { + return true + } + } + } +} + +fn tmp_19(e: Expression, temp: AnnotationAccessArgument) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (temp.key_eq(e.getParent())) { + if (facts(e, __all_data__, __all_data__)) { + return true + } + } + } + } +} + +fn tmp_20(c: ClassOrInterface) -> *Annotation { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (b in Annotation(java_db)) { + for (auto_tmp3 in c.getAnnotation()) { + if (b = auto_tmp3) { + if (b.getName() = "Path") { + yield b + } + } + } + } + } + } +} + +fn tmp_21(c: ClassOrInterface) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (tmp_20(c).len() = 1) { + return true + } + } + } +} + +fn tmp_22(c: ClassOrInterface) -> *Annotation { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (b in Annotation(java_db)) { + for (auto_tmp4 in c.getAnnotation()) { + if (b = auto_tmp4) { + if (b.getName() = "RequestMapping") { + yield b + } + } + } + } + } + } +} + +fn tmp_23(c: ClassOrInterface) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (tmp_22(c).len() = 0) { + return true + } + } + } +} + +fn tmp_24(a: Annotation) -> *AnnotationAccessArgument { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (b in AnnotationAccessArgument(java_db)) { + for (auto_tmp5 in a.getAnnotationArgument()) { + if (b = auto_tmp5) { + if (b.getAnnotationArgumentName() = "value") { + yield b + } + } + } + } + } + } +} + +fn tmp_25(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (tmp_24(a).len() = 0) { + return true + } + } + } +} + +fn tmp_26(n: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (n.matches(".*Mapping")) { + return true + } + } + } +} + +fn tmp_27(a: Expression) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (resolve(ReferenceExpression(java_db).find(a), __all_data__)) { + return true + } + } + } +} + +fn tmp_28(e: Expression) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (resolve(ReferenceExpression(java_db).find(e), __all_data__)) { + return true + } + } + } +} + +fn tmp_29(ID: Expression) -> *auto_tmp_30 { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(Expression(java_db).find(ID), auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_30 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } + } +} + +schema auto_tmp_30 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_31(index: int) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (index = 0) { + return true + } + } + } +} + +fn tmp_32(ID: Expression) -> *auto_tmp_33 { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(Expression(java_db).find(ID), auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_33 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } + } +} + +schema auto_tmp_33 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_34(w: Folder) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (existsWebFolder(w)) { + return true + } + } + } +} + +fn tmp_35(a: Annotation) -> *auto_tmp_36 { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in string::__undetermined_all__()) { + if (getMethodType(a, auto_tmp_var_0)) { + yield auto_tmp_36 { + auto_tmp_var_0 : auto_tmp_var_0 + } + } + } + } + } +} + +schema auto_tmp_36 { + auto_tmp_var_0 : string +} + +fn tmp_37(a: Annotation) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (tmp_35(a).len() = 0) { + return true + } + } + } +} + +fn tmp_38(temp: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (temp = "/") { + return true + } + } + } +} + +fn tmp_39(temp1: string) -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (temp1.contains("app/web/")) { + if (temp1 != "app/web/home") { + return true + } + } + } + } +} + +fn tmp_40() -> bool { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + if (findReleasedArtifact(__all_data__, __all_data__)) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/Keymap/FindAllReleasedTrAPI.gdl b/example/icse25/Keymap/FindAllReleasedTrAPI.gdl new file mode 100644 index 0000000..e9a6bf4 --- /dev/null +++ b/example/icse25/Keymap/FindAllReleasedTrAPI.gdl @@ -0,0 +1,695 @@ +// script +use coref::java::* +use coref::xml::* +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> Interface { + for (value in string::__undetermined_all__()) { + for (i in Interface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_2(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_2(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string, uniqueId: string, type: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (value in string::__undetermined_all__()) { + for (s in SofaService(java_db), + c in Class(java_db), + b in SofaServiceBinding(java_db), + i in Interface(java_db)) { + if (b = s.getBinding()) { + if (value = b.getType()) { + if (value.contains("tr")) { + if (type = "tr") { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i = auto_tmp2) { + if (name = i.getQualifiedName()) { + if (uniqueId = s.getUniqueId()) { + return true + } + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + if (uniqueId = s.getUniqueId()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + +pub fn xmlOutput(bindingType: string, uniqueId: string, className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db), + t in TagXmlElement(xml_db)) { + if (s.key_eq(t.getParent())) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (uniqueId = s.getUniqueId()) { + if (bindingType = s.getBindingType()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(bindingType: string, uniqueId: string, className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + if (uniqueId = s.getUniqueId()) { + if (bindingType = s.getBindingType()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn output1(className: string, interfaceName: string, uniqueId: string, bindingType: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (xmlOutput(bindingType, uniqueId, className, interfaceName)) { + return true + } + if (javaOutput(className, interfaceName, uniqueId, bindingType)) { + return true + } + if (annoOutput(bindingType, uniqueId, className, interfaceName)) { + return true + } + } + } +} +pub fn isSelfDefinedInterface(name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in Interface(java_db)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } +} +schema PublicMethod extends Method { + +} + +impl PublicMethod { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *PublicMethod { + for (tmp in Method(db)) { + for (m in Modifier(db)) { + for (auto_tmp1 in tmp.getModifier()) { + if (m = auto_tmp1) { + if (m.getName() = "public") { + if (!isSetOrGetMethod(tmp)) { + yield PublicMethod { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + signature : tmp.signature, + type_hash_id : tmp.type_hash_id, + parent_hash_id : tmp.parent_hash_id, + location_hash_id : tmp.location_hash_id, + definition_body : tmp.definition_body + } + } + } + } + } + } + } + } + + +} + +pub fn isBooleanTypeField(f: Field, p: string, q: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + n in string::__undetermined_all__(), + tmp1 in string::__undetermined_all__(), + tmp2 in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__()) { + if (n = f.getName()) { + if (i = n.len()) { + if (tmp_7(n)) { + if (tmp1 = n.substr(2,i)) { + if (l = n.substr(2,1)) { + if (tmp2 = n.substr(3,i)) { + if (q = n) { + if (p = "set" + tmp1) { + return true + } + } + if (q = "get" + l + tmp2) { + if (p = "set" + tmp1) { + return true + } + } + } + } + } + } + if (!(tmp_7(n))) { + if (l = n.substr(0,1)) { + if (tmp2 = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp2) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + if (p = "set" + n) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isSetOrGetMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + p in string::__undetermined_all__(), + q in string::__undetermined_all__(), + n in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__(), + tmp in string::__undetermined_all__(), + t in string::__undetermined_all__()) { + for (f in Field(java_db)) { + if (n = f.getName()) { + if (i = n.len()) { + if (f.getParent() = m.getParent()) { + if (p = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_8(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_8(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + if (q = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_8(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_8(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn findReleasedTrAPI(interfaceName: string, className: string, methodName: string, tag: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in Interface(java_db), + c in Class(java_db)) { + if (output1(className, interfaceName, __all_data__, __all_data__)) { + if (tmp_9(interfaceName)) { + if (interfaceName = i.getQualifiedName()) { + for (m in Method(java_db)) { + if (i.key_eq(m.getParent())) { + if (methodName = m.getSignature()) { + if (tag = "Self") { + return true + } + } + } + } + } + } + if (!(tmp_9(interfaceName))) { + if (className = c.getQualifiedName()) { + for (n in PublicMethod(java_db)) { + if (c.key_eq(n.getParent())) { + if (methodName = n.getSignature()) { + if (tag = "External") { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn findReleasedArtifact(moduleName: string, moduleId: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in PomFile(xml_db), + m in ModuleXmlElement(xml_db)) { + if (f.key_eq(m.getLocation().getFile())) { + for (auto_tmp1 in m.getCharacter()) { + if (moduleName = auto_tmp1.getText()) { + for (pa in string::__undetermined_all__(), + id in string::__undetermined_all__()) { + for (e in PomFile(xml_db), + a in ArtifactXmlElement(xml_db), + g in GroupXmlElement(xml_db), + r in RootXmlElement(xml_db)) { + if (moduleName + "/pom.xml" = e.getRelativePath()) { + if (e.key_eq(a.getLocation().getFile())) { + if (e.key_eq(g.getLocation().getFile())) { + if (r.key_eq(a.getParent())) { + for (auto_tmp2 in a.getCharacter()) { + if (id = auto_tmp2.getText()) { + if (g.getParent().getName() = "parent") { + for (auto_tmp3 in g.getCharacter()) { + if (pa = auto_tmp3.getText()) { + if (moduleId = pa + ":" + id) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(interfaceName: string, className: string, methodName: string, tag: string, moduleName: string, moduleId: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp1 in string::__undetermined_all__(), + temp2 in string::__undetermined_all__()) { + for (c in Class(java_db), + f in Folder(java_db)) { + if (c.getQualifiedName() = className) { + if (findReleasedTrAPI(interfaceName, className, methodName, tag)) { + if (findReleasedArtifact(moduleName, moduleId)) { + if (f = c.getLocation().getFile().getBelongedFolder()) { + if (temp1 = f.getRelativePath()) { + if (temp2 = moduleName + "/") { + if (temp1.contains(temp2)) { + return true + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(anno: Annotation) -> *auto_tmp_1 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_1 { + + } + } + } + } +} + +schema auto_tmp_1 { + +} + +fn tmp_2(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_0(anno).len() = 1) { + return true + } + } + } +} + +fn tmp_3(x: SofaServiceXmlElement) -> *auto_tmp_4 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (hasUniqueIdAttribute(XmlElement(__all_data__).find(x))) { + yield auto_tmp_4 { + + } + } + } + } +} + +schema auto_tmp_4 { + +} + +fn tmp_5(x: SofaServiceXmlElement) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_3(x).len() = 1) { + return true + } + } + } +} + +fn tmp_6(auto_replace_var: SofaServiceXmlElement) -> *TagXmlElement { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in TagXmlElement(__all_data__)) { + if (auto_replace_var.key_eq(t.getParent())) { + yield t + } + } + } + } +} + +fn tmp_7(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.matches("is.*")) { + return true + } + } + } +} + +fn tmp_8(t: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (t = "boolean") { + return true + } + if (t = "Boolean") { + return true + } + } + } +} + +fn tmp_9(interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isSelfDefinedInterface(interfaceName)) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/motivation example.md b/example/icse25/motivation example.md new file mode 100644 index 0000000..a78182f --- /dev/null +++ b/example/icse25/motivation example.md @@ -0,0 +1,127 @@ +# Motivation Example + +## Relation + +### Java + +``` +field(id, tid, name, locId) +method(id, tid, name) +parent(id1, id2) +class(id, name) +interface(id, name) +type(id, n) +javaLoc(locId, s, e, path) +``` + +### XML + +``` +xmlEle() +xmlAttri() +``` + +### JS/TS + +``` +enclose(exprId, methodId) +callExpr(exprId, methodId, argExprId, callSiteId) +reference(refId, defId) +service(id, appId, locId) +jsLoc(locId, s, e, path) +app(id, name) +api(id, apiName, apiSignature, appId) +functionLikeDeclaration(id, name) +parent(id1, id2) +class(id, name) +``` + +## Rule + +### Java + +``` +changedField(fid) :- ( + field(fid, _, _, locId), + loc(locId, s, e, path), + changedSet(line, path), + line >= s, + line <= e +). +fieldInClassType(fName, tName) :- ( + field(fid, _, fName), + parent(fid, cid), + class(cid, tName), + type(tid, tName) +). + +fieldInDescendantClassType(fName, tName) :- fieldInClassType(fName, tName). +fieldInDescendantClassType(fName, tName) :- fieldInClassType(fName, tName1), fieldInDescendantClassType(tName1, tName). + +changedMethodInInterface(fid, mid, iid) :- ( + changedField(fid), + field(fid, _, fName, _), + fieldInDescendantClassType(fName, tName), + type(tid, tName), + method(mid, tid, _), + parent(mid, iid), + interface(iid, _) +). +``` + +### Java, XML + +参考原论文 + +``` +getChangedTrAPI(trInterfaceName, trMethodName) :- ( + changedMethodInInterface(fid, mid, iid), + method(mid, _, trMethodName), + interface(iid, trInterfaceName), + service(bid, cid), + in(iid, cid) +). +``` + +### JS + +``` +getAppFacade(appName, proxyFacadeName, facadeQualifiedName) :- ( + service(id, appId, locId), + jsLoc(locId, _, _, path), + path = "config/proxy.js", + app(appId, appName), + api(_, proxyFacadeName, facadeQualifiedName, appId) +). +getInfluencedTrAPI(appName, proxyFacadeName, facadeQualifiedName, trMethodName) :- ( + getChangedTrAPI(facadeQualifiedName, trMethodName), + getAppFacade(appName, proxyFacadeName, facadeQualifiedName) +). +``` + +### TS + +``` +getInfluencedTrAPICall(appName, proxyFacadeName, callExprId) :- ( + getInfluencedTrAPI(appName, proxyFacadeName, facadeQualifiedName, trMethodName), + callExpr(callExprId, mid, _, callSiteId), + reference(callSiteId, defId), + api(defId, proxyFacadeName, _, _) +). + +getInfluencedFrontEndAPI(rpcName, trFuncName) :- ( + getInfluencedTrAPICall(_, _, callExprId), + enclose(callExprId, methodId), + functionLikeDeclaration(mid, trFuncName), + parent(mid, cid), + class(cid, rpcName) +). +``` + +## Workflow + +1. 根据变更行号,识别出变更内容为新增某一个Field f。 +2. 通过影响面分析,得出有一个 Interface 的函数 m 的返回类型为包含这个新增字段的类 c。 +3. 通过结合xml配置分析,这个函数 m 所在的 Interface i 实际为一个对外发布的 rpc 接口。 +4. 通过分析 bff 应用的配置 proxy.js 文件,发现 该应用 配置了 变更的 rpc 接口。 +5. 通过分析 bff 应用里所有的 函数调用,发现有使用了 该变更的 rpc 接口,并且 调用函数所在类也是对前端开放的服务接口,由于调用函数的传参与变更后的不一致,导致查询失败,使用该接口的前端服务全部崩溃。 \ No newline at end of file diff --git a/example/icse25/procedure.md b/example/icse25/procedure.md new file mode 100644 index 0000000..dc6c0e3 --- /dev/null +++ b/example/icse25/procedure.md @@ -0,0 +1,27 @@ +实验步骤: + +1. 运行gitdiff脚本,识别出两个commit之间的所有变更文件名和行号 +2. 运行rule1.gdl,将变更文件名和行号转换为对应的java ecg node id。 +3. 运行rule5.gdl,将变更文件名和行号转换为对应的xml ecg node id。 +4. 运行rule4.gdl,输入为rule1找到的java ecg node,输出为这些ecg node影响到的发布的http request函数。 +4. 运行rule2.gdl,输入为rule1找到的java ecg node,输出为这些ecg node影响到的http response函数。 +5. 运行rule6.gdl,输入为rule1和rule5找到的所有ecg node,输出为这些ecg node是否为发布的tr接口。 +6. 运行rule7.gdl,输入为rule5找到的xml ecg node,输出为这些node对应的mybatis 框架下的java源码,字段或函数。 +7. 运行rule8.gdl,输入为rule1和rule7找到的所有ecg node,输出为这些ecg node 影响到的发布的tr接口。 +8. 运行rule13.gdl,输入为变更行和行号,输出为本次变更的变更影响调用链路的调用根节点的函数签名(默认为baseline)。 +9. 比较rule13与rule4,rule6的结果。 +10. rule17 仓库地址:{unknown} +11. 运行rule17, 输入为rule1找到的java ecg node,输出为本次变更影响到的tr接口和函数名。 +12. BFF为私仓,本地下好。 +13. 运行rule18, 输入为rule17找到的tr接口全名和函数名,输出为BFF应用使用到的appname配置,tr接口和函数名。 +14. 运行rule19,输入为rule18找到的appname配置,tr接口和函数名,输出为使用到这些tr接口的rpc接口和函数 + +update 版本 +1. 运行gitdiff脚本,识别出两个commit之间的所有变更文件名和行号 +2. 运行rule_ecg.gdl,输入为变更行和行号,输出为本次变更的tr接口和http接口信息。 +3. 运行rule_1_5.gdl,输入为变更行和行号,输出为本次变更的ecg node。 +4. 运行rule_6_8.gdl,输入为变更行和行号,输出为本次变更的tr接口。 +5. 运行rule_1_4.gdl,输入为变更行和行号,输出为本次变更的http接口。 +3. 运行rule13.gdl,输入为变更行和行号,输出为本次变更的变更影响调用链路的调用根节点的函数签名(默认为baseline)。 +4. 运行rule9 输出为查询到该应用发布的所有http request接口,用于与rule_1_4的结果进行比较。 +5. 运行rule12.gdl,输出为该应用发布的所有tr接口、实现类和对应的具体函数信息,用于与rule6_8结果进行比较。 diff --git a/example/icse25/rules/ecg.gdl b/example/icse25/rules/ecg.gdl new file mode 100644 index 0000000..2ffcd13 --- /dev/null +++ b/example/icse25/rules/ecg.gdl @@ -0,0 +1,711 @@ +// script +use coref::java::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +pub fn getNode(node: int) -> bool { + [ + // {-6062664004747450091}, + // {-8976777526123968441}, + // {-7423165299222302626} + ] +} + +pub fn temp(a: ECGNode, b: ECGNode, c: ECGNode, edgeType: string, direction: string) -> bool { + let (java_db = default_java_db()) { + if (getNode(a.id)) { + if (b = a.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (c = b.getECGNode(edgeType, direction)) { + return true + } + } + if (b = a) { + if (c = b.getECGNode(edgeType, direction)) { + return true + } + } + } + } +} + +pub fn real_output(m: ECGNode, nodeType1: string, nodeText1: string, n: ECGNode, nodeType2: string, nodeText2: string, edgeType: string, direction: string) -> bool { + let (java_db = default_java_db()) { + for (e in ECGNode(java_db)) { + if (temp(e, m, n, edgeType, direction)) { + if (nodeType1 = m.getType()) { + if (nodeText1 = m.print()) { + if (nodeText2 = n.print()) { + if (nodeType2 = n.getType()) { + return true + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/ecgformybatis.gdl b/example/icse25/rules/ecgformybatis.gdl new file mode 100644 index 0000000..f13eb58 --- /dev/null +++ b/example/icse25/rules/ecgformybatis.gdl @@ -0,0 +1,54 @@ +// script +use coref::xml::* + +schema SqlIncludeElement extends XmlElement {} + +impl SqlIncludeElement { + pub fn __all__(db: XmlDB) -> *SqlIncludeElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "include") { + yield SqlIncludeElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } +} + +pub fn real_output(id: string, type: string, table: string, columns: string) -> bool { + let (xml_db = default_xml_db()) { + for (d in DalXmlElement(xml_db)) { + if (id = d.getValueByAttributeName("id")) { + if (type = d.getValueByAttributeName("parameterType")) { + for (auto_tmp1 in d.getTableName()) { + if (table = auto_tmp1) { + if (columns = d.getColumnLists()) { + return true + } + } + } + } + } + } + } +} + + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(temp1: string) -> bool { + let (xml_db = default_xml_db()) { + if (temp1.len() > 0) { + return true + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/ecgforpom.gdl b/example/icse25/rules/ecgforpom.gdl new file mode 100644 index 0000000..a495718 --- /dev/null +++ b/example/icse25/rules/ecgforpom.gdl @@ -0,0 +1,292 @@ +// script +use coref::xml::* +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> Location { + for (l in Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } +} + +schema DependencyElement extends XmlElement {} + +impl DependencyElement { + pub fn __all__(db: XmlDB) -> *DependencyElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "dependency") { + yield DependencyElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } +} + +schema GroupElement extends XmlElement {} + +impl GroupElement { + pub fn __all__(db: XmlDB) -> *GroupElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "groupId") { + yield GroupElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } +} + +schema VersionElement extends XmlElement {} + +impl VersionElement { + pub fn __all__(db: XmlDB) -> *VersionElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "version") { + yield VersionElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getLineNo(self) -> int { + for (lineNo in int::__undetermined_all__()) { + if (lineNo = self.getLocation().getStartLineNumber()) { + return lineNo + } + } + } + + pub fn getVersion(self) -> string { + for (version in string::__undetermined_all__(), + dependencyCharacterText in string::__undetermined_all__()) { + for (dependencyCharacter in XmlCharacter(__all_data__)) { + if (dependencyCharacter.getBelongedElement().key_eq(self)) { + if (dependencyCharacterText = dependencyCharacter.getText()) { + if (tmp_0(dependencyCharacterText)) { + for (propertyCharacterText in string::__undetermined_all__()) { + for (property in PropertyElement(__all_data__), + propertyCharacter in XmlCharacter(__all_data__)) { + if (propertyCharacter.getBelongedElement().key_eq(property)) { + if (propertyCharacterText = property.getElementName()) { + if (dependencyCharacterText.contains(propertyCharacterText)) { + if (version = propertyCharacter.getText()) { + return version + } + } + } + } + } + } + } + if (!(tmp_0(dependencyCharacterText))) { + if (version = dependencyCharacter.getText()) { + return version + } + } + } + } + } + } + } +} + +schema PropertyElement extends XmlElement { + +} + +impl PropertyElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *PropertyElement { + for (tmp in XmlElement(db)) { + if (tmp.getParent().getElementName() = "properties") { + yield PropertyElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema ArtifactElement extends XmlElement { + +} + +impl ArtifactElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *ArtifactElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "artifactId") { + yield ArtifactElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +pub fn existVersion(p: DependencyElement) -> bool { + let (xml_db = default_xml_db()) { + for (v in VersionElement(xml_db)) { + if (p.key_eq(v.getParent())) { + return true + } + } + } +} +pub fn real_output(fileName: string, groupId: string, artifactId: string, version: string) -> bool { + let (xml_db = default_xml_db()) { + for (f in PomFile(xml_db), + e1 in GroupElement(xml_db), + e2 in VersionElement(xml_db), + e3 in ArtifactElement(xml_db), + c1 in XmlCharacter(xml_db), + c2 in XmlCharacter(xml_db), + p in DependencyElement(xml_db)) { + if (f.key_eq(p.getLocation().getFile())) { + if (fileName = f.getRelativePath()) { + if (p.key_eq(e1.getParent())) { + if (e1.key_eq(c1.getBelongedElement())) { + if (groupId = c1.getText()) { + if (tmp_1(p)) { + if (p.key_eq(e2.getParent())) { + if (version = e2.getVersion()) { + if (p.key_eq(e3.getParent())) { + if (e3.key_eq(c2.getBelongedElement())) { + if (artifactId = c2.getText()) { + return true + } + } + } + } + } + } + if (!(tmp_1(p))) { + if (version = "") { + if (p.key_eq(e3.getParent())) { + if (e3.key_eq(c2.getBelongedElement())) { + if (artifactId = c2.getText()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(dependencyCharacterText: string) -> bool { + let (xml_db = default_xml_db()) { + if (dependencyCharacterText.contains("${")) { + return true + } + } +} + +fn tmp_1(p: DependencyElement) -> bool { + let (xml_db = default_xml_db()) { + if (existVersion(p)) { + return true + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/ecgforspring.gdl b/example/icse25/rules/ecgforspring.gdl new file mode 100644 index 0000000..e2263b7 --- /dev/null +++ b/example/icse25/rules/ecgforspring.gdl @@ -0,0 +1,184 @@ +// script +use coref::xml::* +schema BeanElement extends XmlElement { + +} + +impl BeanElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *BeanElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "bean") { + yield BeanElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getProperty(self) -> PropertyElement { + for (e in PropertyElement(__all_data__)) { + if (self.key_eq(e.getParent())) { + return e + } + } + } + + +} + +schema ImportElement extends XmlElement { + +} + +impl ImportElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *ImportElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "import") { + yield ImportElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema MapElement extends XmlElement { + +} + +impl MapElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *MapElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "map") { + yield MapElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema EntryElement extends XmlElement { + +} + +impl EntryElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *EntryElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "entry") { + yield EntryElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema ValueElement extends XmlElement { + +} + +impl ValueElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *ValueElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "value") { + yield ValueElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema PropertyElement extends XmlElement { + +} + +impl PropertyElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *PropertyElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "property") { + yield PropertyElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getValueByPropertyName(self, name: string) -> string { + for (value in string::__undetermined_all__()) { + if (name = self.getValueByAttributeName("name")) { + if (value = self.getValueByAttributeName("value")) { + return value + } + } + } + } + + +} + +pub fn real_output(id: string, pClass: string) -> bool { + let (xml_db = default_xml_db()) { + for (b in BeanElement(xml_db)) { + if (id = b.getValueByAttributeName("id")) { + if (pClass = b.getValueByAttributeName("class")) { + return true + } + } + } + } +} + + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/ecgxml.gdl b/example/icse25/rules/ecgxml.gdl new file mode 100644 index 0000000..b168bfc --- /dev/null +++ b/example/icse25/rules/ecgxml.gdl @@ -0,0 +1,489 @@ +// script +use coref::xml::* +schema BeanElement extends XmlElement { + +} + +impl BeanElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *BeanElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "bean") { + yield BeanElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getProperty(self) -> PropertyElement { + for (e in PropertyElement(__all_data__)) { + if (self.key_eq(e.getParent())) { + return e + } + } + } + + +} + +schema ImportElement extends XmlElement { + +} + +impl ImportElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *ImportElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "import") { + yield ImportElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema MapElement extends XmlElement { + +} + +impl MapElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *MapElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "map") { + yield MapElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema EntryElement extends XmlElement { + +} + +impl EntryElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *EntryElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "entry") { + yield EntryElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema ValueElement extends XmlElement { + +} + +impl ValueElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *ValueElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "value") { + yield ValueElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema PropertyElement extends XmlElement { + +} + +impl PropertyElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *PropertyElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "property") { + yield PropertyElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getValueByPropertyName(self, name: string) -> string { + for (value in string::__undetermined_all__()) { + if (name = self.getValueByAttributeName("name")) { + if (value = self.getValueByAttributeName("value")) { + return value + } + } + } + } + + +} + +schema DependencyElement extends XmlElement { + +} + +impl DependencyElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *DependencyElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "dependency") { + yield DependencyElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema GroupElement extends XmlElement { + +} + +impl GroupElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *GroupElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "groupId") { + yield GroupElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema VersionElement extends XmlElement { + +} + +impl VersionElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *VersionElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "version") { + yield VersionElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getLineNo(self) -> int { + for (lineNo in int::__undetermined_all__()) { + if (lineNo = self.getLocation().getStartLineNumber()) { + return lineNo + } + } + } + + pub fn getVersion(self) -> string { + for (version in string::__undetermined_all__(), + dependencyCharacterText in string::__undetermined_all__()) { + for (dependencyCharacter in XmlCharacter(__all_data__)) { + if (dependencyCharacter.getBelongedElement().key_eq(self)) { + if (dependencyCharacterText = dependencyCharacter.getText()) { + if (Self::tmp_0(dependencyCharacterText)) { + for (propertyCharacterText in string::__undetermined_all__()) { + for (property in PropertyElement(__all_data__), + propertyCharacter in XmlCharacter(__all_data__)) { + if (propertyCharacter.getBelongedElement().key_eq(property)) { + if (propertyCharacterText = property.getElementName()) { + if (dependencyCharacterText.contains(propertyCharacterText)) { + if (version = propertyCharacter.getText()) { + return version + } + } + } + } + } + } + } + if (!Self::tmp_0(dependencyCharacterText)) { + if (version = dependencyCharacter.getText()) { + return version + } + } + } + } + } + } + } + + fn tmp_0(dependencyCharacterText: string) -> bool { + if (dependencyCharacterText.contains("${")) { + return true + } + } +} + +schema PropertyInPomElement extends XmlElement { + +} + +impl PropertyInPomElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *PropertyInPomElement { + for (tmp in XmlElement(db)) { + if (tmp.getParent().getElementName() = "properties") { + yield PropertyInPomElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema ArtifactElement extends XmlElement { + +} + +impl ArtifactElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *ArtifactElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "artifactId") { + yield ArtifactElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> Location { + for (l in Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + [ + {"pom.xml", 27}, + {"pom.xml", 612}, + {"pom.xml", 613}, + {"pom.xml", 614}, + {"pom.xml", 615}, + {"pom.xml", 616}, + {"pom.xml", 617}, + {"pom.xml", 649} + ] +} +pub fn transfertofile(f: XmlFile, filename: string, lineNumber: int) -> bool { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + return true + } + } + } +} +pub fn real_output(filename: string, lineNumber: int, c: ECGXmlNode, typeInAST: string, e: int, s1: int) -> bool { + let (xml_db = default_xml_db()) { + for (f in XmlFile(xml_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } +} + + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule1.gdl b/example/icse25/rules/rule1.gdl new file mode 100644 index 0000000..66b177a --- /dev/null +++ b/example/icse25/rules/rule1.gdl @@ -0,0 +1,998 @@ +// script +use coref::java::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + //python替换 + // $gitdiff + // example + [ {"test", 1111}] +} +pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + if (gitdiff(filename, lineNumber)) { + if (!filename.contains("src/test/java")) { + if (filename = f.getRelativePath()) { + if (isCodeLine(f, filename, lineNumber)) { + return true + } + } + } + } + } +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + if (transfertofile1(f, filename, lineNumber)) { + if (!findSpecialCodeType(filename, lineNumber, __all_data__)) { + return true + } + } + } +} +pub fn isComment(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn isAnnotation(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Annotation(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + if (gitdiff(filename, lineNumber)) { + if (f.getRelativePath() = filename) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (l in Location(java_db)) { + if (l.getFile() = f) { + if (s1 = l.getStartLineNumber()) { + if (e = l.getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn isLog(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (c in Expression(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (text = c.getPrintableText()) { + if (text.matches("^logger\\..*")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in ElementParent(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (s1 = e) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (tmp_0(filename, lineNumber)) { + if (typeInAST = "Callable") { + if (getBelongedCallable(filename, lineNumber, Callable(java_db).find(n))) { + return true + } + } + } + if (!(tmp_0(filename, lineNumber))) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (isFieldOrEnum(ECGNode(java_db).find(n))) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isFieldOrEnum(c: ECGNode) -> bool { + let (java_db = default_java_db()) { + for (f in Field(java_db)) { + if (f.key_eq(c)) { + return true + } + } + for (e in EnumConstant(java_db)) { + if (e.key_eq(c)) { + return true + } + } + } +} +pub fn findSpecialCodeType(filename: string, lineNumber: int, type: string) -> bool { + let (java_db = default_java_db()) { + if (isComment(filename, lineNumber)) { + if (type = "comment") { + return true + } + } + if (isAnnotation(filename, lineNumber)) { + if (type = "annotation") { + return true + } + } + if (isLog(filename, lineNumber)) { + if (type = "log") { + return true + } + } + } +} +pub fn getBelongedCallable(filename: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (l1 in int::__undetermined_all__(), + l2 in int::__undetermined_all__()) { + for (i in Identifier(java_db)) { + if (f = c.getLocation().getFile()) { + if (c.key_eq(i.getParent())) { + if (l1 = i.getLocation().getStartLineNumber()) { + if (l2 = c.getLocation().getEndLineNumber()) { + if (lineNumber > l1 - 1) { + if (lineNumber < l2 + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getBelongedCallableSignature(filename: string, lineNumber: int, belongedCallable: string) -> bool { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__()) { + for (c in Callable(java_db)) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (i = tmp_1().len()) { + if (tmp_2(i)) { + if (belongedCallable = "") { + return true + } + } + if (!(tmp_2(i))) { + if (getBelongedCallable(filename, lineNumber, c)) { + if (belongedCallable = c.getSignature()) { + return true + } + } + } + } + } + } + } + } +} +pub fn real_output(n: ECGNode, belongedCallable: string, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__()) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + return true + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn tmp_0(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + return true + } + } +} + +fn tmp_1() -> *string { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename + } + } +} + +fn tmp_2(i: int) -> bool { + let (java_db = default_java_db()) { + if (i = 0) { + return true + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule10.gdl b/example/icse25/rules/rule10.gdl new file mode 100644 index 0000000..d60ca37 --- /dev/null +++ b/example/icse25/rules/rule10.gdl @@ -0,0 +1,1227 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn xmlOutput(bindingType: string, interfaceName: string, uniqueId: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaReferenceXmlElement(xml_db), + t in TrTagXmlElement(xml_db)) { + if (s.key_eq(t.getParent())) { + if (interfaceName = s.getInterfaceName()) { + if (uniqueId = s.getUniqueId()) { + if (bindingType = "tr") { + return true + } + } + } + } + } + } + } +} +pub fn getXMLInterfaceName(s: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (xmlOutput(__all_data__, s, __all_data__)) { + return true + } + } + } +} +pub fn exclude(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in Class(java_db)) { + if (n = c.getQualifiedName()) { + return true + } + } + for (i in Interface(java_db)) { + if (n = i.getQualifiedName()) { + return true + } + } + } + } +} +schema TrInterface1 extends Import { + +} + +impl TrInterface1 { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *TrInterface1 { + for (tmp in Import(db)) { + for (s in string::__undetermined_all__()) { + if (s = tmp.getName()) { + if (getXMLInterfaceName(s)) { + if (!exclude(s)) { + yield TrInterface1 { + element_hash_id : tmp.element_hash_id, + reference_hash_id : tmp.reference_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + location_hash_id : tmp.location_hash_id, + is_foreign_import : tmp.is_foreign_import + } + } + } + } + } + } + } + + +} + +pub fn output2(n: string, m: string, i: Identifier, r: ReferenceExpression) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in int::__undetermined_all__()) { + for (t in TrInterface1(java_db)) { + if (i.getParent() = r.getParent()) { + if (s = r.getLocation().getFile().element_hash_id) { + if (s = t.getContainingFile().element_hash_id) { + if (n = t.getName()) { + if (t.getTargetName() = r.getPrintableText()) { + if (m = i.getName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn matachField(im: TrInterface1, f: Field) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in int::__undetermined_all__(), + s in string::__undetermined_all__()) { + if (t = f.getLocation().getFile().element_hash_id) { + if (f.getType().getName() = s) { + if (s = im.getTargetName()) { + if (t = im.getContainingFile().element_hash_id) { + return true + } + } + } + } + } + } + } +} +pub fn matchMethod(im: TrInterface1, f: Method) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in int::__undetermined_all__(), + s in string::__undetermined_all__()) { + if (t = f.getLocation().getFile().element_hash_id) { + if (f.getType().getName() = s) { + if (s = im.getTargetName()) { + if (t = im.getContainingFile().element_hash_id) { + return true + } + } + } + } + } + } + } +} +pub fn matchLocalVariable(im: TrInterface1, f: LocalVariable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in int::__undetermined_all__(), + s in string::__undetermined_all__()) { + if (t = f.getLocation().getFile().element_hash_id) { + if (f.getType().getName() = s) { + if (s = im.getTargetName()) { + if (im.getContainingFile().element_hash_id = t) { + return true + } + } + } + } + } + } + } +} +pub fn matchParameter(im: TrInterface1, f: Parameter) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in int::__undetermined_all__(), + s in string::__undetermined_all__()) { + if (f.getType().getName() = s) { + if (s = im.getTargetName()) { + if (t = f.getLocation().getFile().element_hash_id) { + if (im.getContainingFile().element_hash_id = t) { + return true + } + } + } + } + } + } + } +} +pub fn output3(id: string, m: string, iden: Identifier, r1: Expression) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (r in ReferenceExpression(java_db), + im in TrInterface1(java_db)) { + if (r.key_eq(r1)) { + if (r.getParent() = iden.getParent()) { + for (f in Field(java_db)) { + if (f.key_eq(r.getDefinition())) { + if (matachField(im, f)) { + if (id = im.getName()) { + if (m = iden.getName()) { + return true + } + } + } + } + } + for (l in LocalVariable(java_db)) { + if (l.key_eq(r.getDefinition())) { + if (matchLocalVariable(im, l)) { + if (id = im.getName()) { + if (m = iden.getName()) { + return true + } + } + } + } + } + for (l in Parameter(java_db)) { + if (l.key_eq(r.getDefinition())) { + if (matchParameter(im, l)) { + if (id = im.getName()) { + if (m = iden.getName()) { + return true + } + } + } + } + } + } + } + } + for (r in MethodAccessExpression(java_db), + im in TrInterface1(java_db)) { + if (r.key_eq(r1)) { + if (r.getParent() = iden.getParent()) { + for (l in Method(java_db)) { + if (l = r.getMethod()) { + if (matchMethod(im, l)) { + if (id = im.getName()) { + if (m = iden.getName()) { + return true + } + } + } + } + } + } + } + } + if (output2(id, m, iden, ReferenceExpression(java_db).find(r1))) { + return true + } + } + } +} +pub fn importOutput(className: string, methodName: string, fileName: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in TrInterface1(java_db), + r in Expression(java_db)) { + if (className = t.getName()) { + if (getXMLInterfaceName(className)) { + if (!exclude(className)) { + if (tmp_0(className)) { + if (output3(className, methodName, __all_data__, r)) { + if (fileName = r.getLocation().getFile().getRelativePath()) { + if (lineNumber = r.getLocation().getStartLineNumber()) { + if (c = r.getEnclosingCallable()) { + return true + } + } + } + } + } + if (!(tmp_0(className))) { + if (methodName = "null") { + if (fileName = "null") { + if (lineNumber = 0) { + if (c.id = 0) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +schema TrInterface extends Interface { + +} + +impl TrInterface { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *TrInterface { + for (tmp in Interface(db)) { + for (s in string::__undetermined_all__()) { + if (s = tmp.getQualifiedName()) { + if (getXMLInterfaceName(s)) { + yield TrInterface { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + identifier_hash_id : tmp.identifier_hash_id, + location_hash_id : tmp.location_hash_id, + parent_hash_id : tmp.parent_hash_id + } + } + } + } + } + } + + pub fn getCallable(self) -> Callable { + for (m in Callable(__all_data__)) { + if (self.key_eq(m.getBelongedInterface())) { + return m + } + } + } + + pub fn getCallSite(self, d: Callable) -> Expression { + for (c1 in Expression(__all_data__)) { + if (d = self.getCallable()) { + for (c in MethodAccessExpression(__all_data__)) { + if (c.key_eq(c1)) { + if (d.key_eq(c.getMethod())) { + return c1 + } + } + } + for (c in MethodReferenceExpression(__all_data__)) { + if (c.key_eq(c1)) { + if (d.key_eq(c.getMethod())) { + return c1 + } + } + } + } + } + } + + +} + +pub fn getCallers(c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in Callable(java_db)) { + for (auto_tmp1 in c.getCaller()) { + if (m = auto_tmp1) { + return true + } + } + } + } + } +} +pub fn selfDefineOutput(interfaceName: string, methodName: string, fileName: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in TrInterface(java_db)) { + if (c = i.getCallable()) { + if (interfaceName = i.getQualifiedName()) { + if (methodName = c.getName()) { + if (tmp_1(c)) { + for (e in Expression(java_db)) { + if (e = i.getCallSite(c)) { + if (fileName = e.getLocation().getFile().getRelativePath()) { + if (lineNumber = e.getLocation().getStartLineNumber()) { + if (c.id = e.getEnclosingCallable().id) { + return true + } + } + } + } + } + } + if (!(tmp_1(c))) { + if (fileName = "null") { + if (lineNumber = 0) { + if (c.id = 0) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(id: int) -> bool { + // #javaecgnode + // example + [ {1111} ] +} +pub fn getDependsECGNode(id: Callable, c: ECGNode) -> bool { + let (java_db = default_java_db()) { + for (e in Callable(java_db)) { + if (getJavaECGNode(c.id) && e.key_eq(c)) { + if (id in e.getAnAncestorCallee()) { + return true + } + if (id.key_eq(c)) { + return true + } + } + } + } +} +pub fn real_output(bindingType: string, uniqueId: string, interfaceName: string, methodName: string, filePath: string, lineNumber: int, ecgNodeId: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in Callable(java_db)) { + if (xmlOutput(bindingType, interfaceName, uniqueId)) { + if (selfDefineOutput(interfaceName, methodName, filePath, lineNumber, m)) { + if (!filePath.contains("src/test/java")) { + if (getDependsECGNode(m, ecgNodeId)) { + return true + } + } + } + if (importOutput(interfaceName, methodName, filePath, lineNumber, m)) { + if (!filePath.contains("src/test/java")) { + if (getDependsECGNode(m, ecgNodeId)) { + return true + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(className: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (output3(className, __all_data__, __all_data__, __all_data__)) { + return true + } + } + } +} + +fn tmp_1(c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getCallers(Callable(java_db).find(c))) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule11.gdl b/example/icse25/rules/rule11.gdl new file mode 100644 index 0000000..668dff0 --- /dev/null +++ b/example/icse25/rules/rule11.gdl @@ -0,0 +1,430 @@ +// script +use coref::java::* +use coref::xml::* +pub fn xmlOutput(bindingType: string, interfaceName: string, uniqueId: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaReferenceXmlElement(xml_db), + t in TrTagXmlElement(xml_db)) { + if (s.key_eq(t.getParent())) { + if (interfaceName = s.getInterfaceName()) { + if (uniqueId = s.getUniqueId()) { + if (bindingType = "tr") { + return true + } + } + } + } + } + } + } +} +pub fn getXMLInterfaceName(s: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (xmlOutput(__all_data__, s, __all_data__)) { + return true + } + } + } +} +pub fn exclude(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in Class(java_db)) { + if (n = c.getQualifiedName()) { + return true + } + } + for (i in Interface(java_db)) { + if (n = i.getQualifiedName()) { + return true + } + } + } + } +} +schema TrInterface1 extends Import { + +} + +impl TrInterface1 { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *TrInterface1 { + for (tmp in Import(db)) { + for (s in string::__undetermined_all__()) { + if (s = tmp.getName()) { + if (getXMLInterfaceName(s)) { + if (!exclude(s)) { + yield TrInterface1 { + element_hash_id : tmp.element_hash_id, + reference_hash_id : tmp.reference_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + location_hash_id : tmp.location_hash_id, + is_foreign_import : tmp.is_foreign_import + } + } + } + } + } + } + } + + +} + +pub fn output2(n: string, m: string, i: Identifier, r: ReferenceExpression) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in int::__undetermined_all__()) { + for (t in TrInterface1(java_db)) { + if (i.getParent() = r.getParent()) { + if (s = r.getLocation().getFile().element_hash_id) { + if (s = t.getContainingFile().element_hash_id) { + if (n = t.getName()) { + if (t.getTargetName() = r.getPrintableText()) { + if (m = i.getName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn matachField(im: TrInterface1, f: Field) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in int::__undetermined_all__(), + s in string::__undetermined_all__()) { + if (t = f.getLocation().getFile().element_hash_id) { + if (f.getType().getName() = s) { + if (s = im.getTargetName()) { + if (t = im.getContainingFile().element_hash_id) { + return true + } + } + } + } + } + } + } +} +pub fn matchMethod(im: TrInterface1, f: Method) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in int::__undetermined_all__(), + s in string::__undetermined_all__()) { + if (t = f.getLocation().getFile().element_hash_id) { + if (f.getType().getName() = s) { + if (s = im.getTargetName()) { + if (t = im.getContainingFile().element_hash_id) { + return true + } + } + } + } + } + } + } +} +pub fn matchLocalVariable(im: TrInterface1, f: LocalVariable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in int::__undetermined_all__(), + s in string::__undetermined_all__()) { + if (t = f.getLocation().getFile().element_hash_id) { + if (f.getType().getName() = s) { + if (s = im.getTargetName()) { + if (im.getContainingFile().element_hash_id = t) { + return true + } + } + } + } + } + } + } +} +pub fn matchParameter(im: TrInterface1, f: Parameter) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in int::__undetermined_all__(), + s in string::__undetermined_all__()) { + if (f.getType().getName() = s) { + if (s = im.getTargetName()) { + if (t = f.getLocation().getFile().element_hash_id) { + if (im.getContainingFile().element_hash_id = t) { + return true + } + } + } + } + } + } + } +} +pub fn output3(id: string, m: string, iden: Identifier, r1: Expression) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (r in ReferenceExpression(java_db), + im in TrInterface1(java_db)) { + if (r.key_eq(r1)) { + if (r.getParent() = iden.getParent()) { + for (f in Field(java_db)) { + if (f.key_eq(r.getDefinition())) { + if (matachField(im, f)) { + if (id = im.getName()) { + if (m = iden.getName()) { + return true + } + } + } + } + } + for (l in LocalVariable(java_db)) { + if (l.key_eq(r.getDefinition())) { + if (matchLocalVariable(im, l)) { + if (id = im.getName()) { + if (m = iden.getName()) { + return true + } + } + } + } + } + for (l in Parameter(java_db)) { + if (l.key_eq(r.getDefinition())) { + if (matchParameter(im, l)) { + if (id = im.getName()) { + if (m = iden.getName()) { + return true + } + } + } + } + } + } + } + } + for (r in MethodAccessExpression(java_db), + im in TrInterface1(java_db)) { + if (r.key_eq(r1)) { + if (r.getParent() = iden.getParent()) { + for (l in Method(java_db)) { + if (l = r.getMethod()) { + if (matchMethod(im, l)) { + if (id = im.getName()) { + if (m = iden.getName()) { + return true + } + } + } + } + } + } + } + } + if (output2(id, m, iden, ReferenceExpression(java_db).find(r1))) { + return true + } + } + } +} +pub fn importOutput(className: string, methodName: string, tag: string, filePath: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (t in TrInterface1(java_db), + r in Expression(java_db)) { + if (className = t.getName()) { + if (getXMLInterfaceName(className)) { + if (!exclude(className)) { + if (tmp_0(className)) { + if (output3(className, methodName, __all_data__, r)) { + if (tag = "External") { + if (filePath = r.getLocation().getFile().getRelativePath()) { + return true + } + } + } + } + if (!(tmp_0(className))) { + if (methodName = "null") { + if (tag = "External") { + if (filePath = "null") { + return true + } + } + } + } + } + } + } + } + } + } +} +schema TrInterface extends Interface { + +} + +impl TrInterface { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *TrInterface { + for (tmp in Interface(db)) { + for (s in string::__undetermined_all__()) { + if (s = tmp.getQualifiedName()) { + if (getXMLInterfaceName(s)) { + yield TrInterface { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + identifier_hash_id : tmp.identifier_hash_id, + location_hash_id : tmp.location_hash_id, + parent_hash_id : tmp.parent_hash_id + } + } + } + } + } + } + + pub fn getCallable(self) -> Callable { + for (m in Callable(__all_data__)) { + if (self.key_eq(m.getBelongedInterface())) { + return m + } + } + } + + pub fn getCallSite(self, d: Callable) -> Expression { + for (c1 in Expression(__all_data__)) { + if (d = self.getCallable()) { + for (c in MethodAccessExpression(__all_data__)) { + if (c.key_eq(c1)) { + if (d.key_eq(c.getMethod())) { + return c1 + } + } + } + for (c in MethodReferenceExpression(__all_data__)) { + if (c.key_eq(c1)) { + if (d.key_eq(c.getMethod())) { + return c1 + } + } + } + } + } + } + + +} + +pub fn getCallers(c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in Callable(java_db)) { + for (auto_tmp1 in c.getCaller()) { + if (m = auto_tmp1) { + return true + } + } + } + } + } +} +pub fn selfDefineOutput(interfaceName: string, methodName: string, tag: string, filePath: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in TrInterface(java_db), + c in Callable(java_db)) { + if (c = i.getCallable()) { + if (interfaceName = i.getQualifiedName()) { + if (methodName = c.getName()) { + if (tmp_1(c)) { + for (e in Expression(java_db)) { + if (e = i.getCallSite(c)) { + if (tag = "Self") { + if (filePath = e.getLocation().getFile().getRelativePath()) { + return true + } + } + } + } + } + if (!(tmp_1(c))) { + if (filePath = "null") { + if (tag = "Self") { + return true + } + } + } + } + } + } + } + } + } +} +pub fn real_output(bindingType: string, uniqueId: string, interfaceName: string, methodName: string, tag: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (filePath in string::__undetermined_all__()) { + if (xmlOutput(bindingType, interfaceName, uniqueId)) { + if (selfDefineOutput(interfaceName, methodName, tag, filePath)) { + if (!filePath.contains("src/test/java")) { + return true + } + } + if (importOutput(interfaceName, methodName, tag, filePath)) { + if (!filePath.contains("src/test/java")) { + return true + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(className: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (output3(className, __all_data__, __all_data__, __all_data__)) { + return true + } + } + } +} + +fn tmp_1(c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getCallers(c)) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule12.gdl b/example/icse25/rules/rule12.gdl new file mode 100644 index 0000000..75b1c35 --- /dev/null +++ b/example/icse25/rules/rule12.gdl @@ -0,0 +1,570 @@ +// script +use coref::java::* +use coref::xml::* +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> ClassOrInterface { + for (value in string::__undetermined_all__()) { + for (i in ClassOrInterface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_2(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_2(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db)) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn output1(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (xmlOutput(className, interfaceName)) { + return true + } + if (javaOutput(className, interfaceName)) { + return true + } + if (annoOutput(className, interfaceName)) { + return true + } + } + } +} +pub fn isSelfDefinedInterface(name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in Interface(java_db)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } +} +pub fn isSelfDefinedClass(name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in Class(java_db)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } +} +schema PublicMethod extends Method { + +} + +impl PublicMethod { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *PublicMethod { + for (tmp in Method(db)) { + for (m in Modifier(db)) { + for (auto_tmp1 in tmp.getModifier()) { + if (m = auto_tmp1) { + if (m.getName() = "public") { + if (!isSetOrGetMethod(tmp)) { + yield PublicMethod { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + signature : tmp.signature, + type_hash_id : tmp.type_hash_id, + parent_hash_id : tmp.parent_hash_id, + location_hash_id : tmp.location_hash_id, + definition_body : tmp.definition_body + } + } + } + } + } + } + } + } + + +} + +pub fn isBooleanTypeField(f: Field, p: string, q: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + n in string::__undetermined_all__(), + tmp1 in string::__undetermined_all__(), + tmp2 in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__()) { + if (n = f.getName()) { + if (i = n.len()) { + if (tmp_3(n)) { + if (tmp1 = n.substr(2,i)) { + if (l = n.substr(2,1)) { + if (tmp2 = n.substr(3,i)) { + if (q = n) { + if (p = "set" + tmp1) { + return true + } + } + if (q = "get" + l + tmp2) { + if (p = "set" + tmp1) { + return true + } + } + } + } + } + } + if (!(tmp_3(n))) { + if (l = n.substr(0,1)) { + if (tmp2 = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp2) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + if (p = "set" + n) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isSetOrGetMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + p in string::__undetermined_all__(), + q in string::__undetermined_all__(), + n in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__(), + tmp in string::__undetermined_all__(), + t in string::__undetermined_all__()) { + for (f in Field(java_db)) { + if (n = f.getName()) { + if (i = n.len()) { + if (f.getParent() = m.getParent()) { + if (p = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_4(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_4(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + if (q = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_4(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_4(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(interfaceName: string, className: string, methodName: string, tag: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in Interface(java_db), + c in Class(java_db)) { + if (output1(className, interfaceName)) { + if (tmp_5(interfaceName)) { + if (interfaceName = i.getQualifiedName()) { + for (m in Method(java_db)) { + if (i.key_eq(m.getParent())) { + if (methodName = m.getSignature()) { + if (tag = "Self") { + return true + } + } + } + } + } + } + if (!(tmp_5(interfaceName))) { + if (className = c.getQualifiedName()) { + for (n in PublicMethod(java_db)) { + if (c.key_eq(n.getParent())) { + if (methodName = n.getSignature()) { + if (tag = "External") { + return true + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(anno: Annotation) -> *auto_tmp_1 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_1 { + + } + } + } + } +} + +schema auto_tmp_1 { + +} + +fn tmp_2(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_0(anno).len() = 1) { + return true + } + } + } +} + +fn tmp_3(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.matches("is.*")) { + return true + } + } + } +} + +fn tmp_4(t: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (t = "boolean") { + return true + } + if (t = "Boolean") { + return true + } + } + } +} + +fn tmp_5(interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isSelfDefinedInterface(interfaceName)) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule13.gdl b/example/icse25/rules/rule13.gdl new file mode 100644 index 0000000..f6084a3 --- /dev/null +++ b/example/icse25/rules/rule13.gdl @@ -0,0 +1,588 @@ +// script +use coref::java::* +use coref::xml::* +pub fn gitdiff(filename: string, lineNumber: int) -> bool { + //python替换 + // $gitdiff + // example + [ {"test", 1111} ] +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + if (!filename.contains("src/test")) { + return true + } + } + } + } + } +} +pub fn findModifiedLineInClass(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (j in int::__undetermined_all__()) { + if (transfertofile(f, filename, lineNumber)) { + for (c in Class(java_db)) { + if (f = c.getLocation().getFile()) { + if (j = c.getLocation().getStartLineNumber()) { + if (lineNumber > j) { + return true + } + } + } + } + for (c in Interface(java_db)) { + if (f = c.getLocation().getFile()) { + if (j = c.getLocation().getStartLineNumber()) { + if (lineNumber > j) { + return true + } + } + } + } + } + } + } + } +} +schema PublicMethod extends Method { + +} + +impl PublicMethod { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *PublicMethod { + for (tmp in Method(db)) { + for (m in Modifier(db)) { + for (auto_tmp1 in tmp.getModifier()) { + if (m = auto_tmp1) { + if (m.getName() = "public") { + if (!isSetOrGetMethod(tmp)) { + yield PublicMethod { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + signature : tmp.signature, + type_hash_id : tmp.type_hash_id, + parent_hash_id : tmp.parent_hash_id, + location_hash_id : tmp.location_hash_id, + definition_body : tmp.definition_body + } + } + } + } + } + } + } + } + + +} + +pub fn isBooleanTypeField(f: Field, p: string, q: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + n in string::__undetermined_all__(), + tmp1 in string::__undetermined_all__(), + tmp2 in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__()) { + if (n = f.getName()) { + if (i = n.len()) { + if (tmp_0(n)) { + if (tmp1 = n.substr(2,i)) { + if (l = n.substr(2,1)) { + if (tmp2 = n.substr(3,i)) { + if (q = n) { + if (p = "set" + tmp1) { + return true + } + } + if (q = "get" + l + tmp2) { + if (p = "set" + tmp1) { + return true + } + } + } + } + } + } + if (!(tmp_0(n))) { + if (l = n.substr(0,1)) { + if (tmp2 = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp2) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + if (p = "set" + n) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isSetOrGetMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + p in string::__undetermined_all__(), + q in string::__undetermined_all__(), + n in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__(), + tmp in string::__undetermined_all__(), + t in string::__undetermined_all__()) { + for (f in Field(java_db)) { + if (n = f.getName()) { + if (i = n.len()) { + if (f.getParent() = m.getParent()) { + if (p = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_1(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_1(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + if (q = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_1(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_1(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isComment(lineNumber: int, filename: string, f: File) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (findModifiedLineInClass(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn findModifiedCallable(c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__()) { + for (f in File(java_db)) { + if (findModifiedLineInClass(f, filename, lineNumber)) { + if (!isComment(lineNumber, filename, f)) { + for (s1 in int::__undetermined_all__(), + e in int::__undetermined_all__()) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (lineNumber > s1 - 1) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +schema ModifiedCallable extends Callable { + +} + +impl ModifiedCallable { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *ModifiedCallable { + for (tmp in Callable(db)) { + if (findModifiedCallable(tmp)) { + yield ModifiedCallable { + id : tmp.id + } + } + } + } + + pub fn getAnAncestorCallerByIndex(self, index: int) -> Callable { + for (f in Callable(__all_data__)) { + for (auto_tmp1 in self.getCaller()) { + if (f = auto_tmp1) { + if (index = 1) { + return f + } + } + } + for (temp in int::__undetermined_all__(), + total in int::__undetermined_all__()) { + if (total = self.getTotalCaller()) { + if (index < total + 1) { + if (index = temp + 1) { + if (temp > 0) { + for (auto_tmp2 in self.getAnAncestorCallerByIndex(temp).getCaller()) { + if (f = auto_tmp2) { + return f + } + } + } + } + } + } + } + } + } + + pub fn getTotalCaller(self) -> int { + for (total in int::__undetermined_all__()) { + for (c in Callable(__all_data__)) { + if (self.key_eq(c)) { + if (total = tmp_2(c).len()) { + return total + } + } + } + } + } + + pub fn getRootCaller(self) -> CallableNew { + for (f in CallableNew(__all_data__)) { + for (auto_tmp1 in self.getAnAncestorCaller()) { + if (f.key_eq(auto_tmp1)) { + if (!getAnyCaller(f)) { + return f + } + } + } + } + } + + +} + +pub fn getAnyCaller(c: CallableNew) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (a in CallableNew(java_db)) { + for (auto_tmp1 in c.getCaller()) { + if (a.key_eq(auto_tmp1)) { + return true + } + } + } + } + } +} +pub fn getTotalCallerSet(s: ModifiedCallable, index: int, f: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (f = s.getAnAncestorCallerByIndex(index)) { + return true + } + } + } +} +pub fn hasCaller(a: CallableNew) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (b in CallableNew(java_db)) { + for (auto_tmp1 in a.getCaller()) { + if (b.key_eq(auto_tmp1)) { + return true + } + } + } + } + } +} + +schema CallableNew extends Callable { + +} + +impl CallableNew { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *CallableNew { + for (tmp in Callable(db)) { + for (n in string::__undetermined_all__()) { + if (n = tmp.getLocation().getFile().getRelativePath()) { + if (!n.contains("src/test/java")) { + yield CallableNew { + id : tmp.id + } + } + } + } + } + } + + pub fn getEnclosingCallable(self) -> Callable { + for (c in Callable(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(self.getBelongedClass().getParent())) { + if (c = e.getEnclosingCallable()) { + return c + } + } + } + } + + pub fn getNonAnonymousEnclosingCallable(self) -> Callable { + for (c in Callable(__all_data__), + temp in Callable(__all_data__)) { + if (temp = self.getEnclosingCallable()) { + if (tmp_3(temp)) { + for (m in AnonymousMethod(__all_data__)) { + if (m.key_eq(temp)) { + if (c = m.getEnclosingCallable()) { + return c + } + } + } + } + if (!(tmp_3(temp))) { + if (c = temp) { + return c + } + } + } + } + } + + pub fn getRootCaller(self) -> CallableNew { + for (f in CallableNew(__all_data__)) { + for (auto_tmp1 in self.getAnAncestorCaller()) { + if (f.key_eq(auto_tmp1)) { + if (!getAnyCaller(f)) { + return f + } + } + } + } + } + + +} + +pub fn real_output(rootSignature: string, className: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (n in ModifiedCallable(java_db), + a in CallableNew(java_db), + b in CallableNew(java_db), + c in CallableNew(java_db)) { + for (auto_tmp1 in n.getAnAncestorCaller()) { + if (a.key_eq(auto_tmp1)) { + if (tmp_4(a)) { + if (b.key_eq(a.getNonAnonymousEnclosingCallable())) { + if (c = b.getRootCaller()) { + if (rootSignature = c.getSignature()) { + if (className = c.getBelongedClass().getQualifiedName()) { + return true + } + } + } + } + } + if (!(tmp_4(a))) { + if (b = a) { + if (c = b.getRootCaller()) { + if (rootSignature = c.getSignature()) { + if (className = c.getBelongedClass().getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.matches("is.*")) { + return true + } + } + } +} + +fn tmp_1(t: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (t = "boolean") { + return true + } + if (t = "Boolean") { + return true + } + } + } +} + +fn tmp_2(c: Callable) -> *Callable { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (a in Callable(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCaller()) { + if (a = auto_tmp1) { + yield a + } + } + } + } + } +} + +fn tmp_3(temp: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isAnonymousMethod(temp)) { + return true + } + } + } +} + +fn tmp_4(a: CallableNew) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isAnonymousMethod(Callable(java_db).find(a))) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule14.gdl b/example/icse25/rules/rule14.gdl new file mode 100644 index 0000000..bb7932f --- /dev/null +++ b/example/icse25/rules/rule14.gdl @@ -0,0 +1,389 @@ +// script +use coref::javascript::* + +pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionIdentifier: Expression) -> bool { + let (javascript_db = default_javascript_db()) { + for (callExpression in CallExpression(javascript_db)) { + for (routerFile in File(javascript_db)) { + for (routerPath in string::__undetermined_all__()) { + if (routerPath = routerFile.getRelativePath()) { + if (routerPath.matches("app/router(\\.[jt]s|/.+\\.[jt]s)")) { + if (callExpression.getLocation().getFile() = routerFile) { + for (accessExpression in AccessExpression(javascript_db), + property in Expression(javascript_db)) { + if (accessExpression.key_eq(callExpression.getExpression())) { + if (property = accessExpression.getPropertyExpression()) { + if (property.getText() = "rpc") { + for (rpcNameStringLiteral in StringLiteral(javascript_db)) { + if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { + if (rpcName = rpcNameStringLiteral.getValue()) { + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true + } + } + } + } + } + } + if (property.getText() = "rpcAndGet") { + for (rpcNameStringLiteral in StringLiteral(javascript_db)) { + if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { + if (rpcName = rpcNameStringLiteral.getValue()) { + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true + } + } + } + } + } + } + if (property.getText() = "rpcAndPost") { + for (rpcNameStringLiteral in StringLiteral(javascript_db)) { + if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { + if (rpcName = rpcNameStringLiteral.getValue()) { + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn rpcNameControllerFunction(rpcName: string, controllerFunction: FunctionLikeDeclaration) -> bool { + let (javascript_db = default_javascript_db()) { + for (controllerFunctionIdentifier in Expression(javascript_db)) { + if (rpcNameControllerFunctionIdentifier(rpcName, controllerFunctionIdentifier)) { + for (symbol in Symbol(javascript_db)) { + if (symbol = controllerFunctionIdentifier.getSymbol()) { + if (controllerFunction.getSymbol() = symbol) { + return true + } + for (variableDeclaration in VariableDeclaration(javascript_db)) { + if (variableDeclaration.getSymbol() = symbol) { + if (controllerFunction.key_eq(variableDeclaration.getInitializer())) { + return true + } + } + } + for (propertyDeclaration in PropertyDeclaration(javascript_db)) { + if (propertyDeclaration.getSymbol() = symbol) { + if (controllerFunction.key_eq(propertyDeclaration.getInitializer())) { + return true + } + } + } + } + } + } + } + } +} +pub fn controllerReturnField(controllerFunc: FunctionLikeDeclaration, fieldName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (simpleAssignmentExpression in SimpleAssignmentExpression(javascript_db)) { + for (auto_tmp1 in simpleAssignmentExpression.getAnAncestorEnclosingFunction()) { + if (auto_tmp1 = controllerFunc) { + for (leftOperandText in string::__undetermined_all__()) { + for (leftOperand in Expression(javascript_db)) { + if (leftOperand = simpleAssignmentExpression.getLeftOperand()) { + if (leftOperandText = leftOperand.getText()) { + if (leftOperandText.matches("(this\\.|ctx\\.|this\\.ctx\\.)?body")) { + for (object in ObjectLiteralExpression(javascript_db), + objectElement in ObjectLiteralElement(javascript_db)) { + if (object.key_eq(simpleAssignmentExpression.getRightOperand())) { + if (objectElement = object.getPropertyByName(fieldName)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn serviceCallSite(serviceCaller: CallExpression, serviceFunction: FunctionLikeDeclaration) -> bool { + let (javascript_db = default_javascript_db()) { + for (expressionText in string::__undetermined_all__()) { + for (expression in PropertyAccessExpression(javascript_db)) { + if (expression.key_eq(serviceCaller.getExpression())) { + if (expressionText = expression.getText()) { + if (expressionText.matches("(this\\.|ctx\\.|this\\.ctx\\.)?service\\.(.+)")) { + if (serviceFunction = serviceCaller.getCallee()) { + return true + } + } + } + } + } + } + } +} +pub fn getAnDescendantServiceCallee(serviceCaller: CallExpression, descendantServiceCallee: FunctionLikeDeclaration) -> bool { + let (javascript_db = default_javascript_db()) { + if (serviceCallSite(serviceCaller, descendantServiceCallee)) { + return true + } + for (serviceCallee in FunctionLikeDeclaration(javascript_db), + childServiceCaller in CallExpression(javascript_db)) { + if (serviceCallSite(serviceCaller, serviceCallee)) { + for (auto_tmp1 in childServiceCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp1 = serviceCallee) { + if (getAnDescendantServiceCallee(childServiceCaller, descendantServiceCallee)) { + return true + } + } + } + } + } + } +} +pub fn proxyCallerDesc(proxyCaller: CallExpression, facadeName: string, trFuncName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (expression in PropertyAccessExpression(javascript_db)) { + if (expression.key_eq(proxyCaller.getExpression())) { + for (facadeExpressionText in string::__undetermined_all__()) { + for (facadeExpression in LeftHandSideExpression(javascript_db)) { + for (leftHandSideExpression in LeftHandSideExpression(javascript_db)) { + if (leftHandSideExpression = expression.getExpression()) { + for (callExpression in CallExpression(javascript_db)) { + if (callExpression.key_eq(leftHandSideExpression)) { + for (usingExpression in PropertyAccessExpression(javascript_db)) { + if (usingExpression.key_eq(callExpression.getExpression())) { + if (facadeExpression = usingExpression.getExpression()) { + if (facadeExpressionText = facadeExpression.getText()) { + if (facadeName = facadeExpressionText.get_regex_match_result("(this\\.|ctx\\.|this\\.ctx\\.)?proxy\\.(.+)", 2)) { + if (facadeName != "") { + for (serviceFuncIdentifier in Identifier(javascript_db)) { + if (serviceFuncIdentifier.key_eq(expression.getProperty())) { + if (trFuncName = serviceFuncIdentifier.getText()) { + if (trFuncName != "using") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + if (isPropertyAccessExpression(Node(javascript_db).find(leftHandSideExpression))) { + if (facadeExpression = leftHandSideExpression) { + if (facadeExpressionText = facadeExpression.getText()) { + if (facadeName = facadeExpressionText.get_regex_match_result("(this\\.|ctx\\.|this\\.ctx\\.)?proxy\\.(.+)", 2)) { + if (facadeName != "") { + for (serviceFuncIdentifier in Identifier(javascript_db)) { + if (serviceFuncIdentifier.key_eq(expression.getProperty())) { + if (trFuncName = serviceFuncIdentifier.getText()) { + if (trFuncName != "using") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getAppFacade(appName: string, proxyFacadeName: string, facadeQualifiedName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (objectLiteralExpression in ObjectLiteralExpression(javascript_db)) { + for (proxyPath in string::__undetermined_all__()) { + for (file in File(javascript_db), + location in Location(javascript_db), + servicePropertyAssignment in PropertyAssignment(javascript_db), + arrayLiteralExpression in ArrayLiteralExpression(javascript_db)) { + if (proxyPath = file.getRelativePath()) { + if (proxyPath.matches("config/proxy\\.[jt]s")) { + if (location.getFile() = file) { + if (servicePropertyAssignment.getLocation() = location) { + if (servicePropertyAssignment.getName() = "services") { + if (arrayLiteralExpression.key_eq(servicePropertyAssignment.getInitializer())) { + for (auto_tmp1 in arrayLiteralExpression.getAElement()) { + if (objectLiteralExpression.key_eq(auto_tmp1)) { + for (appNamePropertyAssignment in PropertyAssignment(javascript_db), + appNameString in StringLiteral(javascript_db)) { + if (appNamePropertyAssignment = objectLiteralExpression.getPropertyAssignmentByName("appname")) { + if (appNameString.key_eq(appNamePropertyAssignment.getInitializer())) { + if (appName = appNameString.getValue()) { + for (apiPropertyAssignment in PropertyAssignment(javascript_db), + apiObject in ObjectLiteralExpression(javascript_db), + facadePropertyAssignment in PropertyAssignment(javascript_db)) { + if (apiPropertyAssignment = objectLiteralExpression.getPropertyAssignmentByName("api")) { + if (apiObject.key_eq(apiPropertyAssignment.getInitializer())) { + for (auto_tmp2 in apiObject.getAProperty()) { + if (facadePropertyAssignment.key_eq(auto_tmp2)) { + if (proxyFacadeName = facadePropertyAssignment.getName()) { + for (facadeStringLiteral in StringLiteral(javascript_db)) { + if (facadeStringLiteral.key_eq(facadePropertyAssignment.getInitializer())) { + if (facadeQualifiedName = facadeStringLiteral.getValue()) { + return true + } + } + for (facadeObject in ObjectLiteralExpression(javascript_db), + interfaceNamePropertyAssignment in PropertyAssignment(javascript_db)) { + if (facadeObject.key_eq(facadePropertyAssignment.getInitializer())) { + if (interfaceNamePropertyAssignment = facadeObject.getPropertyAssignmentByName("interfaceName")) { + if (facadeStringLiteral.key_eq(interfaceNamePropertyAssignment.getInitializer())) { + if (facadeQualifiedName = facadeStringLiteral.getValue()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(rpcName: string, facadeName: string, trFuncName: string, rpcFieldName: string, trFieldName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (controllerFunc in FunctionLikeDeclaration(javascript_db), + serviceCaller in CallExpression(javascript_db), + serviceCallee in MethodDeclaration(javascript_db), + proxyCaller in CallExpression(javascript_db)) { + if (rpcNameControllerFunction(rpcName, controllerFunc)) { + if (controllerReturnField(controllerFunc, rpcFieldName)) { + if (trFieldName = rpcFieldName) { + for (auto_tmp1 in serviceCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp1 = controllerFunc) { + if (getAnDescendantServiceCallee(serviceCaller, FunctionLikeDeclaration(javascript_db).find(serviceCallee))) { + for (auto_tmp2 in proxyCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp2 = controllerFunc) { + for (facadeProxyName in string::__undetermined_all__()) { + if (proxyCallerDesc(proxyCaller, facadeProxyName, trFuncName)) { + if (getAppFacade(__all_data__, facadeProxyName, facadeName)) { + return true + } + } + } + } + } + for (auto_tmp3 in proxyCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp3.key_eq(serviceCallee)) { + for (facadeProxyName in string::__undetermined_all__()) { + if (proxyCallerDesc(proxyCaller, facadeProxyName, trFuncName)) { + if (getAppFacade(__all_data__, facadeProxyName, facadeName)) { + return true + } + } + } + } + } + } + } + } + } + } + if (tmp_0(controllerFunc).len() = 0) { + if (rpcFieldName = "") { + if (trFieldName = rpcFieldName) { + for (auto_tmp1 in serviceCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp1 = controllerFunc) { + if (getAnDescendantServiceCallee(serviceCaller, FunctionLikeDeclaration(javascript_db).find(serviceCallee))) { + for (auto_tmp2 in proxyCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp2 = controllerFunc) { + for (facadeProxyName in string::__undetermined_all__()) { + if (proxyCallerDesc(proxyCaller, facadeProxyName, trFuncName)) { + if (getAppFacade(__all_data__, facadeProxyName, facadeName)) { + return true + } + } + } + } + } + for (auto_tmp3 in proxyCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp3.key_eq(serviceCallee)) { + for (facadeProxyName in string::__undetermined_all__()) { + if (proxyCallerDesc(proxyCaller, facadeProxyName, trFuncName)) { + if (getAppFacade(__all_data__, facadeProxyName, facadeName)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_javascript_db() -> JavascriptDB { + return JavascriptDB::load("coref_javascript_src.db") +} + +fn tmp_0(controllerFunc: FunctionLikeDeclaration) -> *FunctionLikeDeclaration { + let (javascript_db = default_javascript_db()) { + for (_ in string::__undetermined_all__()) { + for (func in FunctionLikeDeclaration(javascript_db)) { + if (func = controllerFunc) { + if (controllerReturnField(func, __all_data__)) { + yield func + } + } + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule15.gdl b/example/icse25/rules/rule15.gdl new file mode 100644 index 0000000..214e005 --- /dev/null +++ b/example/icse25/rules/rule15.gdl @@ -0,0 +1,168 @@ +// script +use coref::java::* +pub fn getAField(aClass: Class, aField: Field, fieldName: string, isList: string) -> bool { + let (java_db = default_java_db()) { + for (fieldTypeQualifiedName in string::__undetermined_all__()) { + for (fieldType in Type(java_db)) { + for (auto_tmp1 in aClass.getAllFields()) { + if (aField = auto_tmp1) { + if (fieldName = aField.getName()) { + if (fieldType = aField.getType()) { + if (fieldTypeQualifiedName = fieldType.getQualifiedName()) { + if (tmp_0(fieldTypeQualifiedName)) { + if (isList = "Y") { + return true + } + } + if (!(tmp_0(fieldTypeQualifiedName))) { + if (isList = "N") { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn getFieldClass(aField: Field, fieldClass: Class) -> bool { + let (java_db = default_java_db()) { + for (fieldTypeQualifiedName in string::__undetermined_all__(), + isList in string::__undetermined_all__()) { + for (fieldType in Type(java_db)) { + if (fieldType = aField.getType()) { + if (fieldTypeQualifiedName = fieldType.getQualifiedName()) { + if (tmp_1(fieldTypeQualifiedName)) { + if (isList = "Y") { + for (fieldTypeClassQualifiedName in string::__undetermined_all__()) { + if (fieldTypeClassQualifiedName = fieldTypeQualifiedName.get_regex_match_result(".*List<(.+)>", 1)) { + if (fieldClass.getQualifiedName() = fieldTypeClassQualifiedName) { + return true + } + } + } + } + } + if (!(tmp_1(fieldTypeQualifiedName))) { + if (isList = "N") { + if (fieldClass.getQualifiedName() = fieldTypeQualifiedName) { + return true + } + } + } + } + } + } + } + } +} +pub fn getADescendantField(rootField: Field, outerField: Field, aField: Field, fieldName: string, isList: string) -> bool { + let (java_db = default_java_db()) { + for (fieldClass in Class(java_db)) { + if (getFieldClass(rootField, fieldClass)) { + if (outerField = rootField) { + if (getAField(fieldClass, aField, fieldName, isList)) { + return true + } + } + for (childField in Field(java_db)) { + if (getAField(fieldClass, childField, __all_data__, __all_data__)) { + if (getADescendantField(childField, outerField, aField, fieldName, isList)) { + return true + } + } + } + } + } + } +} +pub fn facadeMethod(facadeQualifiedName: string, trMethodName: string) -> bool { + [ + {"com.xxx.filtered.BlockFacade", "using"}, + {"com.xxx.filtered.BlockFacade", "batchLoad"}, + {"com.xxx.filtered.LayoutFacade", "using"}, + {"com.xxx.filtered.LayoutFacade", "loadLayoutData"}, + {"com.xxx.filtered.FpcQueryFacade", "using"}, + {"com.xxx.filtered.FpcQueryFacade", "queryGroupByProduct"}, + {"com.xxx.filtered.FpcQueryFacade", "queryGroupByProductObject"}, + {"com.xxx.filtered.FpcFeaturedListQueryFacade", "using"}, + {"com.xxx.filtered.FpcFundManagerQueryFacade", "queryProfile"}, + {"com.xxx.filtered.FpcFundManagerQueryFacade", "queryProfileExt"}, + {"com.xxx.filtered.FpcGoldFundQueryFacade", "queryTrackDetail"}, + {"com.xxx.filtered.FpcGoldFundQueryFacade", "queryGoldFundCurve"}, + {"com.xxx.filtered.FpcIndexQueryFacade", "queryInfo"}, + {"com.xxx.filtered.FpcIndustryQueryFacade", "queryInfo"}, + {"com.xxx.filtered.FpcYieldLineQueryFacade", "queryProdTimingAbility"}, + {"com.xxx.filtered.FpcManagerQueryFacade", "using"} + ] +} +pub fn real_output(facadeQualifiedName: string, trMethodName: string, outerFieldId: int, fieldId: int, fieldName: string, isList: string) -> bool { + let (java_db = default_java_db()) { + for (returnType in Type(java_db), + returnClass in Class(java_db)) { + for (facadeInterface in Interface(java_db), + trMethod in Method(java_db)) { + if (facadeMethod(facadeQualifiedName, trMethodName)) { + if (facadeInterface.getQualifiedName() = facadeQualifiedName) { + if (trMethod.getParent().key_eq(facadeInterface)) { + if (trMethod.getName() = trMethodName) { + if (returnType = trMethod.getType()) { + if (returnClass.getQualifiedName() = returnType.getQualifiedName()) { + if (fieldName != "serialVersionUID") { + for (aField in Field(java_db)) { + if (getAField(returnClass, aField, fieldName, isList)) { + if (outerFieldId = 0) { + if (fieldId = aField.element_hash_id) { + return true + } + } + } + for (rootField in Field(java_db), outerField in Field(java_db)) { + if (getAField(returnClass, rootField, __all_data__, __all_data__) && outerField.element_hash_id = outerFieldId) { + if (getADescendantField(rootField, outerField, aField, fieldName, isList)) { + if (fieldId = aField.element_hash_id) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn tmp_0(fieldTypeQualifiedName: string) -> bool { + let (java_db = default_java_db()) { + if (fieldTypeQualifiedName.matches(".*List<.+>")) { + return true + } + } +} + +fn tmp_1(fieldTypeQualifiedName: string) -> bool { + let (java_db = default_java_db()) { + if (fieldTypeQualifiedName.matches(".*List<.+>")) { + return true + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule16.gdl b/example/icse25/rules/rule16.gdl new file mode 100644 index 0000000..44acd3d --- /dev/null +++ b/example/icse25/rules/rule16.gdl @@ -0,0 +1,149 @@ +// script +use coref::javascript::* +pub fn getAppFacade(appName: string, proxyFacadeName: string, facadeQualifiedName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (objectLiteralExpression in ObjectLiteralExpression(javascript_db)) { + for (file in File(javascript_db), + location in Location(javascript_db), + servicePropertyAssignment in PropertyAssignment(javascript_db), + arrayLiteralExpression in ArrayLiteralExpression(javascript_db)) { + if (file.getRelativePath() = "config/proxy.js") { + if (location.getFile() = file) { + if (servicePropertyAssignment.getLocation() = location) { + if (servicePropertyAssignment.getName() = "services") { + if (arrayLiteralExpression.key_eq(servicePropertyAssignment.getInitializer())) { + for (auto_tmp1 in arrayLiteralExpression.getAElement()) { + if (objectLiteralExpression.key_eq(auto_tmp1)) { + for (appNamePropertyAssignment in PropertyAssignment(javascript_db), + appNameString in StringLiteral(javascript_db)) { + if (appNamePropertyAssignment = objectLiteralExpression.getPropertyAssignmentByName("appname")) { + if (appNameString.key_eq(appNamePropertyAssignment.getInitializer())) { + if (appName = appNameString.getValue()) { + for (apiPropertyAssignment in PropertyAssignment(javascript_db), + apiObject in ObjectLiteralExpression(javascript_db), + facadePropertyAssignment in PropertyAssignment(javascript_db)) { + if (apiPropertyAssignment = objectLiteralExpression.getPropertyAssignmentByName("api")) { + if (apiObject.key_eq(apiPropertyAssignment.getInitializer())) { + for (auto_tmp2 in apiObject.getAProperty()) { + if (facadePropertyAssignment.key_eq(auto_tmp2)) { + if (proxyFacadeName = facadePropertyAssignment.getName()) { + for (facadeStringLiteral in StringLiteral(javascript_db)) { + if (facadeStringLiteral.key_eq(facadePropertyAssignment.getInitializer())) { + if (facadeQualifiedName = facadeStringLiteral.getValue()) { + return true + } + } + for (facadeObject in ObjectLiteralExpression(javascript_db), + interfaceNamePropertyAssignment in PropertyAssignment(javascript_db)) { + if (facadeObject.key_eq(facadePropertyAssignment.getInitializer())) { + if (interfaceNamePropertyAssignment = facadeObject.getPropertyAssignmentByName("interfaceName")) { + if (facadeStringLiteral.key_eq(interfaceNamePropertyAssignment.getInitializer())) { + if (facadeQualifiedName = facadeStringLiteral.getValue()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn proxyCallerDesc(proxyCaller: CallExpression, facadeName: string, trFuncName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (expression in PropertyAccessExpression(javascript_db)) { + if (expression.key_eq(proxyCaller.getExpression())) { + for (facadeExpressionText in string::__undetermined_all__()) { + for (facadeExpression in LeftHandSideExpression(javascript_db)) { + for (leftHandSideExpression in LeftHandSideExpression(javascript_db)) { + if (leftHandSideExpression = expression.getExpression()) { + for (callExpression in CallExpression(javascript_db)) { + if (callExpression.key_eq(leftHandSideExpression)) { + for (usingExpression in PropertyAccessExpression(javascript_db)) { + if (usingExpression.key_eq(callExpression.getExpression())) { + if (facadeExpression = usingExpression.getExpression()) { + if (facadeExpressionText = facadeExpression.getText()) { + if (facadeName = facadeExpressionText.get_regex_match_result("(this\\.|ctx\\.|this\\.ctx\\.)?proxy\\.(.+)", 2)) { + if (facadeName != "") { + for (serviceFuncIdentifier in Identifier(javascript_db)) { + if (serviceFuncIdentifier.key_eq(expression.getProperty())) { + if (trFuncName = serviceFuncIdentifier.getText()) { + if (trFuncName != "using") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + if (isPropertyAccessExpression(Node(javascript_db).find(leftHandSideExpression))) { + if (facadeExpression = leftHandSideExpression) { + if (facadeExpressionText = facadeExpression.getText()) { + if (facadeName = facadeExpressionText.get_regex_match_result("(this\\.|ctx\\.|this\\.ctx\\.)?proxy\\.(.+)", 2)) { + if (facadeName != "") { + for (serviceFuncIdentifier in Identifier(javascript_db)) { + if (serviceFuncIdentifier.key_eq(expression.getProperty())) { + if (trFuncName = serviceFuncIdentifier.getText()) { + if (trFuncName != "using") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(appName: string, facadeQualifiedName: string, trMethodName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (facadeName in string::__undetermined_all__()) { + if (proxyCallerDesc(__all_data__, facadeName, trMethodName)) { + if (getAppFacade(appName, facadeName, facadeQualifiedName)) { + return true + } + } + } + } +} + + +fn default_javascript_db() -> JavascriptDB { + return JavascriptDB::load("coref_javascript_src.db") +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule17.gdl b/example/icse25/rules/rule17.gdl new file mode 100644 index 0000000..1ce105c --- /dev/null +++ b/example/icse25/rules/rule17.gdl @@ -0,0 +1,766 @@ +// script +use coref::java::* +use coref::xml::* +pub fn getJavaECGNode(id: int) -> bool { + // #javaecgnode + // example + [ {1111} ] +} +pub fn getAField(aClass: Class, aField: Field, fieldName: string, isList: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (fieldTypeQualifiedName in string::__undetermined_all__()) { + for (fieldType in Type(java_db)) { + for (auto_tmp1 in aClass.getAllFields()) { + if (aField = auto_tmp1) { + if (fieldName = aField.getName()) { + if (fieldType = aField.getType()) { + if (fieldTypeQualifiedName = fieldType.getQualifiedName()) { + if (tmp_0(fieldTypeQualifiedName)) { + if (isList = "Y") { + return true + } + } + if (!(tmp_0(fieldTypeQualifiedName))) { + if (isList = "N") { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getFieldClass(aField: Field, fieldClass: Class) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (fieldTypeQualifiedName in string::__undetermined_all__(), + isList in string::__undetermined_all__()) { + for (fieldType in Type(java_db)) { + if (fieldType = aField.getType()) { + if (fieldTypeQualifiedName = fieldType.getQualifiedName()) { + if (tmp_1(fieldTypeQualifiedName)) { + if (isList = "Y") { + for (fieldTypeClassQualifiedName in string::__undetermined_all__()) { + if (fieldTypeClassQualifiedName = fieldTypeQualifiedName.get_regex_match_result(".*List<(.+)>", 1)) { + if (fieldClass.getQualifiedName() = fieldTypeClassQualifiedName) { + return true + } + } + } + } + } + if (!(tmp_1(fieldTypeQualifiedName))) { + if (isList = "N") { + if (fieldClass.getQualifiedName() = fieldTypeQualifiedName) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getADescendantField(rootField: Field, outerField: Field, aField: Field, fieldName: string, isList: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (fieldClass in Class(java_db)) { + if (getFieldClass(rootField, fieldClass)) { + if (outerField = rootField) { + if (getAField(fieldClass, aField, fieldName, isList)) { + return true + } + } + for (childField in Field(java_db)) { + if (getAField(fieldClass, childField, __all_data__, __all_data__)) { + if (getADescendantField(childField, outerField, aField, fieldName, isList)) { + return true + } + } + } + } + } + } + } +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> Interface { + for (value in string::__undetermined_all__()) { + for (i in Interface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_4(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_4(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string, uniqueId: string, type: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (value in string::__undetermined_all__()) { + for (s in SofaService(java_db), + c in Class(java_db), + b in SofaServiceBinding(java_db), + i in Interface(java_db)) { + if (b = s.getBinding()) { + if (value = b.getType()) { + if (value.contains("tr")) { + if (type = "tr") { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i = auto_tmp2) { + if (name = i.getQualifiedName()) { + if (uniqueId = s.getUniqueId()) { + return true + } + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + if (uniqueId = s.getUniqueId()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(bindingType: string, uniqueId: string, className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db), + t in TagXmlElement(xml_db)) { + if (s.key_eq(t.getParent())) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (uniqueId = s.getUniqueId()) { + if (bindingType = s.getBindingType()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(bindingType: string, uniqueId: string, className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + if (uniqueId = s.getUniqueId()) { + if (bindingType = s.getBindingType()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn output1(className: string, interfaceName: string, uniqueId: string, bindingType: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (xmlOutput(bindingType, uniqueId, className, interfaceName)) { + return true + } + if (javaOutput(className, interfaceName, uniqueId, bindingType)) { + return true + } + if (annoOutput(bindingType, uniqueId, className, interfaceName)) { + return true + } + } + } +} +pub fn isSelfDefinedInterface(name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in Interface(java_db)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } +} +schema PublicMethod extends Method { + +} + +impl PublicMethod { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *PublicMethod { + for (tmp in Method(db)) { + for (m in Modifier(db)) { + for (auto_tmp1 in tmp.getModifier()) { + if (m = auto_tmp1) { + if (m.getName() = "public") { + if (!isSetOrGetMethod(tmp)) { + yield PublicMethod { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + signature : tmp.signature, + type_hash_id : tmp.type_hash_id, + parent_hash_id : tmp.parent_hash_id, + location_hash_id : tmp.location_hash_id, + definition_body : tmp.definition_body + } + } + } + } + } + } + } + } + + +} + +pub fn isBooleanTypeField(f: Field, p: string, q: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + n in string::__undetermined_all__(), + tmp1 in string::__undetermined_all__(), + tmp2 in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__()) { + if (n = f.getName()) { + if (i = n.len()) { + if (tmp_5(n)) { + if (tmp1 = n.substr(2,i)) { + if (l = n.substr(2,1)) { + if (tmp2 = n.substr(3,i)) { + if (q = n) { + if (p = "set" + tmp1) { + return true + } + } + if (q = "get" + l + tmp2) { + if (p = "set" + tmp1) { + return true + } + } + } + } + } + } + if (!(tmp_5(n))) { + if (l = n.substr(0,1)) { + if (tmp2 = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp2) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + if (p = "set" + n) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isSetOrGetMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + p in string::__undetermined_all__(), + q in string::__undetermined_all__(), + n in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__(), + tmp in string::__undetermined_all__(), + t in string::__undetermined_all__()) { + for (f in Field(java_db)) { + if (n = f.getName()) { + if (i = n.len()) { + if (f.getParent() = m.getParent()) { + if (p = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_6(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_6(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + if (q = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_6(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_6(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn facadeMethod(interfaceName: string, methodName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (className in string::__undetermined_all__(), + tag in string::__undetermined_all__()) { + for (i in Interface(java_db), + c in Class(java_db)) { + if (output1(className, interfaceName, __all_data__, __all_data__)) { + if (tmp_7(interfaceName)) { + if (interfaceName = i.getQualifiedName()) { + for (m in Method(java_db)) { + if (i.key_eq(m.getParent())) { + if (methodName = m.getName()) { + if (tag = "Self") { + return true + } + } + } + } + } + } + if (!(tmp_7(interfaceName))) { + if (className = c.getQualifiedName()) { + for (n in PublicMethod(java_db)) { + if (c.key_eq(n.getParent())) { + if (methodName = n.getName()) { + if (tag = "External") { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(facadeQualifiedName: string, trMethodName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (outerFieldId in int::__undetermined_all__(), + fieldId in int::__undetermined_all__(), + fieldName in string::__undetermined_all__(), + isList in string::__undetermined_all__()) { + for (returnType in Type(java_db), + returnClass in Class(java_db)) { + for (aField in Field(java_db)) { + if (getJavaECGNode(aField.element_hash_id)) { + if (getAField(returnClass, aField, fieldName, isList)) { + if (outerFieldId = 0) { + if (fieldId = aField.element_hash_id) { + for (facadeInterface in Interface(java_db), + trMethod in Method(java_db)) { + if (facadeMethod(facadeQualifiedName, trMethodName)) { + if (facadeInterface.getQualifiedName() = facadeQualifiedName) { + if (trMethod.getParent().key_eq(facadeInterface)) { + if (trMethod.getName() = trMethodName) { + if (returnType = trMethod.getType()) { + if (returnClass.getQualifiedName() = returnType.getQualifiedName()) { + if (fieldName != "serialVersionUID") { + return true + } + } + } + } + } + } + } + } + } + } + } + for (rootField in Field(java_db), outerField in Field(java_db)) { + if (getAField(returnClass, rootField, __all_data__, __all_data__) && outerField.element_hash_id = outerFieldId) { + if (getADescendantField(rootField, outerField, aField, fieldName, isList)) { + if (fieldId = aField.element_hash_id) { + for (facadeInterface in Interface(java_db), + trMethod in Method(java_db)) { + if (facadeMethod(facadeQualifiedName, trMethodName)) { + if (facadeInterface.getQualifiedName() = facadeQualifiedName) { + if (trMethod.getParent().key_eq(facadeInterface)) { + if (trMethod.getName() = trMethodName) { + if (returnType = trMethod.getType()) { + if (returnClass.getQualifiedName() = returnType.getQualifiedName()) { + if (fieldName != "serialVersionUID") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(fieldTypeQualifiedName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (fieldTypeQualifiedName.matches(".*List<.+>")) { + return true + } + } + } +} + +fn tmp_1(fieldTypeQualifiedName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (fieldTypeQualifiedName.matches(".*List<.+>")) { + return true + } + } + } +} + +fn tmp_2(anno: Annotation) -> *auto_tmp_3 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_3 { + + } + } + } + } +} + +schema auto_tmp_3 { + +} + +fn tmp_4(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_2(anno).len() = 1) { + return true + } + } + } +} + +fn tmp_5(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.matches("is.*")) { + return true + } + } + } +} + +fn tmp_6(t: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (t = "boolean") { + return true + } + if (t = "Boolean") { + return true + } + } + } +} + +fn tmp_7(interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isSelfDefinedInterface(interfaceName)) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule18.gdl b/example/icse25/rules/rule18.gdl new file mode 100644 index 0000000..1560913 --- /dev/null +++ b/example/icse25/rules/rule18.gdl @@ -0,0 +1,160 @@ +// script +use coref::javascript::* +pub fn getInfluencedTrAPI(interfaceName: string, methodName: string) -> bool { + // #rule17的结果 + // example + [ + {"com.xxx.filtered.BlockFacade", "load"}, + {"com.xxx.filtered.BlockFacade", "batchLoad"}, + {"com.xxx.filtered.LayoutFacade", "getLayoutDef"} + ] +} +pub fn getAppFacade(appName: string, proxyFacadeName: string, facadeQualifiedName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (objectLiteralExpression in ObjectLiteralExpression(javascript_db)) { + for (file in File(javascript_db), + location in Location(javascript_db), + servicePropertyAssignment in PropertyAssignment(javascript_db), + arrayLiteralExpression in ArrayLiteralExpression(javascript_db)) { + if (file.getRelativePath() = "config/proxy.js") { + if (location.getFile() = file) { + if (servicePropertyAssignment.getLocation() = location) { + if (servicePropertyAssignment.getName() = "services") { + if (arrayLiteralExpression.key_eq(servicePropertyAssignment.getInitializer())) { + for (auto_tmp1 in arrayLiteralExpression.getAElement()) { + if (objectLiteralExpression.key_eq(auto_tmp1)) { + for (appNamePropertyAssignment in PropertyAssignment(javascript_db), + appNameString in StringLiteral(javascript_db)) { + if (appNamePropertyAssignment = objectLiteralExpression.getPropertyAssignmentByName("appname")) { + if (appNameString.key_eq(appNamePropertyAssignment.getInitializer())) { + if (appName = appNameString.getValue()) { + for (apiPropertyAssignment in PropertyAssignment(javascript_db), + apiObject in ObjectLiteralExpression(javascript_db), + facadePropertyAssignment in PropertyAssignment(javascript_db)) { + if (apiPropertyAssignment = objectLiteralExpression.getPropertyAssignmentByName("api")) { + if (apiObject.key_eq(apiPropertyAssignment.getInitializer())) { + for (auto_tmp2 in apiObject.getAProperty()) { + if (facadePropertyAssignment.key_eq(auto_tmp2)) { + if (proxyFacadeName = facadePropertyAssignment.getName()) { + for (facadeStringLiteral in StringLiteral(javascript_db)) { + if (facadeStringLiteral.key_eq(facadePropertyAssignment.getInitializer())) { + if (facadeQualifiedName = facadeStringLiteral.getValue()) { + return true + } + } + for (facadeObject in ObjectLiteralExpression(javascript_db), + interfaceNamePropertyAssignment in PropertyAssignment(javascript_db)) { + if (facadeObject.key_eq(facadePropertyAssignment.getInitializer())) { + if (interfaceNamePropertyAssignment = facadeObject.getPropertyAssignmentByName("interfaceName")) { + if (facadeStringLiteral.key_eq(interfaceNamePropertyAssignment.getInitializer())) { + if (facadeQualifiedName = facadeStringLiteral.getValue()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn proxyCallerDesc(proxyCaller: CallExpression, facadeName: string, trFuncName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (expression in PropertyAccessExpression(javascript_db)) { + if (expression.key_eq(proxyCaller.getExpression())) { + for (facadeExpressionText in string::__undetermined_all__()) { + for (facadeExpression in LeftHandSideExpression(javascript_db)) { + for (leftHandSideExpression in LeftHandSideExpression(javascript_db)) { + if (leftHandSideExpression = expression.getExpression()) { + for (callExpression in CallExpression(javascript_db)) { + if (callExpression.key_eq(leftHandSideExpression)) { + for (usingExpression in PropertyAccessExpression(javascript_db)) { + if (usingExpression.key_eq(callExpression.getExpression())) { + if (facadeExpression = usingExpression.getExpression()) { + if (facadeExpressionText = facadeExpression.getText()) { + if (facadeName = facadeExpressionText.get_regex_match_result("(this\\.|ctx\\.|this\\.ctx\\.)?proxy\\.(.+)", 2)) { + if (facadeName != "") { + for (serviceFuncIdentifier in Identifier(javascript_db)) { + if (serviceFuncIdentifier.key_eq(expression.getProperty())) { + if (trFuncName = serviceFuncIdentifier.getText()) { + if (trFuncName != "using") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + if (isPropertyAccessExpression(Node(javascript_db).find(leftHandSideExpression))) { + if (facadeExpression = leftHandSideExpression) { + if (facadeExpressionText = facadeExpression.getText()) { + if (facadeName = facadeExpressionText.get_regex_match_result("(this\\.|ctx\\.|this\\.ctx\\.)?proxy\\.(.+)", 2)) { + if (facadeName != "") { + for (serviceFuncIdentifier in Identifier(javascript_db)) { + if (serviceFuncIdentifier.key_eq(expression.getProperty())) { + if (trFuncName = serviceFuncIdentifier.getText()) { + if (trFuncName != "using") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(appName: string, facadeQualifiedName: string, trMethodName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (facadeName in string::__undetermined_all__()) { + if (getInfluencedTrAPI(facadeQualifiedName, trMethodName)) { + if (proxyCallerDesc(__all_data__, facadeName, trMethodName)) { + if (getAppFacade(appName, facadeName, facadeQualifiedName)) { + return true + } + } + } + } + } +} + + +fn default_javascript_db() -> JavascriptDB { + return JavascriptDB::load("coref_javascript_src.db") +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule19.gdl b/example/icse25/rules/rule19.gdl new file mode 100644 index 0000000..440ed3e --- /dev/null +++ b/example/icse25/rules/rule19.gdl @@ -0,0 +1,381 @@ +// script +use coref::javascript::* + +pub fn getInfluencedTrAPI(appName: string, facadeQualifiedName: string, trMethodName: string) -> bool { + // #rule18结果 + // example + [ + {"finpdcenter", "com.xxx.filtered.BlockFacade", "load"}, + {"finpdcenter", "com.xxx.filtered.BlockFacade", "batchLoad"} + ] +} +pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionIdentifier: Expression) -> bool { + let (javascript_db = default_javascript_db()) { + for (callExpression in CallExpression(javascript_db)) { + for (routerFile in File(javascript_db)) { + for (routerPath in string::__undetermined_all__()) { + if (routerPath = routerFile.getRelativePath()) { + if (routerPath.matches("app/router(\\.[jt]s|/.+\\.[jt]s)")) { + if (callExpression.getLocation().getFile() = routerFile) { + for (accessExpression in AccessExpression(javascript_db), + property in Expression(javascript_db)) { + if (accessExpression.key_eq(callExpression.getExpression())) { + if (property = accessExpression.getPropertyExpression()) { + if (property.getText() = "rpc") { + for (rpcNameStringLiteral in StringLiteral(javascript_db)) { + if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { + if (rpcName = rpcNameStringLiteral.getValue()) { + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true + } + } + } + } + } + } + if (property.getText() = "rpcAndGet") { + for (rpcNameStringLiteral in StringLiteral(javascript_db)) { + if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { + if (rpcName = rpcNameStringLiteral.getValue()) { + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true + } + } + } + } + } + } + if (property.getText() = "rpcAndPost") { + for (rpcNameStringLiteral in StringLiteral(javascript_db)) { + if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { + if (rpcName = rpcNameStringLiteral.getValue()) { + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn rpcNameControllerFunction(rpcName: string, controllerFunction: FunctionLikeDeclaration) -> bool { + let (javascript_db = default_javascript_db()) { + for (controllerFunctionIdentifier in Expression(javascript_db)) { + if (rpcNameControllerFunctionIdentifier(rpcName, controllerFunctionIdentifier)) { + for (symbol in Symbol(javascript_db)) { + if (symbol = controllerFunctionIdentifier.getSymbol()) { + if (controllerFunction.getSymbol() = symbol) { + return true + } + for (variableDeclaration in VariableDeclaration(javascript_db)) { + if (variableDeclaration.getSymbol() = symbol) { + if (controllerFunction.key_eq(variableDeclaration.getInitializer())) { + return true + } + } + } + for (propertyDeclaration in PropertyDeclaration(javascript_db)) { + if (propertyDeclaration.getSymbol() = symbol) { + if (controllerFunction.key_eq(propertyDeclaration.getInitializer())) { + return true + } + } + } + } + } + } + } + } +} +pub fn controllerReturnField(controllerFunc: FunctionLikeDeclaration, fieldName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (simpleAssignmentExpression in SimpleAssignmentExpression(javascript_db)) { + for (auto_tmp1 in simpleAssignmentExpression.getAnAncestorEnclosingFunction()) { + if (auto_tmp1 = controllerFunc) { + for (leftOperandText in string::__undetermined_all__()) { + for (leftOperand in Expression(javascript_db)) { + if (leftOperand = simpleAssignmentExpression.getLeftOperand()) { + if (leftOperandText = leftOperand.getText()) { + if (leftOperandText.matches("(this\\.|ctx\\.|this\\.ctx\\.)?body")) { + for (object in ObjectLiteralExpression(javascript_db), + objectElement in ObjectLiteralElement(javascript_db)) { + if (object.key_eq(simpleAssignmentExpression.getRightOperand())) { + if (objectElement = object.getPropertyByName(fieldName)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn serviceCallSite(serviceCaller: CallExpression, serviceFunction: FunctionLikeDeclaration) -> bool { + let (javascript_db = default_javascript_db()) { + for (expressionText in string::__undetermined_all__()) { + for (expression in PropertyAccessExpression(javascript_db)) { + if (expression.key_eq(serviceCaller.getExpression())) { + if (expressionText = expression.getText()) { + if (expressionText.matches("(this\\.|ctx\\.|this\\.ctx\\.)?service\\.(.+)")) { + if (serviceFunction = serviceCaller.getCallee()) { + return true + } + } + } + } + } + } + } +} +pub fn getAnDescendantServiceCallee(serviceCaller: CallExpression, descendantServiceCallee: FunctionLikeDeclaration) -> bool { + let (javascript_db = default_javascript_db()) { + if (serviceCallSite(serviceCaller, descendantServiceCallee)) { + return true + } + for (serviceCallee in FunctionLikeDeclaration(javascript_db), + childServiceCaller in CallExpression(javascript_db)) { + if (serviceCallSite(serviceCaller, serviceCallee)) { + for (auto_tmp1 in childServiceCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp1 = serviceCallee) { + if (getAnDescendantServiceCallee(childServiceCaller, descendantServiceCallee)) { + return true + } + } + } + } + } + } +} +pub fn proxyCallerDesc(proxyCaller: CallExpression, facadeName: string, trFuncName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (expression in PropertyAccessExpression(javascript_db)) { + if (expression.key_eq(proxyCaller.getExpression())) { + for (facadeExpressionText in string::__undetermined_all__()) { + for (facadeExpression in LeftHandSideExpression(javascript_db)) { + for (leftHandSideExpression in LeftHandSideExpression(javascript_db)) { + if (leftHandSideExpression = expression.getExpression()) { + for (callExpression in CallExpression(javascript_db)) { + if (callExpression.key_eq(leftHandSideExpression)) { + for (usingExpression in PropertyAccessExpression(javascript_db)) { + if (usingExpression.key_eq(callExpression.getExpression())) { + if (facadeExpression = usingExpression.getExpression()) { + if (facadeExpressionText = facadeExpression.getText()) { + if (facadeName = facadeExpressionText.get_regex_match_result("(this\\.|ctx\\.|this\\.ctx\\.)?proxy\\.(.+)", 2)) { + if (facadeName != "") { + for (serviceFuncIdentifier in Identifier(javascript_db)) { + if (serviceFuncIdentifier.key_eq(expression.getProperty())) { + if (trFuncName = serviceFuncIdentifier.getText()) { + if (trFuncName != "using") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + if (isPropertyAccessExpression(Node(javascript_db).find(leftHandSideExpression))) { + if (facadeExpression = leftHandSideExpression) { + if (facadeExpressionText = facadeExpression.getText()) { + if (facadeName = facadeExpressionText.get_regex_match_result("(this\\.|ctx\\.|this\\.ctx\\.)?proxy\\.(.+)", 2)) { + if (facadeName != "") { + for (serviceFuncIdentifier in Identifier(javascript_db)) { + if (serviceFuncIdentifier.key_eq(expression.getProperty())) { + if (trFuncName = serviceFuncIdentifier.getText()) { + if (trFuncName != "using") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getAppFacade(appName: string, proxyFacadeName: string, facadeQualifiedName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (objectLiteralExpression in ObjectLiteralExpression(javascript_db)) { + for (proxyPath in string::__undetermined_all__()) { + for (file in File(javascript_db), + location in Location(javascript_db), + servicePropertyAssignment in PropertyAssignment(javascript_db), + arrayLiteralExpression in ArrayLiteralExpression(javascript_db)) { + if (proxyPath = file.getRelativePath()) { + if (proxyPath.matches("config/proxy\\.[jt]s")) { + if (location.getFile() = file) { + if (servicePropertyAssignment.getLocation() = location) { + if (servicePropertyAssignment.getName() = "services") { + if (arrayLiteralExpression.key_eq(servicePropertyAssignment.getInitializer())) { + for (auto_tmp1 in arrayLiteralExpression.getAElement()) { + if (objectLiteralExpression.key_eq(auto_tmp1)) { + for (appNamePropertyAssignment in PropertyAssignment(javascript_db), + appNameString in StringLiteral(javascript_db)) { + if (appNamePropertyAssignment = objectLiteralExpression.getPropertyAssignmentByName("appname")) { + if (appNameString.key_eq(appNamePropertyAssignment.getInitializer())) { + if (appName = appNameString.getValue()) { + for (apiPropertyAssignment in PropertyAssignment(javascript_db), + apiObject in ObjectLiteralExpression(javascript_db), + facadePropertyAssignment in PropertyAssignment(javascript_db)) { + if (apiPropertyAssignment = objectLiteralExpression.getPropertyAssignmentByName("api")) { + if (apiObject.key_eq(apiPropertyAssignment.getInitializer())) { + for (auto_tmp2 in apiObject.getAProperty()) { + if (facadePropertyAssignment.key_eq(auto_tmp2)) { + if (proxyFacadeName = facadePropertyAssignment.getName()) { + for (facadeStringLiteral in StringLiteral(javascript_db)) { + if (facadeStringLiteral.key_eq(facadePropertyAssignment.getInitializer())) { + if (facadeQualifiedName = facadeStringLiteral.getValue()) { + return true + } + } + for (facadeObject in ObjectLiteralExpression(javascript_db), + interfaceNamePropertyAssignment in PropertyAssignment(javascript_db)) { + if (facadeObject.key_eq(facadePropertyAssignment.getInitializer())) { + if (interfaceNamePropertyAssignment = facadeObject.getPropertyAssignmentByName("interfaceName")) { + if (facadeStringLiteral.key_eq(interfaceNamePropertyAssignment.getInitializer())) { + if (facadeQualifiedName = facadeStringLiteral.getValue()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(rpcName: string, facadeName: string, trFuncName: string, rpcFieldName: string, trFieldName: string) -> bool { + let (javascript_db = default_javascript_db()) { + for (controllerFunc in FunctionLikeDeclaration(javascript_db), + serviceCaller in CallExpression(javascript_db), + serviceCallee in MethodDeclaration(javascript_db), + proxyCaller in CallExpression(javascript_db)) { + for (facadeProxyName in string::__undetermined_all__()) { + if (getInfluencedTrAPI(__all_data__, facadeName, trFuncName)) { + if (proxyCallerDesc(proxyCaller, facadeProxyName, trFuncName)) { + if (getAppFacade(__all_data__, facadeProxyName, facadeName)) { + if (rpcNameControllerFunction(rpcName, controllerFunc)) { + if (controllerReturnField(controllerFunc, rpcFieldName)) { + if (trFieldName = rpcFieldName) { + for (auto_tmp1 in serviceCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp1 = controllerFunc) { + if (getAnDescendantServiceCallee(serviceCaller, FunctionLikeDeclaration(javascript_db).find(serviceCallee))) { + for (auto_tmp2 in proxyCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp2 = controllerFunc) { + return true + } + } + for (auto_tmp3 in proxyCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp3.key_eq(serviceCallee)) { + return true + } + } + } + } + } + } + } + if (tmp_0(controllerFunc).len() = 0) { + if (rpcFieldName = "") { + if (trFieldName = rpcFieldName) { + for (auto_tmp1 in serviceCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp1 = controllerFunc) { + if (getAnDescendantServiceCallee(serviceCaller, FunctionLikeDeclaration(javascript_db).find(serviceCallee))) { + for (auto_tmp2 in proxyCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp2 = controllerFunc) { + return true + } + } + for (auto_tmp3 in proxyCaller.getAnAncestorEnclosingFunction()) { + if (auto_tmp3.key_eq(serviceCallee)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_javascript_db() -> JavascriptDB { + return JavascriptDB::load("coref_javascript_src.db") +} + +fn tmp_0(controllerFunc: FunctionLikeDeclaration) -> *FunctionLikeDeclaration { + let (javascript_db = default_javascript_db()) { + for (_ in string::__undetermined_all__()) { + for (func in FunctionLikeDeclaration(javascript_db)) { + if (func = controllerFunc) { + if (controllerReturnField(func, __all_data__)) { + yield func + } + } + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule1_4.gdl b/example/icse25/rules/rule1_4.gdl new file mode 100644 index 0000000..43d817d --- /dev/null +++ b/example/icse25/rules/rule1_4.gdl @@ -0,0 +1,1920 @@ +// script +use coref::java::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + //python替换 + // $gitdiff + // example + [ {"test", 1111} ] +} +pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + if (gitdiff(filename, lineNumber)) { + if (!filename.contains("src/test/java")) { + if (filename = f.getRelativePath()) { + if (isCodeLine(f, filename, lineNumber)) { + return true + } + } + } + } + } +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + if (transfertofile1(f, filename, lineNumber)) { + if (!findSpecialCodeType(filename, lineNumber, __all_data__)) { + return true + } + } + } +} +pub fn isComment(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn isAnnotation(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Annotation(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + if (gitdiff(filename, lineNumber)) { + if (f.getRelativePath() = filename) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (l in Location(java_db)) { + if (l.getFile() = f) { + if (s1 = l.getStartLineNumber()) { + if (e = l.getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn isLog(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (c in Expression(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (text = c.getPrintableText()) { + if (text.matches("^logger\\..*")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in ElementParent(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (s1 = e) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (tmp_0(filename, lineNumber)) { + if (typeInAST = "Callable") { + if (getBelongedCallable(filename, lineNumber, Callable(java_db).find(n))) { + return true + } + } + } + if (!(tmp_0(filename, lineNumber))) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (isFieldOrEnum(ECGNode(java_db).find(n))) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isFieldOrEnum(c: ECGNode) -> bool { + let (java_db = default_java_db()) { + for (f in Field(java_db)) { + if (f.key_eq(c)) { + return true + } + } + for (e in EnumConstant(java_db)) { + if (e.key_eq(c)) { + return true + } + } + } +} +pub fn findSpecialCodeType(filename: string, lineNumber: int, type: string) -> bool { + let (java_db = default_java_db()) { + if (isComment(filename, lineNumber)) { + if (type = "comment") { + return true + } + } + if (isAnnotation(filename, lineNumber)) { + if (type = "annotation") { + return true + } + } + if (isLog(filename, lineNumber)) { + if (type = "log") { + return true + } + } + } +} +pub fn getBelongedCallable(filename: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (l1 in int::__undetermined_all__(), + l2 in int::__undetermined_all__()) { + for (i in Identifier(java_db)) { + if (f = c.getLocation().getFile()) { + if (c.key_eq(i.getParent())) { + if (l1 = i.getLocation().getStartLineNumber()) { + if (l2 = c.getLocation().getEndLineNumber()) { + if (lineNumber > l1 - 1) { + if (lineNumber < l2 + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getBelongedCallableSignature(filename: string, lineNumber: int, belongedCallable: string) -> bool { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__()) { + for (c in Callable(java_db)) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (i = tmp_1().len()) { + if (tmp_2(i)) { + if (belongedCallable = "") { + return true + } + } + if (!(tmp_2(i))) { + if (getBelongedCallable(filename, lineNumber, c)) { + if (belongedCallable = c.getSignature()) { + return true + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(n: ECGNode) -> bool { + let (java_db = default_java_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + belongedCallable in string::__undetermined_all__()) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + return true + } + } + } + } + } +} +@inline +pub fn trim(n: string, m: string) -> bool { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_3(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_3(n))) { + if (m = n) { + return true + } + } + } + } + } +} +@inline +pub fn contact(a: string, b: string, c: string) -> bool { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__()) { + if (i = a.len()) { + if (tmp_4(i)) { + if (tmp_5(a, b)) { + if (c = b) { + return true + } + } + if (!(tmp_5(a, b))) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_4(i))) { + if (tmp_6(a, i, b)) { + if (temp = a.substr(1,i - 1)) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_6(a, i, b))) { + if (tmp_7(a, i, b)) { + if (c = a + "/" + b) { + return true + } + } + if (!(tmp_7(a, i, b))) { + if (c = a + b) { + return true + } + } + } + } + } + } + } +} +schema HttpMethodType extends AnnotationAccessArgument { + +} + +impl HttpMethodType { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *HttpMethodType { + for (tmp in AnnotationAccessArgument(db)) { + if (tmp.getAnnotationArgumentName() = "method") { + yield HttpMethodType { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (a in AnnotationArrayInitializer(__all_data__)) { + if (self.getArgumentValueHashId() = a.getParent().id) { + for (i in Identifier(__all_data__)) { + if (a.key_eq(i.getParent())) { + if (t = i.getName()) { + return t + } + } + } + } + } + for (i in Identifier(__all_data__)) { + if (self.getArgumentValueHashId() = i.getParent().id) { + if (t = i.getName()) { + return t + } + } + } + } + } + + +} + +pub fn getMethodType(a: Annotation, t: string) -> bool { + let (java_db = default_java_db()) { + for (m in Method(java_db), + h in HttpMethodType(java_db)) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (tmp_8(a)) { + if (t = "POST") { + return true + } + } + if (!(tmp_8(a))) { + if (tmp_9(a)) { + if (t = "GET") { + return true + } + } + if (!(tmp_9(a))) { + if (tmp_10(a)) { + if (t = "PUT") { + return true + } + } + if (!(tmp_10(a))) { + if (tmp_11(a)) { + if (t = "DELETE") { + return true + } + } + if (!(tmp_11(a))) { + if (tmp_12(a)) { + if (t = "PATCH") { + return true + } + } + if (!(tmp_12(a))) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (h.key_eq(auto_tmp2)) { + if (t = h.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getSubUri(a: Annotation, sub: string) -> bool { + let (java_db = default_java_db()) { + for (s in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (temp in AnnotationAccessArgument(java_db), + e in Expression(java_db)) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + for (auto_tmp1 in a.getAnnotationArgument()) { + if (temp = auto_tmp1) { + if (temp.getAnnotationArgumentName() = "value") { + if (temp.key_eq(e.getParent())) { + if (tmp_13(e)) { + if (sub = connectStr(e)) { + return true + } + } + if (!(tmp_13(e))) { + if (s = temp.getAnnotationArgumentValue()) { + if (trim(s, sub)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getUri(c: Class, m: Method, uri1: string) -> bool { + let (java_db = default_java_db()) { + for (l1 in string::__undetermined_all__(), + l2 in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (a in Annotation(java_db), + a1 in Annotation(java_db)) { + if (c = m.getBelongedClass()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + for (auto_tmp2 in c.getAnnotation()) { + if (a1 = auto_tmp2) { + if (n = a.getName()) { + if (tmp_15(c)) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (getSubUri(a, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_19(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_19(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + } + if (!(tmp_15(c))) { + if (tmp_17(a)) { + if (n.matches(".*Mapping")) { + if (getSubUri(a1, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_19(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_19(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + if (!(tmp_17(a))) { + if (a1.getName() = "RequestMapping") { + if (n.matches(".*Mapping")) { + if (getSubUri(a, l1)) { + if (getSubUri(a1, l2)) { + if (contact(l2, l1, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_19(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_19(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +schema WebFolder extends Folder { + +} + +impl WebFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebFolder { + for (tmp in Folder(db)) { + yield WebFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + + pub fn getChild(self) -> Folder { + for (f in Folder(__all_data__)) { + if (self.element_hash_id = f.getParentHashId()) { + return f + } + } + } + + +} + +schema WebCarFolder extends Folder { + +} + +impl WebCarFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebCarFolder { + for (tmp in Folder(db)) { + yield WebCarFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + + pub fn getBelongedFolder(self) -> WebCarFolder { + for (f in WebCarFolder(__all_data__)) { + if (f.element_hash_id = self.getParentHashId()) { + return f + } + } + } + + pub fn getAnAncestorFolder(self) -> WebCarFolder { + for (f in WebCarFolder(__all_data__)) { + if (f = self.getBelongedFolder()) { + return f + } + if (f = self.getBelongedFolder().getAnAncestorFolder()) { + return f + } + } + } + + +} + +schema WebCarClass extends Class { + +} + +impl WebCarClass { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebCarClass { + for (tmp in Class(db)) { + for (f in WebCarFolder(db), + w in WebFolder(db)) { + if (f.key_eq(tmp.getContainingFile().getBelongedFolder())) { + if (f.getAnAncestorFolder().key_eq(w)) { + yield WebCarClass { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + identifier_hash_id : tmp.identifier_hash_id, + location_hash_id : tmp.location_hash_id, + parent_hash_id : tmp.parent_hash_id + } + } + } + } + } + } + + pub fn getWebFolder(self) -> WebCarFolder { + for (c in WebCarFolder(__all_data__)) { + for (f in WebCarFolder(__all_data__), + w in WebFolder(__all_data__)) { + if (f.key_eq(self.getContainingFile().getBelongedFolder())) { + if (f.getAnAncestorFolder() = c) { + if (c.key_eq(w.getChild())) { + return c + } + } + } + } + } + } + + +} + +pub fn resolve(r: ReferenceExpression, rr: string) -> bool { + let (java_db = default_java_db()) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (e.getParent() = r.getDefinition()) { + if (temp = e.getPrintableText()) { + if (trim(temp, rr)) { + return true + } + } + } + } + } + } +} +pub fn facts(a: Expression, i: int, value: string) -> bool { + let (java_db = default_java_db()) { + for (p in PolyadicExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_20(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_20(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_21(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_21(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in BinaryExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_20(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_20(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_21(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_21(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in ReferenceExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_20(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_20(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_21(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_21(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn connectStrBase(ID: Expression, index: int, res: string) -> bool { + let (java_db = default_java_db()) { + for (total in int::__undetermined_all__(), + reStr in string::__undetermined_all__(), + currStr in string::__undetermined_all__()) { + if (total = tmp_22(ID).len()) { + if (tmp_24(index)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = currStr) { + return true + } + } + } + if (!(tmp_24(index))) { + if (index > 0) { + if (connectStrBase(ID, index - 1, reStr)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = reStr + currStr) { + return true + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: Expression) -> string { + let (java_db = default_java_db()) { + for (c in int::__undetermined_all__(), res in string::__undetermined_all__()) { + if (c = tmp_25(ID).len()) { + if (connectStrBase(ID, c - 1, res)) { + return res + } + } + } + } +} +pub fn getHttpMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + for (n in string::__undetermined_all__(), + className in string::__undetermined_all__(), + methodSignature in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + type in string::__undetermined_all__()) { + for (c in Class(java_db), + a in Annotation(java_db)) { + if (getUri(c, m, uri)) { + if (className = c.getQualifiedName()) { + if (methodSignature = m.getSignature()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (tmp_29(a)) { + if (type = "EMPTY") { + return true + } + } + if (!(tmp_29(a))) { + if (getMethodType(a, type)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(nodeText: string, path: string) -> bool { + let (java_db = default_java_db()) { + for (direction in string::__undetermined_all__(), + edgeType in string::__undetermined_all__()) { + for (m in ECGNode(java_db), + a in ECGNode(java_db), + b in ECGNode(java_db), + c in ECGNode(java_db)) { + if (getJavaECGNode(a)) { + if (getHttpMethod(Method(java_db).find(m))) { + if (b = m.getAnAncestorCDDependsNode(__all_data__, __all_data__)) { + if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + if (c = a) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + } + if (b = m) { + if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + if (c = a) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn tmp_0(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + return true + } + } +} + +fn tmp_1() -> *string { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename + } + } +} + +fn tmp_2(i: int) -> bool { + let (java_db = default_java_db()) { + if (i = 0) { + return true + } + } +} + +fn tmp_3(n: string) -> bool { + let (java_db = default_java_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } +} + +fn tmp_4(i: int) -> bool { + let (java_db = default_java_db()) { + if (i = 1) { + return true + } + } +} + +fn tmp_5(a: string, b: string) -> bool { + let (java_db = default_java_db()) { + if (a.substr(0,1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } +} + +@inline +fn tmp_6(a: string, i: int, b: string) -> bool { + let (java_db = default_java_db()) { + if (a.substr(i - 1,i - 1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } +} + +@inline +fn tmp_7(a: string, i: int, b: string) -> bool { + let (java_db = default_java_db()) { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { + return true + } + } + } +} + +fn tmp_8(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PostMapping") { + return true + } + } +} + +fn tmp_9(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "GetMapping") { + return true + } + } +} + +fn tmp_10(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PutMapping") { + return true + } + } +} + +fn tmp_11(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "DeleteMapping") { + return true + } + } +} + +fn tmp_12(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PatchMapping") { + return true + } + } +} + +fn tmp_13(e: Expression) -> bool { + let (java_db = default_java_db()) { + if (facts(e, __all_data__, __all_data__)) { + return true + } + } +} + +fn tmp_14(c: Class) -> *Annotation { + let (java_db = default_java_db()) { + for (b in Annotation(java_db)) { + for (auto_tmp3 in c.getAnnotation()) { + if (b = auto_tmp3) { + if (b.getName() = "RequestMapping") { + yield b + } + } + } + } + } +} + +fn tmp_15(c: Class) -> bool { + let (java_db = default_java_db()) { + if (tmp_14(c).len() = 0) { + return true + } + } +} + +fn tmp_16(a: Annotation) -> *AnnotationAccessArgument { + let (java_db = default_java_db()) { + for (b in AnnotationAccessArgument(java_db)) { + for (auto_tmp4 in a.getAnnotationArgument()) { + if (b = auto_tmp4) { + if (b.getAnnotationArgumentName() = "value") { + yield b + } + } + } + } + } +} + +fn tmp_17(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (tmp_16(a).len() = 0) { + return true + } + } +} + +fn tmp_18(w: WebFolder) -> *Folder { + let (java_db = default_java_db()) { + for (f in Folder(java_db)) { + if (f = w.getChild()) { + yield f + } + } + } +} + +fn tmp_19(w: WebFolder) -> bool { + let (java_db = default_java_db()) { + if (tmp_18(w).len() = 1) { + return true + } + } +} + +fn tmp_20(a: Expression) -> bool { + let (java_db = default_java_db()) { + if (resolve(ReferenceExpression(java_db).find(a), __all_data__)) { + return true + } + } +} + +fn tmp_21(e: Expression) -> bool { + let (java_db = default_java_db()) { + if (resolve(ReferenceExpression(java_db).find(e), __all_data__)) { + return true + } + } +} + +fn tmp_22(ID: Expression) -> *auto_tmp_23 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(Expression(java_db).find(ID), auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_23 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } +} + +schema auto_tmp_23 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_24(index: int) -> bool { + let (java_db = default_java_db()) { + if (index = 0) { + return true + } + } +} + +fn tmp_25(ID: Expression) -> *auto_tmp_26 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(Expression(java_db).find(ID), auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_26 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } +} + +schema auto_tmp_26 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_27(a: Annotation) -> *auto_tmp_28 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in string::__undetermined_all__()) { + if (getMethodType(a, auto_tmp_var_0)) { + yield auto_tmp_28 { + auto_tmp_var_0 : auto_tmp_var_0 + } + } + } + } +} + +schema auto_tmp_28 { + auto_tmp_var_0 : string +} + +fn tmp_29(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (tmp_27(a).len() = 0) { + return true + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule1_5.gdl b/example/icse25/rules/rule1_5.gdl new file mode 100644 index 0000000..9fd3688 --- /dev/null +++ b/example/icse25/rules/rule1_5.gdl @@ -0,0 +1,1210 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + //python替换 + // $gitdiff + // example + [ {"test", 1111} ] +} +pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (!filename.contains("src/test/java")) { + if (filename = f.getRelativePath()) { + if (isCodeLine(f, filename, lineNumber)) { + return true + } + } + } + } + } + } +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (transfertofile1(f, filename, lineNumber)) { + if (!findSpecialCodeType(filename, lineNumber, __all_data__)) { + return true + } + } + } + } +} +pub fn isComment(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isAnnotation(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Annotation(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (f.getRelativePath() = filename) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (l in coref::java::Location(java_db)) { + if (l.getFile() = f) { + if (s1 = l.getStartLineNumber()) { + if (e = l.getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isLog(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (c in Expression(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (text = c.getPrintableText()) { + if (text.matches("^logger\\..*")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in ElementParent(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (s1 = e) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (tmp_0(lineNumber, filename)) { + if (typeInAST = "Callable") { + if (getBelongedCallable(filename, lineNumber, Callable(java_db).find(n))) { + return true + } + } + } + if (!(tmp_0(lineNumber, filename))) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (isFieldOrEnum(ECGNode(java_db).find(n))) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isFieldOrEnum(c: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in Field(java_db)) { + if (f.key_eq(c)) { + return true + } + } + for (e in EnumConstant(java_db)) { + if (e.key_eq(c)) { + return true + } + } + } + } +} +pub fn findSpecialCodeType(filename: string, lineNumber: int, type: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isComment(filename, lineNumber)) { + if (type = "comment") { + return true + } + } + if (isAnnotation(filename, lineNumber)) { + if (type = "annotation") { + return true + } + } + if (isLog(filename, lineNumber)) { + if (type = "log") { + return true + } + } + } + } +} +pub fn getBelongedCallable(filename: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (l1 in int::__undetermined_all__(), + l2 in int::__undetermined_all__()) { + for (i in Identifier(java_db)) { + if (f = c.getLocation().getFile()) { + if (c.key_eq(i.getParent())) { + if (l1 = i.getLocation().getStartLineNumber()) { + if (l2 = c.getLocation().getEndLineNumber()) { + if (lineNumber > l1 - 1) { + if (lineNumber < l2 + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getBelongedCallableSignature(filename: string, lineNumber: int, belongedCallable: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + for (c in Callable(java_db)) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (i = tmp_1().len()) { + if (tmp_2(i)) { + if (belongedCallable = "") { + return true + } + } + if (!(tmp_2(i))) { + if (getBelongedCallable(filename, lineNumber, c)) { + if (belongedCallable = c.getSignature()) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + belongedCallable in string::__undetermined_all__()) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + return true + } + } + } + } + } + } +} +pub fn transfertoXmlfile(f: XmlFile, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + return true + } + } + } + } +} +pub fn getXmlECGNode(n: ECGXmlNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (f in XmlFile(xml_db), + o in ECGXmlNode(xml_db)) { + if (transfertoXmlfile(f, filename, lineNumber)) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (text = n.getText()) { + if (o = n.getEnclosingECGXmlNode()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(i: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (e1 in ECGNode(java_db)) { + if (getJavaECGNode(e1)) { + if (i = e1.id) { + return true + } + } + } + for (e2 in ECGXmlNode(xml_db)) { + if (getXmlECGNode(e2)) { + if (i = e2.id) { + return true + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(lineNumber: int, filename: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + return true + } + } + } +} + +fn tmp_1() -> *string { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename + } + } +} + +fn tmp_2(i: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (i = 0) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule1_5_6.gdl b/example/icse25/rules/rule1_5_6.gdl new file mode 100644 index 0000000..eb69e88 --- /dev/null +++ b/example/icse25/rules/rule1_5_6.gdl @@ -0,0 +1,1423 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + //python替换 + // $gitdiff + // example + [ {"test", 1111} ] +} +pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (!filename.contains("src/test/java")) { + if (filename = f.getRelativePath()) { + if (isCodeLine(f, filename, lineNumber)) { + return true + } + } + } + } + } + } +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (transfertofile1(f, filename, lineNumber)) { + if (!findSpecialCodeType(filename, lineNumber, __all_data__)) { + return true + } + } + } + } +} +pub fn isComment(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isAnnotation(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Annotation(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (f.getRelativePath() = filename) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (l in coref::java::Location(java_db)) { + if (l.getFile() = f) { + if (s1 = l.getStartLineNumber()) { + if (e = l.getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isLog(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (c in Expression(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (text = c.getPrintableText()) { + if (text.matches("^logger\\..*")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in ElementParent(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (s1 = e) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (tmp_0(filename, lineNumber)) { + if (typeInAST = "Callable") { + if (getBelongedCallable(filename, lineNumber, Callable(java_db).find(n))) { + return true + } + } + } + if (!(tmp_0(filename, lineNumber))) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (isFieldOrEnum(ECGNode(java_db).find(n))) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isFieldOrEnum(c: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in Field(java_db)) { + if (f.key_eq(c)) { + return true + } + } + for (e in EnumConstant(java_db)) { + if (e.key_eq(c)) { + return true + } + } + } + } +} +pub fn findSpecialCodeType(filename: string, lineNumber: int, type: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isComment(filename, lineNumber)) { + if (type = "comment") { + return true + } + } + if (isAnnotation(filename, lineNumber)) { + if (type = "annotation") { + return true + } + } + if (isLog(filename, lineNumber)) { + if (type = "log") { + return true + } + } + } + } +} +pub fn getBelongedCallable(filename: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (l1 in int::__undetermined_all__(), + l2 in int::__undetermined_all__()) { + for (i in Identifier(java_db)) { + if (f = c.getLocation().getFile()) { + if (c.key_eq(i.getParent())) { + if (l1 = i.getLocation().getStartLineNumber()) { + if (l2 = c.getLocation().getEndLineNumber()) { + if (lineNumber > l1 - 1) { + if (lineNumber < l2 + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getBelongedCallableSignature(filename: string, lineNumber: int, belongedCallable: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + for (c in Callable(java_db)) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (i = tmp_1().len()) { + if (tmp_2(i)) { + if (belongedCallable = "") { + return true + } + } + if (!(tmp_2(i))) { + if (getBelongedCallable(filename, lineNumber, c)) { + if (belongedCallable = c.getSignature()) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + belongedCallable in string::__undetermined_all__()) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + return true + } + } + } + } + } + } +} +pub fn transfertoXmlfile(f: XmlFile, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + return true + } + } + } + } +} +pub fn getXmlECGNode(n: ECGXmlNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (f in XmlFile(xml_db), + o in ECGXmlNode(xml_db)) { + if (transfertoXmlfile(f, filename, lineNumber)) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (text = n.getText()) { + if (o = n.getEnclosingECGXmlNode()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> ClassOrInterface { + for (value in string::__undetermined_all__()) { + for (i in ClassOrInterface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_5(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_5(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db)) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn real_output(className: string, interfaceName: string, id: int, name: string, tag: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + j in int::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db), + c in ClassOrInterface(java_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + if (temp = interfaceName) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + } + if (e2.id = i) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + if (e2.id = j) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + } + } + } + } + } + } + } + if (javaOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db), + c in ClassOrInterface(java_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + if (temp = interfaceName) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + } + if (e2.id = i) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + if (e2.id = j) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + } + } + } + } + } + } + } + if (annoOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db), + c in ClassOrInterface(java_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + if (temp = interfaceName) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + } + if (e2.id = i) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + if (e2.id = j) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + return true + } + } + } +} + +fn tmp_1() -> *string { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename + } + } +} + +fn tmp_2(i: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (i = 0) { + return true + } + } + } +} + +fn tmp_3(anno: Annotation) -> *auto_tmp_4 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_4 { + + } + } + } + } +} + +schema auto_tmp_4 { + +} + +fn tmp_5(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_3(anno).len() = 1) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule1_7_8.gdl b/example/icse25/rules/rule1_7_8.gdl new file mode 100644 index 0000000..7fa9288 --- /dev/null +++ b/example/icse25/rules/rule1_7_8.gdl @@ -0,0 +1,1663 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + // #changeinfo + // example + [ {"test", 1111}] +} +pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (!filename.contains("src/test/java")) { + if (filename = f.getRelativePath()) { + if (isCodeLine(f, filename, lineNumber)) { + return true + } + } + } + } + } + } +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (transfertofile1(f, filename, lineNumber)) { + if (!findSpecialCodeType(filename, lineNumber, __all_data__)) { + return true + } + } + } + } +} +pub fn isComment(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isAnnotation(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Annotation(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (f.getRelativePath() = filename) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (l in coref::java::Location(java_db)) { + if (l.getFile() = f) { + if (s1 = l.getStartLineNumber()) { + if (e = l.getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isLog(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (c in Expression(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (text = c.getPrintableText()) { + if (text.matches("^logger\\..*")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in ElementParent(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (s1 = e) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (tmp_0(filename, lineNumber)) { + if (typeInAST = "Callable") { + if (getBelongedCallable(filename, lineNumber, Callable(java_db).find(n))) { + return true + } + } + } + if (!(tmp_0(filename, lineNumber))) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (isFieldOrEnum(ECGNode(java_db).find(n))) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isFieldOrEnum(c: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in Field(java_db)) { + if (f.key_eq(c)) { + return true + } + } + for (e in EnumConstant(java_db)) { + if (e.key_eq(c)) { + return true + } + } + } + } +} +pub fn findSpecialCodeType(filename: string, lineNumber: int, type: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isComment(filename, lineNumber)) { + if (type = "comment") { + return true + } + } + if (isAnnotation(filename, lineNumber)) { + if (type = "annotation") { + return true + } + } + if (isLog(filename, lineNumber)) { + if (type = "log") { + return true + } + } + } + } +} +pub fn getBelongedCallable(filename: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (l1 in int::__undetermined_all__(), + l2 in int::__undetermined_all__()) { + for (i in Identifier(java_db)) { + if (f = c.getLocation().getFile()) { + if (c.key_eq(i.getParent())) { + if (l1 = i.getLocation().getStartLineNumber()) { + if (l2 = c.getLocation().getEndLineNumber()) { + if (lineNumber > l1 - 1) { + if (lineNumber < l2 + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getBelongedCallableSignature(filename: string, lineNumber: int, belongedCallable: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + for (c in Callable(java_db)) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (i = tmp_1().len()) { + if (tmp_2(i)) { + if (belongedCallable = "") { + return true + } + } + if (!(tmp_2(i))) { + if (getBelongedCallable(filename, lineNumber, c)) { + if (belongedCallable = c.getSignature()) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + belongedCallable in string::__undetermined_all__()) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + return true + } + } + } + } + } + } +} +pub fn transfertoXmlfile(f: XmlFile, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + return true + } + } + } + } +} +pub fn getXmlECGNode1(n: ECGXmlNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (f in XmlFile(xml_db), + o in ECGXmlNode(xml_db)) { + if (transfertoXmlfile(f, filename, lineNumber)) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (text = n.getText()) { + if (o = n.getEnclosingECGXmlNode()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +@inline +pub fn trim(n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_3(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_3(n))) { + if (m = n) { + return true + } + } + } + } + } + } +} +pub fn getXmlECGNode(f: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in ClassOrInterface(java_db), + n in string::__undetermined_all__(), + m in string::__undetermined_all__()) { + for (r in ECGXmlNode(xml_db)) { + if (getXmlECGNode1(r)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { + return true + } + } + } + } + } + } +} +pub fn getChangeSetByResultXmlElement(r1: ECGXmlNode, c: ClassOrInterface, f: Field, n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (r in ResultXmlElement(xml_db)) { + if (r.key_eq(r1)) { + if (getXmlECGNode1(ECGXmlNode(xml_db).find(r))) { + if (n = r.getBelongedMapXmlElement().getMappingClassName()) { + if (n = c.getQualifiedName()) { + if (c = f.getParent()) { + if (r.getValueByAttributeName("property") = f.getName()) { + if (m = f.getName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn getChangeSetByDalXmlElement(d1: ECGXmlNode, c: ClassOrInterface, m: Method, className: string, methodName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__(), + temp1 in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (d in DalXmlElement(xml_db), + cc in XmlComment(xml_db), + l in Literal(java_db)) { + if (d.key_eq(d1)) { + if (getXmlECGNode1(ECGXmlNode(xml_db).find(d))) { + if (d.getLocation().getFile() = cc.getLocation().getFile()) { + if (cc.getLocation().getEndLineNumber() = i) { + if (i + 1 = d.getLocation().getStartLineNumber()) { + if (temp = cc.getText()) { + if (c.getName() = temp.get_regex_match_result("[\\s\\S]*mapped statement for[ \\t]+(\\w+)[\\s\\S]*", 1)) { + if (n = d.getValueByAttributeName("id")) { + if (c.key_eq(m.getBelongedClass())) { + if (m.key_eq(l.getEnclosingCallable())) { + if (temp1 = l.getValue()) { + if (trim(temp1, n)) { + if (className = c.getQualifiedName()) { + if (methodName = m.getSignature()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> ClassOrInterface { + for (value in string::__undetermined_all__()) { + for (i in ClassOrInterface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_6(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_6(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db)) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn getPublishTr(c: ClassOrInterface) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (className in string::__undetermined_all__(), + interfaceName in string::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (javaOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (annoOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } +} +pub fn real_output(c: ClassOrInterface, n: ECGNode, interfaceName: string, nodeName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in ECGNode(java_db)) { + if (getJavaECGNode(m)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + } + } + if (getXmlECGNode(m)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + return true + } + } + } +} + +fn tmp_1() -> *string { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename + } + } +} + +fn tmp_2(i: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (i = 0) { + return true + } + } + } +} + +fn tmp_3(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } + } +} + +fn tmp_4(anno: Annotation) -> *auto_tmp_5 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_5 { + + } + } + } + } +} + +schema auto_tmp_5 { + +} + +fn tmp_6(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_4(anno).len() = 1) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule2.gdl b/example/icse25/rules/rule2.gdl new file mode 100644 index 0000000..65dc1de --- /dev/null +++ b/example/icse25/rules/rule2.gdl @@ -0,0 +1,838 @@ +// script +use coref::java::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +pub fn getJavaECGNode(node: int) -> bool { + // #javaecgnode + // example + [ {1111} ] +} +pub fn getResponseType(t: ReferenceType) -> bool { + let (java_db = default_java_db()) { + for (r in string::__undetermined_all__()) { + for (i in ClassOrInterface(java_db), + c in ClassOrInterface(java_db)) { + if (r in c.getImplementsList()) { + if (r = "implements Response") { + for (auto_tmp1 in i.getAnAscentantClassOrInterface()) { + if (c = auto_tmp1) { + if (t.getQualifiedName() = i.getQualifiedName()) { + return true + } + } + } + if (c = i) { + if (t.getQualifiedName() = i.getQualifiedName()) { + return true + } + } + } + } + if (c.getName() = "BaseResponse") { + for (auto_tmp1 in i.getAnAscentantClassOrInterface()) { + if (c = auto_tmp1) { + if (t.getQualifiedName() = i.getQualifiedName()) { + return true + } + } + } + if (c = i) { + if (t.getQualifiedName() = i.getQualifiedName()) { + return true + } + } + } + if (c.getName() = "HttpResponse") { + for (auto_tmp1 in i.getAnAscentantClassOrInterface()) { + if (c = auto_tmp1) { + if (t.getQualifiedName() = i.getQualifiedName()) { + return true + } + } + } + if (c = i) { + if (t.getQualifiedName() = i.getQualifiedName()) { + return true + } + } + } + } + } + } +} +pub fn getResponseMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + for (a in string::__undetermined_all__(), + b in string::__undetermined_all__(), + l in string::__undetermined_all__()) { + for (t in ReferenceType(java_db)) { + if (getResponseType(t)) { + if (m.getType().key_eq(t)) { + if (l = m.getLocation().getFile().getRelativePath()) { + if (!l.contains("src/test/java")) { + return true + } + } + } + if (b = m.getType().getName()) { + if (a = t.getName()) { + if (b.contains(a)) { + if (l = m.getLocation().getFile().getRelativePath()) { + if (!l.contains("src/test/java")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn temp(a: ECGNode, b: ECGNode, c: ECGNode, edgeType: string, direction: string) -> bool { + let (java_db = default_java_db()) { + if (getJavaECGNode(a.id)) { + if (b = a.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (c = b.getECGNode(edgeType, direction)) { + if (b != c) { + return true + } + } + } + if (b = a) { + if (c = b.getECGNode(edgeType, direction)) { + if (b != c) { + return true + } + } + } + } + } +} +pub fn temp1(c: Callable) -> bool { + let (java_db = default_java_db()) { + for (a in Callable(java_db)) { + if (getResponseMethod(Method(java_db).find(a))) { + for (auto_tmp1 in a.getAnAncestorCaller()) { + if (c = auto_tmp1) { + return true + } + } + if (c = a) { + return true + } + } + } + } +} +pub fn temp2(a: ECGNode, b: ECGNode, c: ECGNode, direction: string, edgeType: string) -> bool { + let (java_db = default_java_db()) { + if (getJavaECGNode(a.id)) { + if (b = a.getAnAncestorCDNode(__all_data__, "Depended")) { + if (c = b.getECGNode(edgeType, "Depended")) { + if (temp1(Callable(java_db).find(c))) { + if (b != c) { + if (direction = "Depended") { + return true + } + } + } + } + } + if (b = a) { + if (c = b.getECGNode(edgeType, "Depended")) { + if (temp1(Callable(java_db).find(c))) { + if (b != c) { + if (direction = "Depended") { + return true + } + } + } + } + } + } + } +} +pub fn real_output(m: ECGNode, nodeType1: string, nodeText1: string, n: ECGNode, nodeType2: string, nodeText2: string, edgeType: string, direction: string) -> bool { + let (java_db = default_java_db()) { + for (e in ECGNode(java_db)) { + if (temp2(e, m, n, edgeType, direction)) { + if (nodeType1 = m.getType()) { + if (nodeText1 = m.print()) { + if (nodeText2 = n.print()) { + if (nodeType2 = n.getType()) { + return true + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule3.gdl b/example/icse25/rules/rule3.gdl new file mode 100644 index 0000000..3a25f79 --- /dev/null +++ b/example/icse25/rules/rule3.gdl @@ -0,0 +1,715 @@ +// script +use coref::java::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +pub fn getNode(node: int) -> bool { + // #javaecgnode + // example + [ {1111} ] +} +pub fn temp(a: Callable, b: Callable, c: Callable) -> bool { + let (java_db = default_java_db()) { + if (getNode(a.id)) { + for (auto_tmp1 in a.getAnAncestorCaller()) { + if (c = auto_tmp1) { + for (auto_tmp2 in c.getCaller()) { + if (b = auto_tmp2) { + return true + } + } + } + } + if (c = a) { + for (auto_tmp2 in c.getCaller()) { + if (b = auto_tmp2) { + return true + } + } + } + } + } +} +pub fn real_output(b: ECGNode, nodeText1: string, c: ECGNode, nodeText2: string) -> bool { + let (java_db = default_java_db()) { + for (a in Callable(java_db), + b1 in Callable(java_db), + c1 in Callable(java_db)) { + if (b.key_eq(b1)) { + if (c.key_eq(c1)) { + if (temp(a, b1, c1)) { + if (nodeText1 = b1.getSignature()) { + if (nodeText2 = c1.getSignature()) { + return true + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule4.gdl b/example/icse25/rules/rule4.gdl new file mode 100644 index 0000000..0cea210 --- /dev/null +++ b/example/icse25/rules/rule4.gdl @@ -0,0 +1,1596 @@ +// script +use coref::java::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +pub fn getJavaECGNode(node: int) -> bool { + // #javaecgnode + // example + [ {1111} ] +} +@inline +pub fn trim(n: string, m: string) -> bool { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_0(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_0(n))) { + if (m = n) { + return true + } + } + } + } + } +} +@inline +pub fn contact(a: string, b: string, c: string) -> bool { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__()) { + if (i = a.len()) { + if (tmp_1(i)) { + if (tmp_2(a, b)) { + if (c = b) { + return true + } + } + if (!(tmp_2(a, b))) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_1(i))) { + if (tmp_3(a, b, i)) { + if (temp = a.substr(1,i - 1)) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_3(a, b, i))) { + if (tmp_4(a, b, i)) { + if (c = a + "/" + b) { + return true + } + } + if (!(tmp_4(a, b, i))) { + if (c = a + b) { + return true + } + } + } + } + } + } + } +} +schema HttpMethodType extends AnnotationAccessArgument { + +} + +impl HttpMethodType { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *HttpMethodType { + for (tmp in AnnotationAccessArgument(db)) { + if (tmp.getAnnotationArgumentName() = "method") { + yield HttpMethodType { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (a in AnnotationArrayInitializer(__all_data__)) { + if (self.getArgumentValueHashId() = a.getParent().id) { + for (i in Identifier(__all_data__)) { + if (a.key_eq(i.getParent())) { + if (t = i.getName()) { + return t + } + } + } + } + } + for (i in Identifier(__all_data__)) { + if (self.getArgumentValueHashId() = i.getParent().id) { + if (t = i.getName()) { + return t + } + } + } + } + } + + +} + +pub fn getMethodType(a: Annotation, t: string) -> bool { + let (java_db = default_java_db()) { + for (m in Method(java_db), + h in HttpMethodType(java_db)) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (tmp_5(a)) { + if (t = "POST") { + return true + } + } + if (!(tmp_5(a))) { + if (tmp_6(a)) { + if (t = "GET") { + return true + } + } + if (!(tmp_6(a))) { + if (tmp_7(a)) { + if (t = "PUT") { + return true + } + } + if (!(tmp_7(a))) { + if (tmp_8(a)) { + if (t = "DELETE") { + return true + } + } + if (!(tmp_8(a))) { + if (tmp_9(a)) { + if (t = "PATCH") { + return true + } + } + if (!(tmp_9(a))) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (h.key_eq(auto_tmp2)) { + if (t = h.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getSubUri(a: Annotation, sub: string) -> bool { + let (java_db = default_java_db()) { + for (s in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (temp in AnnotationAccessArgument(java_db), + e in Expression(java_db)) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + for (auto_tmp1 in a.getAnnotationArgument()) { + if (temp = auto_tmp1) { + if (temp.getAnnotationArgumentName() = "value") { + if (temp.key_eq(e.getParent())) { + if (tmp_10(e)) { + if (sub = connectStr(e)) { + return true + } + } + if (!(tmp_10(e))) { + if (s = temp.getAnnotationArgumentValue()) { + if (trim(s, sub)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getUri(c: Class, m: Method, uri1: string) -> bool { + let (java_db = default_java_db()) { + for (l1 in string::__undetermined_all__(), + l2 in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (a in Annotation(java_db), + a1 in Annotation(java_db)) { + if (c = m.getBelongedClass()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + for (auto_tmp2 in c.getAnnotation()) { + if (a1 = auto_tmp2) { + if (n = a.getName()) { + if (tmp_12(c)) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (getSubUri(a, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_16(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_16(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + } + if (!(tmp_12(c))) { + if (tmp_14(a)) { + if (n.matches(".*Mapping")) { + if (getSubUri(a1, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_16(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_16(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + if (!(tmp_14(a))) { + if (a1.getName() = "RequestMapping") { + if (n.matches(".*Mapping")) { + if (getSubUri(a, l1)) { + if (getSubUri(a1, l2)) { + if (contact(l2, l1, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_16(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_16(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +schema WebFolder extends Folder { + +} + +impl WebFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebFolder { + for (tmp in Folder(db)) { + if (tmp.getRelativePath() = "app/web") { + yield WebFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + } + + pub fn getChild(self) -> Folder { + for (f in Folder(__all_data__)) { + if (self.element_hash_id = f.getParentHashId()) { + return f + } + } + } + + +} + +schema WebCarFolder extends Folder { + +} + +impl WebCarFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebCarFolder { + for (tmp in Folder(db)) { + yield WebCarFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + + pub fn getBelongedFolder(self) -> WebCarFolder { + for (f in WebCarFolder(__all_data__)) { + if (f.element_hash_id = self.getParentHashId()) { + return f + } + } + } + + pub fn getAnAncestorFolder(self) -> WebCarFolder { + for (f in WebCarFolder(__all_data__)) { + if (f = self.getBelongedFolder()) { + return f + } + if (f = self.getBelongedFolder().getAnAncestorFolder()) { + return f + } + } + } + + +} + +schema WebCarClass extends Class { + +} + +impl WebCarClass { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebCarClass { + for (tmp in Class(db)) { + for (f in WebCarFolder(db), + w in WebFolder(db)) { + if (f.key_eq(tmp.getContainingFile().getBelongedFolder())) { + if (f.getAnAncestorFolder().key_eq(w)) { + yield WebCarClass { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + identifier_hash_id : tmp.identifier_hash_id, + location_hash_id : tmp.location_hash_id, + parent_hash_id : tmp.parent_hash_id + } + } + } + } + } + } + + pub fn getWebFolder(self) -> WebCarFolder { + for (c in WebCarFolder(__all_data__)) { + for (f in WebCarFolder(__all_data__), + w in WebFolder(__all_data__)) { + if (f.key_eq(self.getContainingFile().getBelongedFolder())) { + if (f.getAnAncestorFolder() = c) { + if (c.key_eq(w.getChild())) { + return c + } + } + } + } + } + } + + +} + +pub fn resolve(r: ReferenceExpression, rr: string) -> bool { + let (java_db = default_java_db()) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (e.getParent() = r.getDefinition()) { + if (temp = e.getPrintableText()) { + if (trim(temp, rr)) { + return true + } + } + } + } + } + } +} +pub fn facts(a: Expression, i: int, value: string) -> bool { + let (java_db = default_java_db()) { + for (p in PolyadicExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_17(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_17(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_18(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_18(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in BinaryExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_17(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_17(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_18(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_18(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in ReferenceExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_17(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_17(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_18(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_18(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn connectStrBase(ID: Expression, index: int, res: string) -> bool { + let (java_db = default_java_db()) { + for (total in int::__undetermined_all__(), + reStr in string::__undetermined_all__(), + currStr in string::__undetermined_all__()) { + if (total = tmp_19(ID).len()) { + if (tmp_21(index)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = currStr) { + return true + } + } + } + if (!(tmp_21(index))) { + if (index > 0) { + if (connectStrBase(ID, index - 1, reStr)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = reStr + currStr) { + return true + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: Expression) -> string { + let (java_db = default_java_db()) { + for (c in int::__undetermined_all__(), res in string::__undetermined_all__()) { + if (c = tmp_22(ID).len()) { + if (connectStrBase(ID, c - 1, res)) { + return res + } + } + } + } +} +pub fn getHttpMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + for (n in string::__undetermined_all__(), + className in string::__undetermined_all__(), + methodSignature in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + type in string::__undetermined_all__()) { + for (c in Class(java_db), + a in Annotation(java_db)) { + if (getUri(c, m, uri)) { + if (className = c.getQualifiedName()) { + if (methodSignature = m.getSignature()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (tmp_26(a)) { + if (type = "EMPTY") { + return true + } + } + if (!(tmp_26(a))) { + if (getMethodType(a, type)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(nodeText: string, path: string) -> bool { + let (java_db = default_java_db()) { + for (direction in string::__undetermined_all__(), + edgeType in string::__undetermined_all__()) { + for (m in ECGNode(java_db), + a in ECGNode(java_db), + b in ECGNode(java_db), + c in ECGNode(java_db)) { + if (getJavaECGNode(a.id)) { + if (getHttpMethod(Method(java_db).find(m))) { + if (b = m.getAnAncestorCDDependsNode(__all_data__, __all_data__)) { + if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + if (c = a) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + } + if (b = m) { + if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + if (c = a) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn tmp_0(n: string) -> bool { + let (java_db = default_java_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } +} + +fn tmp_1(i: int) -> bool { + let (java_db = default_java_db()) { + if (i = 1) { + return true + } + } +} + +fn tmp_2(a: string, b: string) -> bool { + let (java_db = default_java_db()) { + if (a.substr(0,1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } +} + +@inline +fn tmp_3(a: string, b: string, i: int) -> bool { + let (java_db = default_java_db()) { + if (a.substr(i - 1,i - 1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } +} + +@inline +fn tmp_4(a: string, b: string, i: int) -> bool { + let (java_db = default_java_db()) { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { + return true + } + } + } +} + +fn tmp_5(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PostMapping") { + return true + } + } +} + +fn tmp_6(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "GetMapping") { + return true + } + } +} + +fn tmp_7(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PutMapping") { + return true + } + } +} + +fn tmp_8(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "DeleteMapping") { + return true + } + } +} + +fn tmp_9(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PatchMapping") { + return true + } + } +} + +fn tmp_10(e: Expression) -> bool { + let (java_db = default_java_db()) { + if (facts(e, __all_data__, __all_data__)) { + return true + } + } +} + +fn tmp_11(c: Class) -> *Annotation { + let (java_db = default_java_db()) { + for (b in Annotation(java_db)) { + for (auto_tmp3 in c.getAnnotation()) { + if (b = auto_tmp3) { + if (b.getName() = "RequestMapping") { + yield b + } + } + } + } + } +} + +fn tmp_12(c: Class) -> bool { + let (java_db = default_java_db()) { + if (tmp_11(c).len() = 0) { + return true + } + } +} + +fn tmp_13(a: Annotation) -> *AnnotationAccessArgument { + let (java_db = default_java_db()) { + for (b in AnnotationAccessArgument(java_db)) { + for (auto_tmp4 in a.getAnnotationArgument()) { + if (b = auto_tmp4) { + if (b.getAnnotationArgumentName() = "value") { + yield b + } + } + } + } + } +} + +fn tmp_14(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (tmp_13(a).len() = 0) { + return true + } + } +} + +fn tmp_15(w: WebFolder) -> *Folder { + let (java_db = default_java_db()) { + for (f in Folder(java_db)) { + if (f = w.getChild()) { + yield f + } + } + } +} + +fn tmp_16(w: WebFolder) -> bool { + let (java_db = default_java_db()) { + if (tmp_15(w).len() = 1) { + return true + } + } +} + +fn tmp_17(a: Expression) -> bool { + let (java_db = default_java_db()) { + if (resolve(ReferenceExpression(java_db).find(a), __all_data__)) { + return true + } + } +} + +fn tmp_18(e: Expression) -> bool { + let (java_db = default_java_db()) { + if (resolve(ReferenceExpression(java_db).find(e), __all_data__)) { + return true + } + } +} + +fn tmp_19(ID: Expression) -> *auto_tmp_20 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(ID, auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_20 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } +} + +schema auto_tmp_20 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_21(index: int) -> bool { + let (java_db = default_java_db()) { + if (index = 0) { + return true + } + } +} + +fn tmp_22(ID: Expression) -> *auto_tmp_23 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(ID, auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_23 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } +} + +schema auto_tmp_23 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_24(a: Annotation) -> *auto_tmp_25 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in string::__undetermined_all__()) { + if (getMethodType(a, auto_tmp_var_0)) { + yield auto_tmp_25 { + auto_tmp_var_0 : auto_tmp_var_0 + } + } + } + } +} + +schema auto_tmp_25 { + auto_tmp_var_0 : string +} + +fn tmp_26(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (tmp_24(a).len() = 0) { + return true + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule5.gdl b/example/icse25/rules/rule5.gdl new file mode 100644 index 0000000..a066728 --- /dev/null +++ b/example/icse25/rules/rule5.gdl @@ -0,0 +1,168 @@ +// script +use coref::xml::* + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + // #changeinfo + // example + [ {"test", 1111} ] +} +pub fn transfertofile(f: XmlFile, filename: string, lineNumber: int) -> bool { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + return true + } + } + } +} +pub fn real_output(n: ECGXmlNode) -> bool { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (f in XmlFile(xml_db), + o in ECGXmlNode(xml_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (text = n.getText()) { + if (o = n.getEnclosingECGXmlNode()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule6.gdl b/example/icse25/rules/rule6.gdl new file mode 100644 index 0000000..d3b7fea --- /dev/null +++ b/example/icse25/rules/rule6.gdl @@ -0,0 +1,1216 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn getJavaECGNode(id: int) -> bool { + // #javaxmlnode + // example + [ {1111} ] +} +pub fn getXmlECGNode(id: int) -> bool { + // #xmlecgnode + // example + [ {1111} ] +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> ClassOrInterface { + for (value in string::__undetermined_all__()) { + for (i in ClassOrInterface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_2(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_2(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db)) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn real_output(className: string, interfaceName: string, id: int, name: string, tag: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + j in int::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db), + c in ClassOrInterface(java_db)) { + if (getJavaECGNode(e1.id)) { + if (getXmlECGNode(e2.id)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + if (temp = interfaceName) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + } + if (e2.id = i) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + if (e2.id = j) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + } + } + } + } + } + } + } + if (javaOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db), + c in ClassOrInterface(java_db)) { + if (getJavaECGNode(e1.id)) { + if (getXmlECGNode(e2.id)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + if (temp = interfaceName) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + } + if (e2.id = i) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + if (e2.id = j) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + } + } + } + } + } + } + } + if (annoOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db), + c in ClassOrInterface(java_db)) { + if (getJavaECGNode(e1.id)) { + if (getXmlECGNode(e2.id)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + if (temp = interfaceName) { + if (name = e1.print()) { + if (tag = "Java") { + return true + } + } + } + } + if (e2.id = i) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + if (e2.id = j) { + if (id = e2.id) { + if (name = e2.getText()) { + if (tag = "xml") { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(anno: Annotation) -> *auto_tmp_1 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_1 { + + } + } + } + } +} + +schema auto_tmp_1 { + +} + +fn tmp_2(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_0(anno).len() = 1) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule6_8_no_xml.gdl b/example/icse25/rules/rule6_8_no_xml.gdl new file mode 100644 index 0000000..3ceac03 --- /dev/null +++ b/example/icse25/rules/rule6_8_no_xml.gdl @@ -0,0 +1,1780 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + // #changeinfo + // example + [ {"test", 1111} ] +} +pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (!filename.contains("src/test/java")) { + if (filename = f.getRelativePath()) { + if (isCodeLine(f, filename, lineNumber)) { + return true + } + } + } + } + } + } +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (transfertofile1(f, filename, lineNumber)) { + if (!findSpecialCodeType(filename, lineNumber, __all_data__)) { + return true + } + } + } + } +} +pub fn isComment(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isAnnotation(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Annotation(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (f.getRelativePath() = filename) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (l in coref::java::Location(java_db)) { + if (l.getFile() = f) { + if (s1 = l.getStartLineNumber()) { + if (e = l.getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isLog(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (c in Expression(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (text = c.getPrintableText()) { + if (text.matches("^logger\\..*")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in ElementParent(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (s1 = e) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (tmp_0(filename, lineNumber)) { + if (typeInAST = "Callable") { + if (getBelongedCallable(filename, lineNumber, Callable(java_db).find(n))) { + return true + } + } + } + if (!(tmp_0(filename, lineNumber))) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (isFieldOrEnum(ECGNode(java_db).find(n))) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isFieldOrEnum(c: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in Field(java_db)) { + if (f.key_eq(c)) { + return true + } + } + for (e in EnumConstant(java_db)) { + if (e.key_eq(c)) { + return true + } + } + } + } +} +pub fn findSpecialCodeType(filename: string, lineNumber: int, type: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isComment(filename, lineNumber)) { + if (type = "comment") { + return true + } + } + if (isAnnotation(filename, lineNumber)) { + if (type = "annotation") { + return true + } + } + if (isLog(filename, lineNumber)) { + if (type = "log") { + return true + } + } + } + } +} +pub fn getBelongedCallable(filename: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (l1 in int::__undetermined_all__(), + l2 in int::__undetermined_all__()) { + for (i in Identifier(java_db)) { + if (f = c.getLocation().getFile()) { + if (c.key_eq(i.getParent())) { + if (l1 = i.getLocation().getStartLineNumber()) { + if (l2 = c.getLocation().getEndLineNumber()) { + if (lineNumber > l1 - 1) { + if (lineNumber < l2 + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getBelongedCallableSignature(filename: string, lineNumber: int, belongedCallable: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + for (c in Callable(java_db)) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (i = tmp_1().len()) { + if (tmp_2(i)) { + if (belongedCallable = "") { + return true + } + } + if (!(tmp_2(i))) { + if (getBelongedCallable(filename, lineNumber, c)) { + if (belongedCallable = c.getSignature()) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + belongedCallable in string::__undetermined_all__()) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + return true + } + } + } + } + } + } +} +pub fn transfertoXmlfile(f: XmlFile, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + return true + } + } + } + } +} +pub fn getXmlECGNode1(n: ECGXmlNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (f in XmlFile(xml_db), + o in ECGXmlNode(xml_db)) { + if (transfertoXmlfile(f, filename, lineNumber)) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (text = n.getText()) { + if (o = n.getEnclosingECGXmlNode()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +@inline +pub fn trim(n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_3(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_3(n))) { + if (m = n) { + return true + } + } + } + } + } + } +} +pub fn getXmlECGNode(f: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in ClassOrInterface(java_db), + n in string::__undetermined_all__(), + m in string::__undetermined_all__()) { + for (r in ECGXmlNode(xml_db)) { + if (getXmlECGNode1(r)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { + return true + } + } + } + } + } + } +} +pub fn getChangeSetByResultXmlElement(r1: ECGXmlNode, c: ClassOrInterface, f: Field, n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (r in ResultXmlElement(xml_db)) { + if (r.key_eq(r1)) { + if (getXmlECGNode1(ECGXmlNode(xml_db).find(r))) { + if (n = r.getBelongedMapXmlElement().getMappingClassName()) { + if (n = c.getQualifiedName()) { + if (c = f.getParent()) { + if (r.getValueByAttributeName("property") = f.getName()) { + if (m = f.getName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn getChangeSetByDalXmlElement(d1: ECGXmlNode, c: ClassOrInterface, m: Method, className: string, methodName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__(), + temp1 in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (d in DalXmlElement(xml_db), + cc in XmlComment(xml_db), + l in Literal(java_db)) { + if (d.key_eq(d1)) { + if (getXmlECGNode1(ECGXmlNode(xml_db).find(d))) { + if (d.getLocation().getFile() = cc.getLocation().getFile()) { + if (cc.getLocation().getEndLineNumber() = i) { + if (i + 1 = d.getLocation().getStartLineNumber()) { + if (temp = cc.getText()) { + if (c.getName() = temp.get_regex_match_result("[\\s\\S]*mapped statement for[ \\t]+(\\w+)[\\s\\S]*", 1)) { + if (n = d.getValueByAttributeName("id")) { + if (c.key_eq(m.getBelongedClass())) { + if (m.key_eq(l.getEnclosingCallable())) { + if (temp1 = l.getValue()) { + if (trim(temp1, n)) { + if (className = c.getQualifiedName()) { + if (methodName = m.getSignature()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db)) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn getPublishTr(c: ClassOrInterface) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (className in string::__undetermined_all__(), + interfaceName in string::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (javaOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (annoOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> ClassOrInterface { + for (value in string::__undetermined_all__()) { + for (i in ClassOrInterface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_6(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_6(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +pub fn output1(c: ClassOrInterface, interfaceName: string, id: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + j in int::__undetermined_all__(), + className in string::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode1(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + return true + } + if (temp = interfaceName) { + return true + } + } + if (e2.id = i) { + if (id = e2.id) { + return true + } + } + if (e2.id = j) { + if (id = e2.id) { + return true + } + } + } + } + } + } + } + } + } + if (javaOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode1(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + return true + } + if (temp = interfaceName) { + return true + } + } + if (e2.id = i) { + if (id = e2.id) { + return true + } + } + if (e2.id = j) { + if (id = e2.id) { + return true + } + } + } + } + } + } + } + } + } + if (annoOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode1(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + return true + } + if (temp = interfaceName) { + return true + } + } + if (e2.id = i) { + if (id = e2.id) { + return true + } + } + if (e2.id = j) { + if (id = e2.id) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn output2(c: ClassOrInterface, interfaceName: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in ECGNode(java_db)) { + if (getJavaECGNode(m)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + } + } + if (getXmlECGNode(m)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (n in ECGNode(java_db)) { + for (c in ClassOrInterface(java_db)) { + if (output2(c, interfaceName, n)) { + return true + } + if (output1(c, interfaceName, n.id)) { + return true + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + return true + } + } + } +} + +fn tmp_1() -> *string { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename + } + } +} + +fn tmp_2(i: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (i = 0) { + return true + } + } + } +} + +fn tmp_3(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } + } +} + +fn tmp_4(anno: Annotation) -> *auto_tmp_5 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_5 { + + } + } + } + } +} + +schema auto_tmp_5 { + +} + +fn tmp_6(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_4(anno).len() = 1) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule6_8_spring.gdl b/example/icse25/rules/rule6_8_spring.gdl new file mode 100644 index 0000000..6446282 --- /dev/null +++ b/example/icse25/rules/rule6_8_spring.gdl @@ -0,0 +1,1573 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + // #changeinfo + // example + [ {"test", 1111} ] +} +pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (!filename.contains("src/test/java")) { + if (filename = f.getRelativePath()) { + if (isCodeLine(f, filename, lineNumber)) { + return true + } + } + } + } + } + } +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (transfertofile1(f, filename, lineNumber)) { + if (!findSpecialCodeType(filename, lineNumber, __all_data__)) { + return true + } + } + } + } +} +pub fn isComment(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isAnnotation(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Annotation(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (f.getRelativePath() = filename) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (l in coref::java::Location(java_db)) { + if (l.getFile() = f) { + if (s1 = l.getStartLineNumber()) { + if (e = l.getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isLog(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (c in Expression(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (text = c.getPrintableText()) { + if (text.matches("^logger\\..*")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in ElementParent(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (s1 = e) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (tmp_0(filename, lineNumber)) { + if (typeInAST = "Callable") { + if (getBelongedCallable(filename, lineNumber, Callable(java_db).find(n))) { + return true + } + } + } + if (!(tmp_0(filename, lineNumber))) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (isFieldOrEnum(ECGNode(java_db).find(n))) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isFieldOrEnum(c: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in Field(java_db)) { + if (f.key_eq(c)) { + return true + } + } + for (e in EnumConstant(java_db)) { + if (e.key_eq(c)) { + return true + } + } + } + } +} +pub fn findSpecialCodeType(filename: string, lineNumber: int, type: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isComment(filename, lineNumber)) { + if (type = "comment") { + return true + } + } + if (isAnnotation(filename, lineNumber)) { + if (type = "annotation") { + return true + } + } + if (isLog(filename, lineNumber)) { + if (type = "log") { + return true + } + } + } + } +} +pub fn getBelongedCallable(filename: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (l1 in int::__undetermined_all__(), + l2 in int::__undetermined_all__()) { + for (i in Identifier(java_db)) { + if (f = c.getLocation().getFile()) { + if (c.key_eq(i.getParent())) { + if (l1 = i.getLocation().getStartLineNumber()) { + if (l2 = c.getLocation().getEndLineNumber()) { + if (lineNumber > l1 - 1) { + if (lineNumber < l2 + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getBelongedCallableSignature(filename: string, lineNumber: int, belongedCallable: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + for (c in Callable(java_db)) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (i = tmp_1().len()) { + if (tmp_2(i)) { + if (belongedCallable = "") { + return true + } + } + if (!(tmp_2(i))) { + if (getBelongedCallable(filename, lineNumber, c)) { + if (belongedCallable = c.getSignature()) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + belongedCallable in string::__undetermined_all__()) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + return true + } + } + } + } + } + } +} +pub fn transfertoXmlfile(f: XmlFile, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + return true + } + } + } + } +} +pub fn getXmlECGNode1(n: ECGXmlNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (f in XmlFile(xml_db), + o in ECGXmlNode(xml_db)) { + if (transfertoXmlfile(f, filename, lineNumber)) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (text = n.getText()) { + if (o = n.getEnclosingECGXmlNode()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +@inline +pub fn trim(n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_3(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_3(n))) { + if (m = n) { + return true + } + } + } + } + } + } +} +pub fn getXmlECGNode(f: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in ClassOrInterface(java_db), + n in string::__undetermined_all__(), + m in string::__undetermined_all__()) { + for (r in ECGXmlNode(xml_db)) { + if (getXmlECGNode1(r)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { + return true + } + } + } + } + } + } +} +pub fn getChangeSetByResultXmlElement(r1: ECGXmlNode, c: ClassOrInterface, f: Field, n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (r in ResultXmlElement(xml_db)) { + if (r.key_eq(r1)) { + if (getXmlECGNode1(ECGXmlNode(xml_db).find(r))) { + if (n = r.getBelongedMapXmlElement().getMappingClassName()) { + if (n = c.getQualifiedName()) { + if (c = f.getParent()) { + if (r.getValueByAttributeName("property") = f.getName()) { + if (m = f.getName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn getChangeSetByDalXmlElement(d1: ECGXmlNode, c: ClassOrInterface, m: Method, className: string, methodName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__(), + temp1 in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (d in DalXmlElement(xml_db), + cc in XmlComment(xml_db), + l in Literal(java_db)) { + if (d.key_eq(d1)) { + if (getXmlECGNode1(ECGXmlNode(xml_db).find(d))) { + if (d.getLocation().getFile() = cc.getLocation().getFile()) { + if (cc.getLocation().getEndLineNumber() = i) { + if (i + 1 = d.getLocation().getStartLineNumber()) { + if (temp = cc.getText()) { + if (c.getName() = temp.get_regex_match_result("[\\s\\S]*mapped statement for[ \\t]+(\\w+)[\\s\\S]*", 1)) { + if (n = d.getValueByAttributeName("id")) { + if (c.key_eq(m.getBelongedClass())) { + if (m.key_eq(l.getEnclosingCallable())) { + if (temp1 = l.getValue()) { + if (trim(temp1, n)) { + if (className = c.getQualifiedName()) { + if (methodName = m.getSignature()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i.key_eq(c)) { + if (name = classname) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in ClassOrInterface(java_db), + b in BeanXmlElement(xml_db)) { + if (s.getQualifiedName() = b.getClass()) { + if (className = s.getQualifiedName()) { + if (className = interfaceName) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn getTrAnnotationName1(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Configuration"}, + {"Repository"}, + {"RestController"}, + {"bean"} + ] +} +pub fn getPublishTr(c: ClassOrInterface) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (className in string::__undetermined_all__(), + interfaceName in string::__undetermined_all__()) { + if (javaOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + for (n in string::__undetermined_all__()) { + if (n = tmp.getName()) { + if (getTrAnnotationName1(n)) { + yield SofaService { + id : tmp.id + } + } + } + } + } + } + + +} + +pub fn output1(c: ClassOrInterface, interfaceName: string, id: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + j in int::__undetermined_all__(), + className in string::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode1(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + return true + } + if (temp = interfaceName) { + return true + } + } + if (e2.id = i) { + if (id = e2.id) { + return true + } + } + if (e2.id = j) { + if (id = e2.id) { + return true + } + } + } + } + } + } + } + } + } + if (javaOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode1(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + return true + } + if (temp = interfaceName) { + return true + } + } + if (e2.id = i) { + if (id = e2.id) { + return true + } + } + if (e2.id = j) { + if (id = e2.id) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn output2(c: ClassOrInterface, interfaceName: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in ECGNode(java_db)) { + if (getJavaECGNode(m)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + } + } + if (getXmlECGNode(m)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (n in ECGNode(java_db)) { + for (c in ClassOrInterface(java_db)) { + if (output2(c, interfaceName, n)) { + return true + } + if (output1(c, interfaceName, n.id)) { + return true + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + return true + } + } + } +} + +fn tmp_1() -> *string { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename + } + } +} + +fn tmp_2(i: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (i = 0) { + return true + } + } + } +} + +fn tmp_3(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule7.gdl b/example/icse25/rules/rule7.gdl new file mode 100644 index 0000000..73c3b78 --- /dev/null +++ b/example/icse25/rules/rule7.gdl @@ -0,0 +1,243 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn getXmlECGNode(i: int) -> bool { + // #xmlecgnode + // example + [ {1111} ] +} +@inline +pub fn trim(n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_0(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_0(n))) { + if (m = n) { + return true + } + } + } + } + } + } +} +pub fn real_output(r: ECGXmlNode, c: ClassOrInterface, f: ElementParent, n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getXmlECGNode(r.id)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { + return true + } + } + } + } +} +pub fn getChangeSetByResultXmlElement(r1: ECGXmlNode, c: ClassOrInterface, f: Field, n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (r in ResultXmlElement(xml_db)) { + if (r.key_eq(r1)) { + if (getXmlECGNode(r.id)) { + if (n = r.getBelongedMapXmlElement().getMappingClassName()) { + if (n = c.getQualifiedName()) { + if (c = f.getParent()) { + if (r.getValueByAttributeName("property") = f.getName()) { + if (m = f.getName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn getChangeSetByDalXmlElement(d1: ECGXmlNode, c: ClassOrInterface, m: Method, className: string, methodName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__(), + temp1 in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (d in DalXmlElement(xml_db), + cc in XmlComment(xml_db), + l in Literal(java_db)) { + if (d.key_eq(d1)) { + if (getXmlECGNode(d.id)) { + if (d.getLocation().getFile() = cc.getLocation().getFile()) { + if (cc.getLocation().getEndLineNumber() = i) { + if (i + 1 = d.getLocation().getStartLineNumber()) { + if (temp = cc.getText()) { + if (c.getName() = temp.get_regex_match_result("[\\s\\S]*mapped statement for[ \\t]+(\\w+)[\\s\\S]*", 1)) { + if (n = d.getValueByAttributeName("id")) { + if (c.key_eq(m.getBelongedClass())) { + if (m.key_eq(l.getEnclosingCallable())) { + if (temp1 = l.getValue()) { + if (trim(temp1, n)) { + if (className = c.getQualifiedName()) { + if (methodName = m.getSignature()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule8.gdl b/example/icse25/rules/rule8.gdl new file mode 100644 index 0000000..dac7d2f --- /dev/null +++ b/example/icse25/rules/rule8.gdl @@ -0,0 +1,1149 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn getJavaECGNode(id: int) -> bool { + // #javaecgnode + // example + [ {1111} ] +} +pub fn getXmlECGNode(id: int) -> bool { + // #xmlimpactedecgnode + // example + [ {1111} ] +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> ClassOrInterface { + for (value in string::__undetermined_all__()) { + for (i in ClassOrInterface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_2(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_2(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db)) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn getPublishTr(c: ClassOrInterface) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (className in string::__undetermined_all__(), + interfaceName in string::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (javaOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (annoOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } +} +pub fn real_output(c: ClassOrInterface, n: ECGNode, interfaceName: string, nodeName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in ECGNode(java_db)) { + if (getJavaECGNode(m.id)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + } + } + if (getXmlECGNode(m.id)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(anno: Annotation) -> *auto_tmp_1 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_1 { + + } + } + } + } +} + +schema auto_tmp_1 { + +} + +fn tmp_2(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_0(anno).len() = 1) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule9.gdl b/example/icse25/rules/rule9.gdl new file mode 100644 index 0000000..78e2c26 --- /dev/null +++ b/example/icse25/rules/rule9.gdl @@ -0,0 +1,873 @@ +// script +use coref::java::* +@inline +pub fn trim(n: string, m: string) -> bool { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_0(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_0(n))) { + if (m = n) { + return true + } + } + } + } + } +} +@inline +pub fn contact(a: string, b: string, c: string) -> bool { + let (java_db = default_java_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__()) { + if (i = a.len()) { + if (tmp_1(i)) { + if (tmp_2(a, b)) { + if (c = b) { + return true + } + } + if (!(tmp_2(a, b))) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_1(i))) { + if (tmp_3(i, b, a)) { + if (temp = a.substr(1,i - 1)) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_3(i, b, a))) { + if (tmp_4(i, b, a)) { + if (c = a + "/" + b) { + return true + } + } + if (!(tmp_4(i, b, a))) { + if (c = a + b) { + return true + } + } + } + } + } + } + } +} +schema HttpMethodType extends AnnotationAccessArgument { + +} + +impl HttpMethodType { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *HttpMethodType { + for (tmp in AnnotationAccessArgument(db)) { + if (tmp.getAnnotationArgumentName() = "method") { + yield HttpMethodType { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (a in AnnotationArrayInitializer(__all_data__)) { + if (self.getArgumentValueHashId() = a.getParent().id) { + for (i in Identifier(__all_data__)) { + if (a.key_eq(i.getParent())) { + if (t = i.getName()) { + return t + } + } + } + } + } + for (i in Identifier(__all_data__)) { + if (self.getArgumentValueHashId() = i.getParent().id) { + if (t = i.getName()) { + return t + } + } + } + } + } + + +} + +pub fn getMethodType(a: Annotation, t: string) -> bool { + let (java_db = default_java_db()) { + for (m in Method(java_db), + h in HttpMethodType(java_db)) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (tmp_5(a)) { + if (t = "POST") { + return true + } + } + if (!(tmp_5(a))) { + if (tmp_6(a)) { + if (t = "GET") { + return true + } + } + if (!(tmp_6(a))) { + if (tmp_7(a)) { + if (t = "PUT") { + return true + } + } + if (!(tmp_7(a))) { + if (tmp_8(a)) { + if (t = "DELETE") { + return true + } + } + if (!(tmp_8(a))) { + if (tmp_9(a)) { + if (t = "PATCH") { + return true + } + } + if (!(tmp_9(a))) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (h.key_eq(auto_tmp2)) { + if (t = h.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getSubUri(a: Annotation, sub: string) -> bool { + let (java_db = default_java_db()) { + for (s in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (temp in AnnotationAccessArgument(java_db), + e in Expression(java_db)) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + for (auto_tmp1 in a.getAnnotationArgument()) { + if (temp = auto_tmp1) { + if (temp.getAnnotationArgumentName() = "value") { + if (temp.key_eq(e.getParent())) { + if (tmp_10(e)) { + if (sub = connectStr(e)) { + return true + } + } + if (!(tmp_10(e))) { + if (s = temp.getAnnotationArgumentValue()) { + if (trim(s, sub)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getUri(c: Class, m: Method, uri1: string) -> bool { + let (java_db = default_java_db()) { + for (l1 in string::__undetermined_all__(), + l2 in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (a in Annotation(java_db), + a1 in Annotation(java_db)) { + if (c = m.getBelongedClass()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + for (auto_tmp2 in c.getAnnotation()) { + if (a1 = auto_tmp2) { + if (n = a.getName()) { + if (tmp_12(c)) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (getSubUri(a, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_16(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_16(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + } + if (!(tmp_12(c))) { + if (tmp_14(a)) { + if (n.matches(".*Mapping")) { + if (getSubUri(a1, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_16(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_16(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + if (!(tmp_14(a))) { + if (a1.getName() = "RequestMapping") { + if (n.matches(".*Mapping")) { + if (getSubUri(a, l1)) { + if (getSubUri(a1, l2)) { + if (contact(l2, l1, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_16(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_16(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +schema WebFolder extends Folder { + +} + +impl WebFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebFolder { + for (tmp in Folder(db)) { + yield WebFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + + pub fn getChild(self) -> Folder { + for (f in Folder(__all_data__)) { + if (self.element_hash_id = f.getParentHashId()) { + return f + } + } + } + + +} + +schema WebCarFolder extends Folder { + +} + +impl WebCarFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebCarFolder { + for (tmp in Folder(db)) { + yield WebCarFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + + pub fn getBelongedFolder(self) -> WebCarFolder { + for (f in WebCarFolder(__all_data__)) { + if (f.element_hash_id = self.getParentHashId()) { + return f + } + } + } + + pub fn getAnAncestorFolder(self) -> WebCarFolder { + for (f in WebCarFolder(__all_data__)) { + if (f = self.getBelongedFolder()) { + return f + } + if (f = self.getBelongedFolder().getAnAncestorFolder()) { + return f + } + } + } + + +} + +schema WebCarClass extends Class { + +} + +impl WebCarClass { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebCarClass { + for (tmp in Class(db)) { + for (f in WebCarFolder(db), + w in WebFolder(db)) { + if (f.key_eq(tmp.getContainingFile().getBelongedFolder())) { + if (f.getAnAncestorFolder().key_eq(w)) { + yield WebCarClass { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + identifier_hash_id : tmp.identifier_hash_id, + location_hash_id : tmp.location_hash_id, + parent_hash_id : tmp.parent_hash_id + } + } + } + } + } + } + + pub fn getWebFolder(self) -> WebCarFolder { + for (c in WebCarFolder(__all_data__)) { + for (f in WebCarFolder(__all_data__), + w in WebFolder(__all_data__)) { + if (f.key_eq(self.getContainingFile().getBelongedFolder())) { + if (f.getAnAncestorFolder() = c) { + if (c.key_eq(w.getChild())) { + return c + } + } + } + } + } + } + + +} + +pub fn resolve(r: ReferenceExpression, rr: string) -> bool { + let (java_db = default_java_db()) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (e.getParent() = r.getDefinition()) { + if (temp = e.getPrintableText()) { + if (trim(temp, rr)) { + return true + } + } + } + } + } + } +} +pub fn facts(a: Expression, i: int, value: string) -> bool { + let (java_db = default_java_db()) { + for (p in PolyadicExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_17(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_17(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_18(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_18(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in BinaryExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_17(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_17(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_18(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_18(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in ReferenceExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_17(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_17(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_18(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_18(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn connectStrBase(ID: Expression, index: int, res: string) -> bool { + let (java_db = default_java_db()) { + for (total in int::__undetermined_all__(), + reStr in string::__undetermined_all__(), + currStr in string::__undetermined_all__()) { + if (total = tmp_19(ID).len()) { + if (tmp_21(index)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = currStr) { + return true + } + } + } + if (!(tmp_21(index))) { + if (index > 0) { + if (connectStrBase(ID, index - 1, reStr)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = reStr + currStr) { + return true + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: Expression) -> string { + let (java_db = default_java_db()) { + for (c in int::__undetermined_all__(), res in string::__undetermined_all__()) { + if (c = tmp_22(ID).len()) { + if (connectStrBase(ID, c - 1, res)) { + return res + } + } + } + } +} +pub fn real_output(m: Method, className: string, methodSignature: string, type: string) -> bool { + let (java_db = default_java_db()) { + for (n in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + path in string::__undetermined_all__()) { + for (c in Class(java_db), + a in Annotation(java_db)) { + if (getUri(c, m, uri)) { + if (className = c.getQualifiedName()) { + if (methodSignature = m.getSignature()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (tmp_26(a)) { + if (type = "EMPTY") { + if (path = m.getLocation().getFile().getRelativePath()) { + if (!path.contains("src/test/java")) { + return true + } + } + } + } + if (!(tmp_26(a))) { + if (getMethodType(a, type)) { + if (path = m.getLocation().getFile().getRelativePath()) { + if (!path.contains("src/test/java")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn tmp_0(n: string) -> bool { + let (java_db = default_java_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } +} + +fn tmp_1(i: int) -> bool { + let (java_db = default_java_db()) { + if (i = 1) { + return true + } + } +} + +fn tmp_2(a: string, b: string) -> bool { + let (java_db = default_java_db()) { + if (a.substr(0,1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } +} + +@inline +fn tmp_3(i: int, b: string, a: string) -> bool { + let (java_db = default_java_db()) { + if (a.substr(i - 1,i - 1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } +} + +@inline +fn tmp_4(i: int, b: string, a: string) -> bool { + let (java_db = default_java_db()) { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { + return true + } + } + } +} + +fn tmp_5(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PostMapping") { + return true + } + } +} + +fn tmp_6(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "GetMapping") { + return true + } + } +} + +fn tmp_7(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PutMapping") { + return true + } + } +} + +fn tmp_8(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "DeleteMapping") { + return true + } + } +} + +fn tmp_9(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (a.getName() = "PatchMapping") { + return true + } + } +} + +fn tmp_10(e: Expression) -> bool { + let (java_db = default_java_db()) { + if (facts(e, __all_data__, __all_data__)) { + return true + } + } +} + +fn tmp_11(c: Class) -> *Annotation { + let (java_db = default_java_db()) { + for (b in Annotation(java_db)) { + for (auto_tmp3 in c.getAnnotation()) { + if (b = auto_tmp3) { + if (b.getName() = "RequestMapping") { + yield b + } + } + } + } + } +} + +fn tmp_12(c: Class) -> bool { + let (java_db = default_java_db()) { + if (tmp_11(c).len() = 0) { + return true + } + } +} + +fn tmp_13(a: Annotation) -> *AnnotationAccessArgument { + let (java_db = default_java_db()) { + for (b in AnnotationAccessArgument(java_db)) { + for (auto_tmp4 in a.getAnnotationArgument()) { + if (b = auto_tmp4) { + if (b.getAnnotationArgumentName() = "value") { + yield b + } + } + } + } + } +} + +fn tmp_14(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (tmp_13(a).len() = 0) { + return true + } + } +} + +fn tmp_15(w: WebFolder) -> *Folder { + let (java_db = default_java_db()) { + for (f in Folder(java_db)) { + if (f = w.getChild()) { + yield f + } + } + } +} + +fn tmp_16(w: WebFolder) -> bool { + let (java_db = default_java_db()) { + if (tmp_15(w).len() = 1) { + return true + } + } +} + +fn tmp_17(a: Expression) -> bool { + let (java_db = default_java_db()) { + if (resolve(ReferenceExpression(java_db).find(a), __all_data__)) { + return true + } + } +} + +fn tmp_18(e: Expression) -> bool { + let (java_db = default_java_db()) { + if (resolve(ReferenceExpression(java_db).find(e), __all_data__)) { + return true + } + } +} + +fn tmp_19(ID: Expression) -> *auto_tmp_20 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(Expression(java_db).find(ID), auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_20 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } +} + +schema auto_tmp_20 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_21(index: int) -> bool { + let (java_db = default_java_db()) { + if (index = 0) { + return true + } + } +} + +fn tmp_22(ID: Expression) -> *auto_tmp_23 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(Expression(java_db).find(ID), auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_23 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } +} + +schema auto_tmp_23 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_24(a: Annotation) -> *auto_tmp_25 { + let (java_db = default_java_db()) { + for (auto_tmp_var_0 in string::__undetermined_all__()) { + if (getMethodType(a, auto_tmp_var_0)) { + yield auto_tmp_25 { + auto_tmp_var_0 : auto_tmp_var_0 + } + } + } + } +} + +schema auto_tmp_25 { + auto_tmp_var_0 : string +} + +fn tmp_26(a: Annotation) -> bool { + let (java_db = default_java_db()) { + if (tmp_24(a).len() = 0) { + return true + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule_ecg.gdl b/example/icse25/rules/rule_ecg.gdl new file mode 100644 index 0000000..d4bd39b --- /dev/null +++ b/example/icse25/rules/rule_ecg.gdl @@ -0,0 +1,2545 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + pub fn getECGDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDDependsNode(type, direction)) { + return e + } + if (e = self.getDDDependsNode(type, direction)) { + return e + } + } + } + + pub fn getCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (v in Variable(__all_data__)) { + if (self.key_eq(v)) { + if (v.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in c.getCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getDDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp)) { + if (n = c.getMethodName()) { + if (!n.matches("get.*")) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDDependsNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in c.getAnAncestorCallee()) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + } + } + } + + pub fn getPath(self) -> string { + for (line in int::__undetermined_all__(), + t in string::__undetermined_all__(), + path in string::__undetermined_all__(), + info in string::__undetermined_all__()) { + for (l in coref::java::Location(__all_data__)) { + if (l = self.getLocation()) { + if (path = l.getFile().getRelativePath()) { + if (line = l.getStartLineNumber()) { + if (t = line.to_string()) { + if (info = path + ":" + t) { + return info + } + } + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + pub fn __all__(db: XmlDB) -> *ECGXmlNode { + for (e in XmlPomElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlSpringElement(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlCharacter(db)) { + yield ECGXmlNode {id : e.id} + } + for (e in XmlAttribute(db)) { + yield ECGXmlNode {id : e.id} + } + } + + pub fn getLocation(self) -> coref::xml::Location { + for (l in coref::xml::Location(__all_data__)) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (l = e.getLocation()) { + return l + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlElement") { + return t + } + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlAttribute") { + return t + } + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + if (t = "XmlCharacter") { + return t + } + } + } + } + } + + pub fn getText(self) -> string { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getName() + " = " + e.getValue() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getText() + } + } + } + + pub fn getEnclosingECGXmlNode(self) -> ECGXmlNode { + for (e in XmlElement(__all_data__)) { + if (self.key_eq(e)) { + return e.to() + } + } + for (e in XmlAttribute(__all_data__)) { + if (self.key_eq(e)) { + return e.getXmlElement().to() + } + } + for (e in XmlCharacter(__all_data__)) { + if (self.key_eq(e)) { + return e.getBelongedElement().to() + } + } + } +} + +pub fn gitdiff(filePath: string, lineNo: int) -> bool { + // #changeinfo + // example + [ {"test", 1111} ] +} + +pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (!filename.contains("src/test/java")) { + if (filename = f.getRelativePath()) { + if (isCodeLine(f, filename, lineNumber)) { + return true + } + } + } + } + } + } +} +pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (transfertofile1(f, filename, lineNumber)) { + if (!findSpecialCodeType(filename, lineNumber, __all_data__)) { + return true + } + } + } + } +} +pub fn isComment(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Comment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in JavadocComment(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isAnnotation(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in Annotation(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (f.getRelativePath() = filename) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (l in coref::java::Location(java_db)) { + if (l.getFile() = f) { + if (s1 = l.getStartLineNumber()) { + if (e = l.getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isLog(filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile1(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (c in Expression(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (text = c.getPrintableText()) { + if (text.matches("^logger\\..*")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + for (c in ElementParent(java_db)) { + if (c.getLocation().getFile() = f) { + if (s1 = c.getLocation().getStartLineNumber()) { + if (e = c.getLocation().getEndLineNumber()) { + if (s1 = e) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = c.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + if (tmp_0(lineNumber, filename)) { + if (typeInAST = "Callable") { + if (getBelongedCallable(filename, lineNumber, Callable(java_db).find(n))) { + return true + } + } + } + if (!(tmp_0(lineNumber, filename))) { + for (e in int::__undetermined_all__(), + s1 in int::__undetermined_all__()) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (isFieldOrEnum(ECGNode(java_db).find(n))) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isFieldOrEnum(c: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in Field(java_db)) { + if (f.key_eq(c)) { + return true + } + } + for (e in EnumConstant(java_db)) { + if (e.key_eq(c)) { + return true + } + } + } + } +} +pub fn findSpecialCodeType(filename: string, lineNumber: int, type: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isComment(filename, lineNumber)) { + if (type = "comment") { + return true + } + } + if (isAnnotation(filename, lineNumber)) { + if (type = "annotation") { + return true + } + } + if (isLog(filename, lineNumber)) { + if (type = "log") { + return true + } + } + } + } +} +pub fn getBelongedCallable(filename: string, lineNumber: int, c: Callable) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in File(java_db)) { + if (transfertofile(f, filename, lineNumber)) { + for (l1 in int::__undetermined_all__(), + l2 in int::__undetermined_all__()) { + for (i in Identifier(java_db)) { + if (f = c.getLocation().getFile()) { + if (c.key_eq(i.getParent())) { + if (l1 = i.getLocation().getStartLineNumber()) { + if (l2 = c.getLocation().getEndLineNumber()) { + if (lineNumber > l1 - 1) { + if (lineNumber < l2 + 1) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getBelongedCallableSignature(filename: string, lineNumber: int, belongedCallable: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + for (c in Callable(java_db)) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (i = tmp_1().len()) { + if (tmp_2(i)) { + if (belongedCallable = "") { + return true + } + } + if (!(tmp_2(i))) { + if (getBelongedCallable(filename, lineNumber, c)) { + if (belongedCallable = c.getSignature()) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + belongedCallable in string::__undetermined_all__()) { + if (transfertofile(__all_data__, filename, lineNumber)) { + if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + return true + } + } + } + } + } + } +} +pub fn transfertoXmlfile(f: XmlFile, filename: string, lineNumber: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (gitdiff(filename, lineNumber)) { + if (filename = f.getRelativePath()) { + return true + } + } + } + } +} +pub fn getXmlECGNode1(n: ECGXmlNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (lineNumber in int::__undetermined_all__(), + e in int::__undetermined_all__(), + s1 in int::__undetermined_all__(), + filename in string::__undetermined_all__(), + typeInAST in string::__undetermined_all__(), + text in string::__undetermined_all__()) { + for (f in XmlFile(xml_db), + o in ECGXmlNode(xml_db)) { + if (transfertoXmlfile(f, filename, lineNumber)) { + if (n.getLocation().getFile() = f) { + if (s1 = n.getLocation().getStartLineNumber()) { + if (e = n.getLocation().getEndLineNumber()) { + if (lineNumber > s1 - 1) { + if (lineNumber < e + 1) { + if (typeInAST = n.getType()) { + if (text = n.getText()) { + if (o = n.getEnclosingECGXmlNode()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +@inline +pub fn trim(n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__()) { + if (i = n.len()) { + if (tmp_3(n)) { + if (m = n.substr(1,i - 2)) { + return true + } + } + if (!(tmp_3(n))) { + if (m = n) { + return true + } + } + } + } + } + } +} +pub fn getXmlECGNode(f: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in ClassOrInterface(java_db), + n in string::__undetermined_all__(), + m in string::__undetermined_all__()) { + for (r in ECGXmlNode(xml_db)) { + if (getXmlECGNode1(r)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { + return true + } + } + } + } + } + } +} +pub fn getChangeSetByResultXmlElement(r1: ECGXmlNode, c: ClassOrInterface, f: Field, n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (r in ResultXmlElement(xml_db)) { + if (r.key_eq(r1)) { + if (getXmlECGNode1(ECGXmlNode(xml_db).find(r))) { + if (n = r.getBelongedMapXmlElement().getMappingClassName()) { + if (n = c.getQualifiedName()) { + if (c = f.getParent()) { + if (r.getValueByAttributeName("property") = f.getName()) { + if (m = f.getName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn getChangeSetByDalXmlElement(d1: ECGXmlNode, c: ClassOrInterface, m: Method, className: string, methodName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__(), + temp1 in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (d in DalXmlElement(xml_db), + cc in XmlComment(xml_db), + l in Literal(java_db)) { + if (d.key_eq(d1)) { + if (getXmlECGNode1(ECGXmlNode(xml_db).find(d))) { + if (d.getLocation().getFile() = cc.getLocation().getFile()) { + if (cc.getLocation().getEndLineNumber() = i) { + if (i + 1 = d.getLocation().getStartLineNumber()) { + if (temp = cc.getText()) { + if (c.getName() = temp.get_regex_match_result("[\\s\\S]*mapped statement for[ \\t]+(\\w+)[\\s\\S]*", 1)) { + if (n = d.getValueByAttributeName("id")) { + if (c.key_eq(m.getBelongedClass())) { + if (m.key_eq(l.getEnclosingCallable())) { + if (temp1 = l.getValue()) { + if (trim(temp1, n)) { + if (className = c.getQualifiedName()) { + if (methodName = m.getSignature()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i.key_eq(c)) { + if (name = classname) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in ClassOrInterface(java_db), + b in BeanXmlElement(xml_db)) { + if (s.getQualifiedName() = b.getClass()) { + if (className = s.getQualifiedName()) { + if (className = interfaceName) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn getTrAnnotationName1(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Configuration"}, + {"Repository"}, + {"RestController"}, + {"bean"} + ] +} +pub fn getPublishTr(c: ClassOrInterface) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (className in string::__undetermined_all__(), + interfaceName in string::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (javaOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + for (n in string::__undetermined_all__()) { + if (n = tmp.getName()) { + if (getTrAnnotationName1(n)) { + yield SofaService { + id : tmp.id + } + } + } + } + } + } + + +} + +pub fn output1(c: ClassOrInterface, interfaceName: string, id: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + j in int::__undetermined_all__(), + className in string::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode1(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + return true + } + if (temp = interfaceName) { + return true + } + } + if (e2.id = i) { + if (id = e2.id) { + return true + } + } + if (e2.id = j) { + if (id = e2.id) { + return true + } + } + } + } + } + } + } + } + } + if (javaOutput(className, interfaceName)) { + for (temp in string::__undetermined_all__()) { + for (e1 in ECGNode(java_db), + e2 in ECGXmlNode(xml_db)) { + if (getJavaECGNode(e1)) { + if (getXmlECGNode1(e2)) { + if (c.key_eq(e1.getElementParent())) { + if (temp = c.getQualifiedName()) { + if (id = e1.id) { + if (temp = className) { + return true + } + if (temp = interfaceName) { + return true + } + } + if (e2.id = i) { + if (id = e2.id) { + return true + } + } + if (e2.id = j) { + if (id = e2.id) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn output2(c: ClassOrInterface, interfaceName: string, n: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in ECGNode(java_db)) { + if (getJavaECGNode(m)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + } + } + if (getXmlECGNode(m)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } +} +@inline +pub fn contact(a: string, b: string, c: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + temp in string::__undetermined_all__()) { + if (i = a.len()) { + if (tmp_4(i)) { + if (tmp_5(a, b)) { + if (c = b) { + return true + } + } + if (!(tmp_5(a, b))) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_4(i))) { + if (tmp_6(a, i, b)) { + if (temp = a.substr(1,i - 1)) { + if (c = a + b) { + return true + } + } + } + if (!(tmp_6(a, i, b))) { + if (tmp_7(a, i, b)) { + if (c = a + "/" + b) { + return true + } + } + if (!(tmp_7(a, i, b))) { + if (c = a + b) { + return true + } + } + } + } + } + } + } + } +} +schema HttpMethodType extends AnnotationAccessArgument { + +} + +impl HttpMethodType { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *HttpMethodType { + for (tmp in AnnotationAccessArgument(db)) { + if (tmp.getAnnotationArgumentName() = "method") { + yield HttpMethodType { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (a in AnnotationArrayInitializer(__all_data__)) { + if (self.getArgumentValueHashId() = a.getParent().id) { + for (i in Identifier(__all_data__)) { + if (a.key_eq(i.getParent())) { + if (t = i.getName()) { + return t + } + } + } + } + } + for (i in Identifier(__all_data__)) { + if (self.getArgumentValueHashId() = i.getParent().id) { + if (t = i.getName()) { + return t + } + } + } + } + } + + +} + +pub fn getMethodType(a: Annotation, t: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in Method(java_db), + h in HttpMethodType(java_db)) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (tmp_8(a)) { + if (t = "POST") { + return true + } + } + if (!(tmp_8(a))) { + if (tmp_9(a)) { + if (t = "GET") { + return true + } + } + if (!(tmp_9(a))) { + if (tmp_10(a)) { + if (t = "PUT") { + return true + } + } + if (!(tmp_10(a))) { + if (tmp_11(a)) { + if (t = "DELETE") { + return true + } + } + if (!(tmp_11(a))) { + if (tmp_12(a)) { + if (t = "PATCH") { + return true + } + } + if (!(tmp_12(a))) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (h.key_eq(auto_tmp2)) { + if (t = h.getType()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getSubUri(a: Annotation, sub: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (temp in AnnotationAccessArgument(java_db), + e in Expression(java_db)) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + for (auto_tmp1 in a.getAnnotationArgument()) { + if (temp = auto_tmp1) { + if (temp.getAnnotationArgumentName() = "value") { + if (temp.key_eq(e.getParent())) { + if (tmp_13(e)) { + if (sub = connectStr(e)) { + return true + } + } + if (!(tmp_13(e))) { + if (s = temp.getAnnotationArgumentValue()) { + if (trim(s, sub)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getUri(c: Class, m: Method, uri1: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (l1 in string::__undetermined_all__(), + l2 in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + n in string::__undetermined_all__()) { + for (a in Annotation(java_db), + a1 in Annotation(java_db)) { + if (c = m.getBelongedClass()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + for (auto_tmp2 in c.getAnnotation()) { + if (a1 = auto_tmp2) { + if (n = a.getName()) { + if (tmp_15(c)) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (getSubUri(a, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_19(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_19(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + } + if (!(tmp_15(c))) { + if (tmp_17(a)) { + if (n.matches(".*Mapping")) { + if (getSubUri(a1, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_19(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_19(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + if (!(tmp_17(a))) { + if (a1.getName() = "RequestMapping") { + if (n.matches(".*Mapping")) { + if (getSubUri(a, l1)) { + if (getSubUri(a1, l2)) { + if (contact(l2, l1, uri)) { + for (tt in string::__undetermined_all__()) { + for (w in WebFolder(java_db), + cc in WebCarClass(java_db)) { + if (tmp_19(w)) { + if (uri1 = uri) { + return true + } + } + if (!(tmp_19(w))) { + if (cc.key_eq(c)) { + if (tt = cc.getWebFolder().getName()) { + if (uri1 = "/" + tt + uri) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +schema WebFolder extends Folder { + +} + +impl WebFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebFolder { + for (tmp in Folder(db)) { + yield WebFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + + pub fn getChild(self) -> Folder { + for (f in Folder(__all_data__)) { + if (self.element_hash_id = f.getParentHashId()) { + return f + } + } + } + + +} + +schema WebCarFolder extends Folder { + +} + +impl WebCarFolder { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebCarFolder { + for (tmp in Folder(db)) { + yield WebCarFolder { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id + } + } + } + + pub fn getBelongedFolder(self) -> WebCarFolder { + for (f in WebCarFolder(__all_data__)) { + if (f.element_hash_id = self.getParentHashId()) { + return f + } + } + } + + pub fn getAnAncestorFolder(self) -> WebCarFolder { + for (f in WebCarFolder(__all_data__)) { + if (f = self.getBelongedFolder()) { + return f + } + if (f = self.getBelongedFolder().getAnAncestorFolder()) { + return f + } + } + } + + +} + +schema WebCarClass extends Class { + +} + +impl WebCarClass { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *WebCarClass { + for (tmp in Class(db)) { + for (f in WebCarFolder(db), + w in WebFolder(db)) { + if (f.key_eq(tmp.getContainingFile().getBelongedFolder())) { + if (f.getAnAncestorFolder().key_eq(w)) { + yield WebCarClass { + element_hash_id : tmp.element_hash_id, + qualified_name : tmp.qualified_name, + identifier_hash_id : tmp.identifier_hash_id, + location_hash_id : tmp.location_hash_id, + parent_hash_id : tmp.parent_hash_id + } + } + } + } + } + } + + pub fn getWebFolder(self) -> WebCarFolder { + for (c in WebCarFolder(__all_data__)) { + for (f in WebCarFolder(__all_data__), + w in WebFolder(__all_data__)) { + if (f.key_eq(self.getContainingFile().getBelongedFolder())) { + if (f.getAnAncestorFolder() = c) { + if (c.key_eq(w.getChild())) { + return c + } + } + } + } + } + } + + +} + +pub fn resolve(r: ReferenceExpression, rr: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (e.getParent() = r.getDefinition()) { + if (temp = e.getPrintableText()) { + if (trim(temp, rr)) { + return true + } + } + } + } + } + } + } +} +pub fn facts(a: Expression, i: int, value: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (p in PolyadicExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_20(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_20(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_21(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_21(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in BinaryExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_20(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_20(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_21(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_21(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + for (p in ReferenceExpression(java_db)) { + if (a.key_eq(p)) { + for (temp in string::__undetermined_all__()) { + for (e in Expression(java_db)) { + if (tmp_20(a)) { + if (resolve(ReferenceExpression(java_db).find(a), value)) { + if (i = 0) { + return true + } + } + } + if (!(tmp_20(a))) { + if (a.key_eq(e.getParent())) { + if (i = e.getIndex()) { + if (tmp_21(e)) { + if (resolve(ReferenceExpression(java_db).find(e), value)) { + return true + } + } + if (!(tmp_21(e))) { + if (temp = e.getPrintableText()) { + if (trim(temp, value)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn connectStrBase(ID: Expression, index: int, res: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (total in int::__undetermined_all__(), + reStr in string::__undetermined_all__(), + currStr in string::__undetermined_all__()) { + if (total = tmp_22(ID).len()) { + if (tmp_24(index)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = currStr) { + return true + } + } + } + if (!(tmp_24(index))) { + if (index > 0) { + if (connectStrBase(ID, index - 1, reStr)) { + if (facts(Expression(java_db).find(ID), index, currStr)) { + if (res = reStr + currStr) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: Expression) -> string { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in int::__undetermined_all__(), res in string::__undetermined_all__()) { + if (c = tmp_25(ID).len()) { + if (connectStrBase(ID, c - 1, res)) { + return res + } + } + } + } + } +} +pub fn getHttpMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (n in string::__undetermined_all__(), + className in string::__undetermined_all__(), + methodSignature in string::__undetermined_all__(), + uri in string::__undetermined_all__(), + type in string::__undetermined_all__()) { + for (c in Class(java_db), + a in Annotation(java_db)) { + if (getUri(c, m, uri)) { + if (className = c.getQualifiedName()) { + if (methodSignature = m.getSignature()) { + for (auto_tmp1 in m.getAnnotation()) { + if (a = auto_tmp1) { + if (n = a.getName()) { + if (n.matches(".*Mapping")) { + if (tmp_29(a)) { + if (type = "EMPTY") { + return true + } + } + if (!(tmp_29(a))) { + if (getMethodType(a, type)) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn output3(nodeText: string, path: string, m: ECGNode) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (direction in string::__undetermined_all__(), + edgeType in string::__undetermined_all__()) { + for (a in ECGNode(java_db), + b in ECGNode(java_db), + c in ECGNode(java_db)) { + if (getJavaECGNode(a)) { + if (getHttpMethod(Method(java_db).find(m))) { + if (b = m.getAnAncestorCDDependsNode(__all_data__, __all_data__)) { + if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + if (c = a) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + } + if (b = m) { + if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + if (c = a) { + if (c = b.getECGDependsNode(edgeType, direction)) { + if (b != c) { + if (nodeText = m.print()) { + if (path = m.getPath()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(nodeText: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in ClassOrInterface(java_db), + n in ECGNode(java_db)) { + if (output2(c, interfaceName, n)) { + if (nodeText = c.getQualifiedName()) { + return true + } + } + if (output1(c, interfaceName, n.id)) { + if (nodeText = c.getQualifiedName()) { + return true + } + } + } + for (n in ECGNode(java_db)) { + if (output3(nodeText, interfaceName, n)) { + return true + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(lineNumber: int, filename: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + return true + } + } + } +} + +fn tmp_1() -> *string { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename + } + } +} + +fn tmp_2(i: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (i = 0) { + return true + } + } + } +} + +fn tmp_3(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.substr(0,1) = "\"") { + return true + } + } + } +} + +fn tmp_4(i: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (i = 1) { + return true + } + } + } +} + +fn tmp_5(a: string, b: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (a.substr(0,1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } + } +} + +@inline +fn tmp_6(a: string, i: int, b: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (a.substr(i - 1,i - 1) = "/") { + if (b.substr(0,1) = "/") { + return true + } + } + } + } +} + +@inline +fn tmp_7(a: string, i: int, b: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { + return true + } + } + } + } +} + +fn tmp_8(a: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (a.getName() = "PostMapping") { + return true + } + } + } +} + +fn tmp_9(a: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (a.getName() = "GetMapping") { + return true + } + } + } +} + +fn tmp_10(a: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (a.getName() = "PutMapping") { + return true + } + } + } +} + +fn tmp_11(a: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (a.getName() = "DeleteMapping") { + return true + } + } + } +} + +fn tmp_12(a: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (a.getName() = "PatchMapping") { + return true + } + } + } +} + +fn tmp_13(e: Expression) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (facts(e, __all_data__, __all_data__)) { + return true + } + } + } +} + +fn tmp_14(c: Class) -> *Annotation { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (b in Annotation(java_db)) { + for (auto_tmp3 in c.getAnnotation()) { + if (b = auto_tmp3) { + if (b.getName() = "RequestMapping") { + yield b + } + } + } + } + } + } +} + +fn tmp_15(c: Class) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_14(c).len() = 0) { + return true + } + } + } +} + +fn tmp_16(a: Annotation) -> *AnnotationAccessArgument { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (b in AnnotationAccessArgument(java_db)) { + for (auto_tmp4 in a.getAnnotationArgument()) { + if (b = auto_tmp4) { + if (b.getAnnotationArgumentName() = "value") { + yield b + } + } + } + } + } + } +} + +fn tmp_17(a: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_16(a).len() = 0) { + return true + } + } + } +} + +fn tmp_18(w: WebFolder) -> *Folder { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (f in Folder(java_db)) { + if (f = w.getChild()) { + yield f + } + } + } + } +} + +fn tmp_19(w: WebFolder) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_18(w).len() = 1) { + return true + } + } + } +} + +fn tmp_20(a: Expression) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (resolve(ReferenceExpression(java_db).find(a), __all_data__)) { + return true + } + } + } +} + +fn tmp_21(e: Expression) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (resolve(ReferenceExpression(java_db).find(e), __all_data__)) { + return true + } + } + } +} + +fn tmp_22(ID: Expression) -> *auto_tmp_23 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(Expression(java_db).find(ID), auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_23 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } + } +} + +schema auto_tmp_23 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_24(index: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (index = 0) { + return true + } + } + } +} + +fn tmp_25(ID: Expression) -> *auto_tmp_26 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (auto_tmp_var_0 in int::__undetermined_all__(), + auto_tmp_var_1 in string::__undetermined_all__()) { + if (facts(Expression(java_db).find(ID), auto_tmp_var_0, auto_tmp_var_1)) { + yield auto_tmp_26 { + auto_tmp_var_0 : auto_tmp_var_0, + auto_tmp_var_1 : auto_tmp_var_1 + } + } + } + } + } +} + +schema auto_tmp_26 { + auto_tmp_var_0 : int, + auto_tmp_var_1 : string +} + +fn tmp_27(a: Annotation) -> *auto_tmp_28 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (auto_tmp_var_0 in string::__undetermined_all__()) { + if (getMethodType(a, auto_tmp_var_0)) { + yield auto_tmp_28 { + auto_tmp_var_0 : auto_tmp_var_0 + } + } + } + } + } +} + +schema auto_tmp_28 { + auto_tmp_var_0 : string +} + +fn tmp_29(a: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_27(a).len() = 0) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/rule_spring.gdl b/example/icse25/rules/rule_spring.gdl new file mode 100644 index 0000000..cb24b11 --- /dev/null +++ b/example/icse25/rules/rule_spring.gdl @@ -0,0 +1,411 @@ +// script +use coref::java::* +use coref::xml::* +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + for (n in string::__undetermined_all__()) { + if (n = tmp.getName()) { + if (getTrAnnotationName1(n)) { + yield SofaService { + id : tmp.id + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i.key_eq(c)) { + if (name = classname) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in ClassOrInterface(java_db), + b in BeanXmlElement(xml_db)) { + if (s.getQualifiedName() = b.getClass()) { + if (className = s.getQualifiedName()) { + if (className = interfaceName) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn getTrAnnotationName1(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Configuration"}, + {"Repository"}, + {"bean"} + ] +} +pub fn output1(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (javaOutput(className, interfaceName)) { + return true + } + } + } +} +pub fn isSelfDefinedInterface(name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in Interface(java_db)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } +} +pub fn isSelfDefinedClass(name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in Class(java_db)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } +} +schema PublicMethod extends Method { + +} + +impl PublicMethod { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *PublicMethod { + for (tmp in Method(db)) { + for (m in Modifier(db)) { + for (auto_tmp1 in tmp.getModifier()) { + if (m = auto_tmp1) { + if (m.getName() = "public") { + if (!isSetOrGetMethod(tmp)) { + yield PublicMethod { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + signature : tmp.signature, + type_hash_id : tmp.type_hash_id, + parent_hash_id : tmp.parent_hash_id, + location_hash_id : tmp.location_hash_id, + definition_body : tmp.definition_body + } + } + } + } + } + } + } + } + + +} + +pub fn isBooleanTypeField(f: Field, p: string, q: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + n in string::__undetermined_all__(), + tmp1 in string::__undetermined_all__(), + tmp2 in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__()) { + if (n = f.getName()) { + if (i = n.len()) { + if (tmp_0(n)) { + if (tmp1 = n.substr(2,i)) { + if (l = n.substr(2,1)) { + if (tmp2 = n.substr(3,i)) { + if (q = n) { + if (p = "set" + tmp1) { + return true + } + } + if (q = "get" + l + tmp2) { + if (p = "set" + tmp1) { + return true + } + } + } + } + } + } + if (!(tmp_0(n))) { + if (l = n.substr(0,1)) { + if (tmp2 = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp2) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + if (p = "set" + n) { + if (q = "is" + j + tmp2) { + return true + } + if (q = "get" + j + tmp2) { + return true + } + } + } + } + } + } + } + } + } + } + } +} +pub fn isSetOrGetMethod(m: Method) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in int::__undetermined_all__(), + p in string::__undetermined_all__(), + q in string::__undetermined_all__(), + n in string::__undetermined_all__(), + l in string::__undetermined_all__(), + j in string::__undetermined_all__(), + tmp in string::__undetermined_all__(), + t in string::__undetermined_all__()) { + for (f in Field(java_db)) { + if (n = f.getName()) { + if (i = n.len()) { + if (f.getParent() = m.getParent()) { + if (p = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_1(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_1(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + if (q = m.getName()) { + if (t = f.getTypeElement().getPrintableText()) { + if (tmp_1(t)) { + if (isBooleanTypeField(f, p, q)) { + return true + } + } + if (!(tmp_1(t))) { + if (l = n.substr(0,1)) { + if (tmp = n.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (p = "set" + j + tmp) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + if (p = "set" + n) { + if (q = "get" + j + tmp) { + return true + } + if (q = "get" + n) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn real_output(methodName: string, tag: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (interfaceName in string::__undetermined_all__(), + className in string::__undetermined_all__(), + path in string::__undetermined_all__()) { + for (i in Interface(java_db), + c in Class(java_db)) { + if (output1(className, interfaceName)) { + if (tmp_2(interfaceName)) { + if (interfaceName = i.getQualifiedName()) { + for (m in Method(java_db)) { + if (i.key_eq(m.getParent())) { + if (methodName = m.getSignature()) { + if (tag = "Self") { + if (path = m.getLocation().getFile().getRelativePath()) { + if (!path.contains("src/test/java")) { + return true + } + } + } + } + } + } + } + } + if (!(tmp_2(interfaceName))) { + if (className = c.getQualifiedName()) { + for (n in PublicMethod(java_db)) { + if (c.key_eq(n.getParent())) { + if (methodName = n.getSignature()) { + if (tag = "External") { + if (path = n.getLocation().getFile().getRelativePath()) { + if (!path.contains("src/test/java")) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(n: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (n.matches("is.*")) { + return true + } + } + } +} + +fn tmp_1(t: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (t = "boolean") { + return true + } + if (t = "Boolean") { + return true + } + } + } +} + +fn tmp_2(interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (isSelfDefinedInterface(interfaceName)) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file diff --git a/example/icse25/rules/test.gdl b/example/icse25/rules/test.gdl new file mode 100644 index 0000000..f1d551e --- /dev/null +++ b/example/icse25/rules/test.gdl @@ -0,0 +1,867 @@ +// script +use coref::java::* +use coref::xml::* + +schema ECGNode extends ElementParent {} + +impl ECGNode { + pub fn __all__(db: JavaDB) -> *ECGNode { + for (tmp in ElementParent(db)) { + for (m in Method(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Variable(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + for (m in Expression(db)) { + if (tmp.key_eq(m)) { + yield ECGNode { + id : tmp.id + } + } + } + } + } + + pub fn getType(self) -> string { + for (t in string::__undetermined_all__()) { + for (m in Method(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Method") { + return t + } + } + } + for (m in LocalVariable(__all_data__)) { + if (self.key_eq(m)) { + if (t = "LocalVariable") { + return t + } + } + } + for (m in Parameter(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Parameter") { + return t + } + } + } + for (m in Field(__all_data__)) { + if (self.key_eq(m)) { + if (t = "Field") { + return t + } + } + } + for (m in EnumConstant(__all_data__)) { + if (self.key_eq(m)) { + if (t = "EnumConstant") { + return t + } + } + } + for (m in Expression(__all_data__)) { + if (self.key_eq(m)) { + if (t = m.getType()) { + return t + } + } + } + } + } + + pub fn getDDNode(self, type: string, direction: string) -> ECGNode { + for (e1 in ECGNode(__all_data__)) { + for (e in Parameter(__all_data__), + c in Method(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + for (auto_tmp1 in c.getParameter()) { + if (e = auto_tmp1) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (r in ReturnStatement(__all_data__), + c in Method(__all_data__), + e in Expression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getEnclosingCallable())) { + if (e = r.getResult()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = r.getEnclosingCallable()) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in Field(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (e in Callable(__all_data__), + c in EnumConstant(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c.key_eq(r.getDefinition())) { + if (e = r.getEnclosingCallable()) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + for (c in Callable(__all_data__), + e in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (c = e.getEnclosingCallable()) { + for (m in Method(__all_data__)) { + if (m = e.getMethod()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + for (f in LombokField(__all_data__)) { + if (f = e.getLombokField()) { + if (!isDirectCall(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (n in string::__undetermined_all__()) { + for (e in LombokField(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (e = c.getLombokField()) { + let (tmp_find = CallExpression(__all_data__).find(e)) { + if (!isDirectCall(tmp_find)) { + if (n = c.getMethodName()) { + if (Self::tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + for (e in Variable(__all_data__), + c in CallExpression(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp2 in c.getArguments()) { + if (r.key_eq(auto_tmp2)) { + if (e.key_eq(r.getDefinition())) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp3 in c.getArguments()) { + if (e.key_eq(auto_tmp3)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + for (e in CallExpression(__all_data__), + c in CallExpression(__all_data__), + s in CallExpression(__all_data__)) { + if (e.key_eq(e1)) { + if (self.key_eq(c)) { + if (!isDirectCall(c)) { + for (auto_tmp4 in c.getAnAncestor()) { + if (s.getReference().key_eq(auto_tmp4)) { + for (auto_tmp5 in s.getArguments()) { + if (auto_tmp5.key_eq(e)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (type = "DD") { + if (e = self.getDDNode(type, direction)) { + return e + } + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + return e + } + } + } + } + + pub fn getCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (self.key_eq(c)) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + if (type = "CD") { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getAnAncestorCDNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + c in Callable(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c)) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + if (self.key_eq(r.getDefinition())) { + if (c = r.getEnclosingCallable()) { + for (e1 in Method(__all_data__)) { + for (auto_tmp1 in c.getAnAncestorCallee()) { + if (e1.key_eq(auto_tmp1)) { + if (direction = "Depends") { + if (e.key_eq(e1)) { + return e + } + } + } + } + } + for (e2 in Method(__all_data__)) { + for (auto_tmp2 in c.getAnAncestorCaller()) { + if (e2.key_eq(auto_tmp2)) { + if (direction = "Depended") { + if (e.key_eq(e2)) { + return e + } + } + } + } + } + } + } + } + } + } + + pub fn getECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__)) { + if (e = self.getCDNode(type, direction)) { + return e + } + if (e = self.getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), tmp in ECGNode(__all_data__)) { + if (tmp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = tmp.getECGNode(type, direction)) { + return e + } + } + } + } + + pub fn getAnAncestorCDDependedNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), c in Callable(__all_data__), r in ReferenceExpression(__all_data__)) { + if (type = "CD") { + if (self.key_eq(c) || (self.key_eq(r.getDefinition()) && r.getEnclosingCallable() = c)) { + for (e2 in Method(__all_data__), c_caller in c.getAnAncestorCaller()) { + if (e2.key_eq(c_caller) && direction = "Depended" && e.key_eq(e2)) { + return e + } + } + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + +pub fn getJavaECGNode(id: int) -> bool { + [ + // {-2697619382280646740}, + // {-2697619382280646740}, + {5305694462395891450}, + {5305694462395891450} + ] +} +pub fn getXmlECGNode(id: int) -> bool { + [ + // {-1} + ] +} +schema SofaService extends Annotation { + +} + +impl SofaService { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaService { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaService") { + yield SofaService { + id : tmp.id + } + } + } + } + + pub fn getService(self) -> ClassOrInterface { + for (value in string::__undetermined_all__()) { + for (i in ClassOrInterface(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "interfaceType") { + if (value = argus.getAnnotationArgumentValue()) { + if (i.getQualifiedName() = value) { + return i + } + } + } + } + } + } + } + } + + @inline + pub fn getBinding(self) -> SofaServiceBinding { + for (b in SofaServiceBinding(__all_data__), + argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindings") { + if (b.key_eq(argus.getArgumentAnnotation())) { + return b + } + if (argus.key_eq(b.getParent())) { + return b + } + } + } + } + } + } + + @inline + pub fn getUniqueId(self) -> string { + for (uniqueId in string::__undetermined_all__()) { + for (anno in Annotation(__all_data__)) { + if (self.key_eq(anno)) { + if (tmp_2(anno)) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + if (uniqueId = argus.getAnnotationArgumentValue()) { + return uniqueId + } + } + } + } + } + } + if (!(tmp_2(anno))) { + if (uniqueId = "null") { + return uniqueId + } + } + } + } + } + } + + +} + +pub fn uniqueArgument(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (argus in AnnotationAccessArgument(java_db)) { + for (auto_tmp1 in anno.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "uniqueId") { + return true + } + } + } + } + } + } +} +schema SofaServiceBinding extends Annotation { + +} + +impl SofaServiceBinding { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *SofaServiceBinding { + for (tmp in Annotation(db)) { + if (tmp.getName() = "SofaServiceBinding") { + yield SofaServiceBinding { + id : tmp.id + } + } + } + } + + pub fn getType(self) -> string { + for (value in string::__undetermined_all__()) { + for (argus in AnnotationAccessArgument(__all_data__)) { + for (auto_tmp1 in self.getAnnotationArgument()) { + if (argus = auto_tmp1) { + if (argus.getAnnotationArgumentName() = "bindingType") { + if (value = argus.getAnnotationArgumentValue()) { + return value + } + } + } + } + } + } + } + + +} + +pub fn javaOutput(classname: string, name: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (s in SofaService(java_db), + c in Class(java_db), + i in ClassOrInterface(java_db)) { + for (auto_tmp1 in c.getAnnotation()) { + if (s.key_eq(auto_tmp1)) { + if (classname = c.getQualifiedName()) { + for (auto_tmp2 in c.getImplementsInterface()) { + if (i.key_eq(auto_tmp2)) { + if (name = i.getQualifiedName()) { + return true + } + } + } + if (i = s.getService()) { + if (name = i.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } +} +pub fn xmlOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (temp in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in BeanXmlElement(xml_db)) { + if (s.getRef() = b.getId()) { + if (interfaceName = s.getInterfaceName()) { + if (className = b.getClass()) { + if (temp = b.getLocation().getFile().getRelativePath()) { + if (!temp.contains("src/test/resources")) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn annoOutput(className: string, interfaceName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (v in string::__undetermined_all__(), + k in string::__undetermined_all__()) { + for (s in SofaServiceXmlElement(xml_db), + b in Class(java_db), + t in TagXmlElement(xml_db), + a in Annotation(java_db)) { + if (s.key_eq(t.getParent())) { + if (v = s.getRef()) { + if (interfaceName = s.getInterfaceName()) { + for (auto_tmp1 in b.getAnnotation()) { + if (a = auto_tmp1) { + if (a.getName() = k) { + if (getTrAnnotationName(k)) { + for (auto_tmp2 in a.getAnnotationArgument()) { + if (auto_tmp2.getAnnotationArgumentValue() = "\"" + v + "\"") { + if (className = b.getQualifiedName()) { + return true + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +pub fn getTrAnnotationName(a: string) -> bool { + [ + {"Service"}, + {"Component"}, + {"Scope"}, + {"Repository"}, + {"Controller"}, + {"RestController"}, + {"RequestMapping"}, + {"PathVariable"}, + {"ResponseBody"}, + {"bean"} + ] +} +pub fn getPublishTr(c: ClassOrInterface) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (className in string::__undetermined_all__(), + interfaceName in string::__undetermined_all__()) { + if (xmlOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (javaOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + if (annoOutput(className, interfaceName)) { + if (interfaceName = c.getQualifiedName()) { + return true + } + } + } + } + } +} +pub fn real_output(c: ClassOrInterface, n: ECGNode, interfaceName: string, nodeName: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (m in ECGNode(java_db)) { + if (getJavaECGNode(m.id)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + } + } + if (getXmlECGNode(m.id)) { + if (getPublishTr(c)) { + for (t in Method(java_db)) { + if (n.key_eq(t)) { + if (c = t.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + for (f in Field(java_db)) { + if (n.key_eq(f)) { + if (c = f.getParent()) { + if (n = m.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { + if (interfaceName = c.getQualifiedName()) { + if (nodeName = n.print()) { + return true + } + } + } + } + } + } + } + } + } + } + } +} + + +fn default_java_db() -> JavaDB { + return JavaDB::load("coref_java_src.db") +} + +fn default_xml_db() -> XmlDB { + return XmlDB::load("coref_xml_src.db") +} + +fn tmp_0(anno: Annotation) -> *auto_tmp_1 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (uniqueArgument(anno)) { + yield auto_tmp_1 { + + } + } + } + } +} + +schema auto_tmp_1 { + +} + +fn tmp_2(anno: Annotation) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (tmp_0(anno).len() = 1) { + return true + } + } + } +} + +fn main() { + output(real_output()) +} \ No newline at end of file