From 0a087ce744f494f336ecce3a980e6aab8ea39978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=95=E5=B1=B1?= Date: Mon, 28 Apr 2025 14:37:05 +0800 Subject: [PATCH 1/5] add experiment script of icse25 paper --- .../icse25/Keymap/FindAllReleasedHttpAPI.gdl | 1337 +++++++++++++ .../icse25/Keymap/FindAllReleasedTrAPI.gdl | 1046 ++++++++++ example/icse25/motivation example.md | 127 ++ example/icse25/procedure.md | 27 + example/icse25/rules/ecg.gdl | 817 ++++++++ example/icse25/rules/ecgformybatis.gdl | 248 +++ example/icse25/rules/ecgforpom.gdl | 341 ++++ example/icse25/rules/ecgforspring.gdl | 184 ++ example/icse25/rules/ecgxml.gdl | 627 ++++++ example/icse25/rules/rule1.gdl | 340 ++++ example/icse25/rules/rule10.gdl | 460 +++++ example/icse25/rules/rule11.gdl | 430 ++++ example/icse25/rules/rule12.gdl | 570 ++++++ example/icse25/rules/rule13.gdl | 598 ++++++ example/icse25/rules/rule14.gdl | 402 ++++ example/icse25/rules/rule15.gdl | 168 ++ example/icse25/rules/rule16.gdl | 149 ++ example/icse25/rules/rule17.gdl | 766 +++++++ example/icse25/rules/rule18.gdl | 156 ++ example/icse25/rules/rule19.gdl | 393 ++++ example/icse25/rules/rule1_4.gdl | 1261 ++++++++++++ example/icse25/rules/rule1_5.gdl | 445 +++++ example/icse25/rules/rule1_5_6.gdl | 848 ++++++++ example/icse25/rules/rule1_7_8.gdl | 898 +++++++++ example/icse25/rules/rule2.gdl | 180 ++ example/icse25/rules/rule3.gdl | 57 + example/icse25/rules/rule4.gdl | 937 +++++++++ example/icse25/rules/rule5.gdl | 58 + example/icse25/rules/rule6.gdl | 449 +++++ example/icse25/rules/rule6_8_no_xml.gdl | 1015 ++++++++++ example/icse25/rules/rule6_8_spring.gdl | 808 ++++++++ example/icse25/rules/rule7.gdl | 133 ++ example/icse25/rules/rule8.gdl | 382 ++++ example/icse25/rules/rule9.gdl | 872 ++++++++ example/icse25/rules/rule_ecg.gdl | 1778 +++++++++++++++++ example/icse25/rules/rule_spring.gdl | 411 ++++ example/icse25/rules/test.gdl | 385 ++++ 37 files changed, 20103 insertions(+) create mode 100644 example/icse25/Keymap/FindAllReleasedHttpAPI.gdl create mode 100644 example/icse25/Keymap/FindAllReleasedTrAPI.gdl create mode 100644 example/icse25/motivation example.md create mode 100644 example/icse25/procedure.md create mode 100644 example/icse25/rules/ecg.gdl create mode 100644 example/icse25/rules/ecgformybatis.gdl create mode 100644 example/icse25/rules/ecgforpom.gdl create mode 100644 example/icse25/rules/ecgforspring.gdl create mode 100644 example/icse25/rules/ecgxml.gdl create mode 100644 example/icse25/rules/rule1.gdl create mode 100644 example/icse25/rules/rule10.gdl create mode 100644 example/icse25/rules/rule11.gdl create mode 100644 example/icse25/rules/rule12.gdl create mode 100644 example/icse25/rules/rule13.gdl create mode 100644 example/icse25/rules/rule14.gdl create mode 100644 example/icse25/rules/rule15.gdl create mode 100644 example/icse25/rules/rule16.gdl create mode 100644 example/icse25/rules/rule17.gdl create mode 100644 example/icse25/rules/rule18.gdl create mode 100644 example/icse25/rules/rule19.gdl create mode 100644 example/icse25/rules/rule1_4.gdl create mode 100644 example/icse25/rules/rule1_5.gdl create mode 100644 example/icse25/rules/rule1_5_6.gdl create mode 100644 example/icse25/rules/rule1_7_8.gdl create mode 100644 example/icse25/rules/rule2.gdl create mode 100644 example/icse25/rules/rule3.gdl create mode 100644 example/icse25/rules/rule4.gdl create mode 100644 example/icse25/rules/rule5.gdl create mode 100644 example/icse25/rules/rule6.gdl create mode 100644 example/icse25/rules/rule6_8_no_xml.gdl create mode 100644 example/icse25/rules/rule6_8_spring.gdl create mode 100644 example/icse25/rules/rule7.gdl create mode 100644 example/icse25/rules/rule8.gdl create mode 100644 example/icse25/rules/rule9.gdl create mode 100644 example/icse25/rules/rule_ecg.gdl create mode 100644 example/icse25/rules/rule_spring.gdl create mode 100644 example/icse25/rules/test.gdl diff --git a/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl new file mode 100644 index 0000000..bb3974c --- /dev/null +++ b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl @@ -0,0 +1,1337 @@ +// 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: int, index: int, result: 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 (result = 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 (result = reStr + currStr) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: int) -> string { + let (xml_db = default_xml_db()) { + let (java_db = default_java_db()) { + for (c in int::__undetermined_all__(), + result in string::__undetermined_all__()) { + if (c = tmp_32(ID).len()) { + if (connectStrBase(ID, c - 1, result)) { + return result + } + } + } + } + } +} +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 + } + } + } + } +} + +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 + } + } + } + } +} + +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: int) -> *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: int) -> *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..abf92fa --- /dev/null +++ b/example/icse25/Keymap/FindAllReleasedTrAPI.gdl @@ -0,0 +1,1046 @@ +// 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 + } + } + } + } + } + } + } + } + } + } + } + } + } + } +} +schema SofaServiceXmlElement extends XmlElement { + +} + +impl SofaServiceXmlElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *SofaServiceXmlElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "sofa:service") { + yield SofaServiceXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getRef(self) -> string { + for (value in string::__undetermined_all__()) { + for (e in XmlAttribute(__all_data__)) { + for (auto_tmp1 in self.getAttribute()) { + if (e = auto_tmp1) { + if (e.getName() = "ref") { + if (value = e.getValue()) { + return value + } + } + } + } + } + } + } + + pub fn getInterfaceName(self) -> string { + for (value in string::__undetermined_all__()) { + for (e in XmlAttribute(__all_data__)) { + for (auto_tmp1 in self.getAttribute()) { + if (e = auto_tmp1) { + if (e.getName() = "interface") { + if (value = e.getValue()) { + return value + } + } + } + } + } + } + } + + pub fn getUniqueId(self) -> string { + for (value in string::__undetermined_all__()) { + for (x in SofaServiceXmlElement(__all_data__)) { + if (self = x) { + if (tmp_5(x)) { + for (e in XmlAttribute(__all_data__)) { + for (auto_tmp1 in self.getAttribute()) { + if (e = auto_tmp1) { + if (e.getName() = "unique-id") { + if (value = e.getValue()) { + return value + } + } + if (e.getName() = "uniqueId") { + if (value = e.getValue()) { + return value + } + } + } + } + } + } + if (!(tmp_5(x))) { + if (value = "null") { + return value + } + } + } + } + } + } + + pub fn getSingleBindingType(self) -> *string { + for (value in string::__undetermined_all__()) { + for (t in TagXmlElement(__all_data__)) { + if (self.key_eq(t.getParent())) { + if (value = t.getTag()) { + yield value + } + } + } + } + } + + pub fn getMultiBindingType(self) -> string { + for (value in string::__undetermined_all__(), + s1 in string::__undetermined_all__(), + s2 in string::__undetermined_all__()) { + for (x1 in TagXmlElement(__all_data__), + x2 in TagXmlElement(__all_data__)) { + if (self.key_eq(x1.getParent())) { + if (self.key_eq(x2.getParent())) { + if (x1 > x2) { + if (s1 = x1.getTag()) { + if (s2 = x2.getTag()) { + if (value = s1 + "_" + s2) { + return value + } + } + } + } + } + } + } + } + } + + pub fn getBindingType(self) -> string { + for (num in int::__undetermined_all__(), + value in string::__undetermined_all__()) { + if (num = tmp_6(self).len()) { + if (num = 1) { + for (auto_tmp1 in self.getSingleBindingType()) { + if (value = auto_tmp1) { + return value + } + } + } + if (num = 2) { + if (value = self.getMultiBindingType()) { + return value + } + } + } + } + } + + +} + +pub fn hasUniqueIdAttribute(s: XmlElement) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (value in string::__undetermined_all__()) { + for (auto_tmp1 in s.getAttribute()) { + if (value = auto_tmp1.getName()) { + if (value = "unique-id") { + return true + } + if (value = "uniqueId") { + return true + } + } + } + } + } + } +} +schema BeanXmlElement extends XmlElement { + +} + +impl BeanXmlElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *BeanXmlElement { + for (tmp in XmlElement(db)) { + if (tmp.getElementName() = "bean") { + yield BeanXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getId(self) -> string { + for (value in string::__undetermined_all__()) { + for (e in XmlAttribute(__all_data__)) { + for (auto_tmp1 in self.getAttribute()) { + if (e = auto_tmp1) { + if (e.getName() = "id") { + if (value = e.getValue()) { + return value + } + } + } + } + } + } + } + + pub fn getClass(self) -> string { + for (value in string::__undetermined_all__()) { + for (e in XmlAttribute(__all_data__)) { + for (auto_tmp1 in self.getAttribute()) { + if (e = auto_tmp1) { + if (e.getName() = "class") { + if (value = e.getValue()) { + return value + } + } + } + } + } + } + } + + pub fn getProperty(self) -> *PropertyXmlElement { + for (e in PropertyXmlElement(__all_data__)) { + if (self.key_eq(e.getParent())) { + yield e + } + } + } + + +} + +schema TagXmlElement extends XmlElement { + +} + +impl TagXmlElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *TagXmlElement { + for (tmp in XmlElement(db)) { + for (s in string::__undetermined_all__()) { + if (tmp.getName() = "sofa:binding.tr") { + if (s = tmp.getName()) { + if (s.contains("sofa:binding")) { + yield TagXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + if (tmp.getName() = "sofa:binding.ws") { + if (s = tmp.getName()) { + if (s.contains("sofa:binding")) { + yield TagXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + if (tmp.getName() = "sofa:binding.rest") { + if (s = tmp.getName()) { + if (s.contains("sofa:binding")) { + yield TagXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + if (tmp.getName() = "sofa:binding.bolt") { + if (s = tmp.getName()) { + if (s.contains("sofa:binding")) { + yield TagXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + if (tmp.getName() = "sofa:binding.tri") { + if (s = tmp.getName()) { + if (s.contains("sofa:binding")) { + yield TagXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + } + } + } + + @inline + pub fn getTag(self) -> string { + for (l in int::__undetermined_all__(), + s in string::__undetermined_all__(), + a in string::__undetermined_all__()) { + if (a = self.getName()) { + if (l = a.len()) { + if (s = a.substr(13,l)) { + return s + } + } + } + } + } + + +} + +schema PropertyXmlElement extends XmlElement { + +} + +impl PropertyXmlElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *PropertyXmlElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "property") { + yield PropertyXmlElement { + 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 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..6f4fc99 --- /dev/null +++ b/example/icse25/rules/ecg.gdl @@ -0,0 +1,817 @@ +// script +use coref::java::* +schema ECGNode extends ElementParent { + +} + +impl ECGNode { + + @data_constraint + @inline + 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()) { + if (!isDirectCall(CallExpression(__all_data__).find(e))) { + if (n = c.getMethodName()) { + if (tmp_0(n)) { + if (direction = "Depended") { + if (type = "DD") { + return e1 + } + } + } + if (!(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.id = getDDNode(type, direction)) { + return e + } + if (e.id = 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.id = getCDNode(type, direction)) { + return e + } + if (e.id = getDDNode(type, direction)) { + return e + } + } + } + + pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { + for (e in ECGNode(__all_data__), + temp in ECGNode(__all_data__)) { + if (temp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { + if (e = temp.getECGNode(type, direction)) { + return e + } + } + } + } + + +} + +schema CallExpression extends Expression { + +} + +impl CallExpression { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *CallExpression { + for (tmp in Expression(db)) { + for (m in MethodAccessExpression(db)) { + if (tmp.key_eq(m)) { + yield CallExpression { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + index_order : tmp.index_order, + location_hash_id : tmp.location_hash_id, + printable_text : tmp.printable_text + } + } + } + for (m in MethodReferenceExpression(db)) { + if (tmp.key_eq(m)) { + yield CallExpression { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + index_order : tmp.index_order, + location_hash_id : tmp.location_hash_id, + printable_text : tmp.printable_text + } + } + } + } + } + + pub fn getMethod(self) -> Method { + for (m in Method(__all_data__)) { + for (e in MethodAccessExpression(__all_data__)) { + if (self.key_eq(e)) { + if (m = e.getMethod()) { + return m + } + } + } + for (e in MethodReferenceExpression(__all_data__)) { + if (self.key_eq(e)) { + if (m = e.getMethod()) { + return m + } + } + } + } + } + + pub fn getMethodName(self) -> string { + for (m in string::__undetermined_all__()) { + for (i in Identifier(__all_data__)) { + for (e in MethodAccessExpression(__all_data__)) { + if (self.key_eq(e)) { + if (e.getReference().key_eq(i.getParent())) { + if (m = i.getName()) { + return m + } + } + } + } + for (e in MethodReferenceExpression(__all_data__)) { + if (self.key_eq(e)) { + if (e.key_eq(i.getParent())) { + if (m = i.getName()) { + return m + } + } + } + } + } + } + } + + pub fn getCallSite(self) -> ReferenceExpression { + for (e in ReferenceExpression(__all_data__)) { + for (m in MethodAccessExpression(__all_data__)) { + if (self.key_eq(m)) { + if (e = m.getCallSite()) { + return e + } + } + } + for (m in MethodReferenceExpression(__all_data__)) { + if (self.key_eq(m)) { + if (e = m.getReference()) { + return e + } + } + } + } + } + + pub fn getReference(self) -> ReferenceExpression { + for (e in ReferenceExpression(__all_data__)) { + for (m in MethodAccessExpression(__all_data__)) { + if (self.key_eq(m)) { + if (e = m.getReference()) { + return e + } + } + } + for (m in MethodReferenceExpression(__all_data__)) { + if (self.key_eq(m)) { + if (e = m.getReference()) { + return e + } + } + } + } + } + + pub fn getCallSiteDefinition(self) -> ClassOrInterface { + for (c in ClassOrInterface(__all_data__), + r in ReferenceExpression(__all_data__)) { + if (r = self.getCallSite()) { + if (c.key_eq(r.getDefinition())) { + return c + } + for (v in Variable(__all_data__)) { + if (v.key_eq(r.getDefinition())) { + if (v.getType().getQualifiedName() = c.getQualifiedName()) { + return c + } + } + } + } + } + } + + pub fn getLombokField(self) -> LombokField { + for (f in LombokField(__all_data__)) { + if (self.getCallSiteDefinition() = f.getParent()) { + for (auto_tmp1 in f.getLombokMethodName()) { + if (auto_tmp1 = self.getMethodName()) { + return f + } + } + } + } + } + + pub fn getArguments(self) -> *Expression { + for (e in Expression(__all_data__), + m in MethodAccessExpression(__all_data__), + l in ExpressionListExpressionRelation(__all_data__)) { + if (self.key_eq(m)) { + if (m.getExpressionList() = l.getExpressionList()) { + if (e = l.getExpression()) { + yield e + } + for (auto_tmp1 in e.getAnAncestor()) { + if (l.getExpression().key_eq(auto_tmp1)) { + yield e + } + } + } + } + } + } + + +} + +schema LombokField extends Field { + +} + +impl LombokField { + + @data_constraint + @inline + pub fn __all__(db: JavaDB) -> *LombokField { + for (tmp in Field(db)) { + for (a in Annotation(db)) { + for (auto_tmp2 in tmp.getAnnotation()) { + if (a = auto_tmp2) { + if (a.getName() = "Data") { + yield LombokField { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + printable_text : tmp.printable_text, + location_hash_id : tmp.location_hash_id + } + } + if (a.getName() = "Getter") { + yield LombokField { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + printable_text : tmp.printable_text, + location_hash_id : tmp.location_hash_id + } + } + if (a.getName() = "Setter") { + yield LombokField { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + printable_text : tmp.printable_text, + location_hash_id : tmp.location_hash_id + } + } + } + } + for (c in ClassOrInterface(db)) { + if (c = tmp.getParent()) { + for (auto_tmp3 in c.getAnnotation()) { + if (a = auto_tmp3) { + if (a.getName() = "Data") { + yield LombokField { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + printable_text : tmp.printable_text, + location_hash_id : tmp.location_hash_id + } + } + if (a.getName() = "Getter") { + yield LombokField { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + printable_text : tmp.printable_text, + location_hash_id : tmp.location_hash_id + } + } + if (a.getName() = "Setter") { + yield LombokField { + element_hash_id : tmp.element_hash_id, + name : tmp.name, + parent_hash_id : tmp.parent_hash_id, + printable_text : tmp.printable_text, + location_hash_id : tmp.location_hash_id + } + } + } + } + } + } + } + } + } + + pub fn getLombokMethodName(self) -> *string { + for (name in string::__undetermined_all__()) { + for (l in int::__undetermined_all__(), + i in int::__undetermined_all__(), + temp in string::__undetermined_all__(), + p in string::__undetermined_all__(), + j in string::__undetermined_all__()) { + if (temp = self.getName()) { + if (i = temp.len()) { + if (l = temp.substr(0,1)) { + if (p = temp.substr(1,i)) { + if (lowerToUpper(l, j)) { + if (name = "set" + j + p) { + yield name + } + if (name = "get" + j + p) { + yield name + } + } + } + } + } + } + } + } + } + + +} + +pub fn isDirectCall(e: CallExpression) -> bool { + let (java_db = default_java_db()) { + for (s in ExpressionStatement(java_db)) { + if (s.key_eq(e.getParent())) { + 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)) { + 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 tmp_0(n: string) -> bool { + let (java_db = default_java_db()) { + if (n.matches("get.*")) { + return true + } + } +} + +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..205604c --- /dev/null +++ b/example/icse25/rules/ecgformybatis.gdl @@ -0,0 +1,248 @@ +// script +use coref::xml::* +schema SqlXmlElement extends XmlElement { + +} + +impl SqlXmlElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *SqlXmlElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "sql") { + yield SqlXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getContent(self) -> string { + for (n in string::__undetermined_all__()) { + for (c in XmlCharacter(__all_data__)) { + if (self.key_eq(c.getBelongedElement())) { + if (n = c.getText()) { + return n + } + } + } + } + } + + +} + +schema SqlIncludeElement extends XmlElement { + +} + +impl SqlIncludeElement { + + @data_constraint + @inline + 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 + } + } + } + } + + +} + +schema DalXmlElement extends XmlElement { + +} + +impl DalXmlElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *DalXmlElement { + for (tmp in XmlElement(db)) { + if (tmp.getName() = "select") { + yield DalXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + if (tmp.getName() = "update") { + yield DalXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + if (tmp.getName() = "insert") { + yield DalXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + if (tmp.getName() = "delete") { + yield DalXmlElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + + pub fn getTableName(self) -> *string { + for (name in string::__undetermined_all__()) { + for (temp in string::__undetermined_all__()) { + for (c in XmlCharacter(__all_data__)) { + if (self.key_eq(c.getBelongedElement())) { + if (temp = c.getText()) { + if (self.getName() = "update") { + if (temp.contains("update ")) { + if (name = temp.get_regex_match_result("[\\s\\S]*update[ \\t]+(\\w+)[\\s\\S]*", 1)) { + yield name + } + } + } + if (self.getName() = "insert") { + if (temp.contains("insert into ")) { + if (name = temp.get_regex_match_result("[\\s\\S]*insert into[ \\t]+(\\w+)[\\s\\S]*", 1)) { + yield name + } + } + } + if (self.getName() = "delete") { + if (temp.contains("delete from ")) { + if (name = temp.get_regex_match_result("[\\s\\S]*delete from[ \\t]+(\\w+)[\\s\\S]*", 1)) { + yield name + } + } + } + if (self.getName() = "select") { + if (temp.contains("from ")) { + if (name = temp.get_regex_match_result("[\\s\\S]*from[ \\t]+(\\w+)[\\s\\S]*", 1)) { + yield name + } + } + if (temp.contains("FROM")) { + for (temp1 in string::__undetermined_all__()) { + if (temp1 = temp.get_regex_match_result("[\\s\\S]*FROM[\\s\\S][ \\t]+(\\w+)[\\s\\S]*", 1)) { + if (tmp_0(temp1)) { + if (name = temp1) { + yield name + } + } + if (!(tmp_0(temp1))) { + if (name = temp.get_regex_match_result("[\\s\\S]*FROM[ \\t]+(\\w+)[\\s\\S]*", 1)) { + yield name + } + } + } + } + } + } + } + } + } + } + } + } + + pub fn getColumnLists(self) -> string { + for (c in string::__undetermined_all__()) { + if (self.getName() = "select") { + for (i in SqlIncludeElement(__all_data__), + x in SqlXmlElement(__all_data__)) { + if (self.key_eq(i.getParent())) { + if (i.getLocation().getFile() = x.getLocation().getFile()) { + if (i.getValueByAttributeName("refid") = x.getValueByAttributeName("id")) { + if (c = x.getContent()) { + return c + } + } + } + } + } + for (temp in string::__undetermined_all__()) { + for (x in XmlCharacter(__all_data__)) { + if (self.key_eq(x.getBelongedElement())) { + if (temp = x.getText()) { + if (temp.contains("SELECT")) { + if (c = temp) { + return c + } + } + } + } + } + } + } + if (self.getName() = "delete") { + if (c = "") { + return c + } + } + if (self.getName() = "insert") { + if (c = "") { + return c + } + } + if (self.getName() = "update") { + if (c = "") { + return c + } + } + } + } + + +} + +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..7471de7 --- /dev/null +++ b/example/icse25/rules/ecgforpom.gdl @@ -0,0 +1,341 @@ +// script +use coref::xml::* +schema ECGXmlNode { + @primary id: int +} + +impl ECGXmlNode { + + @data_constraint + @inline + 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 PomFile extends XmlFile { + +} + +impl PomFile { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *PomFile { + for (tmp in XmlFile(db)) { + if (tmp.getFileName() = "pom.xml") { + yield PomFile { + id : tmp.id, + file_name : tmp.file_name, + relative_path : tmp.relative_path + } + } + } + } + + +} + +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 (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..eee7890 --- /dev/null +++ b/example/icse25/rules/ecgxml.gdl @@ -0,0 +1,627 @@ +// 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 XmlSpringElement extends XmlElement { + +} + +impl XmlSpringElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *XmlSpringElement { + for (tmp in XmlElement(db)) { + for (e in BeanElement(db)) { + if (tmp.key_eq(e)) { + yield XmlSpringElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in ImportElement(db)) { + if (tmp.key_eq(e)) { + yield XmlSpringElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in MapElement(db)) { + if (tmp.key_eq(e)) { + yield XmlSpringElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in EntryElement(db)) { + if (tmp.key_eq(e)) { + yield XmlSpringElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in ValueElement(db)) { + if (tmp.key_eq(e)) { + yield XmlSpringElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in PropertyElement(db)) { + if (tmp.key_eq(e)) { + yield XmlSpringElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + } + } + + +} + +schema PomFile extends XmlFile { + +} + +impl PomFile { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *PomFile { + for (tmp in XmlFile(db)) { + if (tmp.getFileName() = "pom.xml") { + yield PomFile { + id : tmp.id, + file_name : tmp.file_name, + relative_path : tmp.relative_path + } + } + } + } + + +} + +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 (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 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 XmlPomElement extends XmlElement { + +} + +impl XmlPomElement { + + @data_constraint + @inline + pub fn __all__(db: XmlDB) -> *XmlPomElement { + for (tmp in XmlElement(db)) { + for (e in ArtifactElement(db)) { + if (tmp.key_eq(e)) { + yield XmlPomElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in PropertyInPomElement(db)) { + if (tmp.key_eq(e)) { + yield XmlPomElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in VersionElement(db)) { + if (tmp.key_eq(e)) { + yield XmlPomElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in GroupElement(db)) { + if (tmp.key_eq(e)) { + yield XmlPomElement { + id : tmp.id, + parent_id : tmp.parent_id, + index_order : tmp.index_order, + location_id : tmp.location_id + } + } + } + for (e in DependencyElement(db)) { + if (tmp.key_eq(e)) { + yield XmlPomElement { + 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 { + + @data_constraint + @inline + 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 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 tmp_0(dependencyCharacterText: string) -> bool { + let (xml_db = default_xml_db()) { + if (dependencyCharacterText.contains("${")) { + return true + } + } +} + +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..859b516 --- /dev/null +++ b/example/icse25/rules/rule1.gdl @@ -0,0 +1,340 @@ +// script +use coref::java::* +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: int) -> 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.element_hash_id) { + 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 { + let (java_db = default_java_db()) { + 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..4860524 --- /dev/null +++ b/example/icse25/rules/rule10.gdl @@ -0,0 +1,460 @@ +// 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, fileName: string, lineNumber: int, c: int) -> 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().id) { + return true + } + } + } + } + } + if (!(tmp_0(className))) { + if (methodName = "null") { + if (fileName = "null") { + if (lineNumber = 0) { + if (c = 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: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (i in TrInterface(java_db)) { + if (c = i.getCallable().id) { + 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 = e.getEnclosingCallable().id) { + return true + } + } + } + } + } + } + if (!(tmp_1(c))) { + if (fileName = "null") { + if (lineNumber = 0) { + if (c = 0) { + return true + } + } + } + } + } + } + } + } + } + } +} +pub fn getJavaECGNode(id: int) -> bool { + #javaecgnode + // example + // [ {1111} ] +} +pub fn getDependsECGNode(id: int, c: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getJavaECGNode(c)) { + if (id = c.getAnAncestorCallee()) { + return true + } + if (id = c) { + return true + } + } + } + } +} +pub fn real_output(bindingType: string, uniqueId: string, interfaceName: string, methodName: string, filePath: string, lineNumber: int, ecgNodeId: int) -> 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: int) -> 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..5a5e91c --- /dev/null +++ b/example/icse25/rules/rule13.gdl @@ -0,0 +1,598 @@ +// 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 + } + } + } + } + } +} +pub fn isAnonymousMethod(c: CallableNew) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (a in AnonymousMethod(java_db)) { + if (c.key_eq(a)) { + 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..67f2ed5 --- /dev/null +++ b/example/icse25/rules/rule14.gdl @@ -0,0 +1,402 @@ +// 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()) { + for (argumentCount in int::__undetermined_all__()) { + for (auto_tmp1 in callExpression.getArgumentCount()) { + if (argumentCount = auto_tmp1) { + 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()) { + for (argumentCount in int::__undetermined_all__()) { + for (auto_tmp1 in callExpression.getArgumentCount()) { + if (argumentCount = auto_tmp1) { + 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()) { + for (argumentCount in int::__undetermined_all__()) { + for (auto_tmp1 in callExpression.getArgumentCount()) { + if (argumentCount = auto_tmp1) { + 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..8a55f15 --- /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)) { + if (getAField(returnClass, rootField, __all_data__, __all_data__)) { + if (getADescendantField(rootField, Field(java_db).find(outerFieldId), 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..632912f --- /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)) { + 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)) { + if (getAField(returnClass, rootField, __all_data__, __all_data__)) { + if (getADescendantField(rootField, Field(java_db).find(outerFieldId), 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..18d4773 --- /dev/null +++ b/example/icse25/rules/rule18.gdl @@ -0,0 +1,156 @@ +// 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..bc9406d --- /dev/null +++ b/example/icse25/rules/rule19.gdl @@ -0,0 +1,393 @@ +// 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()) { + for (argumentCount in int::__undetermined_all__()) { + for (auto_tmp1 in callExpression.getArgumentCount()) { + if (argumentCount = auto_tmp1) { + 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()) { + for (argumentCount in int::__undetermined_all__()) { + for (auto_tmp1 in callExpression.getArgumentCount()) { + if (argumentCount = auto_tmp1) { + 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()) { + for (argumentCount in int::__undetermined_all__()) { + for (auto_tmp1 in callExpression.getArgumentCount()) { + if (argumentCount = auto_tmp1) { + 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..274aa8b --- /dev/null +++ b/example/icse25/rules/rule1_4.gdl @@ -0,0 +1,1261 @@ +// script +use coref::java::* +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: int) -> 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.element_hash_id) { + 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: int, index: int, result: 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 (result = 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 (result = reStr + currStr) { + return true + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: int) -> string { + let (java_db = default_java_db()) { + for (c in int::__undetermined_all__(), + result in string::__undetermined_all__()) { + if (c = tmp_25(ID).len()) { + if (connectStrBase(ID, c - 1, result)) { + return result + } + } + } + } +} +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 { + let (java_db = default_java_db()) { + 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 + } + } + } +} + +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 + } + } + } +} + +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: int) -> *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: int) -> *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..74a79fa --- /dev/null +++ b/example/icse25/rules/rule1_5.gdl @@ -0,0 +1,445 @@ +// script +use coref::java::* +use coref::xml::* +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 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: int) -> 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.element_hash_id) { + 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 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + 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..b9e82e2 --- /dev/null +++ b/example/icse25/rules/rule1_5_6.gdl @@ -0,0 +1,848 @@ +// script +use coref::java::* +use coref::xml::* +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 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: int) -> 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.element_hash_id) { + 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 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + 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..19ec048 --- /dev/null +++ b/example/icse25/rules/rule1_7_8.gdl @@ -0,0 +1,898 @@ +// script +use coref::java::* +use coref::xml::* +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 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: int) -> 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.element_hash_id) { + 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: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in int::__undetermined_all__(), + n in string::__undetermined_all__(), + m in string::__undetermined_all__()) { + for (r in ECGXmlNode(xml_db)) { + if (getXmlECGNode1(r)) { + if (getChangeSetByDalXmlElement(r, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(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 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + 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..3ba6a60 --- /dev/null +++ b/example/icse25/rules/rule2.gdl @@ -0,0 +1,180 @@ +// script +use coref::java::* +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 = 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)) { + 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)) { + 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..2aa7265 --- /dev/null +++ b/example/icse25/rules/rule3.gdl @@ -0,0 +1,57 @@ +// script +use coref::java::* +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)) { + 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..f4656d5 --- /dev/null +++ b/example/icse25/rules/rule4.gdl @@ -0,0 +1,937 @@ +// script +use coref::java::* +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: int, index: int, result: 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 (result = 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 (result = reStr + currStr) { + return true + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: int) -> string { + let (java_db = default_java_db()) { + for (c in int::__undetermined_all__(), + result in string::__undetermined_all__()) { + if (c = tmp_22(ID).len()) { + if (connectStrBase(ID, c - 1, result)) { + return result + } + } + } + } +} +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)) { + 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 + } + } + } +} + +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 + } + } + } +} + +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: int) -> *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: int) -> *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/rule5.gdl b/example/icse25/rules/rule5.gdl new file mode 100644 index 0000000..7b5d7bc --- /dev/null +++ b/example/icse25/rules/rule5.gdl @@ -0,0 +1,58 @@ +// script +use coref::xml::* +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..504837c --- /dev/null +++ b/example/icse25/rules/rule6.gdl @@ -0,0 +1,449 @@ +// script +use coref::java::* +use coref::xml::* +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)) { + 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(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..36702ba --- /dev/null +++ b/example/icse25/rules/rule6_8_no_xml.gdl @@ -0,0 +1,1015 @@ +// script +use coref::java::* +use coref::xml::* +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 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: int) -> 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.element_hash_id) { + 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: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in int::__undetermined_all__(), + n in string::__undetermined_all__(), + m in string::__undetermined_all__()) { + for (r in ECGXmlNode(xml_db)) { + if (getXmlECGNode1(r)) { + if (getChangeSetByDalXmlElement(r, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(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 int::__undetermined_all__()) { + for (c in ClassOrInterface(java_db)) { + if (output2(c, interfaceName, ECGNode(java_db).find(n))) { + return true + } + if (output1(c, 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(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 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + 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..6af947b --- /dev/null +++ b/example/icse25/rules/rule6_8_spring.gdl @@ -0,0 +1,808 @@ +// script +use coref::java::* +use coref::xml::* +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 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: int) -> 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.element_hash_id) { + 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: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in int::__undetermined_all__(), + n in string::__undetermined_all__(), + m in string::__undetermined_all__()) { + for (r in ECGXmlNode(xml_db)) { + if (getXmlECGNode1(r)) { + if (getChangeSetByDalXmlElement(r, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(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 int::__undetermined_all__()) { + for (c in ClassOrInterface(java_db)) { + if (output2(c, interfaceName, ECGNode(java_db).find(n))) { + return true + } + if (output1(c, 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(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 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + 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..83643c1 --- /dev/null +++ b/example/icse25/rules/rule7.gdl @@ -0,0 +1,133 @@ +// script +use coref::java::* +use coref::xml::* +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: int, f: int, n: string, m: string) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + if (getXmlECGNode(r)) { + if (getChangeSetByDalXmlElement(r, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(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)) { + 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)) { + 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..a6b468b --- /dev/null +++ b/example/icse25/rules/rule8.gdl @@ -0,0 +1,382 @@ +// script +use coref::java::* +use coref::xml::* +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)) { + 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(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..0727412 --- /dev/null +++ b/example/icse25/rules/rule9.gdl @@ -0,0 +1,872 @@ +// 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: int, index: int, result: 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 (result = 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 (result = reStr + currStr) { + return true + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: int) -> string { + let (java_db = default_java_db()) { + for (c in int::__undetermined_all__(), + result in string::__undetermined_all__()) { + if (c = tmp_22(ID).len()) { + if (connectStrBase(ID, c - 1, result)) { + return result + } + } + } + } +} +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 + } + } + } +} + +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 + } + } + } +} + +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: int) -> *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: int) -> *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..07a45dd --- /dev/null +++ b/example/icse25/rules/rule_ecg.gdl @@ -0,0 +1,1778 @@ +// script +use coref::java::* +use coref::xml::* +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 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: int) -> 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.element_hash_id) { + 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: int) -> bool { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in int::__undetermined_all__(), + n in string::__undetermined_all__(), + m in string::__undetermined_all__()) { + for (r in ECGXmlNode(xml_db)) { + if (getXmlECGNode1(r)) { + if (getChangeSetByDalXmlElement(r, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + return true + } + if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(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: int, index: int, result: 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 (result = 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 (result = reStr + currStr) { + return true + } + } + } + } + } + } + } + } + } +} +pub fn connectStr(ID: int) -> string { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + for (c in int::__undetermined_all__(), + result in string::__undetermined_all__()) { + if (c = tmp_25(ID).len()) { + if (connectStrBase(ID, c - 1, result)) { + return result + } + } + } + } + } +} +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)) { + 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 { + let (java_db = default_java_db()) { + let (xml_db = default_xml_db()) { + 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 + } + } + } + } +} + +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 + } + } + } + } +} + +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: int) -> *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: int) -> *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..83ebee8 --- /dev/null +++ b/example/icse25/rules/test.gdl @@ -0,0 +1,385 @@ +// script +use coref::java::* +use coref::xml::* +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)) { + 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(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 From c201d5211f7d2d0fc75e846fc2710908e9337355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=95=E5=B1=B1?= Date: Mon, 28 Apr 2025 15:38:42 +0800 Subject: [PATCH 2/5] fix some compilation failures --- .../icse25/Keymap/FindAllReleasedHttpAPI.gdl | 10 +- .../icse25/Keymap/FindAllReleasedTrAPI.gdl | 351 ------------- example/icse25/rules/ecg.gdl | 357 ++----------- example/icse25/rules/ecgformybatis.gdl | 196 +------ example/icse25/rules/ecgforpom.gdl | 57 +- example/icse25/rules/ecgxml.gdl | 185 +------ example/icse25/rules/rule1.gdl | 4 +- example/icse25/rules/rule10.gdl | 14 +- example/icse25/rules/rule13.gdl | 16 +- example/icse25/rules/rule14.gdl | 31 +- example/icse25/rules/rule15.gdl | 6 +- example/icse25/rules/rule17.gdl | 8 +- example/icse25/rules/rule18.gdl | 6 +- example/icse25/rules/rule19.gdl | 30 +- example/icse25/rules/rule1_4.gdl | 486 +++++++++++++++++- example/icse25/rules/rule1_5.gdl | 4 +- example/icse25/rules/rule1_5_6.gdl | 472 ++++++++++++++++- example/icse25/rules/rule1_7_8.gdl | 4 +- example/icse25/rules/rule2.gdl | 4 +- example/icse25/rules/rule3.gdl | 4 +- example/icse25/rules/rule4.gdl | 4 +- example/icse25/rules/rule5.gdl | 4 +- example/icse25/rules/rule6.gdl | 8 +- example/icse25/rules/rule6_8_no_xml.gdl | 4 +- example/icse25/rules/rule6_8_spring.gdl | 4 +- example/icse25/rules/rule7.gdl | 4 +- example/icse25/rules/rule8.gdl | 8 +- example/icse25/rules/rule_ecg.gdl | 5 +- example/icse25/rules/test.gdl | 472 ++++++++++++++++- 29 files changed, 1538 insertions(+), 1220 deletions(-) diff --git a/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl index bb3974c..24abfae 100644 --- a/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl +++ b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl @@ -576,7 +576,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: int, index: int, result: string) -> bool { +pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { let (xml_db = default_xml_db()) { let (java_db = default_java_db()) { for (total in int::__undetermined_all__(), @@ -606,7 +606,7 @@ pub fn connectStrBase(ID: int, index: int, result: string) -> bool { } } } -pub fn connectStr(ID: int) -> string { +pub fn connectStr(ID: Expression) -> string { let (xml_db = default_xml_db()) { let (java_db = default_java_db()) { for (c in int::__undetermined_all__(), @@ -962,6 +962,7 @@ fn tmp_6(b: string, a: string) -> bool { } } +@inline fn tmp_7(b: string, i: int, a: string) -> bool { let (xml_db = default_xml_db()) { let (java_db = default_java_db()) { @@ -974,6 +975,7 @@ fn tmp_7(b: string, i: int, a: string) -> bool { } } +@inline fn tmp_8(b: string, i: int, a: string) -> bool { let (xml_db = default_xml_db()) { let (java_db = default_java_db()) { @@ -1210,7 +1212,7 @@ fn tmp_28(e: Expression) -> bool { } } -fn tmp_29(ID: int) -> *auto_tmp_30 { +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__(), @@ -1241,7 +1243,7 @@ fn tmp_31(index: int) -> bool { } } -fn tmp_32(ID: int) -> *auto_tmp_33 { +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__(), diff --git a/example/icse25/Keymap/FindAllReleasedTrAPI.gdl b/example/icse25/Keymap/FindAllReleasedTrAPI.gdl index abf92fa..e9a6bf4 100644 --- a/example/icse25/Keymap/FindAllReleasedTrAPI.gdl +++ b/example/icse25/Keymap/FindAllReleasedTrAPI.gdl @@ -183,357 +183,6 @@ pub fn javaOutput(classname: string, name: string, uniqueId: string, type: strin } } } -schema SofaServiceXmlElement extends XmlElement { - -} - -impl SofaServiceXmlElement { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *SofaServiceXmlElement { - for (tmp in XmlElement(db)) { - if (tmp.getName() = "sofa:service") { - yield SofaServiceXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - - pub fn getRef(self) -> string { - for (value in string::__undetermined_all__()) { - for (e in XmlAttribute(__all_data__)) { - for (auto_tmp1 in self.getAttribute()) { - if (e = auto_tmp1) { - if (e.getName() = "ref") { - if (value = e.getValue()) { - return value - } - } - } - } - } - } - } - - pub fn getInterfaceName(self) -> string { - for (value in string::__undetermined_all__()) { - for (e in XmlAttribute(__all_data__)) { - for (auto_tmp1 in self.getAttribute()) { - if (e = auto_tmp1) { - if (e.getName() = "interface") { - if (value = e.getValue()) { - return value - } - } - } - } - } - } - } - - pub fn getUniqueId(self) -> string { - for (value in string::__undetermined_all__()) { - for (x in SofaServiceXmlElement(__all_data__)) { - if (self = x) { - if (tmp_5(x)) { - for (e in XmlAttribute(__all_data__)) { - for (auto_tmp1 in self.getAttribute()) { - if (e = auto_tmp1) { - if (e.getName() = "unique-id") { - if (value = e.getValue()) { - return value - } - } - if (e.getName() = "uniqueId") { - if (value = e.getValue()) { - return value - } - } - } - } - } - } - if (!(tmp_5(x))) { - if (value = "null") { - return value - } - } - } - } - } - } - - pub fn getSingleBindingType(self) -> *string { - for (value in string::__undetermined_all__()) { - for (t in TagXmlElement(__all_data__)) { - if (self.key_eq(t.getParent())) { - if (value = t.getTag()) { - yield value - } - } - } - } - } - - pub fn getMultiBindingType(self) -> string { - for (value in string::__undetermined_all__(), - s1 in string::__undetermined_all__(), - s2 in string::__undetermined_all__()) { - for (x1 in TagXmlElement(__all_data__), - x2 in TagXmlElement(__all_data__)) { - if (self.key_eq(x1.getParent())) { - if (self.key_eq(x2.getParent())) { - if (x1 > x2) { - if (s1 = x1.getTag()) { - if (s2 = x2.getTag()) { - if (value = s1 + "_" + s2) { - return value - } - } - } - } - } - } - } - } - } - - pub fn getBindingType(self) -> string { - for (num in int::__undetermined_all__(), - value in string::__undetermined_all__()) { - if (num = tmp_6(self).len()) { - if (num = 1) { - for (auto_tmp1 in self.getSingleBindingType()) { - if (value = auto_tmp1) { - return value - } - } - } - if (num = 2) { - if (value = self.getMultiBindingType()) { - return value - } - } - } - } - } - - -} - -pub fn hasUniqueIdAttribute(s: XmlElement) -> bool { - let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - for (value in string::__undetermined_all__()) { - for (auto_tmp1 in s.getAttribute()) { - if (value = auto_tmp1.getName()) { - if (value = "unique-id") { - return true - } - if (value = "uniqueId") { - return true - } - } - } - } - } - } -} -schema BeanXmlElement extends XmlElement { - -} - -impl BeanXmlElement { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *BeanXmlElement { - for (tmp in XmlElement(db)) { - if (tmp.getElementName() = "bean") { - yield BeanXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - - pub fn getId(self) -> string { - for (value in string::__undetermined_all__()) { - for (e in XmlAttribute(__all_data__)) { - for (auto_tmp1 in self.getAttribute()) { - if (e = auto_tmp1) { - if (e.getName() = "id") { - if (value = e.getValue()) { - return value - } - } - } - } - } - } - } - - pub fn getClass(self) -> string { - for (value in string::__undetermined_all__()) { - for (e in XmlAttribute(__all_data__)) { - for (auto_tmp1 in self.getAttribute()) { - if (e = auto_tmp1) { - if (e.getName() = "class") { - if (value = e.getValue()) { - return value - } - } - } - } - } - } - } - - pub fn getProperty(self) -> *PropertyXmlElement { - for (e in PropertyXmlElement(__all_data__)) { - if (self.key_eq(e.getParent())) { - yield e - } - } - } - - -} - -schema TagXmlElement extends XmlElement { - -} - -impl TagXmlElement { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *TagXmlElement { - for (tmp in XmlElement(db)) { - for (s in string::__undetermined_all__()) { - if (tmp.getName() = "sofa:binding.tr") { - if (s = tmp.getName()) { - if (s.contains("sofa:binding")) { - yield TagXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - if (tmp.getName() = "sofa:binding.ws") { - if (s = tmp.getName()) { - if (s.contains("sofa:binding")) { - yield TagXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - if (tmp.getName() = "sofa:binding.rest") { - if (s = tmp.getName()) { - if (s.contains("sofa:binding")) { - yield TagXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - if (tmp.getName() = "sofa:binding.bolt") { - if (s = tmp.getName()) { - if (s.contains("sofa:binding")) { - yield TagXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - if (tmp.getName() = "sofa:binding.tri") { - if (s = tmp.getName()) { - if (s.contains("sofa:binding")) { - yield TagXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - } - } - } - - @inline - pub fn getTag(self) -> string { - for (l in int::__undetermined_all__(), - s in string::__undetermined_all__(), - a in string::__undetermined_all__()) { - if (a = self.getName()) { - if (l = a.len()) { - if (s = a.substr(13,l)) { - return s - } - } - } - } - } - - -} - -schema PropertyXmlElement extends XmlElement { - -} - -impl PropertyXmlElement { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *PropertyXmlElement { - for (tmp in XmlElement(db)) { - if (tmp.getName() = "property") { - yield PropertyXmlElement { - 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 xmlOutput(bindingType: string, uniqueId: string, className: string, interfaceName: string) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/ecg.gdl b/example/icse25/rules/ecg.gdl index 6f4fc99..ea5a64f 100644 --- a/example/icse25/rules/ecg.gdl +++ b/example/icse25/rules/ecg.gdl @@ -1,13 +1,8 @@ // script use coref::java::* -schema ECGNode extends ElementParent { - -} +schema ECGNode extends ElementParent {} impl ECGNode { - - @data_constraint - @inline pub fn __all__(db: JavaDB) -> *ECGNode { for (tmp in ElementParent(db)) { for (m in Method(db)) { @@ -221,19 +216,21 @@ impl ECGNode { if (e.key_eq(e1)) { if (self.key_eq(c)) { if (e = c.getLombokField()) { - if (!isDirectCall(CallExpression(__all_data__).find(e))) { - if (n = c.getMethodName()) { - if (tmp_0(n)) { - if (direction = "Depended") { - if (type = "DD") { - return e1 + 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 (!(tmp_0(n))) { - if (direction = "Depends") { - if (type = "DD") { - return e1 + if (!Self::tmp_0(n)) { + if (direction = "Depends") { + if (type = "DD") { + return e1 + } } } } @@ -312,10 +309,10 @@ impl ECGNode { pub fn getAnAncestorDDNode(self, type: string, direction: string) -> ECGNode { for (e in ECGNode(__all_data__)) { if (type = "DD") { - if (e.id = getDDNode(type, direction)) { + if (e = self.getDDNode(type, direction)) { return e } - if (e.id = getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { + if (e = self.getAnAncestorDDNode(__all_data__, __all_data__).getDDNode(type, direction)) { return e } } @@ -444,330 +441,43 @@ impl ECGNode { pub fn getECGNode(self, type: string, direction: string) -> ECGNode { for (e in ECGNode(__all_data__)) { - if (e.id = getCDNode(type, direction)) { + if (e = self.getCDNode(type, direction)) { return e } - if (e.id = getDDNode(type, direction)) { + if (e = self.getDDNode(type, direction)) { return e } } } pub fn getAnAncestorECGNode(self, type: string, direction: string) -> ECGNode { - for (e in ECGNode(__all_data__), - temp in ECGNode(__all_data__)) { - if (temp = self.getAnAncestorCDNode(__all_data__, __all_data__)) { - if (e = temp.getECGNode(type, direction)) { + 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 } } } } - - -} -schema CallExpression extends Expression { - -} - -impl CallExpression { - - @data_constraint - @inline - pub fn __all__(db: JavaDB) -> *CallExpression { - for (tmp in Expression(db)) { - for (m in MethodAccessExpression(db)) { - if (tmp.key_eq(m)) { - yield CallExpression { - element_hash_id : tmp.element_hash_id, - name : tmp.name, - parent_hash_id : tmp.parent_hash_id, - index_order : tmp.index_order, - location_hash_id : tmp.location_hash_id, - printable_text : tmp.printable_text - } - } - } - for (m in MethodReferenceExpression(db)) { - if (tmp.key_eq(m)) { - yield CallExpression { - element_hash_id : tmp.element_hash_id, - name : tmp.name, - parent_hash_id : tmp.parent_hash_id, - index_order : tmp.index_order, - location_hash_id : tmp.location_hash_id, - printable_text : tmp.printable_text - } - } - } - } - } - - pub fn getMethod(self) -> Method { - for (m in Method(__all_data__)) { - for (e in MethodAccessExpression(__all_data__)) { - if (self.key_eq(e)) { - if (m = e.getMethod()) { - return m - } - } - } - for (e in MethodReferenceExpression(__all_data__)) { - if (self.key_eq(e)) { - if (m = e.getMethod()) { - return m - } - } - } - } - } - - pub fn getMethodName(self) -> string { - for (m in string::__undetermined_all__()) { - for (i in Identifier(__all_data__)) { - for (e in MethodAccessExpression(__all_data__)) { - if (self.key_eq(e)) { - if (e.getReference().key_eq(i.getParent())) { - if (m = i.getName()) { - return m - } - } - } - } - for (e in MethodReferenceExpression(__all_data__)) { - if (self.key_eq(e)) { - if (e.key_eq(i.getParent())) { - if (m = i.getName()) { - return m - } - } - } - } - } - } - } - - pub fn getCallSite(self) -> ReferenceExpression { - for (e in ReferenceExpression(__all_data__)) { - for (m in MethodAccessExpression(__all_data__)) { - if (self.key_eq(m)) { - if (e = m.getCallSite()) { - return e - } - } - } - for (m in MethodReferenceExpression(__all_data__)) { - if (self.key_eq(m)) { - if (e = m.getReference()) { - return e - } - } - } - } - } - - pub fn getReference(self) -> ReferenceExpression { - for (e in ReferenceExpression(__all_data__)) { - for (m in MethodAccessExpression(__all_data__)) { - if (self.key_eq(m)) { - if (e = m.getReference()) { - return e - } - } - } - for (m in MethodReferenceExpression(__all_data__)) { - if (self.key_eq(m)) { - if (e = m.getReference()) { - return e - } - } - } - } - } - - pub fn getCallSiteDefinition(self) -> ClassOrInterface { - for (c in ClassOrInterface(__all_data__), - r in ReferenceExpression(__all_data__)) { - if (r = self.getCallSite()) { - if (c.key_eq(r.getDefinition())) { - return c - } - for (v in Variable(__all_data__)) { - if (v.key_eq(r.getDefinition())) { - if (v.getType().getQualifiedName() = c.getQualifiedName()) { - return c - } - } - } - } - } - } - - pub fn getLombokField(self) -> LombokField { - for (f in LombokField(__all_data__)) { - if (self.getCallSiteDefinition() = f.getParent()) { - for (auto_tmp1 in f.getLombokMethodName()) { - if (auto_tmp1 = self.getMethodName()) { - return f - } - } - } - } - } - - pub fn getArguments(self) -> *Expression { - for (e in Expression(__all_data__), - m in MethodAccessExpression(__all_data__), - l in ExpressionListExpressionRelation(__all_data__)) { - if (self.key_eq(m)) { - if (m.getExpressionList() = l.getExpressionList()) { - if (e = l.getExpression()) { - yield e - } - for (auto_tmp1 in e.getAnAncestor()) { - if (l.getExpression().key_eq(auto_tmp1)) { - yield e - } - } - } - } - } - } - - -} - -schema LombokField extends Field { - -} - -impl LombokField { - - @data_constraint - @inline - pub fn __all__(db: JavaDB) -> *LombokField { - for (tmp in Field(db)) { - for (a in Annotation(db)) { - for (auto_tmp2 in tmp.getAnnotation()) { - if (a = auto_tmp2) { - if (a.getName() = "Data") { - yield LombokField { - element_hash_id : tmp.element_hash_id, - name : tmp.name, - parent_hash_id : tmp.parent_hash_id, - printable_text : tmp.printable_text, - location_hash_id : tmp.location_hash_id - } - } - if (a.getName() = "Getter") { - yield LombokField { - element_hash_id : tmp.element_hash_id, - name : tmp.name, - parent_hash_id : tmp.parent_hash_id, - printable_text : tmp.printable_text, - location_hash_id : tmp.location_hash_id - } - } - if (a.getName() = "Setter") { - yield LombokField { - element_hash_id : tmp.element_hash_id, - name : tmp.name, - parent_hash_id : tmp.parent_hash_id, - printable_text : tmp.printable_text, - location_hash_id : tmp.location_hash_id - } - } - } - } - for (c in ClassOrInterface(db)) { - if (c = tmp.getParent()) { - for (auto_tmp3 in c.getAnnotation()) { - if (a = auto_tmp3) { - if (a.getName() = "Data") { - yield LombokField { - element_hash_id : tmp.element_hash_id, - name : tmp.name, - parent_hash_id : tmp.parent_hash_id, - printable_text : tmp.printable_text, - location_hash_id : tmp.location_hash_id - } - } - if (a.getName() = "Getter") { - yield LombokField { - element_hash_id : tmp.element_hash_id, - name : tmp.name, - parent_hash_id : tmp.parent_hash_id, - printable_text : tmp.printable_text, - location_hash_id : tmp.location_hash_id - } - } - if (a.getName() = "Setter") { - yield LombokField { - element_hash_id : tmp.element_hash_id, - name : tmp.name, - parent_hash_id : tmp.parent_hash_id, - printable_text : tmp.printable_text, - location_hash_id : tmp.location_hash_id - } - } - } - } - } - } - } - } - } - - pub fn getLombokMethodName(self) -> *string { - for (name in string::__undetermined_all__()) { - for (l in int::__undetermined_all__(), - i in int::__undetermined_all__(), - temp in string::__undetermined_all__(), - p in string::__undetermined_all__(), - j in string::__undetermined_all__()) { - if (temp = self.getName()) { - if (i = temp.len()) { - if (l = temp.substr(0,1)) { - if (p = temp.substr(1,i)) { - if (lowerToUpper(l, j)) { - if (name = "set" + j + p) { - yield name - } - if (name = "get" + j + p) { - yield name - } - } - } - } - } - } - } + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true } } - - } -pub fn isDirectCall(e: CallExpression) -> bool { - let (java_db = default_java_db()) { - for (s in ExpressionStatement(java_db)) { - if (s.key_eq(e.getParent())) { - return true - } - } - } -} pub fn getNode(node: int) -> bool { [ - {-6062664004747450091}, - {-8976777526123968441}, - {-7423165299222302626} + // {-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)) { + if (getNode(a.id)) { if (b = a.getAnAncestorCDNode(__all_data__, __all_data__)) { if (c = b.getECGNode(edgeType, direction)) { return true @@ -781,6 +491,7 @@ pub fn temp(a: ECGNode, b: ECGNode, c: ECGNode, edgeType: string, direction: str } } } + 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)) { @@ -804,14 +515,6 @@ 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.matches("get.*")) { - return true - } - } -} - 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 index 205604c..f13eb58 100644 --- a/example/icse25/rules/ecgformybatis.gdl +++ b/example/icse25/rules/ecgformybatis.gdl @@ -1,49 +1,9 @@ // script use coref::xml::* -schema SqlXmlElement extends XmlElement { - -} - -impl SqlXmlElement { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *SqlXmlElement { - for (tmp in XmlElement(db)) { - if (tmp.getName() = "sql") { - yield SqlXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - - pub fn getContent(self) -> string { - for (n in string::__undetermined_all__()) { - for (c in XmlCharacter(__all_data__)) { - if (self.key_eq(c.getBelongedElement())) { - if (n = c.getText()) { - return n - } - } - } - } - } - - -} -schema SqlIncludeElement extends XmlElement { - -} +schema SqlIncludeElement extends XmlElement {} impl SqlIncludeElement { - - @data_constraint - @inline pub fn __all__(db: XmlDB) -> *SqlIncludeElement { for (tmp in XmlElement(db)) { if (tmp.getName() = "include") { @@ -56,160 +16,6 @@ impl SqlIncludeElement { } } } - - -} - -schema DalXmlElement extends XmlElement { - -} - -impl DalXmlElement { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *DalXmlElement { - for (tmp in XmlElement(db)) { - if (tmp.getName() = "select") { - yield DalXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - if (tmp.getName() = "update") { - yield DalXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - if (tmp.getName() = "insert") { - yield DalXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - if (tmp.getName() = "delete") { - yield DalXmlElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - - pub fn getTableName(self) -> *string { - for (name in string::__undetermined_all__()) { - for (temp in string::__undetermined_all__()) { - for (c in XmlCharacter(__all_data__)) { - if (self.key_eq(c.getBelongedElement())) { - if (temp = c.getText()) { - if (self.getName() = "update") { - if (temp.contains("update ")) { - if (name = temp.get_regex_match_result("[\\s\\S]*update[ \\t]+(\\w+)[\\s\\S]*", 1)) { - yield name - } - } - } - if (self.getName() = "insert") { - if (temp.contains("insert into ")) { - if (name = temp.get_regex_match_result("[\\s\\S]*insert into[ \\t]+(\\w+)[\\s\\S]*", 1)) { - yield name - } - } - } - if (self.getName() = "delete") { - if (temp.contains("delete from ")) { - if (name = temp.get_regex_match_result("[\\s\\S]*delete from[ \\t]+(\\w+)[\\s\\S]*", 1)) { - yield name - } - } - } - if (self.getName() = "select") { - if (temp.contains("from ")) { - if (name = temp.get_regex_match_result("[\\s\\S]*from[ \\t]+(\\w+)[\\s\\S]*", 1)) { - yield name - } - } - if (temp.contains("FROM")) { - for (temp1 in string::__undetermined_all__()) { - if (temp1 = temp.get_regex_match_result("[\\s\\S]*FROM[\\s\\S][ \\t]+(\\w+)[\\s\\S]*", 1)) { - if (tmp_0(temp1)) { - if (name = temp1) { - yield name - } - } - if (!(tmp_0(temp1))) { - if (name = temp.get_regex_match_result("[\\s\\S]*FROM[ \\t]+(\\w+)[\\s\\S]*", 1)) { - yield name - } - } - } - } - } - } - } - } - } - } - } - } - - pub fn getColumnLists(self) -> string { - for (c in string::__undetermined_all__()) { - if (self.getName() = "select") { - for (i in SqlIncludeElement(__all_data__), - x in SqlXmlElement(__all_data__)) { - if (self.key_eq(i.getParent())) { - if (i.getLocation().getFile() = x.getLocation().getFile()) { - if (i.getValueByAttributeName("refid") = x.getValueByAttributeName("id")) { - if (c = x.getContent()) { - return c - } - } - } - } - } - for (temp in string::__undetermined_all__()) { - for (x in XmlCharacter(__all_data__)) { - if (self.key_eq(x.getBelongedElement())) { - if (temp = x.getText()) { - if (temp.contains("SELECT")) { - if (c = temp) { - return c - } - } - } - } - } - } - } - if (self.getName() = "delete") { - if (c = "") { - return c - } - } - if (self.getName() = "insert") { - if (c = "") { - return c - } - } - if (self.getName() = "update") { - if (c = "") { - return c - } - } - } - } - - } pub fn real_output(id: string, type: string, table: string, columns: string) -> bool { diff --git a/example/icse25/rules/ecgforpom.gdl b/example/icse25/rules/ecgforpom.gdl index 7471de7..a495718 100644 --- a/example/icse25/rules/ecgforpom.gdl +++ b/example/icse25/rules/ecgforpom.gdl @@ -5,9 +5,6 @@ schema ECGXmlNode { } impl ECGXmlNode { - - @data_constraint - @inline pub fn __all__(db: XmlDB) -> *ECGXmlNode { for (e in XmlElement(db)) { yield ECGXmlNode {id : e.id} @@ -70,42 +67,12 @@ impl ECGXmlNode { } } } - } - - -} - -schema PomFile extends XmlFile { - -} - -impl PomFile { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *PomFile { - for (tmp in XmlFile(db)) { - if (tmp.getFileName() = "pom.xml") { - yield PomFile { - id : tmp.id, - file_name : tmp.file_name, - relative_path : tmp.relative_path - } - } - } - } - - + } } -schema DependencyElement extends XmlElement { - -} +schema DependencyElement extends XmlElement {} impl DependencyElement { - - @data_constraint - @inline pub fn __all__(db: XmlDB) -> *DependencyElement { for (tmp in XmlElement(db)) { if (tmp.getElementName() = "dependency") { @@ -118,18 +85,11 @@ impl DependencyElement { } } } - - } -schema GroupElement extends XmlElement { - -} +schema GroupElement extends XmlElement {} impl GroupElement { - - @data_constraint - @inline pub fn __all__(db: XmlDB) -> *GroupElement { for (tmp in XmlElement(db)) { if (tmp.getElementName() = "groupId") { @@ -142,18 +102,11 @@ impl GroupElement { } } } - - } -schema VersionElement extends XmlElement { - -} +schema VersionElement extends XmlElement {} impl VersionElement { - - @data_constraint - @inline pub fn __all__(db: XmlDB) -> *VersionElement { for (tmp in XmlElement(db)) { if (tmp.getElementName() = "version") { @@ -207,8 +160,6 @@ impl VersionElement { } } } - - } schema PropertyElement extends XmlElement { diff --git a/example/icse25/rules/ecgxml.gdl b/example/icse25/rules/ecgxml.gdl index eee7890..8ac5e69 100644 --- a/example/icse25/rules/ecgxml.gdl +++ b/example/icse25/rules/ecgxml.gdl @@ -160,105 +160,6 @@ impl PropertyElement { } -} - -schema XmlSpringElement extends XmlElement { - -} - -impl XmlSpringElement { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *XmlSpringElement { - for (tmp in XmlElement(db)) { - for (e in BeanElement(db)) { - if (tmp.key_eq(e)) { - yield XmlSpringElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in ImportElement(db)) { - if (tmp.key_eq(e)) { - yield XmlSpringElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in MapElement(db)) { - if (tmp.key_eq(e)) { - yield XmlSpringElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in EntryElement(db)) { - if (tmp.key_eq(e)) { - yield XmlSpringElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in ValueElement(db)) { - if (tmp.key_eq(e)) { - yield XmlSpringElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in PropertyElement(db)) { - if (tmp.key_eq(e)) { - yield XmlSpringElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - } - - -} - -schema PomFile extends XmlFile { - -} - -impl PomFile { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *PomFile { - for (tmp in XmlFile(db)) { - if (tmp.getFileName() = "pom.xml") { - yield PomFile { - id : tmp.id, - file_name : tmp.file_name, - relative_path : tmp.relative_path - } - } - } - } - - } schema DependencyElement extends XmlElement { @@ -344,7 +245,7 @@ impl VersionElement { for (dependencyCharacter in XmlCharacter(__all_data__)) { if (dependencyCharacter.getBelongedElement().key_eq(self)) { if (dependencyCharacterText = dependencyCharacter.getText()) { - if (tmp_0(dependencyCharacterText)) { + if (Self::tmp_0(dependencyCharacterText)) { for (propertyCharacterText in string::__undetermined_all__()) { for (property in PropertyElement(__all_data__), propertyCharacter in XmlCharacter(__all_data__)) { @@ -360,7 +261,7 @@ impl VersionElement { } } } - if (!(tmp_0(dependencyCharacterText))) { + if (!Self::tmp_0(dependencyCharacterText)) { if (version = dependencyCharacter.getText()) { return version } @@ -370,8 +271,12 @@ impl VersionElement { } } } - - + + fn tmp_0(dependencyCharacterText: string) -> bool { + if (dependencyCharacterText.contains("${")) { + return true + } + } } schema PropertyInPomElement extends XmlElement { @@ -420,72 +325,6 @@ impl ArtifactElement { } -} - -schema XmlPomElement extends XmlElement { - -} - -impl XmlPomElement { - - @data_constraint - @inline - pub fn __all__(db: XmlDB) -> *XmlPomElement { - for (tmp in XmlElement(db)) { - for (e in ArtifactElement(db)) { - if (tmp.key_eq(e)) { - yield XmlPomElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in PropertyInPomElement(db)) { - if (tmp.key_eq(e)) { - yield XmlPomElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in VersionElement(db)) { - if (tmp.key_eq(e)) { - yield XmlPomElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in GroupElement(db)) { - if (tmp.key_eq(e)) { - yield XmlPomElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - for (e in DependencyElement(db)) { - if (tmp.key_eq(e)) { - yield XmlPomElement { - id : tmp.id, - parent_id : tmp.parent_id, - index_order : tmp.index_order, - location_id : tmp.location_id - } - } - } - } - } - - } schema ECGXmlNode { @@ -614,14 +453,6 @@ 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 main() { output(real_output()) } \ No newline at end of file diff --git a/example/icse25/rules/rule1.gdl b/example/icse25/rules/rule1.gdl index 859b516..d0e44ea 100644 --- a/example/icse25/rules/rule1.gdl +++ b/example/icse25/rules/rule1.gdl @@ -2,9 +2,9 @@ use coref::java::* pub fn gitdiff(filePath: string, lineNo: int) -> bool { //python替换 - $gitdiff + // $gitdiff // example - // [ {"test", 1111}] + [ {"test", 1111}] } pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/rule10.gdl b/example/icse25/rules/rule10.gdl index 4860524..1b74fe7 100644 --- a/example/icse25/rules/rule10.gdl +++ b/example/icse25/rules/rule10.gdl @@ -346,11 +346,11 @@ pub fn getCallers(c: Callable) -> bool { } } } -pub fn selfDefineOutput(interfaceName: string, methodName: string, fileName: string, lineNumber: int, c: int) -> bool { +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().id) { + if (c = i.getCallable()) { if (interfaceName = i.getQualifiedName()) { if (methodName = c.getName()) { if (tmp_1(c)) { @@ -358,7 +358,7 @@ pub fn selfDefineOutput(interfaceName: string, methodName: string, fileName: str if (e = i.getCallSite(c)) { if (fileName = e.getLocation().getFile().getRelativePath()) { if (lineNumber = e.getLocation().getStartLineNumber()) { - if (c = e.getEnclosingCallable().id) { + if (c.id = e.getEnclosingCallable().id) { return true } } @@ -369,7 +369,7 @@ pub fn selfDefineOutput(interfaceName: string, methodName: string, fileName: str if (!(tmp_1(c))) { if (fileName = "null") { if (lineNumber = 0) { - if (c = 0) { + if (c.id = 0) { return true } } @@ -383,9 +383,9 @@ pub fn selfDefineOutput(interfaceName: string, methodName: string, fileName: str } } pub fn getJavaECGNode(id: int) -> bool { - #javaecgnode + // #javaecgnode // example - // [ {1111} ] + [ {1111} ] } pub fn getDependsECGNode(id: int, c: int) -> bool { let (java_db = default_java_db()) { @@ -445,7 +445,7 @@ fn tmp_0(className: string) -> bool { } } -fn tmp_1(c: int) -> bool { +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))) { diff --git a/example/icse25/rules/rule13.gdl b/example/icse25/rules/rule13.gdl index 5a5e91c..f6084a3 100644 --- a/example/icse25/rules/rule13.gdl +++ b/example/icse25/rules/rule13.gdl @@ -3,9 +3,9 @@ use coref::java::* use coref::xml::* pub fn gitdiff(filename: string, lineNumber: int) -> bool { //python替换 - $gitdiff + // $gitdiff // example - // [ {"test", 1111} ] + [ {"test", 1111} ] } pub fn transfertofile(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { @@ -408,17 +408,7 @@ pub fn hasCaller(a: CallableNew) -> bool { } } } -pub fn isAnonymousMethod(c: CallableNew) -> bool { - let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - for (a in AnonymousMethod(java_db)) { - if (c.key_eq(a)) { - return true - } - } - } - } -} + schema CallableNew extends Callable { } diff --git a/example/icse25/rules/rule14.gdl b/example/icse25/rules/rule14.gdl index 67f2ed5..bb7932f 100644 --- a/example/icse25/rules/rule14.gdl +++ b/example/icse25/rules/rule14.gdl @@ -1,7 +1,6 @@ // script use coref::javascript::* - pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionIdentifier: Expression) -> bool { let (javascript_db = default_javascript_db()) { for (callExpression in CallExpression(javascript_db)) { @@ -18,13 +17,9 @@ pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionId for (rpcNameStringLiteral in StringLiteral(javascript_db)) { if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { if (rpcName = rpcNameStringLiteral.getValue()) { - for (argumentCount in int::__undetermined_all__()) { - for (auto_tmp1 in callExpression.getArgumentCount()) { - if (argumentCount = auto_tmp1) { - if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { - return true - } - } + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true } } } @@ -35,13 +30,9 @@ pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionId for (rpcNameStringLiteral in StringLiteral(javascript_db)) { if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { if (rpcName = rpcNameStringLiteral.getValue()) { - for (argumentCount in int::__undetermined_all__()) { - for (auto_tmp1 in callExpression.getArgumentCount()) { - if (argumentCount = auto_tmp1) { - if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { - return true - } - } + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true } } } @@ -52,13 +43,9 @@ pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionId for (rpcNameStringLiteral in StringLiteral(javascript_db)) { if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { if (rpcName = rpcNameStringLiteral.getValue()) { - for (argumentCount in int::__undetermined_all__()) { - for (auto_tmp1 in callExpression.getArgumentCount()) { - if (argumentCount = auto_tmp1) { - if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { - return true - } - } + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true } } } diff --git a/example/icse25/rules/rule15.gdl b/example/icse25/rules/rule15.gdl index 8a55f15..214e005 100644 --- a/example/icse25/rules/rule15.gdl +++ b/example/icse25/rules/rule15.gdl @@ -120,9 +120,9 @@ pub fn real_output(facadeQualifiedName: string, trMethodName: string, outerField } } } - for (rootField in Field(java_db)) { - if (getAField(returnClass, rootField, __all_data__, __all_data__)) { - if (getADescendantField(rootField, Field(java_db).find(outerFieldId), aField, fieldName, isList)) { + 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 } diff --git a/example/icse25/rules/rule17.gdl b/example/icse25/rules/rule17.gdl index 632912f..1ce105c 100644 --- a/example/icse25/rules/rule17.gdl +++ b/example/icse25/rules/rule17.gdl @@ -614,7 +614,7 @@ pub fn real_output(facadeQualifiedName: string, trMethodName: string) -> bool { for (returnType in Type(java_db), returnClass in Class(java_db)) { for (aField in Field(java_db)) { - if (getJavaECGNode(aField)) { + if (getJavaECGNode(aField.element_hash_id)) { if (getAField(returnClass, aField, fieldName, isList)) { if (outerFieldId = 0) { if (fieldId = aField.element_hash_id) { @@ -639,9 +639,9 @@ pub fn real_output(facadeQualifiedName: string, trMethodName: string) -> bool { } } } - for (rootField in Field(java_db)) { - if (getAField(returnClass, rootField, __all_data__, __all_data__)) { - if (getADescendantField(rootField, Field(java_db).find(outerFieldId), aField, fieldName, isList)) { + 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)) { diff --git a/example/icse25/rules/rule18.gdl b/example/icse25/rules/rule18.gdl index 18d4773..1560913 100644 --- a/example/icse25/rules/rule18.gdl +++ b/example/icse25/rules/rule18.gdl @@ -3,7 +3,11 @@ 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"} ] + [ + {"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()) { diff --git a/example/icse25/rules/rule19.gdl b/example/icse25/rules/rule19.gdl index bc9406d..440ed3e 100644 --- a/example/icse25/rules/rule19.gdl +++ b/example/icse25/rules/rule19.gdl @@ -25,13 +25,9 @@ pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionId for (rpcNameStringLiteral in StringLiteral(javascript_db)) { if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { if (rpcName = rpcNameStringLiteral.getValue()) { - for (argumentCount in int::__undetermined_all__()) { - for (auto_tmp1 in callExpression.getArgumentCount()) { - if (argumentCount = auto_tmp1) { - if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { - return true - } - } + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true } } } @@ -42,13 +38,9 @@ pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionId for (rpcNameStringLiteral in StringLiteral(javascript_db)) { if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { if (rpcName = rpcNameStringLiteral.getValue()) { - for (argumentCount in int::__undetermined_all__()) { - for (auto_tmp1 in callExpression.getArgumentCount()) { - if (argumentCount = auto_tmp1) { - if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { - return true - } - } + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true } } } @@ -59,13 +51,9 @@ pub fn rpcNameControllerFunctionIdentifier(rpcName: string, controllerFunctionId for (rpcNameStringLiteral in StringLiteral(javascript_db)) { if (rpcNameStringLiteral.key_eq(callExpression.getArgument(0))) { if (rpcName = rpcNameStringLiteral.getValue()) { - for (argumentCount in int::__undetermined_all__()) { - for (auto_tmp1 in callExpression.getArgumentCount()) { - if (argumentCount = auto_tmp1) { - if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { - return true - } - } + let (argumentCount = callExpression.getArgumentCount()) { + if (controllerFunctionIdentifier = callExpression.getArgument(argumentCount - 1)) { + return true } } } diff --git a/example/icse25/rules/rule1_4.gdl b/example/icse25/rules/rule1_4.gdl index 274aa8b..06188e0 100644 --- a/example/icse25/rules/rule1_4.gdl +++ b/example/icse25/rules/rule1_4.gdl @@ -1,10 +1,478 @@ // 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 + } + } + } + } + + fn tmp_0(n: string) -> bool { + if (n.matches("get.*")) { + return true + } + } +} + pub fn gitdiff(filePath: string, lineNo: int) -> bool { //python替换 - $gitdiff + // $gitdiff // example - // [ {"test", 1111} ] + [ {"test", 1111} ] } pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { @@ -299,7 +767,7 @@ pub fn getJavaECGNode(n: ECGNode) -> bool { belongedCallable in string::__undetermined_all__()) { if (transfertofile(__all_data__, filename, lineNumber)) { if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { - if (getTypeInECG(filename, lineNumber, typeInAST, n)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n.id)) { return true } } @@ -843,7 +1311,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: int, index: int, result: string) -> bool { +pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { let (java_db = default_java_db()) { for (total in int::__undetermined_all__(), reStr in string::__undetermined_all__(), @@ -871,7 +1339,7 @@ pub fn connectStrBase(ID: int, index: int, result: string) -> bool { } } } -pub fn connectStr(ID: int) -> string { +pub fn connectStr(ID: Expression) -> string { let (java_db = default_java_db()) { for (c in int::__undetermined_all__(), result in string::__undetermined_all__()) { @@ -999,7 +1467,7 @@ fn tmp_0(filename: string, lineNumber: int) -> bool { } fn tmp_1() -> *string { - let (java_db = default_java_db()) { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { if (getBelongedCallable(filename, lineNumber, __all_data__)) { yield filename } @@ -1040,6 +1508,7 @@ fn tmp_5(a: string, b: string) -> bool { } } +@inline fn tmp_6(a: string, i: int, b: string) -> bool { let (java_db = default_java_db()) { if (a.substr(i - 1,i - 1) = "/") { @@ -1050,6 +1519,7 @@ fn tmp_6(a: string, i: int, b: string) -> bool { } } +@inline fn tmp_7(a: string, i: int, b: string) -> bool { let (java_db = default_java_db()) { if (!a.substr(i - 1,i - 1) = "/") { @@ -1186,7 +1656,7 @@ fn tmp_21(e: Expression) -> bool { } } -fn tmp_22(ID: int) -> *auto_tmp_23 { +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__()) { @@ -1213,7 +1683,7 @@ fn tmp_24(index: int) -> bool { } } -fn tmp_25(ID: int) -> *auto_tmp_26 { +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__()) { diff --git a/example/icse25/rules/rule1_5.gdl b/example/icse25/rules/rule1_5.gdl index 74a79fa..f9fc4c5 100644 --- a/example/icse25/rules/rule1_5.gdl +++ b/example/icse25/rules/rule1_5.gdl @@ -3,9 +3,9 @@ use coref::java::* use coref::xml::* pub fn gitdiff(filePath: string, lineNo: int) -> bool { //python替换 - $gitdiff + // $gitdiff // example - // [ {"test", 1111} ] + [ {"test", 1111} ] } pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/rule1_5_6.gdl b/example/icse25/rules/rule1_5_6.gdl index b9e82e2..7590d14 100644 --- a/example/icse25/rules/rule1_5_6.gdl +++ b/example/icse25/rules/rule1_5_6.gdl @@ -1,11 +1,479 @@ // 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 + } + } +} + pub fn gitdiff(filePath: string, lineNo: int) -> bool { //python替换 - $gitdiff + // $gitdiff // example - // [ {"test", 1111} ] + [ {"test", 1111} ] } pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/rule1_7_8.gdl b/example/icse25/rules/rule1_7_8.gdl index 19ec048..94cffe5 100644 --- a/example/icse25/rules/rule1_7_8.gdl +++ b/example/icse25/rules/rule1_7_8.gdl @@ -2,9 +2,9 @@ use coref::java::* use coref::xml::* pub fn gitdiff(filePath: string, lineNo: int) -> bool { - #changeinfo + // #changeinfo // example - // [ {"test", 1111}] + [ {"test", 1111}] } pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/rule2.gdl b/example/icse25/rules/rule2.gdl index 3ba6a60..ed280cd 100644 --- a/example/icse25/rules/rule2.gdl +++ b/example/icse25/rules/rule2.gdl @@ -1,9 +1,9 @@ // script use coref::java::* pub fn getJavaECGNode(node: int) -> bool { - #javaecgnode + // #javaecgnode // example - // [ {1111} ] + [ {1111} ] } pub fn getResponseType(t: ReferenceType) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/rule3.gdl b/example/icse25/rules/rule3.gdl index 2aa7265..46002af 100644 --- a/example/icse25/rules/rule3.gdl +++ b/example/icse25/rules/rule3.gdl @@ -1,9 +1,9 @@ // script use coref::java::* pub fn getNode(node: int) -> bool { - #javaecgnode + // #javaecgnode // example - // [ {1111} ] + [ {1111} ] } pub fn temp(a: Callable, b: Callable, c: Callable) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/rule4.gdl b/example/icse25/rules/rule4.gdl index f4656d5..d2b8643 100644 --- a/example/icse25/rules/rule4.gdl +++ b/example/icse25/rules/rule4.gdl @@ -1,9 +1,9 @@ // script use coref::java::* pub fn getJavaECGNode(node: int) -> bool { - #javaecgnode + // #javaecgnode // example - // [ {1111} ] + [ {1111} ] } @inline pub fn trim(n: string, m: string) -> bool { diff --git a/example/icse25/rules/rule5.gdl b/example/icse25/rules/rule5.gdl index 7b5d7bc..a88dff2 100644 --- a/example/icse25/rules/rule5.gdl +++ b/example/icse25/rules/rule5.gdl @@ -1,9 +1,9 @@ // script use coref::xml::* pub fn gitdiff(filePath: string, lineNo: int) -> bool { - #changeinfo + // #changeinfo // example - // [ {"test", 1111} ] + [ {"test", 1111} ] } pub fn transfertofile(f: XmlFile, filename: string, lineNumber: int) -> bool { let (xml_db = default_xml_db()) { diff --git a/example/icse25/rules/rule6.gdl b/example/icse25/rules/rule6.gdl index 504837c..708b498 100644 --- a/example/icse25/rules/rule6.gdl +++ b/example/icse25/rules/rule6.gdl @@ -2,14 +2,14 @@ use coref::java::* use coref::xml::* pub fn getJavaECGNode(id: int) -> bool { - #javaxmlnode + // #javaxmlnode // example - // [ {1111} ] + [ {1111} ] } pub fn getXmlECGNode(id: int) -> bool { - #xmlecgnode + // #xmlecgnode // example - // [ {1111} ] + [ {1111} ] } schema SofaService extends Annotation { diff --git a/example/icse25/rules/rule6_8_no_xml.gdl b/example/icse25/rules/rule6_8_no_xml.gdl index 36702ba..a5a8ecb 100644 --- a/example/icse25/rules/rule6_8_no_xml.gdl +++ b/example/icse25/rules/rule6_8_no_xml.gdl @@ -2,9 +2,9 @@ use coref::java::* use coref::xml::* pub fn gitdiff(filePath: string, lineNo: int) -> bool { - #changeinfo + // #changeinfo // example - // [ {"test", 1111} ] + [ {"test", 1111} ] } pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/rule6_8_spring.gdl b/example/icse25/rules/rule6_8_spring.gdl index 6af947b..df58d01 100644 --- a/example/icse25/rules/rule6_8_spring.gdl +++ b/example/icse25/rules/rule6_8_spring.gdl @@ -2,9 +2,9 @@ use coref::java::* use coref::xml::* pub fn gitdiff(filePath: string, lineNo: int) -> bool { - #changeinfo + // #changeinfo // example - // [ {"test", 1111} ] + [ {"test", 1111} ] } pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/rule7.gdl b/example/icse25/rules/rule7.gdl index 83643c1..ea047b2 100644 --- a/example/icse25/rules/rule7.gdl +++ b/example/icse25/rules/rule7.gdl @@ -2,9 +2,9 @@ use coref::java::* use coref::xml::* pub fn getXmlECGNode(i: int) -> bool { - #xmlecgnode + // #xmlecgnode // example - // [ {1111} ] + [ {1111} ] } @inline pub fn trim(n: string, m: string) -> bool { diff --git a/example/icse25/rules/rule8.gdl b/example/icse25/rules/rule8.gdl index a6b468b..3bd238a 100644 --- a/example/icse25/rules/rule8.gdl +++ b/example/icse25/rules/rule8.gdl @@ -2,14 +2,14 @@ use coref::java::* use coref::xml::* pub fn getJavaECGNode(id: int) -> bool { - #javaecgnode + // #javaecgnode // example - // [ {1111} ] + [ {1111} ] } pub fn getXmlECGNode(id: int) -> bool { - #xmlimpactedecgnode + // #xmlimpactedecgnode // example - // [ {1111} ] + [ {1111} ] } schema SofaService extends Annotation { diff --git a/example/icse25/rules/rule_ecg.gdl b/example/icse25/rules/rule_ecg.gdl index 07a45dd..7fce47c 100644 --- a/example/icse25/rules/rule_ecg.gdl +++ b/example/icse25/rules/rule_ecg.gdl @@ -1,10 +1,11 @@ // script use coref::java::* use coref::xml::* + pub fn gitdiff(filePath: string, lineNo: int) -> bool { - #changeinfo + // #changeinfo // example - // [ {"test", "1111"} ] + [ {"test", "1111"} ] } pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { diff --git a/example/icse25/rules/test.gdl b/example/icse25/rules/test.gdl index 83ebee8..863948e 100644 --- a/example/icse25/rules/test.gdl +++ b/example/icse25/rules/test.gdl @@ -1,6 +1,474 @@ // 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 + } + } +} + pub fn getJavaECGNode(id: int) -> bool { [ // {-2697619382280646740}, @@ -280,7 +748,7 @@ pub fn real_output(c: ClassOrInterface, n: ECGNode, interfaceName: string, nodeN let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { for (m in ECGNode(java_db)) { - if (getJavaECGNode(m)) { + if (getJavaECGNode(m.id)) { if (getPublishTr(c)) { for (t in Method(java_db)) { if (n.key_eq(t)) { @@ -310,7 +778,7 @@ pub fn real_output(c: ClassOrInterface, n: ECGNode, interfaceName: string, nodeN } } } - if (getXmlECGNode(m)) { + if (getXmlECGNode(m.id)) { if (getPublishTr(c)) { for (t in Method(java_db)) { if (n.key_eq(t)) { From d5876f088fce99b0f31cbdb993868af2dda2dcce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=95=E5=B1=B1?= Date: Mon, 28 Apr 2025 17:14:00 +0800 Subject: [PATCH 3/5] fix compilation failure --- example/icse25/rules/ecg.gdl | 191 ++++++ example/icse25/rules/ecgxml.gdl | 41 +- example/icse25/rules/rule1.gdl | 664 ++++++++++++++++++- example/icse25/rules/rule10.gdl | 785 ++++++++++++++++++++++- example/icse25/rules/rule1_4.gdl | 196 +++++- example/icse25/rules/rule1_5.gdl | 781 ++++++++++++++++++++++- example/icse25/rules/rule1_5_6.gdl | 123 +++- example/icse25/rules/rule1_7_8.gdl | 789 ++++++++++++++++++++++- example/icse25/rules/rule2.gdl | 672 +++++++++++++++++++- example/icse25/rules/rule3.gdl | 660 ++++++++++++++++++- example/icse25/rules/rule4.gdl | 682 +++++++++++++++++++- example/icse25/rules/rule5.gdl | 110 ++++ example/icse25/rules/rule6.gdl | 779 ++++++++++++++++++++++- example/icse25/rules/rule6_8_no_xml.gdl | 795 ++++++++++++++++++++++- example/icse25/rules/rule6_8_spring.gdl | 795 ++++++++++++++++++++++- example/icse25/rules/rule7.gdl | 122 +++- example/icse25/rules/rule8.gdl | 771 +++++++++++++++++++++- example/icse25/rules/rule9.gdl | 10 +- example/icse25/rules/rule_ecg.gdl | 811 +++++++++++++++++++++++- example/icse25/rules/test.gdl | 14 + 20 files changed, 9654 insertions(+), 137 deletions(-) diff --git a/example/icse25/rules/ecg.gdl b/example/icse25/rules/ecg.gdl index ea5a64f..2ffcd13 100644 --- a/example/icse25/rules/ecg.gdl +++ b/example/icse25/rules/ecg.gdl @@ -1,5 +1,6 @@ // script use coref::java::* + schema ECGNode extends ElementParent {} impl ECGNode { @@ -460,6 +461,196 @@ impl ECGNode { } } + 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 diff --git a/example/icse25/rules/ecgxml.gdl b/example/icse25/rules/ecgxml.gdl index 8ac5e69..b168bfc 100644 --- a/example/icse25/rules/ecgxml.gdl +++ b/example/icse25/rules/ecgxml.gdl @@ -332,9 +332,6 @@ schema ECGXmlNode { } impl ECGXmlNode { - - @data_constraint - @inline pub fn __all__(db: XmlDB) -> *ECGXmlNode { for (e in XmlPomElement(db)) { yield ECGXmlNode {id : e.id} @@ -401,8 +398,42 @@ impl ECGXmlNode { } } } - - + + 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 { diff --git a/example/icse25/rules/rule1.gdl b/example/icse25/rules/rule1.gdl index d0e44ea..66b177a 100644 --- a/example/icse25/rules/rule1.gdl +++ b/example/icse25/rules/rule1.gdl @@ -1,5 +1,663 @@ // 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 @@ -173,7 +831,7 @@ pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> boo } } } -pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int) -> bool { +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)) { @@ -187,7 +845,7 @@ pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int if (!(tmp_0(filename, lineNumber))) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - if (n.getLocation().getFile() = f.element_hash_id) { + if (n.getLocation().getFile() = f) { if (s1 = n.getLocation().getStartLineNumber()) { if (e = n.getLocation().getEndLineNumber()) { if (lineNumber > s1 - 1) { @@ -320,7 +978,7 @@ fn tmp_0(filename: string, lineNumber: int) -> bool { } fn tmp_1() -> *string { - let (java_db = default_java_db()) { + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { if (getBelongedCallable(filename, lineNumber, __all_data__)) { yield filename } diff --git a/example/icse25/rules/rule10.gdl b/example/icse25/rules/rule10.gdl index 1b74fe7..d60ca37 100644 --- a/example/icse25/rules/rule10.gdl +++ b/example/icse25/rules/rule10.gdl @@ -1,6 +1,773 @@ // 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()) { @@ -238,7 +1005,7 @@ pub fn output3(id: string, m: string, iden: Identifier, r1: Expression) -> bool } } } -pub fn importOutput(className: string, methodName: string, fileName: string, lineNumber: int, c: int) -> bool { +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), @@ -250,7 +1017,7 @@ pub fn importOutput(className: string, methodName: string, fileName: string, lin if (output3(className, methodName, __all_data__, r)) { if (fileName = r.getLocation().getFile().getRelativePath()) { if (lineNumber = r.getLocation().getStartLineNumber()) { - if (c = r.getEnclosingCallable().id) { + if (c = r.getEnclosingCallable()) { return true } } @@ -261,7 +1028,7 @@ pub fn importOutput(className: string, methodName: string, fileName: string, lin if (methodName = "null") { if (fileName = "null") { if (lineNumber = 0) { - if (c = 0) { + if (c.id = 0) { return true } } @@ -387,21 +1154,21 @@ pub fn getJavaECGNode(id: int) -> bool { // example [ {1111} ] } -pub fn getDependsECGNode(id: int, c: int) -> bool { +pub fn getDependsECGNode(id: Callable, c: ECGNode) -> bool { let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - if (getJavaECGNode(c)) { - if (id = c.getAnAncestorCallee()) { + for (e in Callable(java_db)) { + if (getJavaECGNode(c.id) && e.key_eq(c)) { + if (id in e.getAnAncestorCallee()) { return true } - if (id = c) { + if (id.key_eq(c)) { return true } } } } } -pub fn real_output(bindingType: string, uniqueId: string, interfaceName: string, methodName: string, filePath: string, lineNumber: int, ecgNodeId: int) -> bool { +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)) { diff --git a/example/icse25/rules/rule1_4.gdl b/example/icse25/rules/rule1_4.gdl index 06188e0..f8b3ade 100644 --- a/example/icse25/rules/rule1_4.gdl +++ b/example/icse25/rules/rule1_4.gdl @@ -461,6 +461,196 @@ impl ECGNode { } } + 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 @@ -641,7 +831,7 @@ pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> boo } } } -pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int) -> bool { +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)) { @@ -655,7 +845,7 @@ pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int if (!(tmp_0(filename, lineNumber))) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - if (n.getLocation().getFile() = f.element_hash_id) { + if (n.getLocation().getFile() = f) { if (s1 = n.getLocation().getStartLineNumber()) { if (e = n.getLocation().getEndLineNumber()) { if (lineNumber > s1 - 1) { @@ -767,7 +957,7 @@ pub fn getJavaECGNode(n: ECGNode) -> bool { belongedCallable in string::__undetermined_all__()) { if (transfertofile(__all_data__, filename, lineNumber)) { if (getBelongedCallableSignature(filename, lineNumber, belongedCallable)) { - if (getTypeInECG(filename, lineNumber, typeInAST, n.id)) { + if (getTypeInECG(filename, lineNumber, typeInAST, n)) { return true } } diff --git a/example/icse25/rules/rule1_5.gdl b/example/icse25/rules/rule1_5.gdl index f9fc4c5..9fd3688 100644 --- a/example/icse25/rules/rule1_5.gdl +++ b/example/icse25/rules/rule1_5.gdl @@ -1,6 +1,773 @@ // 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 @@ -108,7 +875,7 @@ pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { if (f.getRelativePath() = filename) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - for (l in Location(java_db)) { + for (l in coref::java::Location(java_db)) { if (l.getFile() = f) { if (s1 = l.getStartLineNumber()) { if (e = l.getEndLineNumber()) { @@ -188,7 +955,7 @@ pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> boo } } } -pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int) -> bool { +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)) { @@ -203,7 +970,7 @@ pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int if (!(tmp_0(lineNumber, filename))) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - if (n.getLocation().getFile() = f.element_hash_id) { + if (n.getLocation().getFile() = f) { if (s1 = n.getLocation().getStartLineNumber()) { if (e = n.getLocation().getEndLineNumber()) { if (lineNumber > s1 - 1) { @@ -421,11 +1188,9 @@ fn tmp_0(lineNumber: int, filename: string) -> bool { } fn tmp_1() -> *string { - let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - if (getBelongedCallable(filename, lineNumber, __all_data__)) { - yield filename - } + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename } } } diff --git a/example/icse25/rules/rule1_5_6.gdl b/example/icse25/rules/rule1_5_6.gdl index 7590d14..eb69e88 100644 --- a/example/icse25/rules/rule1_5_6.gdl +++ b/example/icse25/rules/rule1_5_6.gdl @@ -469,6 +469,115 @@ impl ECGNode { } } +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 @@ -576,7 +685,7 @@ pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { if (f.getRelativePath() = filename) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - for (l in Location(java_db)) { + for (l in coref::java::Location(java_db)) { if (l.getFile() = f) { if (s1 = l.getStartLineNumber()) { if (e = l.getEndLineNumber()) { @@ -656,7 +765,7 @@ pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> boo } } } -pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int) -> bool { +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)) { @@ -671,7 +780,7 @@ pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int if (!(tmp_0(filename, lineNumber))) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - if (n.getLocation().getFile() = f.element_hash_id) { + if (n.getLocation().getFile() = f) { if (s1 = n.getLocation().getStartLineNumber()) { if (e = n.getLocation().getEndLineNumber()) { if (lineNumber > s1 - 1) { @@ -1266,11 +1375,9 @@ fn tmp_0(filename: string, lineNumber: int) -> bool { } fn tmp_1() -> *string { - let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - if (getBelongedCallable(filename, lineNumber, __all_data__)) { - yield filename - } + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename } } } diff --git a/example/icse25/rules/rule1_7_8.gdl b/example/icse25/rules/rule1_7_8.gdl index 94cffe5..7fa9288 100644 --- a/example/icse25/rules/rule1_7_8.gdl +++ b/example/icse25/rules/rule1_7_8.gdl @@ -1,6 +1,773 @@ // 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 @@ -107,7 +874,7 @@ pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { if (f.getRelativePath() = filename) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - for (l in Location(java_db)) { + for (l in coref::java::Location(java_db)) { if (l.getFile() = f) { if (s1 = l.getStartLineNumber()) { if (e = l.getEndLineNumber()) { @@ -187,7 +954,7 @@ pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> boo } } } -pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int) -> bool { +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)) { @@ -202,7 +969,7 @@ pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int if (!(tmp_0(filename, lineNumber))) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - if (n.getLocation().getFile() = f.element_hash_id) { + if (n.getLocation().getFile() = f) { if (s1 = n.getLocation().getStartLineNumber()) { if (e = n.getLocation().getEndLineNumber()) { if (lineNumber > s1 - 1) { @@ -400,18 +1167,18 @@ pub fn trim(n: string, m: string) -> bool { } } } -pub fn getXmlECGNode(f: int) -> bool { +pub fn getXmlECGNode(f: ECGNode) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { - for (c in int::__undetermined_all__(), + 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, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { return true } - if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(c), Field(java_db).find(f), n, m)) { + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { return true } } @@ -838,11 +1605,9 @@ fn tmp_0(filename: string, lineNumber: int) -> bool { } fn tmp_1() -> *string { - let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - if (getBelongedCallable(filename, lineNumber, __all_data__)) { - yield filename - } + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename } } } diff --git a/example/icse25/rules/rule2.gdl b/example/icse25/rules/rule2.gdl index ed280cd..65dc1de 100644 --- a/example/icse25/rules/rule2.gdl +++ b/example/icse25/rules/rule2.gdl @@ -1,5 +1,663 @@ // 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 @@ -10,7 +668,7 @@ pub fn getResponseType(t: ReferenceType) -> bool { for (r in string::__undetermined_all__()) { for (i in ClassOrInterface(java_db), c in ClassOrInterface(java_db)) { - if (r = c.getImplementsList()) { + if (r in c.getImplementsList()) { if (r = "implements Response") { for (auto_tmp1 in i.getAnAscentantClassOrInterface()) { if (c = auto_tmp1) { @@ -90,17 +748,17 @@ pub fn getResponseMethod(m: Method) -> bool { } pub fn temp(a: ECGNode, b: ECGNode, c: ECGNode, edgeType: string, direction: string) -> bool { let (java_db = default_java_db()) { - if (getJavaECGNode(a)) { + if (getJavaECGNode(a.id)) { if (b = a.getAnAncestorCDNode(__all_data__, __all_data__)) { if (c = b.getECGNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { return true } } } if (b = a) { if (c = b.getECGNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { return true } } @@ -126,11 +784,11 @@ pub fn temp1(c: Callable) -> bool { } pub fn temp2(a: ECGNode, b: ECGNode, c: ECGNode, direction: string, edgeType: string) -> bool { let (java_db = default_java_db()) { - if (getJavaECGNode(a)) { + 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 (b != c) { if (direction = "Depended") { return true } @@ -141,7 +799,7 @@ pub fn temp2(a: ECGNode, b: ECGNode, c: ECGNode, direction: string, edgeType: st if (b = a) { if (c = b.getECGNode(edgeType, "Depended")) { if (temp1(Callable(java_db).find(c))) { - if (!b = c) { + if (b != c) { if (direction = "Depended") { return true } diff --git a/example/icse25/rules/rule3.gdl b/example/icse25/rules/rule3.gdl index 46002af..3a25f79 100644 --- a/example/icse25/rules/rule3.gdl +++ b/example/icse25/rules/rule3.gdl @@ -1,5 +1,663 @@ // 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 @@ -7,7 +665,7 @@ pub fn getNode(node: int) -> bool { } pub fn temp(a: Callable, b: Callable, c: Callable) -> bool { let (java_db = default_java_db()) { - if (getNode(a)) { + if (getNode(a.id)) { for (auto_tmp1 in a.getAnAncestorCaller()) { if (c = auto_tmp1) { for (auto_tmp2 in c.getCaller()) { diff --git a/example/icse25/rules/rule4.gdl b/example/icse25/rules/rule4.gdl index d2b8643..bb46b26 100644 --- a/example/icse25/rules/rule4.gdl +++ b/example/icse25/rules/rule4.gdl @@ -1,5 +1,663 @@ // 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 @@ -543,7 +1201,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: int, index: int, result: string) -> bool { +pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { let (java_db = default_java_db()) { for (total in int::__undetermined_all__(), reStr in string::__undetermined_all__(), @@ -571,7 +1229,7 @@ pub fn connectStrBase(ID: int, index: int, result: string) -> bool { } } } -pub fn connectStr(ID: int) -> string { +pub fn connectStr(ID: Expression) -> string { let (java_db = default_java_db()) { for (c in int::__undetermined_all__(), result in string::__undetermined_all__()) { @@ -628,12 +1286,12 @@ pub fn real_output(nodeText: string, path: string) -> bool { a in ECGNode(java_db), b in ECGNode(java_db), c in ECGNode(java_db)) { - if (getJavaECGNode(a)) { + 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 (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -644,7 +1302,7 @@ pub fn real_output(nodeText: string, path: string) -> bool { } if (c = a) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -657,7 +1315,7 @@ pub fn real_output(nodeText: string, path: string) -> bool { if (b = m) { if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -668,7 +1326,7 @@ pub fn real_output(nodeText: string, path: string) -> bool { } if (c = a) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -716,6 +1374,7 @@ fn tmp_2(a: string, b: string) -> bool { } } +@inline fn tmp_3(a: string, b: string, i: int) -> bool { let (java_db = default_java_db()) { if (a.substr(i - 1,i - 1) = "/") { @@ -726,6 +1385,7 @@ fn tmp_3(a: string, b: string, i: int) -> bool { } } +@inline fn tmp_4(a: string, b: string, i: int) -> bool { let (java_db = default_java_db()) { if (!a.substr(i - 1,i - 1) = "/") { @@ -862,11 +1522,11 @@ fn tmp_18(e: Expression) -> bool { } } -fn tmp_19(ID: int) -> *auto_tmp_20 { +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)) { + 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 @@ -889,11 +1549,11 @@ fn tmp_21(index: int) -> bool { } } -fn tmp_22(ID: int) -> *auto_tmp_23 { +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)) { + 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 diff --git a/example/icse25/rules/rule5.gdl b/example/icse25/rules/rule5.gdl index a88dff2..a066728 100644 --- a/example/icse25/rules/rule5.gdl +++ b/example/icse25/rules/rule5.gdl @@ -1,5 +1,115 @@ // 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 diff --git a/example/icse25/rules/rule6.gdl b/example/icse25/rules/rule6.gdl index 708b498..d3b7fea 100644 --- a/example/icse25/rules/rule6.gdl +++ b/example/icse25/rules/rule6.gdl @@ -1,6 +1,773 @@ // 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 @@ -259,8 +1026,8 @@ pub fn real_output(className: string, interfaceName: string, id: int, name: stri for (e1 in ECGNode(java_db), e2 in ECGXmlNode(xml_db), c in ClassOrInterface(java_db)) { - if (getJavaECGNode(e1)) { - if (getXmlECGNode(e2)) { + if (getJavaECGNode(e1.id)) { + if (getXmlECGNode(e2.id)) { if (c.key_eq(e1.getElementParent())) { if (temp = c.getQualifiedName()) { if (id = e1.id) { @@ -309,8 +1076,8 @@ pub fn real_output(className: string, interfaceName: string, id: int, name: stri for (e1 in ECGNode(java_db), e2 in ECGXmlNode(xml_db), c in ClassOrInterface(java_db)) { - if (getJavaECGNode(e1)) { - if (getXmlECGNode(e2)) { + if (getJavaECGNode(e1.id)) { + if (getXmlECGNode(e2.id)) { if (c.key_eq(e1.getElementParent())) { if (temp = c.getQualifiedName()) { if (id = e1.id) { @@ -359,8 +1126,8 @@ pub fn real_output(className: string, interfaceName: string, id: int, name: stri for (e1 in ECGNode(java_db), e2 in ECGXmlNode(xml_db), c in ClassOrInterface(java_db)) { - if (getJavaECGNode(e1)) { - if (getXmlECGNode(e2)) { + if (getJavaECGNode(e1.id)) { + if (getXmlECGNode(e2.id)) { if (c.key_eq(e1.getElementParent())) { if (temp = c.getQualifiedName()) { if (id = e1.id) { diff --git a/example/icse25/rules/rule6_8_no_xml.gdl b/example/icse25/rules/rule6_8_no_xml.gdl index a5a8ecb..3ceac03 100644 --- a/example/icse25/rules/rule6_8_no_xml.gdl +++ b/example/icse25/rules/rule6_8_no_xml.gdl @@ -1,6 +1,773 @@ // 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 @@ -107,7 +874,7 @@ pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { if (f.getRelativePath() = filename) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - for (l in Location(java_db)) { + for (l in coref::java::Location(java_db)) { if (l.getFile() = f) { if (s1 = l.getStartLineNumber()) { if (e = l.getEndLineNumber()) { @@ -187,7 +954,7 @@ pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> boo } } } -pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int) -> bool { +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)) { @@ -202,7 +969,7 @@ pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int if (!(tmp_0(filename, lineNumber))) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - if (n.getLocation().getFile() = f.element_hash_id) { + if (n.getLocation().getFile() = f) { if (s1 = n.getLocation().getStartLineNumber()) { if (e = n.getLocation().getEndLineNumber()) { if (lineNumber > s1 - 1) { @@ -400,18 +1167,18 @@ pub fn trim(n: string, m: string) -> bool { } } } -pub fn getXmlECGNode(f: int) -> bool { +pub fn getXmlECGNode(f: ECGNode) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { - for (c in int::__undetermined_all__(), + 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, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { return true } - if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(c), Field(java_db).find(f), n, m)) { + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { return true } } @@ -921,12 +1688,12 @@ pub fn output2(c: ClassOrInterface, interfaceName: string, n: ECGNode) -> bool { pub fn real_output(interfaceName: string) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { - for (n in int::__undetermined_all__()) { + for (n in ECGNode(java_db)) { for (c in ClassOrInterface(java_db)) { - if (output2(c, interfaceName, ECGNode(java_db).find(n))) { + if (output2(c, interfaceName, n)) { return true } - if (output1(c, interfaceName, n)) { + if (output1(c, interfaceName, n.id)) { return true } } @@ -955,11 +1722,9 @@ fn tmp_0(filename: string, lineNumber: int) -> bool { } fn tmp_1() -> *string { - let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - if (getBelongedCallable(filename, lineNumber, __all_data__)) { - yield filename - } + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename } } } diff --git a/example/icse25/rules/rule6_8_spring.gdl b/example/icse25/rules/rule6_8_spring.gdl index df58d01..6446282 100644 --- a/example/icse25/rules/rule6_8_spring.gdl +++ b/example/icse25/rules/rule6_8_spring.gdl @@ -1,6 +1,773 @@ // 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 @@ -107,7 +874,7 @@ pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { if (f.getRelativePath() = filename) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - for (l in Location(java_db)) { + for (l in coref::java::Location(java_db)) { if (l.getFile() = f) { if (s1 = l.getStartLineNumber()) { if (e = l.getEndLineNumber()) { @@ -187,7 +954,7 @@ pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> boo } } } -pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int) -> bool { +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)) { @@ -202,7 +969,7 @@ pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int if (!(tmp_0(filename, lineNumber))) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - if (n.getLocation().getFile() = f.element_hash_id) { + if (n.getLocation().getFile() = f) { if (s1 = n.getLocation().getStartLineNumber()) { if (e = n.getLocation().getEndLineNumber()) { if (lineNumber > s1 - 1) { @@ -400,18 +1167,18 @@ pub fn trim(n: string, m: string) -> bool { } } } -pub fn getXmlECGNode(f: int) -> bool { +pub fn getXmlECGNode(f: ECGNode) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { - for (c in int::__undetermined_all__(), + 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, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { return true } - if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(c), Field(java_db).find(f), n, m)) { + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { return true } } @@ -740,12 +1507,12 @@ pub fn output2(c: ClassOrInterface, interfaceName: string, n: ECGNode) -> bool { pub fn real_output(interfaceName: string) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { - for (n in int::__undetermined_all__()) { + for (n in ECGNode(java_db)) { for (c in ClassOrInterface(java_db)) { - if (output2(c, interfaceName, ECGNode(java_db).find(n))) { + if (output2(c, interfaceName, n)) { return true } - if (output1(c, interfaceName, n)) { + if (output1(c, interfaceName, n.id)) { return true } } @@ -774,11 +1541,9 @@ fn tmp_0(filename: string, lineNumber: int) -> bool { } fn tmp_1() -> *string { - let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - if (getBelongedCallable(filename, lineNumber, __all_data__)) { - yield filename - } + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename } } } diff --git a/example/icse25/rules/rule7.gdl b/example/icse25/rules/rule7.gdl index ea047b2..73c3b78 100644 --- a/example/icse25/rules/rule7.gdl +++ b/example/icse25/rules/rule7.gdl @@ -1,6 +1,116 @@ // 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 @@ -27,14 +137,14 @@ pub fn trim(n: string, m: string) -> bool { } } } -pub fn real_output(r: ECGXmlNode, c: int, f: int, n: string, m: string) -> bool { +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)) { - if (getChangeSetByDalXmlElement(r, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + if (getXmlECGNode(r.id)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { return true } - if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(c), Field(java_db).find(f), n, m)) { + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { return true } } @@ -46,7 +156,7 @@ pub fn getChangeSetByResultXmlElement(r1: ECGXmlNode, c: ClassOrInterface, f: Fi let (xml_db = default_xml_db()) { for (r in ResultXmlElement(xml_db)) { if (r.key_eq(r1)) { - if (getXmlECGNode(r)) { + if (getXmlECGNode(r.id)) { if (n = r.getBelongedMapXmlElement().getMappingClassName()) { if (n = c.getQualifiedName()) { if (c = f.getParent()) { @@ -75,7 +185,7 @@ pub fn getChangeSetByDalXmlElement(d1: ECGXmlNode, c: ClassOrInterface, m: Metho cc in XmlComment(xml_db), l in Literal(java_db)) { if (d.key_eq(d1)) { - if (getXmlECGNode(d)) { + if (getXmlECGNode(d.id)) { if (d.getLocation().getFile() = cc.getLocation().getFile()) { if (cc.getLocation().getEndLineNumber() = i) { if (i + 1 = d.getLocation().getStartLineNumber()) { diff --git a/example/icse25/rules/rule8.gdl b/example/icse25/rules/rule8.gdl index 3bd238a..dac7d2f 100644 --- a/example/icse25/rules/rule8.gdl +++ b/example/icse25/rules/rule8.gdl @@ -1,6 +1,773 @@ // 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 @@ -277,7 +1044,7 @@ pub fn real_output(c: ClassOrInterface, n: ECGNode, interfaceName: string, nodeN let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { for (m in ECGNode(java_db)) { - if (getJavaECGNode(m)) { + if (getJavaECGNode(m.id)) { if (getPublishTr(c)) { for (t in Method(java_db)) { if (n.key_eq(t)) { @@ -307,7 +1074,7 @@ pub fn real_output(c: ClassOrInterface, n: ECGNode, interfaceName: string, nodeN } } } - if (getXmlECGNode(m)) { + if (getXmlECGNode(m.id)) { if (getPublishTr(c)) { for (t in Method(java_db)) { if (n.key_eq(t)) { diff --git a/example/icse25/rules/rule9.gdl b/example/icse25/rules/rule9.gdl index 0727412..9a694c6 100644 --- a/example/icse25/rules/rule9.gdl +++ b/example/icse25/rules/rule9.gdl @@ -536,7 +536,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: int, index: int, result: string) -> bool { +pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { let (java_db = default_java_db()) { for (total in int::__undetermined_all__(), reStr in string::__undetermined_all__(), @@ -564,7 +564,7 @@ pub fn connectStrBase(ID: int, index: int, result: string) -> bool { } } } -pub fn connectStr(ID: int) -> string { +pub fn connectStr(ID: Expression) -> string { let (java_db = default_java_db()) { for (c in int::__undetermined_all__(), result in string::__undetermined_all__()) { @@ -651,6 +651,7 @@ fn tmp_2(a: string, b: string) -> bool { } } +@inline fn tmp_3(i: int, b: string, a: string) -> bool { let (java_db = default_java_db()) { if (a.substr(i - 1,i - 1) = "/") { @@ -661,6 +662,7 @@ fn tmp_3(i: int, b: string, a: string) -> bool { } } +@inline fn tmp_4(i: int, b: string, a: string) -> bool { let (java_db = default_java_db()) { if (!a.substr(i - 1,i - 1) = "/") { @@ -797,7 +799,7 @@ fn tmp_18(e: Expression) -> bool { } } -fn tmp_19(ID: int) -> *auto_tmp_20 { +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__()) { @@ -824,7 +826,7 @@ fn tmp_21(index: int) -> bool { } } -fn tmp_22(ID: int) -> *auto_tmp_23 { +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__()) { diff --git a/example/icse25/rules/rule_ecg.gdl b/example/icse25/rules/rule_ecg.gdl index 7fce47c..b445c28 100644 --- a/example/icse25/rules/rule_ecg.gdl +++ b/example/icse25/rules/rule_ecg.gdl @@ -2,11 +2,778 @@ 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"} ] + [ {"test", 1111} ] } + pub fn transfertofile1(f: File, filename: string, lineNumber: int) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { @@ -108,7 +875,7 @@ pub fn isCodeLine(f: File, filename: string, lineNumber: int) -> bool { if (f.getRelativePath() = filename) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - for (l in Location(java_db)) { + for (l in coref::java::Location(java_db)) { if (l.getFile() = f) { if (s1 = l.getStartLineNumber()) { if (e = l.getEndLineNumber()) { @@ -188,7 +955,7 @@ pub fn getTypeInAST(filename: string, lineNumber: int, typeInAST: string) -> boo } } } -pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int) -> bool { +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)) { @@ -203,7 +970,7 @@ pub fn getTypeInECG(filename: string, lineNumber: int, typeInAST: string, n: int if (!(tmp_0(lineNumber, filename))) { for (e in int::__undetermined_all__(), s1 in int::__undetermined_all__()) { - if (n.getLocation().getFile() = f.element_hash_id) { + if (n.getLocation().getFile() = f) { if (s1 = n.getLocation().getStartLineNumber()) { if (e = n.getLocation().getEndLineNumber()) { if (lineNumber > s1 - 1) { @@ -401,18 +1168,18 @@ pub fn trim(n: string, m: string) -> bool { } } } -pub fn getXmlECGNode(f: int) -> bool { +pub fn getXmlECGNode(f: ECGNode) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { - for (c in int::__undetermined_all__(), + 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, ClassOrInterface(java_db).find(c), Method(java_db).find(f), n, m)) { + if (getChangeSetByDalXmlElement(r, c, Method(java_db).find(f), n, m)) { return true } - if (getChangeSetByResultXmlElement(r, ClassOrInterface(java_db).find(c), Field(java_db).find(f), n, m)) { + if (getChangeSetByResultXmlElement(r, c, Field(java_db).find(f), n, m)) { return true } } @@ -1272,7 +2039,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: int, index: int, result: string) -> bool { +pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { for (total in int::__undetermined_all__(), @@ -1302,7 +2069,7 @@ pub fn connectStrBase(ID: int, index: int, result: string) -> bool { } } } -pub fn connectStr(ID: int) -> string { +pub fn connectStr(ID: Expression) -> string { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { for (c in int::__undetermined_all__(), @@ -1368,7 +2135,7 @@ pub fn output3(nodeText: string, path: string, m: ECGNode) -> bool { 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 (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -1379,7 +2146,7 @@ pub fn output3(nodeText: string, path: string, m: ECGNode) -> bool { } if (c = a) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -1392,7 +2159,7 @@ pub fn output3(nodeText: string, path: string, m: ECGNode) -> bool { if (b = m) { if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -1403,7 +2170,7 @@ pub fn output3(nodeText: string, path: string, m: ECGNode) -> bool { } if (c = a) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -1430,7 +2197,7 @@ pub fn real_output(nodeText: string, interfaceName: string) -> bool { return true } } - if (output1(c, interfaceName, n)) { + if (output1(c, interfaceName, n.id)) { if (nodeText = c.getQualifiedName()) { return true } @@ -1465,11 +2232,9 @@ fn tmp_0(lineNumber: int, filename: string) -> bool { } fn tmp_1() -> *string { - let (java_db = default_java_db()) { - let (xml_db = default_xml_db()) { - if (getBelongedCallable(filename, lineNumber, __all_data__)) { - yield filename - } + for (filename in string::__undetermined_all__(), lineNumber in int::__undetermined_all__()) { + if (getBelongedCallable(filename, lineNumber, __all_data__)) { + yield filename } } } @@ -1516,6 +2281,7 @@ fn tmp_5(a: string, b: string) -> bool { } } +@inline fn tmp_6(a: string, i: int, b: string) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { @@ -1528,6 +2294,7 @@ fn tmp_6(a: string, i: int, b: string) -> bool { } } +@inline fn tmp_7(a: string, i: int, b: string) -> bool { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { @@ -1694,7 +2461,7 @@ fn tmp_21(e: Expression) -> bool { } } -fn tmp_22(ID: int) -> *auto_tmp_23 { +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__(), @@ -1725,7 +2492,7 @@ fn tmp_24(index: int) -> bool { } } -fn tmp_25(ID: int) -> *auto_tmp_26 { +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__(), diff --git a/example/icse25/rules/test.gdl b/example/icse25/rules/test.gdl index 863948e..f1d551e 100644 --- a/example/icse25/rules/test.gdl +++ b/example/icse25/rules/test.gdl @@ -462,6 +462,20 @@ impl ECGNode { } } + 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 From fa1cd001cf542792410dade0045589619265835f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=95=E5=B1=B1?= Date: Mon, 28 Apr 2025 17:18:20 +0800 Subject: [PATCH 4/5] fix compilation failure --- example/icse25/Keymap/FindAllReleasedHttpAPI.gdl | 12 ++++++------ example/icse25/rules/rule1_4.gdl | 13 ++++++------- example/icse25/rules/rule4.gdl | 13 ++++++------- example/icse25/rules/rule9.gdl | 13 ++++++------- example/icse25/rules/rule_ecg.gdl | 13 ++++++------- 5 files changed, 30 insertions(+), 34 deletions(-) diff --git a/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl index 24abfae..456095c 100644 --- a/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl +++ b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl @@ -576,7 +576,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { +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__(), @@ -585,7 +585,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (total = tmp_29(ID).len()) { if (tmp_31(index)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = currStr) { + if (res = currStr) { return true } } @@ -594,7 +594,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (index > 0) { if (connectStrBase(ID, index - 1, reStr)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = reStr + currStr) { + if (res = reStr + currStr) { return true } } @@ -610,10 +610,10 @@ pub fn connectStr(ID: Expression) -> string { let (xml_db = default_xml_db()) { let (java_db = default_java_db()) { for (c in int::__undetermined_all__(), - result in string::__undetermined_all__()) { + res in string::__undetermined_all__()) { if (c = tmp_32(ID).len()) { - if (connectStrBase(ID, c - 1, result)) { - return result + if (connectStrBase(ID, c - 1, res)) { + return res } } } diff --git a/example/icse25/rules/rule1_4.gdl b/example/icse25/rules/rule1_4.gdl index f8b3ade..41492b1 100644 --- a/example/icse25/rules/rule1_4.gdl +++ b/example/icse25/rules/rule1_4.gdl @@ -1501,7 +1501,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { +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__(), @@ -1509,7 +1509,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (total = tmp_22(ID).len()) { if (tmp_24(index)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = currStr) { + if (res = currStr) { return true } } @@ -1518,7 +1518,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (index > 0) { if (connectStrBase(ID, index - 1, reStr)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = reStr + currStr) { + if (res = reStr + currStr) { return true } } @@ -1531,11 +1531,10 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { } pub fn connectStr(ID: Expression) -> string { let (java_db = default_java_db()) { - for (c in int::__undetermined_all__(), - result in string::__undetermined_all__()) { + for (c in int::__undetermined_all__(), res in string::__undetermined_all__()) { if (c = tmp_25(ID).len()) { - if (connectStrBase(ID, c - 1, result)) { - return result + if (connectStrBase(ID, c - 1, res)) { + return res } } } diff --git a/example/icse25/rules/rule4.gdl b/example/icse25/rules/rule4.gdl index bb46b26..e415206 100644 --- a/example/icse25/rules/rule4.gdl +++ b/example/icse25/rules/rule4.gdl @@ -1201,7 +1201,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { +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__(), @@ -1209,7 +1209,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (total = tmp_19(ID).len()) { if (tmp_21(index)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = currStr) { + if (res = currStr) { return true } } @@ -1218,7 +1218,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (index > 0) { if (connectStrBase(ID, index - 1, reStr)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = reStr + currStr) { + if (res = reStr + currStr) { return true } } @@ -1231,11 +1231,10 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { } pub fn connectStr(ID: Expression) -> string { let (java_db = default_java_db()) { - for (c in int::__undetermined_all__(), - result in string::__undetermined_all__()) { + for (c in int::__undetermined_all__(), res in string::__undetermined_all__()) { if (c = tmp_22(ID).len()) { - if (connectStrBase(ID, c - 1, result)) { - return result + if (connectStrBase(ID, c - 1, res)) { + return res } } } diff --git a/example/icse25/rules/rule9.gdl b/example/icse25/rules/rule9.gdl index 9a694c6..64389d5 100644 --- a/example/icse25/rules/rule9.gdl +++ b/example/icse25/rules/rule9.gdl @@ -536,7 +536,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { +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__(), @@ -544,7 +544,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (total = tmp_19(ID).len()) { if (tmp_21(index)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = currStr) { + if (res = currStr) { return true } } @@ -553,7 +553,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (index > 0) { if (connectStrBase(ID, index - 1, reStr)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = reStr + currStr) { + if (res = reStr + currStr) { return true } } @@ -566,11 +566,10 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { } pub fn connectStr(ID: Expression) -> string { let (java_db = default_java_db()) { - for (c in int::__undetermined_all__(), - result in string::__undetermined_all__()) { + for (c in int::__undetermined_all__(), res in string::__undetermined_all__()) { if (c = tmp_22(ID).len()) { - if (connectStrBase(ID, c - 1, result)) { - return result + if (connectStrBase(ID, c - 1, res)) { + return res } } } diff --git a/example/icse25/rules/rule_ecg.gdl b/example/icse25/rules/rule_ecg.gdl index b445c28..ce0e7ff 100644 --- a/example/icse25/rules/rule_ecg.gdl +++ b/example/icse25/rules/rule_ecg.gdl @@ -2039,7 +2039,7 @@ pub fn facts(a: Expression, i: int, value: string) -> bool { } } } -pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { +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__(), @@ -2048,7 +2048,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (total = tmp_22(ID).len()) { if (tmp_24(index)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = currStr) { + if (res = currStr) { return true } } @@ -2057,7 +2057,7 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { if (index > 0) { if (connectStrBase(ID, index - 1, reStr)) { if (facts(Expression(java_db).find(ID), index, currStr)) { - if (result = reStr + currStr) { + if (res = reStr + currStr) { return true } } @@ -2072,11 +2072,10 @@ pub fn connectStrBase(ID: Expression, index: int, result: string) -> bool { pub fn connectStr(ID: Expression) -> string { let (java_db = default_java_db()) { let (xml_db = default_xml_db()) { - for (c in int::__undetermined_all__(), - result in string::__undetermined_all__()) { + for (c in int::__undetermined_all__(), res in string::__undetermined_all__()) { if (c = tmp_25(ID).len()) { - if (connectStrBase(ID, c - 1, result)) { - return result + if (connectStrBase(ID, c - 1, res)) { + return res } } } From 45914d926f775f19dc242aecb3062783da56a995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=95=E5=B1=B1?= Date: Mon, 28 Apr 2025 17:33:22 +0800 Subject: [PATCH 5/5] fix warnings --- example/icse25/Keymap/FindAllReleasedHttpAPI.gdl | 6 +++--- example/icse25/rules/rule1_4.gdl | 12 ++++++------ example/icse25/rules/rule4.gdl | 4 ++-- example/icse25/rules/rule9.gdl | 4 ++-- example/icse25/rules/rule_ecg.gdl | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl index 456095c..b29585f 100644 --- a/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl +++ b/example/icse25/Keymap/FindAllReleasedHttpAPI.gdl @@ -979,8 +979,8 @@ fn tmp_7(b: string, i: int, a: string) -> bool { 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) = "/") { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { return true } } @@ -1316,7 +1316,7 @@ 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") { + if (temp1 != "app/web/home") { return true } } diff --git a/example/icse25/rules/rule1_4.gdl b/example/icse25/rules/rule1_4.gdl index 41492b1..43d817d 100644 --- a/example/icse25/rules/rule1_4.gdl +++ b/example/icse25/rules/rule1_4.gdl @@ -1590,7 +1590,7 @@ pub fn real_output(nodeText: string, path: string) -> bool { 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 (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -1601,7 +1601,7 @@ pub fn real_output(nodeText: string, path: string) -> bool { } if (c = a) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -1614,7 +1614,7 @@ pub fn real_output(nodeText: string, path: string) -> bool { if (b = m) { if (c = a.getAnAncestorCDDependedNode(__all_data__, __all_data__)) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -1625,7 +1625,7 @@ pub fn real_output(nodeText: string, path: string) -> bool { } if (c = a) { if (c = b.getECGDependsNode(edgeType, direction)) { - if (!b = c) { + if (b != c) { if (nodeText = m.print()) { if (path = m.getPath()) { return true @@ -1711,8 +1711,8 @@ fn tmp_6(a: string, i: int, b: string) -> bool { @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) = "/") { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { return true } } diff --git a/example/icse25/rules/rule4.gdl b/example/icse25/rules/rule4.gdl index e415206..0cea210 100644 --- a/example/icse25/rules/rule4.gdl +++ b/example/icse25/rules/rule4.gdl @@ -1387,8 +1387,8 @@ fn tmp_3(a: string, b: string, i: int) -> bool { @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) = "/") { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { return true } } diff --git a/example/icse25/rules/rule9.gdl b/example/icse25/rules/rule9.gdl index 64389d5..78e2c26 100644 --- a/example/icse25/rules/rule9.gdl +++ b/example/icse25/rules/rule9.gdl @@ -664,8 +664,8 @@ fn tmp_3(i: int, b: string, a: string) -> bool { @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) = "/") { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { return true } } diff --git a/example/icse25/rules/rule_ecg.gdl b/example/icse25/rules/rule_ecg.gdl index ce0e7ff..d4bd39b 100644 --- a/example/icse25/rules/rule_ecg.gdl +++ b/example/icse25/rules/rule_ecg.gdl @@ -2297,8 +2297,8 @@ fn tmp_6(a: string, i: int, b: string) -> bool { 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) = "/") { + if (a.substr(i - 1,i - 1) != "/") { + if (b.substr(0,1) != "/") { return true } }