diff --git a/.gitignore b/.gitignore index afd5918..1c81bff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,157 @@ +# Created by https://www.toptal.com/developers/gitignore/api/intellij,java,maven +# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,java,maven + +### Intellij ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/ +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# eclipse project file +.settings/ +.classpath +.project + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized es.uniovi.reflection.progquery.cache file +.idea/caches/build_file_checksums.ser + +### Intellij Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +# https://plugins.jetbrains.com/plugin/7973-sonarlint +.idea/**/sonarlint/ + +# SonarQube Plugin +# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin +.idea/**/sonarIssues.xml + +# Markdown Navigator plugin +# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced +.idea/**/markdown-navigator.xml +.idea/**/markdown-navigator-enh.xml +.idea/**/markdown-navigator/ + +# Cache file creation bug +# See https://youtrack.jetbrains.com/issue/JBR-2257 +.idea/$CACHE_FILE$ + +# CodeStream plugin +# https://plugins.jetbrains.com/plugin/12206-codestream +.idea/codestream.xml + +### Java ### +# Compiled class file *.class -ProgQuery/build/* -ProgQuery/neo4j/* -ProgQuery/data/* -ProgQuery/bin/ -ProgQuery/bon/ -ProgQuery/temp/* -ProgQuery/.gradle/* -ProgQuery/.classpath -ProgQuery/.project -ProgQuery/cdAdapted.bat -ProgQuery/cdAdaptedUpdated.bat -ProgQuery/pdgTest_wiggle.bat -ProgQuery/python_measurement.bat -ProgQuery/startup.test.csv -ProgQuery/*.pyc -ProgQuery/compilePlugin.bat -ProgQuery/compileAndExecuteWithArgs.bat -ProgQuery/executePlugin--.bat -ProgQuery/loadExecuteAndView.bat -ProgQuery/.metadata/* -*.pyc -*.py -*.csv -*.bat -*.txt + +# Log file *.log -*.exe -*.gexf -binaries_bad/* -__pycache__/* -ProgQuery/javac.*.args \ No newline at end of file + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +### Maven ### +target/ +*/target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar +.flattened-pom.xml + +# End of https://www.toptal.com/developers/gitignore/api/intellij,java,maven + +#Added by me +/bin/ +/data/ \ No newline at end of file diff --git a/ExampleClasses/.classpath b/ExampleClasses/.classpath deleted file mode 100644 index fb50116..0000000 --- a/ExampleClasses/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/ExampleClasses/.gitignore b/ExampleClasses/.gitignore deleted file mode 100644 index ae3c172..0000000 --- a/ExampleClasses/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/bin/ diff --git a/ExampleClasses/.project b/ExampleClasses/.project deleted file mode 100644 index c241c69..0000000 --- a/ExampleClasses/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - ExampleClasses - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/ExampleClasses/emptyIf.ql b/ExampleClasses/emptyIf.ql deleted file mode 100644 index fd140fb..0000000 --- a/ExampleClasses/emptyIf.ql +++ /dev/null @@ -1,6 +0,0 @@ - - -import java - -from ControlFlowNode node -select node \ No newline at end of file diff --git a/ExampleClasses/src/TL.java b/ExampleClasses/src/TL.java deleted file mode 100644 index ca6b9e1..0000000 --- a/ExampleClasses/src/TL.java +++ /dev/null @@ -1,9 +0,0 @@ -import java.util.ArrayList; - -public class TL { - - - public void m(){ - System.out.println(ArrayList.class); - } -} diff --git a/ExampleClasses/src/annotations/MyAnn.java b/ExampleClasses/src/annotations/MyAnn.java deleted file mode 100644 index 2387bfb..0000000 --- a/ExampleClasses/src/annotations/MyAnn.java +++ /dev/null @@ -1,52 +0,0 @@ -package annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.util.ArrayList; -import java.util.List; - -import examples.mig.C; - -public abstract class MyAnn extends C{ - public MyAnn(int i) { - super(i); - } - - // public void f() throws T{ - // Class c; - // Class d; - // - // } - private List l = new ArrayList(); - private List l2 = getL(); - - ArrayList getL() { - return null; - } - - int getI() { - return 0; - } - - public String toString() { - return ""; - } - public String getS(){ - return null; - } - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - public @interface JsonElement { - public static final String o = "GGGG"; - - public String key() default JsonElement.o; - - public int g() default (int) 2.9; - } - - @JsonElement - private int a; -} diff --git a/ExampleClasses/src/drawable/Figure2D.java b/ExampleClasses/src/drawable/Figure2D.java deleted file mode 100644 index dde6e64..0000000 --- a/ExampleClasses/src/drawable/Figure2D.java +++ /dev/null @@ -1,5 +0,0 @@ -package drawable; - -public interface Figure2D { - double getPerimeter(); -} diff --git a/ExampleClasses/src/drawable/polygons/Polygon.java b/ExampleClasses/src/drawable/polygons/Polygon.java deleted file mode 100644 index bc3afe2..0000000 --- a/ExampleClasses/src/drawable/polygons/Polygon.java +++ /dev/null @@ -1,37 +0,0 @@ -package drawable.polygons; - -import java.awt.geom.Point2D; - -import drawable.Figure2D; - -public class Polygon implements Figure2D { - - final Point2D[] points;//line 9 - - public Polygon(Point2D... pts) {//line 11 - if (pts.length < 3)//line 12 - throw new IllegalArgumentException("A polygon must have at least three vertices."); - clonePoints(pts, this.points = new Point2D[pts.length]);//line 14 - } - - private static void clonePoints(Point2D[] src, Point2D[] dest) { - if (src.length != dest.length) - throw new IllegalArgumentException("Point arrays must have the same length."); - for (int i = 0; i < src.length; i++) - dest[i] = (Point2D) src[i].clone(); - } - - public void setPoint(int index, Point2D newPoint) { - points[index] = newPoint; - } - - @Override - public double getPerimeter() { - double perimeter = 0; - int nVertices = points.length; - for (int i = 0; i < nVertices; i++) - perimeter += points[i].distance(points[(i + 1) % nVertices]); - return perimeter; - } - -} diff --git a/ExampleClasses/src/drawable/polygons/RegularPolygon.java b/ExampleClasses/src/drawable/polygons/RegularPolygon.java deleted file mode 100644 index 57d15ed..0000000 --- a/ExampleClasses/src/drawable/polygons/RegularPolygon.java +++ /dev/null @@ -1,30 +0,0 @@ -package drawable.polygons; - -import java.awt.geom.Point2D; - -public class RegularPolygon extends Polygon { - - public RegularPolygon(Point2D... points) { - super(points); - if (!equidistantPoints(points)) - throw new IllegalArgumentException("These points do not represent a regular polygon."); - } - - private boolean equidistantPoints(Point2D[] points) { - double distance = points[points.length - 1].distance(points[0]); - for (int i = 0; i < points.length - 1; i++) - if (points[i].distance(points[i + 1]) != distance) - return false; - return true; - } - - @Override - public double getPerimeter() { - return points[0].distance(points[1]) * points.length; - } - - @Override - public void setPoint(int index, Point2D newPoint) { - throw new IllegalStateException("You cannot modify points in a regular polygon."); - } -} diff --git a/ExampleClasses/src/examples/CFG/A.java b/ExampleClasses/src/examples/CFG/A.java deleted file mode 100644 index bb9bebb..0000000 --- a/ExampleClasses/src/examples/CFG/A.java +++ /dev/null @@ -1,33 +0,0 @@ -package examples.CFG; - -import java.io.IOException; - -public class A { - - public A() throws IOException { - - - } - - public void m() throws IOException { - new B().mThrows(); - m(); - } - - int getI() { - return 0; - } - - public static void main(String[] args) { - try { - boolean i = false; - i &= false; - i |= true; - if (args.length == 0) - throw new RuntimeException(); - } finally { - System.out.println("FINALLY"); - } - System.out.println("AFTER FINALLy"); - } -} diff --git a/ExampleClasses/src/examples/CFG/B.java b/ExampleClasses/src/examples/CFG/B.java deleted file mode 100644 index a459d01..0000000 --- a/ExampleClasses/src/examples/CFG/B.java +++ /dev/null @@ -1,16 +0,0 @@ -package examples.CFG; - -import java.io.IOException; - -public class B extends A { - - public B() throws IOException { - super(); - // TODO Auto-generated constructor stub - } - - public void mThrows() throws IOException, AssertionError, NullPointerException { - mThrows(); - new A().m(); - } -} diff --git a/ExampleClasses/src/examples/CFG/BreakTest.java b/ExampleClasses/src/examples/CFG/BreakTest.java deleted file mode 100644 index 36006b6..0000000 --- a/ExampleClasses/src/examples/CFG/BreakTest.java +++ /dev/null @@ -1,112 +0,0 @@ -package examples.CFG; - -public class BreakTest { - static final String F = "FFF"; - - public static void main(final String[] args) { - final int index = 0; - // System.out.println("A"); - // // break; - // System.out.println("B"); - // b: { - // if ("B".length() == 1) - // break b; - // // break a sin label da error de compilación, sólo deja dentro de un - // // loop o switch - // System.out.println("UNREACHEABLE"); - // if (true) - // ; - // // ERROR COMPILACIÓN - // // continue b; - // } - // - // b: do { - // if (true) { - // // ERROR duplicate label b - // // b:; - // a: ; - // // ERROR misssing label a - // // break a; - // } - // - // continue b; - // } while (args[0].contains("a")); - switch (args[0]) { - } - a: { - System.out.println("BLOC K INI"); - if ("A".contains("A")) - break a; - System.out.println("BLOCK END"); - - } - - a: if (true) - b: { - if ("A".contains("A")) - break a; - else - break b; - } - s: synchronized (args) { - - } - int i = 1; - while (i < 20) { - b: { - - if (i % 3 == 0) - break b; - System.out.println("BLOCK END" + i); - - } - - if (i % 5 == 0) - break; - System.out.println("LOOP END" + i); - i++; - } - final String s2 = "J"; - final String s = "DDD"; - switch (s) { - case s: - System.out.println("A"); - case "B": { - } - System.out.println("B"); - // while (true) - // if ("A".contains("A")) - // break; - // else - // break sw; - case "D": - switch (2 + 5) { - case 3: - break; - case 89: - } - case BreakTest.F: { - System.out.println("C"); - break; - } - case (int) 2.9 + "": - default: - System.out.println("DEFAULT"); - - // Aquí podemos dar fallo , no tiene sentido, es como añadir más - // sentencias al default - case "JH": - System.out.println("JH"); - } - } - - static String a = "B"; - - private static String getC() { - System.out.println("EVAL GETC"); - String ret = a; - if (!a.contentEquals("X")) - a = "C"; - return ret; - } -} diff --git a/ExampleClasses/src/examples/CFG/ConstructorInit.java b/ExampleClasses/src/examples/CFG/ConstructorInit.java deleted file mode 100644 index 0034a75..0000000 --- a/ExampleClasses/src/examples/CFG/ConstructorInit.java +++ /dev/null @@ -1,24 +0,0 @@ -package examples.CFG; - -public class ConstructorInit { - - int a = getInt("A"), b = getInt("B"); - public ConstructorInit() { - System.out.println("FIRST ST IN CONST"); - } - - int d = getInt("D"); - - private int getInt(String string) { - System.out.println(string); - return 0; - } - - int e = getInt("E"), f = getInt("F"), g = getInt("G"); - public static void main(String[] args) { - new ConstructorInit(); - } - - int c = getInt("C"); - -} diff --git a/ExampleClasses/src/examples/CFG/LabeledStatementTest.java b/ExampleClasses/src/examples/CFG/LabeledStatementTest.java deleted file mode 100644 index f50acd3..0000000 --- a/ExampleClasses/src/examples/CFG/LabeledStatementTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package examples.CFG; - -public class LabeledStatementTest { - - public static void main(String[] args) { - int a; - label: while (true) - break label; - label: for (int i = 0; i < 4; i++) - label2: { - System.out.println(i); - if (i > 1) - continue; - System.out.println("A"); - } - - } -} diff --git a/ExampleClasses/src/examples/CFG/TryCatchFinally.java b/ExampleClasses/src/examples/CFG/TryCatchFinally.java deleted file mode 100644 index c3a2d2a..0000000 --- a/ExampleClasses/src/examples/CFG/TryCatchFinally.java +++ /dev/null @@ -1,137 +0,0 @@ -package examples.CFG; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.Reader; -import java.lang.reflect.Method; - -public class TryCatchFinally { - boolean aux = false; - - public void m(int a) throws IOException, ClassNotFoundException, AssertionError, CloneNotSupportedException, - InstantiationException, IllegalAccessException { - // Statement 0 - Method m = null; - // Statement 1(label), 2(try), 3, 4 (resources) - tr: try (BufferedReader r = new BufferedReader(getS()); BufferedReader r2 = null) { - // Statement 5 - new TryCatchFinally().getR(); - // Statement 6 - try { - // Statement 7, 8, 9 - m.getDeclaringClass().getFields()[7].set(m, 2); - NullPointerException n = null; - if (a < 2) - // Statement 10 - throw n; - // Statement 11, 12 - try (BufferedReader rd = null) { - // Statement 13 - m.invoke(m, 1); - } - // Statement 14,15 - } catch (IndexOutOfBoundsException e) { - // Statement 16 - a = 5; - // Statement 17,18,19,20 - } catch (RuntimeException f) { - a += 7; - m.getClass().newInstance(); - // Satetement 21,22 - } catch (Exception g) { - // Statement 23,24,25 (initialization), 26 (update) - fr: for (int i = 0; i < 6; i++) - // Statement 27 - try { - // Statement 28,29,30 (continue), 31, 32 (break), 33, 34 - // (continue fr), 35 (break tr) - assert (i >= 9); - if (i == a) - continue; - else if ("J".contains(i + "")) - break; - else if (aux) - continue fr; - else - break tr; - // Statement 36 - } finally { - // Statement 37, 38, 39, 40, 41, 42, 43 - a++; - NullPointerException n = null; - if (a == 6) - throw n; - else if (a == 7) - assert (a == 8); - else if(a==9) - continue fr; - else - throw new IllegalAccessError(); - } - } - // Statement 44 - throw new RuntimeException(); - // Statement 45,46,47 - } catch (NullPointerException h) { - break tr; - // Statement 48,49 - } catch (AssertionError i) { - // Statement 50 (label) ,51,52 (declaration) - fr: for (String st : "H".split("H")) - // Statement 53 - while (true) - // Statement 54 - try { - // Statement 55,56,57,58,59 - if (a == 4) - break; - else if (a == 7) - break tr; - else - continue fr; - // Statement 60 - } finally { - } - // Statement 61 - } finally { - // Statement 62 - System.out.println(a); - // Statement 63 - try { - // Statement 64,65 - assert (a * 2 == 9); - m.getClass().newInstance(); - // Statement 66 - do - // Statement 67 , 68 - if (m.toString().length() == 2) - break; - while (true); - // Statement 69 - throw new IllegalMonitorStateException(); - // Statement 70,71,72 - } catch (Throwable t) { - ; - // Statement 73 - } finally { - // Statement 74,75,76,77 - try (BufferedReader br = null) { - if (getR().ready()) - break tr; - } - } - } - } - - public Reader getS() throws IOException { - return null; - } - - public Reader getR() throws ClassNotFoundException, AssertionError { - return null; - } - - public TryCatchFinally() throws CloneNotSupportedException { - - } -} diff --git a/ExampleClasses/src/examples/CFG/TryClauseTest.java b/ExampleClasses/src/examples/CFG/TryClauseTest.java deleted file mode 100644 index 07aa8c6..0000000 --- a/ExampleClasses/src/examples/CFG/TryClauseTest.java +++ /dev/null @@ -1,110 +0,0 @@ -package examples.CFG; - -import java.io.BufferedReader; -import java.io.IOException; - -public class TryClauseTest { - - public static void main(String[] args) throws IOException, InterruptedException { - int i = 0; - // BufferedReader brd = m(); - // w: while (true) - try (BufferedReader br = m()) { - - // break w; - } catch (Exception e) { - System.out.println("CAUGHT"); - throw e; - // break w; - } finally { - System.out.println("FIRST FINALLY"); - } - bb: { - try { - break bb; - } finally { - - } - - } - while (true) - try { - if (args.length == 0) - continue; - else - break; - } finally { - System.out.println("LOOP FINALLY"); - } - - othertr: try { - // if (args.length == 0) - // break tr; - try { - System.out.println("TRY"); - // break tr; - } finally { - System.out.println("FIRST FINALLY"); - if (args.length == 0) - break othertr; - System.out.println("FIRST FINALLY END"); - } - } catch (Exception f) { - System.out.println("CAUGHT"); - if (args.length == 0) - break othertr; - System.out.println("POST CAUGHT"); - } finally { - System.out.println("FINALLY"); - if (args.length == 0) - break othertr; - System.out.println("POST-BREAK"); - } - - try { - try { - System.out.println("FIRST NESTED TRY"); - if (args.length == 0) - throw new IllegalAccessError(); - } finally { - // throw new IllegalStateException(); - } - } - // catch (IllegalAccessError e) { - // System.out.println("SECOND CATCHED " + e); - // } - finally { - try { - System.out.println("NESTED TRY"); - } catch (IllegalAccessError e) { - System.out.println("CAUGHT " + e); - } finally { - System.out.println("SECOND FINALLY"); - - } - - try (BufferedReader br = new BufferedReader(null); BufferedReader br2 = null) { - - assert (false); - System.out.println("FIN"); - } - // catch(Exception e){ - // - // } - finally { - Thread.sleep(3000); - System.out.println("Finally"); - throw new IllegalAccessError(); - } - } - } - - private static BufferedReader m() throws IOException { - throw new IOException(); - } - - // int i = 0; - // i++; - - // } -} diff --git a/ExampleClasses/src/examples/Constructores.java b/ExampleClasses/src/examples/Constructores.java deleted file mode 100644 index dea2918..0000000 --- a/ExampleClasses/src/examples/Constructores.java +++ /dev/null @@ -1,58 +0,0 @@ -package examples; - -import java.io.BufferedReader; - -import examples.classesDependencies.ClassUse; -import examples.classesDependencies.Interface; -import examples.cmu.SubA; -import examples.cmu.SubA2; - -public class Constructores { - SubA a; - SubA2 a2; - double b; - - public Constructores() { - } - - public Constructores(Object a) { - this.b = a.hashCode() / 2.0; - } - - public Constructores(Integer a) { - b = a / 2.0; - } - - public Constructores(Interface a) { - // b = a / 2.0; - } - - public Constructores(BufferedReader a) { - // b = a / 2.0; - } - - public Constructores(int a) { - b *= a / 2.0; - - new Interface() { - - public int a() { - return 2; - } - }; - } - - public static Constructores newInstance(int a) { - new Constructores(); - new Constructores(new BufferedReader(null)); - new Constructores(); - new Constructores("JMO"); - new Constructores(new ClassUse()); - - return new Constructores(a); - } - - public void m() { - super.toString(); - } -} diff --git a/ExampleClasses/src/examples/Interface.java b/ExampleClasses/src/examples/Interface.java deleted file mode 100644 index 08c7a20..0000000 --- a/ExampleClasses/src/examples/Interface.java +++ /dev/null @@ -1,7 +0,0 @@ -package examples; - -public interface Interface { - default void m () throws InterruptedException{ - this.wait(); - } -} diff --git a/ExampleClasses/src/examples/OtherClass.java b/ExampleClasses/src/examples/OtherClass.java deleted file mode 100644 index e56590e..0000000 --- a/ExampleClasses/src/examples/OtherClass.java +++ /dev/null @@ -1,15 +0,0 @@ -package examples; - -import examples.classesDependencies.Interface; - -public class OtherClass /* extends BufferedReader */ implements Interface { - - public OtherClass() { - } - - public int n; - - public static class InnerClass implements Interface { - public static int n = 0; - } -} diff --git a/ExampleClasses/src/examples/Test.java b/ExampleClasses/src/examples/Test.java deleted file mode 100644 index 53569d2..0000000 --- a/ExampleClasses/src/examples/Test.java +++ /dev/null @@ -1,20 +0,0 @@ -package examples; - -public class Test { - - public static void main(String[] args) { - int a = 2; - } - - @Override - public boolean equals(Object o) { - return true; - } - public boolean equals(Object o,Object o2) { - return true; - } - @Override - public int hashCode() { - return 2; - } -} diff --git a/ExampleClasses/src/examples/TestNoHash.java b/ExampleClasses/src/examples/TestNoHash.java deleted file mode 100644 index 615534e..0000000 --- a/ExampleClasses/src/examples/TestNoHash.java +++ /dev/null @@ -1,15 +0,0 @@ -package examples; - -public class TestNoHash { - @Override - public boolean equals(Object o) { - return true; - } - - public int hashCode(int arg) { -// Class c; - return arg -// +2.5 - ; - } -} diff --git a/ExampleClasses/src/examples/TestSwitch.java b/ExampleClasses/src/examples/TestSwitch.java deleted file mode 100644 index d37192f..0000000 --- a/ExampleClasses/src/examples/TestSwitch.java +++ /dev/null @@ -1,19 +0,0 @@ -package examples; - -public class TestSwitch { - - public static void main(String[] args) { - - switch (args[0]) { - - case "a": - System.out.println("OKKKOKIHUHIJKDFP"); - Integer i = 2; - - case "b": - // i.toString(); - - default: - } - } -} diff --git a/ExampleClasses/src/examples/TestUtil.java b/ExampleClasses/src/examples/TestUtil.java deleted file mode 100644 index c19b66c..0000000 --- a/ExampleClasses/src/examples/TestUtil.java +++ /dev/null @@ -1,8 +0,0 @@ -package examples; - -public class TestUtil { - @Override - public boolean equals(Object o) { - return true; - } -} diff --git a/ExampleClasses/src/examples/bloch/_11/S_BAD.java b/ExampleClasses/src/examples/bloch/_11/S_BAD.java deleted file mode 100644 index 23e9027..0000000 --- a/ExampleClasses/src/examples/bloch/_11/S_BAD.java +++ /dev/null @@ -1,21 +0,0 @@ -package examples.bloch._11; - -import java.io.IOException; -import java.io.Serializable; - -public class S_BAD implements Serializable { - - private void writeObject(java.io.ObjectOutputStream out) - { - - } - private void readObject() - throws IOException, ClassNotFoundException{ - - } - - Object readResolve() { - return null; - - } -} diff --git a/ExampleClasses/src/examples/bloch/_11/S_BAD2.java b/ExampleClasses/src/examples/bloch/_11/S_BAD2.java deleted file mode 100644 index 627158f..0000000 --- a/ExampleClasses/src/examples/bloch/_11/S_BAD2.java +++ /dev/null @@ -1,14 +0,0 @@ -package examples.bloch._11; - -import java.io.IOException; -import java.io.Serializable; - -public class S_BAD2 implements Serializable { - - - protected void readObject(java.io.ObjectInputStream in) - throws IOException, ClassNotFoundException{ - - } - -} diff --git a/ExampleClasses/src/examples/bloch/_11/S_COM.java b/ExampleClasses/src/examples/bloch/_11/S_COM.java deleted file mode 100644 index 7b5778f..0000000 --- a/ExampleClasses/src/examples/bloch/_11/S_COM.java +++ /dev/null @@ -1,14 +0,0 @@ -package examples.bloch._11; - -import java.io.IOException; -import java.io.Serializable; - -public class S_COM implements Serializable { - - - private void readObject(java.io.ObjectInputStream in) - throws IOException, ClassNotFoundException{ - - } - -} diff --git a/ExampleClasses/src/examples/bloch/_11/S_COM2.java b/ExampleClasses/src/examples/bloch/_11/S_COM2.java deleted file mode 100644 index b29c359..0000000 --- a/ExampleClasses/src/examples/bloch/_11/S_COM2.java +++ /dev/null @@ -1,13 +0,0 @@ -package examples.bloch._11; - -import java.io.IOException; -import java.io.ObjectStreamException; -import java.io.Serializable; - -public class S_COM2 implements Serializable { - - - public Object readResolve() throws ObjectStreamException{ - return new S_COM2(); - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/AnnotationsAndWarningsTest.java b/ExampleClasses/src/examples/bloch/experiments/AnnotationsAndWarningsTest.java deleted file mode 100644 index f2180fd..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/AnnotationsAndWarningsTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package examples.bloch.experiments; - -import java.util.ArrayList; - -//@SuppressWarnings("unchecked") -/** - * @author Oscar - * - * @param - */ -public class AnnotationsAndWarningsTest { - - public String toString(){ - E[] array=(E[]) new ArrayList().toArray(); - return array.toString(); - } - - - /** - * @param a2 - */ - @SuppressWarnings("unchecked") - public void foo(int a2){ - @SuppressWarnings("unchecked") - int a=2; - } - - -} diff --git a/ExampleClasses/src/examples/bloch/experiments/AssertTest.java b/ExampleClasses/src/examples/bloch/experiments/AssertTest.java deleted file mode 100644 index 6daec02..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/AssertTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package examples.bloch.experiments; - -public class AssertTest { - - public static void main(String[] args) { - System.out.println("START"); - try { - assert (args.length > 0); - } catch (AssertionError | Exception e) { - System.out.println("CACHADO"); - e.printStackTrace(); - } - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/BaseEnum.java b/ExampleClasses/src/examples/bloch/experiments/BaseEnum.java deleted file mode 100644 index 45c2cd8..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/BaseEnum.java +++ /dev/null @@ -1,8 +0,0 @@ -package examples.bloch.experiments; - -public enum BaseEnum { - A,B; -static{ - - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/ExtensibleEnumsTest.java b/ExampleClasses/src/examples/bloch/experiments/ExtensibleEnumsTest.java deleted file mode 100644 index d068017..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/ExtensibleEnumsTest.java +++ /dev/null @@ -1,6 +0,0 @@ -package examples.bloch.experiments; - -import java.io.Serializable; - -public enum ExtensibleEnumsTest implements Serializable{ -} diff --git a/ExampleClasses/src/examples/bloch/experiments/GenericsTest.java b/ExampleClasses/src/examples/bloch/experiments/GenericsTest.java deleted file mode 100644 index 2ea3fe0..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/GenericsTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package examples.bloch.experiments; - -import java.util.HashSet; -import java.util.Set; - -public class GenericsTest { - - - public void foo(Set s){ - Set s2=new HashSet<>(); - Set s3=new HashSet(); - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/HierarchyTest.java b/ExampleClasses/src/examples/bloch/experiments/HierarchyTest.java deleted file mode 100644 index 1d66e23..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/HierarchyTest.java +++ /dev/null @@ -1,9 +0,0 @@ -package examples.bloch.experiments; - -public class HierarchyTest extends NestedClassesTest{ - @Override - public String toString(){ - return "HIERAR TOSTRING"; - } - -} diff --git a/ExampleClasses/src/examples/bloch/experiments/MetodosHeredados.java b/ExampleClasses/src/examples/bloch/experiments/MetodosHeredados.java deleted file mode 100644 index 29d395a..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/MetodosHeredados.java +++ /dev/null @@ -1,16 +0,0 @@ -package examples.bloch.experiments; - -public class MetodosHeredados extends Thread{ - - @Override - public void interrupt(){ - System.out.println("naaaaaaa"); - } - - - public void foo(){ - interrupt(); - super.interrupt(); - this.interrupt(); - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/MetodosHeredadosTest2.java b/ExampleClasses/src/examples/bloch/experiments/MetodosHeredadosTest2.java deleted file mode 100644 index 2e7d23c..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/MetodosHeredadosTest2.java +++ /dev/null @@ -1,11 +0,0 @@ -package examples.bloch.experiments; - -public class MetodosHeredadosTest2 extends Thread{ - - - public void foo(){ - interrupt(); - super.interrupt(); - this.interrupt(); - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/NativeTest.java b/ExampleClasses/src/examples/bloch/experiments/NativeTest.java deleted file mode 100644 index 4cf860d..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/NativeTest.java +++ /dev/null @@ -1,10 +0,0 @@ -package examples.bloch.experiments; - -public class NativeTest { - public native void printText (); - - static{ - System.loadLibrary ("happy"); - } - -} diff --git a/ExampleClasses/src/examples/bloch/experiments/NestedClassesTest.java b/ExampleClasses/src/examples/bloch/experiments/NestedClassesTest.java deleted file mode 100644 index 070532b..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/NestedClassesTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package examples.bloch.experiments; -public class NestedClassesTest { - private int val; - public String toString(){ - return "NESTED TOSTRING"; - } - - Comparable c= new Comparable(){ - - public void foo(){ - boolean val; - val=false; - System.out.println(val); - } - @Override - public int compareTo(Object o) { - return val; - }}; -} diff --git a/ExampleClasses/src/examples/bloch/experiments/TestCalls.java b/ExampleClasses/src/examples/bloch/experiments/TestCalls.java deleted file mode 100644 index 71eb74a..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/TestCalls.java +++ /dev/null @@ -1,35 +0,0 @@ -package examples.bloch.experiments; - -import java.util.ArrayList; -import java.util.Collections; - -public class TestCalls { - - public static void main(String[] args) throws Throwable { - new HierarchyTest(); - new TestCalls(); - // System.out.println(o.toString()); - // NestedClassesTest n = (NestedClassesTest) o; - - // System.out.println(n.toString()); - // System.out.println( new HierarchyTest().toString()); - - TestExceptions.m(); - - - Collections.emptyEnumeration(); - new TestCalls().classMethod(); - new HierarchyTest().toString(); - m2(); - new Exception(); - new ArrayList<>(); - } - - public static void m2() { - - } - - public void classMethod() { - - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/TestExceptions.java b/ExampleClasses/src/examples/bloch/experiments/TestExceptions.java deleted file mode 100644 index 9724bd9..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/TestExceptions.java +++ /dev/null @@ -1,25 +0,0 @@ -package examples.bloch.experiments; - -import java.io.IOException; -import java.sql.SQLException; - -public class TestExceptions { - - public static void m() throws Throwable { - m1(); - try { - m2(); - } catch (Exception e) { - e.printStackTrace(); - throw new Exception("ERROR", e); - } - } - - public static void m1() throws Exception { - - } - - public static void m2() throws IOException, SQLException { - - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/TestSynchro.java b/ExampleClasses/src/examples/bloch/experiments/TestSynchro.java deleted file mode 100644 index 959394e..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/TestSynchro.java +++ /dev/null @@ -1,16 +0,0 @@ -package examples.bloch.experiments; - -public class TestSynchro { - - - - public static synchronized void m() throws InterruptedException{ - new TestSynchro().wait(); - } - public void m2() throws InterruptedException{ - synchronized(this){ - - } - wait(); - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/TryCatchFinallyTest.java b/ExampleClasses/src/examples/bloch/experiments/TryCatchFinallyTest.java deleted file mode 100644 index 03855d2..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/TryCatchFinallyTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package examples.bloch.experiments; - -public class TryCatchFinallyTest { - - public static void main(String[] args) { - System.out.println("START"); - try { - System.out.println(1 / 0); - } catch (Exception e) { - System.out.println("CACHADO"); - e.printStackTrace(); - } - } -} diff --git a/ExampleClasses/src/examples/bloch/experiments/VarargsTest.java b/ExampleClasses/src/examples/bloch/experiments/VarargsTest.java deleted file mode 100644 index c875f26..0000000 --- a/ExampleClasses/src/examples/bloch/experiments/VarargsTest.java +++ /dev/null @@ -1,12 +0,0 @@ -package examples.bloch.experiments; - -public class VarargsTest { - - public void foo(int... iarray){ - int i=0; - System.out.println(iarray[i]); - } - public void faa(boolean[] iarray){ - - } -} diff --git a/ExampleClasses/src/examples/bloch/ruledetection/chapter4_17/Base.java b/ExampleClasses/src/examples/bloch/ruledetection/chapter4_17/Base.java deleted file mode 100644 index b348385..0000000 --- a/ExampleClasses/src/examples/bloch/ruledetection/chapter4_17/Base.java +++ /dev/null @@ -1,17 +0,0 @@ -package examples.bloch.ruledetection.chapter4_17; - -public class Base { - - protected Base() { - method(); - method2(); - } - - protected void method() { - - } - - void method2() { - - } -} diff --git a/ExampleClasses/src/examples/bloch/ruledetection/chapter4_17/Other.java b/ExampleClasses/src/examples/bloch/ruledetection/chapter4_17/Other.java deleted file mode 100644 index e33f8df..0000000 --- a/ExampleClasses/src/examples/bloch/ruledetection/chapter4_17/Other.java +++ /dev/null @@ -1,14 +0,0 @@ -package examples.bloch.ruledetection.chapter4_17; - -public class Other extends Base { - int i = 5; - - @Override - public void method2() { - System.out.println(i); - } - - public static void main(String[] args) { - new Other(); - } -} diff --git a/ExampleClasses/src/examples/classesDependencies/ClassUse.java b/ExampleClasses/src/examples/classesDependencies/ClassUse.java deleted file mode 100644 index d6c4c2c..0000000 --- a/ExampleClasses/src/examples/classesDependencies/ClassUse.java +++ /dev/null @@ -1,58 +0,0 @@ -package examples.classesDependencies; - -import java.util.ArrayList; -import java.util.Collections; - -import examples.Constructores; -import examples.OtherClass; - -public class ClassUse implements Interface { - - - Constructores getCOnstructores() { - return new Constructores(); - } - - - - private ArrayList l; - - // public static Z getZ() { - // return new Z(); - // } - public int m() { - return Collections.emptyMap().size(); - } - - public int m(Integer i) { - return Collections.emptyMap().size(); - } - - public int m(String s) { - return Collections.emptyMap().size(); - } - - public int m(Object o) { - return Collections.emptyMap().size(); - } - - public int mm() { - m("JBOÑL"); - m(1); - m("MLL".getClass()); - return new ExtraClass().OTHER.n; - } - - public int mmm() { - - return getE().getO().n; - } - - public ExtraClass getE() { - return new ExtraClass(); - } - - public Object getI() { - return OtherClass.InnerClass.n; - } -} diff --git a/ExampleClasses/src/examples/classesDependencies/ExtraClass.java b/ExampleClasses/src/examples/classesDependencies/ExtraClass.java deleted file mode 100644 index a26aafc..0000000 --- a/ExampleClasses/src/examples/classesDependencies/ExtraClass.java +++ /dev/null @@ -1,37 +0,0 @@ -package examples.classesDependencies; - -import examples.OtherClass; -import examples.cmu.SubE; - -public class ExtraClass implements Interface { - public SubE getE() { - return null; - } - - static { - ExtraClass e; - (e = new ExtraClass()).getO(); - e.getO(); - } - - public ExtraClass() { - ExtraClass e; - (e = new ExtraClass()).getO(); - e.getO(); - } - - public static OtherClass getA() { - return new ExtraClass().OTHER; - } - - public OtherClass getO() { - return getA(); - } - - private static class InnerClass { - static int n = 0; - } - - public OtherClass OTHER = new OtherClass(); - -} diff --git a/ExampleClasses/src/examples/classesDependencies/Interface.java b/ExampleClasses/src/examples/classesDependencies/Interface.java deleted file mode 100644 index 27f1fa4..0000000 --- a/ExampleClasses/src/examples/classesDependencies/Interface.java +++ /dev/null @@ -1,5 +0,0 @@ -package examples.classesDependencies; - -public interface Interface { - -} diff --git a/ExampleClasses/src/examples/cmu/A.java b/ExampleClasses/src/examples/cmu/A.java deleted file mode 100644 index 2deac0c..0000000 --- a/ExampleClasses/src/examples/cmu/A.java +++ /dev/null @@ -1,112 +0,0 @@ -package examples.cmu; - -import java.io.File; -import java.io.Serializable; - -import examples.classesDependencies.ClassUse; - -public class A implements Serializable { - protected int test; - - public static final int m = 3; - public File f; - int[] array; - static int i; - - public void a(){ - i++; - } - - public SubA s() { - System.out.println(s); - return s; - } - - SubA s; - - public int[] getArray() { - return array; - } - - public void setArray(int index, int val) { - array[index] = val; - } - - static int staticMethod(String s) { - return Z.staticMethod(s); - } - - static int staticMethodBis(String s) { - return A.staticMethodBis(s); - } - - public static void main(String[] args) { - System.out.println(new A().clone()); - } - - // @Override - public void confusing(int i, String g) { - synchronized (g) { - - } - // VAR DEC - // RETURN TYPE - // new Class - // Static Member access or ( mInv or Ident, static access implicit- - // excluding the class itself) - // Solo Z.m, o Z.A.m, nunca ().().a.m aunque m sea estático - // Distinguir Z.a.m de Z.A.m symbol(Z.A) classSymbol vs symbol(Z.a) - // attribute symbol - // Class IDENT - // System.out.println(new D().c().b + 2); - if (this.f != null) { - int[] array; - array = null; - } - else{ - array[8]++; - System.out.println("HELLLO"); - } - this.f = null; - f = null; - int[] array; - this.array[6] = 0; - array = null; - new ClassUse(); - // int a = ClassUse.getZ().fff.hashCode() + ClassUse.getZ().confusing(g, - // i) + 2; - - switch ("MKOK".length()) { - case 3: - array = null; - - case 5: - break; - case 6: - System.out.println(array); - } - } - - public Object clone() { - return null; - } - - public void m(A o) { - - } - - float ff = 7 / 2; - - public void convertToFloat() { - float f = 9.0f; - System.out.println(ff); - float ff; - System.out.println((ff = 7 / 5 / 8 / 2) * 0.9); - f = f + 5 / 6; - double d = f; - } - -private final void aaa() { - -} -} diff --git a/ExampleClasses/src/examples/cmu/C.java b/ExampleClasses/src/examples/cmu/C.java deleted file mode 100644 index 789b1a8..0000000 --- a/ExampleClasses/src/examples/cmu/C.java +++ /dev/null @@ -1,62 +0,0 @@ - -package examples.cmu; - -class C extends A { - public final A a; - public int b = 2; - D d; - - public C() { - int aux; - aux = 2; - C c = new C(); - c.d = null; - a = null; - b++; - init(); - d = c.d; - } - - private void init() { - b--; - } - @Override - public void confusing(int i, String g) { - g = null; - - } - - public void m() { - d = null; - } - - static class SINNER { - static class II { - static int b; - } - } - - private class INNER extends E { - - @Override - public void a() { - - } - public INNER() { - - SINNER.II.b = 8; - - f = null; - C.this.f = null; - array = null; - C.this.array = null; - // just d means inherited attr - C.this.d = null; - - this.d = 8; - d = 3; - super.d = 3; - - } - } -} diff --git a/ExampleClasses/src/examples/cmu/CL.java b/ExampleClasses/src/examples/cmu/CL.java deleted file mode 100644 index 3c73b0c..0000000 --- a/ExampleClasses/src/examples/cmu/CL.java +++ /dev/null @@ -1,10 +0,0 @@ -package examples.cmu; - -public class CL extends PT { - - @Override - public PT clone() { - return this.clone(); - } - -} diff --git a/ExampleClasses/src/examples/cmu/CLC.java b/ExampleClasses/src/examples/cmu/CLC.java deleted file mode 100644 index 14cb5e3..0000000 --- a/ExampleClasses/src/examples/cmu/CLC.java +++ /dev/null @@ -1,14 +0,0 @@ -package examples.cmu; - -public class CLC extends PT { - - - - - - @Override - public PT clone() throws CloneNotSupportedException { - return super.getMyClon(); - } - -} diff --git a/ExampleClasses/src/examples/cmu/D.java b/ExampleClasses/src/examples/cmu/D.java deleted file mode 100644 index 2907068..0000000 --- a/ExampleClasses/src/examples/cmu/D.java +++ /dev/null @@ -1,18 +0,0 @@ -package examples.cmu; - -public class D { - - public final A a = null; - public final int b = 2; - public final C c = null; - - public C c() { - new PT(); - System.out.println(new C().b + 2); - c.confusing(2, ""); - C c = new C(); - c.d = null; - a.array[6] = 9; - return null; - } -} diff --git a/ExampleClasses/src/examples/cmu/E.java b/ExampleClasses/src/examples/cmu/E.java deleted file mode 100644 index 2bb3aae..0000000 --- a/ExampleClasses/src/examples/cmu/E.java +++ /dev/null @@ -1,14 +0,0 @@ -package examples.cmu; - -public class E { - int d; - - public E() { - d = 5; - } - - public void a() { - d = 7; - System.out.println(d); - } -} diff --git a/ExampleClasses/src/examples/cmu/MC.java b/ExampleClasses/src/examples/cmu/MC.java deleted file mode 100644 index b646b35..0000000 --- a/ExampleClasses/src/examples/cmu/MC.java +++ /dev/null @@ -1,7 +0,0 @@ -package examples.cmu; - -import java.util.ArrayList; - -public class MC extends ArrayList { - -} diff --git a/ExampleClasses/src/examples/cmu/O.java b/ExampleClasses/src/examples/cmu/O.java deleted file mode 100644 index a0a83cd..0000000 --- a/ExampleClasses/src/examples/cmu/O.java +++ /dev/null @@ -1,12 +0,0 @@ -package examples.cmu; - -public class O { - - public static O a(String s, int i, O o, String ss) { - return new O(); - } - - public static void a(String s, int i, O o, String ss, String another) { - - } -} diff --git a/ExampleClasses/src/examples/cmu/OMC.java b/ExampleClasses/src/examples/cmu/OMC.java deleted file mode 100644 index 6e3c65a..0000000 --- a/ExampleClasses/src/examples/cmu/OMC.java +++ /dev/null @@ -1,7 +0,0 @@ -package examples.cmu; - -import java.util.ArrayList; - -public class OMC extends ArrayList { - -} diff --git a/ExampleClasses/src/examples/cmu/PT.java b/ExampleClasses/src/examples/cmu/PT.java deleted file mode 100644 index 021426a..0000000 --- a/ExampleClasses/src/examples/cmu/PT.java +++ /dev/null @@ -1,9 +0,0 @@ -package examples.cmu; - -public class PT extends Z implements Cloneable { - - public PT getMyClon() throws CloneNotSupportedException { - return (PT) clone(); - } - -} diff --git a/ExampleClasses/src/examples/cmu/SubA.java b/ExampleClasses/src/examples/cmu/SubA.java deleted file mode 100644 index 9df8485..0000000 --- a/ExampleClasses/src/examples/cmu/SubA.java +++ /dev/null @@ -1,65 +0,0 @@ -package examples.cmu; -@SuppressWarnings(value = { "" }) -public class SubA extends A { - - public SubA() { - super.array = new int[2]; - f = null;// A F en vez de a THIS - change(array); - } - - public static int c; - - public final D d = null; - private double[] otherArray; - - @Override - public int[] getArray() { - return array; - } - - @Override - public void confusing(int i, String g) { // DOS RELACIONES <-THIS REPETIDAS 'igual deberían ser this y attr' - // array[2] = 0; - change(d.a.array); // MAY BE MAL, - change(this.array);// MAY BE MAL, - change(array);// NINGUNA, FALTAN A THIS Y A ARRAY - changee(this); - changeIns();/*FALTA A THIS, Y A ARRAY OPCIONAL-cada vez más*/ changeIns(array);/*Falta a this, y a array*/changeInsBis();changeInsBisBis();changeInsBisBisBis(); - changeIns(this); - confusing(i, g); - } - - private static void changee(SubA a) { - a.array[7] = 5; - change(a.array); - } - - private static void change(int[] array) {// FALTA A PARAM - array[7] = 5; - } - - private void changeIns(SubA a) { - a.array[7] = 5; - this.otherArray[9]++; - } - - private void changeIns() {// FALTAN THIS y ATTR - array[7] = 5;// EN VEZ DE THIS, ATTR, tenemos ATTR,ATTR DUP - } - private void changeIns(int[] array) { - array[7] = 5; - } - - private void changeInsBis() { - array = null;// TAMBIÉN MAL - } - - private void changeInsBisBis() { - otherArray = null;// BIEN, DEBE SER POR EL ATRIBUTO SUPER - } - - private void changeInsBisBisBis() { - otherArray[8] = 0; - } -} diff --git a/ExampleClasses/src/examples/cmu/SubA2.java b/ExampleClasses/src/examples/cmu/SubA2.java deleted file mode 100644 index 2c771bf..0000000 --- a/ExampleClasses/src/examples/cmu/SubA2.java +++ /dev/null @@ -1,14 +0,0 @@ -package examples.cmu; - -public class SubA2 { - - public int[] getArray() { - - return null; - } - - // @Override - public void confusing(int i, String g) { - } - -} diff --git a/ExampleClasses/src/examples/cmu/SubE.java b/ExampleClasses/src/examples/cmu/SubE.java deleted file mode 100644 index 86c8b23..0000000 --- a/ExampleClasses/src/examples/cmu/SubE.java +++ /dev/null @@ -1,7 +0,0 @@ -package examples.cmu; - -public class SubE extends E { - public void a() { - - } -} diff --git a/ExampleClasses/src/examples/cmu/SubSubA.java b/ExampleClasses/src/examples/cmu/SubSubA.java deleted file mode 100644 index 07349b3..0000000 --- a/ExampleClasses/src/examples/cmu/SubSubA.java +++ /dev/null @@ -1,5 +0,0 @@ -package examples.cmu; -@SuppressWarnings(value = { "" }) -public class SubSubA extends A { - -} diff --git a/ExampleClasses/src/examples/cmu/Z.java b/ExampleClasses/src/examples/cmu/Z.java deleted file mode 100644 index 140dea3..0000000 --- a/ExampleClasses/src/examples/cmu/Z.java +++ /dev/null @@ -1,345 +0,0 @@ -package examples.cmu; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.List; -import java.util.function.Function; - - -import examples.cmu.otherPackage.B; -import examples.util.EnumExample; - -public class Z implements Serializable, Cloneable { - final int mm = 33 + /* SUMA */99; - - public static /* COMMENT */transient File fff; - - X id(X x) { - - new A().f = null; - Map m = new HashMap(); - - return m.put("key", x); - } - - static int staticMethod(String s) { - return A.staticMethod(s); - } - - public static SubA getSUBA() { - return new SubA(); - } - - public static int X() { - return 0; - } - - public void ordinal() { - B b = new B(); - D d; - EnumExample.FIRST.ordinal(); - } - - public void confusing(int i, String g) { - EnumExample.SECOND.ordinal(); - } - - public int confusing(String g, int i) { - return EnumExample.THIRD.ordinal(); - } - - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - - MC getMC() { - return null; - } - - OMC getOMC() { - return null; - } - - public List getC() { - return null; - } - - public List getRawC() { - return null; - } - - public int[] getArray() { - if ("JOJ".contains("JK")) - return null; - else - return "LMLM".length() == 3 ? null : new int[] {}; - - } - - public void closeable() throws IOException { - - BufferedReader br = new BufferedReader(new FileReader(new File("NJKNJK"))); // <----- - BufferedReader br2 = new BufferedReader(new FileReader(new File("NJKNJK"))); - br.close(); - if (8 == "HBUHB".length()) - "IHHHOIJ".toCharArray(); - Function c = (br = null)::equals; // <------ - for (int i = 0; i < 6; i++) - System.out.println(i); - br2.close(); - br.close(); - - } - - public void compliantCloseable() throws IOException { - - BufferedReader br = new BufferedReader(new FileReader(new File("NJKNJK"))); // <---- - br.close(); - if (8 == "HBUHB".length()) - "IHHHOIJ".toCharArray(); - Function c = (br = null)::equals;// <----- - for (int i = 0; i < 6; i++) - System.out.println(i); - br.close(); - - } - - public void compliantResourcesCloseable() throws IOException { - try (BufferedReader br = new BufferedReader(new FileReader(new File("NJKNJK"))); - BufferedReader br2 = new BufferedReader(new FileReader(new File("NJKNJK")))) { - br.close(); - if (8 == "HBUHB".length()) - "IHHHOIJ".toCharArray(); - for (int i = 0; i < 6; i++) - System.out.println(i); - br2.close(); - br.close(); - } - } - - public void ifTest(String p) { - - if (p == null) { - for (;;) {// - p = p + "OO";// - if (a == 4) {// - p = null;// - System.out.println("");// - } else - System.out.println(p); - System.out.println("KK");// - } - } - System.out.println("LAST");// - } - - public void difficultCompliantCloseable() throws IOException { - - BufferedReader br = new BufferedReader(new FileReader(new File("NJKNJK"))); - br.close(); - BufferedReader br2 = new BufferedReader(new FileReader(new File("NJKNJK"))); - try { - if (8 == "HBUHB".length()) { - if (8 == "HBUHB".length()) { - if (8 == "HBUHB".length()) - "IHHHOIJ".toCharArray(); - Function c = (br = null)::equals; - if (8 == "HBUHB".length()) - "IHHHOIJ".toCharArray(); - int b; - for (int i = 0; i < 6; i++) - System.out.println(i + "" + (br = null)); - assert (br.hashCode() == 9); - } else { - try { - try { - assert (br.hashCode() == 9); - br2.close(); - } finally { - - } - br2.close(); - } catch (AssertionError e) { - try { - throw new IllegalAccessError(); - } finally { - - } - - } finally { - - } - br2.close(); - } - } - } finally { - br2.close(); - } - - } - - public void helpingCG() { - Object o = new Object(), o2 = new Object(); - int a = o.hashCode(); - o = null; - System.out.println(o); - if (89 > "NKNK".length()) - o = null; - else - System.out.println("ELSE"); - for (int i = 0; i < 10; i++) { - System.out.println(o2); - o2 = null; - } - try { - } catch (Exception e) { - o2 = null; - } catch (Error r) { - a++; - } - } - - public void vardecScope() { - Object object = new Object(); - if ("JOJNO".contains("OJ")) { - - if (object.equals(null)) { - object.toString(); - } - object.toString(); - } - } - - private int a, b, c, d, e, a2; - private Z z, y; - - public void attrUse() { - y.e = 3; - System.out.println(z.e + y.e); - } - - public void setA(int i) { - a = i; - new Z().d = 3; - d = 4; - System.out.println(new Z().d); - } - - // public void attrAuxMethod() { - // setA(4); - // System.out.println(a); - // } - - public void blocks() { - if ("INIJO".contains("")) - if ("JIJOJO".length() == 9) - a = 5; - { - a = 3; - } - - synchronized (z) { - if ("".contains("")) - System.out.println(a); - } - } - - public void blocksTwo(O o) { - attrScope(); - if ("NK".length() == 8) { - a = 3; - - if (a == 5) - if (a == 3) { - System.out.println(a); - } - } - - } - - void changes(Z z) { - z.a = 2; - } - - void changes(A a) { - a.array[2] = 5; - } - - public void apparentlyNoChanges() { - changes(this); - - } - - public void apparentlyNoChangesBis() { - changes(this.externallyMutableAttr); - - } - - public void attrScope() { - this.a2 = 9; - Z z = null; - z.a = 0; - this.b = 7; - System.out.println(a2); - System.out.println(z.a + b); - } - - public void attrScopeBis() { - a = 3; - if ("NJHI".length() == 8) - b = 4; - System.out.println(a + b); - } - - public void attrScopeBisBis() { - if ("NJHI".length() == 8) { - b = 4; - a = 3; - System.out.println(a + b); - } - } - - public void attrScopeLoop() { - - for (int i = 0; i < 50; i++) { - a = 3; - - System.out.println(a + this.c); - - c = 4; - } - } - - private E eee; - - public E getE() { - return eee; - } - - private A externallyMutableAttr; - - public A getA() { - return externallyMutableAttr; - } - - public void untrustedClone(Z z) throws CloneNotSupportedException { - a2 = 9; - Z aux = (Z) z.clone(); - } - - public static void main(String[] args) { - try { - throw new NullPointerException(); - } catch (NullPointerException n) { - throw new IllegalStateException(); - } catch (IllegalStateException l) { - - } - } -} diff --git a/ExampleClasses/src/examples/cmu/exs/EX.java b/ExampleClasses/src/examples/cmu/exs/EX.java deleted file mode 100644 index 97a4418..0000000 --- a/ExampleClasses/src/examples/cmu/exs/EX.java +++ /dev/null @@ -1,13 +0,0 @@ -package examples.cmu.exs; - -public class EX extends RuntimeException { - - - public void g(){ - try{ - - }catch(IllegalStateException | IllegalAccessError | StackOverflowError e){ - - } - } -} diff --git a/ExampleClasses/src/examples/cmu/exs/SEx.java b/ExampleClasses/src/examples/cmu/exs/SEx.java deleted file mode 100644 index e8a90c3..0000000 --- a/ExampleClasses/src/examples/cmu/exs/SEx.java +++ /dev/null @@ -1,5 +0,0 @@ -package examples.cmu.exs; - -public class SEx extends EX { - -} diff --git a/ExampleClasses/src/examples/cmu/otherPackage/B.java b/ExampleClasses/src/examples/cmu/otherPackage/B.java deleted file mode 100644 index 2ce359b..0000000 --- a/ExampleClasses/src/examples/cmu/otherPackage/B.java +++ /dev/null @@ -1,24 +0,0 @@ -package examples.cmu.otherPackage; - -import examples.cmu.A; -import examples.cmu.SubA; - - -public class B extends A { - public int a = SubA.c; - public char c = (char) 9.8; - - A getA() { - return null; - } - @Override - public Object clone() { - Object clon; - System.out.println((clon = a == c ? super.clone() : null).hashCode()); - test++; - new B().test++; - ((B) getA()).test++; - return clon; - } - -} diff --git a/ExampleClasses/src/examples/cmu/otherPackage/OP.java b/ExampleClasses/src/examples/cmu/otherPackage/OP.java deleted file mode 100644 index 221737b..0000000 --- a/ExampleClasses/src/examples/cmu/otherPackage/OP.java +++ /dev/null @@ -1,8 +0,0 @@ -package examples.cmu.otherPackage; - -public class OP { - - public static void main(String[] args) { - // new A().test; COMPILER ERROR - } -} diff --git a/ExampleClasses/src/examples/mig/A.java b/ExampleClasses/src/examples/mig/A.java deleted file mode 100644 index 3050489..0000000 --- a/ExampleClasses/src/examples/mig/A.java +++ /dev/null @@ -1,30 +0,0 @@ -package examples.mig; - -public class A implements I { - public A() { - am(); - asm(); - } - - public A identity(A a) { - return a; - } - - public void am() { - new B().m(); - new A(); - asm(); - identity(null); - } - - public static void asm() { - B.sm(); - new A().am(); - - } - - // @Override - // public boolean equals(Object a) { - // return false; - // } -} diff --git a/ExampleClasses/src/examples/mig/B.java b/ExampleClasses/src/examples/mig/B.java deleted file mode 100644 index 0c75475..0000000 --- a/ExampleClasses/src/examples/mig/B.java +++ /dev/null @@ -1,21 +0,0 @@ -package examples.mig; - -public class B extends A { - @Override - public B identity(A a) { - return (B) a; - } - - public void m() { - new A().am(); - new B(); - sm(); - equals(null); - } - - public static void sm() { - A.asm(); - new B().m(); - new B().equals(null); - } -} diff --git a/ExampleClasses/src/examples/mig/C.java b/ExampleClasses/src/examples/mig/C.java deleted file mode 100644 index 3c18ceb..0000000 --- a/ExampleClasses/src/examples/mig/C.java +++ /dev/null @@ -1,44 +0,0 @@ -package examples.mig; - -public class C { - private int i = getI(); - private int j = 2; - private int k; - - @Override - public String toString() { - return "C [i=" + i + ", j=" + j + ", k=" + k + "]"; - } - - public C(int i) { - super(); - SO(); - O(); - } - - static { - SO(); - new C(2).O(); - } - - private static int si = getI(); - private static int sj = 2; - private static int sk; - - private static int getI() { - return 2; - } - - private static void SO() { - - } - - private void O() { - } - - private void OOOO(int nuevadec) { - } - - public static void main(String[] a) { - } -} diff --git a/ExampleClasses/src/examples/mig/I.java b/ExampleClasses/src/examples/mig/I.java deleted file mode 100644 index 73b3055..0000000 --- a/ExampleClasses/src/examples/mig/I.java +++ /dev/null @@ -1,9 +0,0 @@ -package examples.mig; - -public interface I extends J { - @Override - default void i() { - this.toString(); -// super.toString(); - } -} diff --git a/ExampleClasses/src/examples/mig/J.java b/ExampleClasses/src/examples/mig/J.java deleted file mode 100644 index d80cb2a..0000000 --- a/ExampleClasses/src/examples/mig/J.java +++ /dev/null @@ -1,10 +0,0 @@ -package examples.mig; - -import java.io.Serializable; - -public interface J extends Serializable { - - strictfp default void i() { - - } -} diff --git a/ExampleClasses/src/examples/pdg/AttrInitialization.java b/ExampleClasses/src/examples/pdg/AttrInitialization.java deleted file mode 100644 index e892c53..0000000 --- a/ExampleClasses/src/examples/pdg/AttrInitialization.java +++ /dev/null @@ -1,18 +0,0 @@ -package examples.pdg; - -public class AttrInitialization { - - private final int foo; - - public AttrInitialization() { - // COMPILATION_ERROR - // System.out.println(foo); - foo = 2; - System.out.println(foo); - } - - public static void main(String[] args) { - new AttrInitialization(); - } - -} diff --git a/ExampleClasses/src/examples/pdg/LocalVars.java b/ExampleClasses/src/examples/pdg/LocalVars.java deleted file mode 100644 index 56066f4..0000000 --- a/ExampleClasses/src/examples/pdg/LocalVars.java +++ /dev/null @@ -1,47 +0,0 @@ -package examples.pdg; - -import examples.cmu.A; - -public class LocalVars { - - private int a; - - public void m() { - new LocalVars().a--; - a--; - System.out.println(new A().m); - int c=0; - c++; - // -// { -// final int a = 2, b = 3, c = new A().m; -// System.out.println(a + b + c); -// m(); -// } -// while (true) { -// String c, a = "", b; -// a.split("IHJ"); -// break; -// } -// if ("IJIJ".contains("B")) { -// char a; -// a = 'v'; -// this.a++; -// } -// a++; -// class a { -// int a; -// -// public void m2() { -// new a(); -// a++; -// String a = "K"; -// System.out.println(a); -// this.a--; -// System.out.println(LocalVars.a); -// } -// } -// -// System.out.println(new a().a); - } -} diff --git a/ExampleClasses/src/examples/pdg/PDG1.java b/ExampleClasses/src/examples/pdg/PDG1.java deleted file mode 100644 index dd5c4aa..0000000 --- a/ExampleClasses/src/examples/pdg/PDG1.java +++ /dev/null @@ -1,76 +0,0 @@ -package examples.pdg; - -public class PDG1 { - public int i; - private int[] array; - static int si; - - public int[] getArray() { - return array; - } - - public void setI() { - array[0] = 7; - } - - public void setI(int i) { - // method that changes the state of this - PDG1.this.i = i; - } - - public void setSt() { - si = 2; - - } - - public void m(String param) { - param = i + ""; - PDG2 pdg = new PDG2(); - // Aqui en i=.... además de que el atributo i es modifica , el estado de - // this es modificado - i = pdg.pdg.array[8] = pdg.pdg.i; - System.out.println(this.i = array[pdg.pdg.i]); - { - int i = param.length(); - array[i] = array[this.i]; - i = this.i++; - array[i] *= array[i]--; - } - pdg.pdg = this; - while (i == 6) { - int i = array[8] = (pdg.pdg.i * 8) + 5 ^ param.length(); - pdg.tensor[this.i = 5][2 + 3][5].i = (param = "" + (i = array[i])).length(); - array = new int[i]; - } - pdg.m(this); - pdg.m2(this); - PDG1.this.i++; - Exception[] d; - d = new RuntimeException[5]; - } - - public static interface I { - public default void m() { - I.this.toString(); - } - - public void m2(PDG1 p); - - } - - // public void exx() { - // Z a = new A(); - // a.confusing(0, "JON"); - // A aa = (A) a; - // aa.confusing(00, "KOJO"); - // } - // De comment to fail with Enums and A,B element treated as members of - // classes or attributes uninitialized - // private enum E { - // A, B; - // public void m() { - // E.this.toString(); - // A.m(); - // } - // } -} diff --git a/ExampleClasses/src/examples/pdg/PDG2.java b/ExampleClasses/src/examples/pdg/PDG2.java deleted file mode 100644 index 71c0b7e..0000000 --- a/ExampleClasses/src/examples/pdg/PDG2.java +++ /dev/null @@ -1,140 +0,0 @@ -package examples.pdg; - -public class PDG2 implements PDG1.I { - public PDG1 pdg; - public PDG1[][][] tensor; - - /* - * - * - * - * - * - * - * - * - * - * - * - * Multiple comment to keep ordered the results of the query - * - * - * - * - * null - * - * - * - * - * - * - * - * - * - */ - public void m(PDG1 pdg) { - // pdg state mod - pdg.i = 2; - - pdg.i = 5; - } - - public void m2(PDG1 pdg) { - // pdg state mod through method - pdg.setI(2); - } - - public void m22(PDG1 pdg) { - // pdg state mod through method - if (pdg.i == 9) - pdg = null; - pdg.setI(2); - } - - public void m23(PDG1 pdg) { - // pdg state mod through method - pdg = null; - pdg.setI(2); - } - - public void m3(PDG1 pdg) { - - this.pdg = null; - } - - public void m4(PDG1 pdg) { - if (pdg != null) - this.pdg = null; - } - - public void m5(PDG1 pdg) { - if (pdg != null) - this.pdg = null; - else - this.pdg = new PDG1(); - } - - public void m6(PDG1 pdg) { - - pdg = new PDG1(); - // pdg state mod - pdg.i = 2; - - pdg.i = 5; - } - - public void m7(PDG1 pdg) { - m6(pdg); - if (pdg.i == 5) - pdg = new PDG1(); - // pdg state mod - pdg.i = 2; - - pdg.i = 5; - } - - public void m8(PDG1 pdg) { - if (pdg.i == 5) - pdg = new PDG1(); - if (pdg.i == 2) - pdg.i = 5; - } - - public PDG1 getPDG1() { - - return pdg; - } - - public PDG1[][] getTensor() { - - return tensor[0]; - } - - public int[] getPDG1Array() { - return pdg.getArray(); - } - // Falta pasar un array con un atributo como elemento o un objeto con un - // atributo de esta clase como atributo - // Está chungo ---> ES UN MAY - - public PDG2 variableRet(PDG2 p) { - return p.hashCode() == 2 ? p : this; - } - - public PDG2 variableRetBis(PDG2 p) { - if (p.hashCode() == 2) - return p; - else - return this; - } - - public PDG2 thisReturn(PDG2 p) { - return this; - } - - public PDG2 paramReturn(PDG2 p) { - p.m(); - return p; - } - -} diff --git a/ExampleClasses/src/examples/util/EnumExample.java b/ExampleClasses/src/examples/util/EnumExample.java deleted file mode 100644 index 187e45d..0000000 --- a/ExampleClasses/src/examples/util/EnumExample.java +++ /dev/null @@ -1,8 +0,0 @@ -package examples.util; - -public enum EnumExample { - - FIRST, SECOND, THIRD; - - public static final int A=2; -} diff --git a/ExampleClasses/src/examples/visual/A.java b/ExampleClasses/src/examples/visual/A.java deleted file mode 100644 index b134881..0000000 --- a/ExampleClasses/src/examples/visual/A.java +++ /dev/null @@ -1,19 +0,0 @@ -package examples.visual; - -import java.io.File; - -public class A extends File { - - public A(String arg0) { - super(arg0); - } - - int a; - - public void m() { - A aIns = new A("FOO"); - aIns.a = this.a; - while (a < 10) - this.a = this.a + 1; - } -} diff --git a/ExampleClasses/src/java_bio/Error.java b/ExampleClasses/src/java_bio/Error.java deleted file mode 100644 index f8c006b..0000000 --- a/ExampleClasses/src/java_bio/Error.java +++ /dev/null @@ -1,30 +0,0 @@ -package java_bio; - -import java.util.Iterator; - -public class Error implements Iterable { - - - - public Iterator iterator(){ - return new Iterator() { - -// (){ -// super(); -// } - int result=0; - @Override - public boolean hasNext() { - // TODO Auto-generated method stub - return false; - } - - @Override - public String next() { - // TODO Auto-generated method stub - return null; - } - - }; - } -} diff --git a/ProgQuery/.metadata/.lock b/ProgQuery/.metadata/.lock deleted file mode 100644 index e69de29..0000000 diff --git a/ProgQuery/.metadata/.mylyn/.taskListIndex/segments_1 b/ProgQuery/.metadata/.mylyn/.taskListIndex/segments_1 deleted file mode 100644 index 6ac4ce5..0000000 Binary files a/ProgQuery/.metadata/.mylyn/.taskListIndex/segments_1 and /dev/null differ diff --git a/ProgQuery/.metadata/.mylyn/.taskListIndex/write.lock b/ProgQuery/.metadata/.mylyn/.taskListIndex/write.lock deleted file mode 100644 index e69de29..0000000 diff --git a/ProgQuery/.metadata/.mylyn/repositories.xml.zip b/ProgQuery/.metadata/.mylyn/repositories.xml.zip deleted file mode 100644 index 6a22812..0000000 Binary files a/ProgQuery/.metadata/.mylyn/repositories.xml.zip and /dev/null differ diff --git a/ProgQuery/.metadata/.mylyn/tasks.xml.zip b/ProgQuery/.metadata/.mylyn/tasks.xml.zip deleted file mode 100644 index c2f45b3..0000000 Binary files a/ProgQuery/.metadata/.mylyn/tasks.xml.zip and /dev/null differ diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version deleted file mode 100644 index 25cb955..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index deleted file mode 100644 index ed9b514..0000000 Binary files a/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index and /dev/null differ diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version deleted file mode 100644 index 6b2aaa7..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources deleted file mode 100644 index 10fbde5..0000000 Binary files a/ProgQuery/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources and /dev/null differ diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index dffc6b5..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -version=1 diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 90e2f95..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,7 +0,0 @@ -content_assist_proposals_background=255,255,255 -content_assist_proposals_foreground=0,0,0 -eclipse.preferences.version=1 -org.eclipse.jdt.ui.formatterprofiles.version=18 -spelling_locale_initialized=true -useAnnotationsPrefPage=true -useQuickDiffPrefPage=true diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jsch.core.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jsch.core.prefs deleted file mode 100644 index d56c53f..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jsch.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jsch.core.hasChangedDefaultWin32SshHome=true diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs deleted file mode 100644 index 67b1d96..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.m2e.discovery.pref.projects= diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs deleted file mode 100644 index 43e97e4..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -mylyn.attention.migrated=true diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs deleted file mode 100644 index 8d462a6..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs deleted file mode 100644 index 2b60c21..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -migrated.task.repositories.secure.store=true -org.eclipse.mylyn.tasks.ui.filters.nonmatching=true -org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true -org.eclipse.mylyn.tasks.ui.welcome.message=true diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs deleted file mode 100644 index cec8acc..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +++ /dev/null @@ -1,5 +0,0 @@ -PROBLEMS_FILTERS_MIGRATE=true -eclipse.preferences.version=1 -platformState=1584878713036 -quickStart=false -tipsAndTricks=true diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs deleted file mode 100644 index 08076f2..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -showIntro=false diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs deleted file mode 100644 index aa3dc02..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs +++ /dev/null @@ -1,3 +0,0 @@ -//org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false -PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery; -eclipse.preferences.version=1 diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/ProgQuery/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi deleted file mode 100644 index effe214..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi +++ /dev/null @@ -1,2325 +0,0 @@ - - - - activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration - ModelMigrationProcessor.001 - - - - - - - - topLevel - shellMaximized - - - - - persp.actionSet:org.eclipse.mylyn.doc.actionSet - persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation - persp.actionSet:org.eclipse.ui.cheatsheets.actionSet - persp.actionSet:org.eclipse.search.searchActionSet - persp.actionSet:org.eclipse.text.quicksearch.actionSet - persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation - persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation - persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo - persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet - persp.actionSet:org.eclipse.ui.actionSet.keyBindings - persp.actionSet:org.eclipse.ui.actionSet.openFiles - persp.actionSet:org.eclipse.debug.ui.launchActionSet - persp.actionSet:org.eclipse.jdt.ui.JavaActionSet - persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet - persp.actionSet:org.eclipse.ui.NavigateActionSet - persp.viewSC:org.eclipse.jdt.ui.PackageExplorer - persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy - persp.viewSC:org.eclipse.jdt.ui.SourceView - persp.viewSC:org.eclipse.jdt.ui.JavadocView - persp.viewSC:org.eclipse.search.ui.views.SearchView - persp.viewSC:org.eclipse.ui.console.ConsoleView - persp.viewSC:org.eclipse.ui.views.ContentOutline - persp.viewSC:org.eclipse.ui.views.ProblemView - persp.viewSC:org.eclipse.ui.views.ResourceNavigator - persp.viewSC:org.eclipse.ui.views.TaskList - persp.viewSC:org.eclipse.ui.views.ProgressView - persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer - persp.viewSC:org.eclipse.ui.texteditor.TemplatesView - persp.viewSC:org.eclipse.pde.runtime.LogView - persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard - persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard - persp.newWizSC:org.eclipse.ui.wizards.new.folder - persp.newWizSC:org.eclipse.ui.wizards.new.file - persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard - persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective - persp.perspSC:org.eclipse.debug.ui.DebugPerspective - persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks - persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task - persp.showIn:org.eclipse.jdt.ui.PackageExplorer - persp.showIn:org.eclipse.team.ui.GenericHistoryView - persp.showIn:org.eclipse.ui.navigator.ProjectExplorer - persp.actionSet:org.eclipse.debug.ui.breakpointActionSet - persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet - persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet - persp.showIn:org.eclipse.eclemma.ui.CoverageView - persp.showIn:org.eclipse.egit.ui.RepositoriesView - persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard - persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet - persp.viewSC:org.eclipse.ant.ui.views.AntView - - - - org.eclipse.e4.primaryNavigationStack - active - - View - categoryTag:Java - - - View - categoryTag:Java - - - View - categoryTag:General - - - View - categoryTag:Java - - - - - View - categoryTag:Git - - - - - - - - - - View - categoryTag:Mylyn - - - - org.eclipse.e4.secondaryNavigationStack - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:Ant - - - - - - org.eclipse.e4.secondaryDataStack - - View - categoryTag:General - - - View - categoryTag:Java - - - View - categoryTag:Java - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - View - categoryTag:General - - - - - - - - - View - categoryTag:Help - - - View - categoryTag:General - - - View - categoryTag:Help - - - - - - - View - categoryTag:Help - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:Help - - - - org.eclipse.e4.primaryDataStack - EditorStack - - - - - - - View - categoryTag:Java - active - activeOnClose - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:Java - - - - - View - categoryTag:General - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - - View - categoryTag:General - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - - View - categoryTag:Mylyn - - ViewMenu - menuContribution:menu - - - - - - - View - categoryTag:Git - - - - - View - categoryTag:Java - - - - - View - categoryTag:Ant - - - - toolbarSeparator - - - - Draggable - - - - toolbarSeparator - - - - Draggable - - - toolbarSeparator - - - - Draggable - - - Draggable - - - Draggable - - - toolbarSeparator - - - - Draggable - - - - toolbarSeparator - - - - toolbarSeparator - - - - Draggable - - - stretch - SHOW_RESTORE_MENU - - - Draggable - HIDEABLE - SHOW_RESTORE_MENU - - - - - stretch - - - Draggable - - - Draggable - - - - - TrimStack - Draggable - - - - - - - - - - - - - - - - - - - - - - platform:win32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - platform:win32 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Editor - removeOnHide - - - - - View - categoryTag:Ant - - - - - View - categoryTag:Gradle - - - - - View - categoryTag:Gradle - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Java - - - - - View - categoryTag:Git - - - - - View - categoryTag:Git - - - - - View - categoryTag:Git - - - - - View - categoryTag:Git - NoRestore - - - - - View - categoryTag:Git - - - - - View - categoryTag:General - - - - - View - categoryTag:Help - - - - - View - categoryTag:Debug - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java Browsing - - - - - View - categoryTag:Java Browsing - - - - - View - categoryTag:Java Browsing - - - - - View - categoryTag:Java Browsing - - - - - View - categoryTag:Java - - - - - View - categoryTag:General - - - - - View - categoryTag:Java - - - - - View - categoryTag:Java - - - - - View - categoryTag:Maven - - - - - View - categoryTag:Maven - - - - - View - categoryTag:Mylyn - - - - - View - categoryTag:Mylyn - - - - - View - categoryTag:Mylyn - - - - - View - categoryTag:Mylyn - - - - - View - categoryTag:Oomph - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:Team - - - - - View - categoryTag:Team - - - View - categoryTag:Help - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:Help - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:General - - - - - View - categoryTag:XML - - - - - View - categoryTag:XML - - - - glue - move_after:PerspectiveSpacer - SHOW_RESTORE_MENU - - - move_after:Spacer Glue - HIDEABLE - SHOW_RESTORE_MENU - - - glue - move_after:SearchField - SHOW_RESTORE_MENU - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache deleted file mode 100644 index 593f470..0000000 Binary files a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache and /dev/null differ diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache deleted file mode 100644 index 593f470..0000000 Binary files a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache and /dev/null differ diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache deleted file mode 100644 index 593f470..0000000 Binary files a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache and /dev/null differ diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat deleted file mode 100644 index 0edae4b..0000000 Binary files a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat and /dev/null differ diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml deleted file mode 100644 index a4ee3cb..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml deleted file mode 100644 index 9e390f5..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml deleted file mode 100644 index 90b5d77..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml +++ /dev/null @@ -1,10 +0,0 @@ - -
-
- - - - - -
-
diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml b/ProgQuery/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml deleted file mode 100644 index e33758c..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.15.0.20191217-1149.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - %date [%thread] %-5level %logger{35} - %msg%n - - - OFF - - - - - ${org.eclipse.m2e.log.dir}/0.log - - ${org.eclipse.m2e.log.dir}/%i.log - 1 - 10 - - - 100MB - - - %date [%thread] %-5level %logger{35} - %msg%n - - - - - - WARN - - - - - - - - - - - - - - - diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/ProgQuery/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup deleted file mode 100644 index 1f73e14..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/ProgQuery/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml deleted file mode 100644 index 5ca0b77..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - -
-
diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml b/ProgQuery/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml deleted file mode 100644 index ce63673..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - -
-
- - -
-
diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.ui.intro/introstate b/ProgQuery/.metadata/.plugins/org.eclipse.ui.intro/introstate deleted file mode 100644 index 02f134f..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.ui.intro/introstate +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/ProgQuery/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml deleted file mode 100644 index 5b583c4..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +++ /dev/null @@ -1,5 +0,0 @@ - -
-
-
-
diff --git a/ProgQuery/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/ProgQuery/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml deleted file mode 100644 index fe2da5f..0000000 --- a/ProgQuery/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/ProgQuery/.metadata/version.ini b/ProgQuery/.metadata/version.ini deleted file mode 100644 index 06961bf..0000000 --- a/ProgQuery/.metadata/version.ini +++ /dev/null @@ -1,3 +0,0 @@ -#Wed Jan 27 16:55:20 CET 2021 -org.eclipse.core.runtime=2 -org.eclipse.platform=4.15.0.v20200305-0155 diff --git a/ProgQuery/.settings/org.eclipse.jdt.core.prefs b/ProgQuery/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 0fee6a9..0000000 --- a/ProgQuery/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,15 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/ProgQuery/src/META-INF/MANIFEST.MF b/ProgQuery/src/META-INF/MANIFEST.MF deleted file mode 100644 index e17c6b6..0000000 --- a/ProgQuery/src/META-INF/MANIFEST.MF +++ /dev/null @@ -1,2 +0,0 @@ -ProgQueryPlugin # ProgQueryPlugin - diff --git a/ProgQuery/src/META-INF/services/com.sun.source.util.Plugin b/ProgQuery/src/META-INF/services/com.sun.source.util.Plugin deleted file mode 100644 index 4a94de9..0000000 --- a/ProgQuery/src/META-INF/services/com.sun.source.util.Plugin +++ /dev/null @@ -1 +0,0 @@ -ProgQueryPlugin \ No newline at end of file diff --git a/ProgQuery/src/ProgQueryPlugin.java b/ProgQuery/src/ProgQueryPlugin.java deleted file mode 100644 index f43cbc2..0000000 --- a/ProgQuery/src/ProgQueryPlugin.java +++ /dev/null @@ -1,52 +0,0 @@ - -//import org.neo4j.graphdb.GraphDatabaseService; - -import java.time.ZonedDateTime; - -import com.sun.source.util.JavacTask; - -import database.DatabaseFachade; -import database.EmbeddedGGDBServiceInsertion; -import database.InsertionStrategy; -import database.Neo4jDriverLazyWrapperInsertion; -import tasklisteners.GetStructuresAfterAnalyze; - -public class ProgQueryPlugin implements com.sun.source.util.Plugin { - - private static final String PLUGIN_NAME = "ProgQueryPlugin"; - - @Override - public void init(JavacTask task, String[] args) { - // final GraphDatabaseService graphDb = args.length > 0 ? - // DatabaseFachade.getDB(args[0]) : DatabaseFachade.getDB(); - // First argument if any contents the db path - - // DatabaseFachade.setDB(graphDb); - String id = args.length == 0 ? "NO_SPECIFIED_ID_" + ZonedDateTime.now() : args[0]; - DatabaseFachade - .init(args.length == 1 ? new EmbeddedGGDBServiceInsertion() - : args[1].contains("S") - ? args.length == 2 ? invalidArgs() - : args.length == 3 ? serverTwoArgs(args[2]) - : new Neo4jDriverLazyWrapperInsertion(Integer.parseInt(args[3]), - args[2]) - : args.length > 2 ? new EmbeddedGGDBServiceInsertion(args[2]) - : new EmbeddedGGDBServiceInsertion()); - task.addTaskListener(new GetStructuresAfterAnalyze(task, id)); - } - - private InsertionStrategy invalidArgs() { - throw new IllegalArgumentException("You need to specify the connection string to run PQ Server"); - } - - private InsertionStrategy serverTwoArgs(String arg2) { - - return new Neo4jDriverLazyWrapperInsertion(arg2); - } - - @Override - public String getName() { - return PLUGIN_NAME; - } - -} diff --git a/ProgQuery/src/cache/DefinitionCache.java b/ProgQuery/src/cache/DefinitionCache.java deleted file mode 100644 index 7516f5c..0000000 --- a/ProgQuery/src/cache/DefinitionCache.java +++ /dev/null @@ -1,243 +0,0 @@ -package cache; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import javax.lang.model.type.TypeMirror; - -import com.sun.tools.javac.code.Symbol; - -import ast.ASTAuxiliarStorage; -import database.querys.cypherWrapper.EdgeDirection; -import database.relations.CDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import node_wrappers.NodeWrapper; -import node_wrappers.RelationshipWrapper; -import visitors.KeyTypeVisitor; -import visitors.TypeVisitor; - -public class DefinitionCache { - private static final boolean DEBUG = false; - public static ASTAuxiliarStorage ast; - public static final DefinitionCache CLASS_TYPE_CACHE = new DefinitionCache(); - // public static final DefinitionCache PRIMITIVE_TYPE_CACHE = - // new DefinitionCache(); - - public static final DefinitionCache METHOD_TYPE_CACHE = new DefinitionCache(); - - private final Map auxNodeCache = new HashMap<>(); - final Map definitionNodeCache = new HashMap<>(); - - public void put(TKEY k, NodeWrapper v) { - if (DEBUG) - System.out.println("putting " + k + " " + v); - // System.out.println("Trying to put "); - if (auxNodeCache.containsKey(k)) - throw new IllegalArgumentException("Key " + k + " twice "); - - if (!definitionNodeCache.containsKey(k)) - auxNodeCache.put(k, v); - // System.out.println("PUTTNG n=" + v.getId() + " k=" + k); - else - throw new IllegalArgumentException("Key " + k + " already in definition"); - } - - public void putClassDefinition(TKEY classSymbol, NodeWrapper classDec, Set typeDecNodeList, - Set typeDecsUses) { - NodeWrapper oldClassNode = null; - // AuxDebugInfo.lastMessage = "BEFORE PUTTING DEFINITION " + - // classSymbol.toString(); - - if (auxNodeCache.containsKey(classSymbol)) { - oldClassNode = auxNodeCache.get(classSymbol); - for (RelationshipWrapper r : oldClassNode.getRelationships(EdgeDirection.OUTGOING, - RelationTypes.DECLARES_METHOD, RelationTypes.DECLARES_CONSTRUCTOR, RelationTypes.DECLARES_FIELD, - TypeRelations.IS_SUBTYPE_EXTENDS, TypeRelations.IS_SUBTYPE_IMPLEMENTS)) - r.delete(); - // System.out.println("TRYING TO REMOVE n=" + oldClassNode.getId()); - // System.out.println("CONTAINS = " + - // typeDecNodeList.contains(oldClassNode)); - // System.out.println("INDEX OF = " + - // typeDecNodeList.indexOf(oldClassNode)); - // System.out.println(typeDecNodeList.get(typeDecNodeList.indexOf(oldClassNode)).getId()); - // System.out.println("TYPE DEC LIST BEFORE - // "+typeDecNodeList.size()); - // typeDecNodeList.forEach(n -> System.out.print(n.getId() + ", ")); - // System.out.println(); - typeDecNodeList.remove(oldClassNode); - // System.out.println("TYPE DEC LIST AFTER"+typeDecNodeList.size()); - // typeDecNodeList.forEach(n -> System.out.print(n.getId() + ", ")); - // System.out.println(); - oldClassNode.getRelationships(EdgeDirection.OUTGOING, CDGRelationTypes.USES_TYPE_DEF) - .forEach(usesTypeDecRel -> - - // LOS PAQUETES NO SON DECLARADOS O NO...SIEMPRE SE CREAN... - typeDecsUses.add(usesTypeDecRel.getEndNode())); - } - - putDefinition(classSymbol, classDec, oldClassNode); - // AuxDebugInfo.lastMessage = null; - } - - public void putDefinition(TKEY k, NodeWrapper v) { - putDefinition(k, v, auxNodeCache.get(k)); - } - - private void putDefinition(TKEY k, NodeWrapper v, NodeWrapper previousNode) { - if (DEBUG) - System.out.println("putting def " + k + " " + v); - - if (previousNode != null) { - // if (DEBUG) - // System.out.println("Removing " + previousNode.getId() + " from - // cache"); - // No me deja eliminalo porque todavía tiene relaciones - - // Habria que pasar las relaciones al nuevo type - // Igual es más eficiente iterar todas y un if??? con direction - for (RelationshipWrapper r : previousNode.getRelationships(EdgeDirection.INCOMING)) { - r.getStartNode().createRelationshipTo(v, r.getType()); - r.delete(); - } - for (RelationshipWrapper r : previousNode.getRelationships(EdgeDirection.OUTGOING)) { - v.createRelationshipTo(r.getEndNode(), r.getType()); - r.delete(); - } - - auxNodeCache.remove(k); - previousNode.delete(); - } - - definitionNodeCache.put(k, v); - } - - public NodeWrapper get(TKEY k) { - return definitionNodeCache.containsKey(k) ? definitionNodeCache.get(k) : auxNodeCache.get(k); - } - - public boolean containsKey(TKEY k) { - return auxNodeCache.containsKey(k) || definitionNodeCache.containsKey(k); - } - - public boolean containsDef(TKEY k) { - return definitionNodeCache.containsKey(k); - } - - public int totalTypesCached() { - return auxNodeCache.size(); - } - - public int totalDefsCached() { - return definitionNodeCache.size(); - } - /* - * private final static Map>> - * fromKindToCreateStrategyXX = initMap(); - * - * // private final static Map> - * // fromKindToKey = initKeyStrategyMap(); - * - * private static Map>> initMap() { // Aqui puedo poner la - * creación particular de cada uno Tupla NodeType, // Strategy - * BiConsumer voidF = (type, node) -> { - * DefinitionCache.CLASS_TYPE_CACHE.put(type, node); }, voidFPrimitive = - * (type, node) -> { DefinitionCache.CLASS_TYPE_CACHE.put(type.tsym, node); - * }; - * - * Map>> map = new - * HashMap>>(); - * map.put(TypeKind.ARRAY, Pair.create(NodeTypes.ARRAY_TYPE, (type, node) -> - * { node.createRelationshipTo(DefinitionCache.getOrCreateType(((ArrayType) - * type).elemtype), RelationTypes.ELEMENT_TYPE); - * DefinitionCache.CLASS_TYPE_CACHE.put(type, node); })); - * map.put(TypeKind.BOOLEAN, Pair.create(NodeTypes.PRIMITIVE_TYPE, - * voidFPrimitive)); map.put(TypeKind.BYTE, - * Pair.create(NodeTypes.PRIMITIVE_TYPE, voidFPrimitive)); - * map.put(TypeKind.CHAR, Pair.create(NodeTypes.PRIMITIVE_TYPE, - * voidFPrimitive)); map.put(TypeKind.DOUBLE, - * Pair.create(NodeTypes.PRIMITIVE_TYPE, voidFPrimitive)); - * - * map.put(TypeKind.ERROR, Pair.create(NodeTypes.ERROR_TYPE, voidF)); - * - * map.put(TypeKind.EXECUTABLE, Pair.create(NodeTypes.EXECUTABLE_TYPE, - * (type, node) -> { throw new IllegalStateException(); })); - * map.put(TypeKind.FLOAT, Pair.create(NodeTypes.PRIMITIVE_TYPE, - * voidFPrimitive)); map.put(TypeKind.INT, - * Pair.create(NodeTypes.PRIMITIVE_TYPE, voidFPrimitive)); - * map.put(TypeKind.INTERSECTION, Pair.create(NodeTypes.INTERSECTION_TYPE, - * voidF)); - * - * map.put(TypeKind.LONG, Pair.create(NodeTypes.PRIMITIVE_TYPE, - * voidFPrimitive)); map.put(TypeKind.NONE, Pair.create(NodeTypes.NONE_TYPE, - * voidF)); map.put(TypeKind.NULL, Pair.create(NodeTypes.NULL_TYPE, voidF)); - * map.put(TypeKind.PACKAGE, Pair.create(NodeTypes.PACKAGE_TYPE, voidF)); - * map.put(TypeKind.SHORT, Pair.create(NodeTypes.PRIMITIVE_TYPE, - * voidFPrimitive)); - * - * // ESTUIDAR EL CASO DEL TYPEVAR DE MOMENTO SIN METER - * map.put(TypeKind.UNION, Pair.create(NodeTypes.PRIMITIVE_TYPE, - * voidFPrimitive)); map.put(TypeKind.VOID, - * Pair.create(NodeTypes.PRIMITIVE_TYPE, voidFPrimitive)); - * map.put(TypeKind.WILDCARD, Pair.create(NodeTypes.WILDCARD, voidF)); - * - * return map; } - * - * private static Object fromTypeToKey(Type type) { // return - * fromKindToKey.get(t.getKind()).apply(t); return type.isPrimitiveOrVoid() - * ? type.tsym : type; } - */ - - public static NodeWrapper getOrCreateType(TypeMirror type, Object key, ASTAuxiliarStorage ast) { - // System.out.println(type + " inspected in cache"); - // System.out.println("looking for key " + key); - // System.out.println(DefinitionCache.CLASS_TYPE_CACHE.auxNodeCache.toString()); - // System.out.println(DefinitionCache.CLASS_TYPE_CACHE.auxNodeCache.size()); - if (DefinitionCache.CLASS_TYPE_CACHE.containsKey(key)) { - - // System.out.println("RECOVERED FROM KEY " + key + "\n\t FROM " + - // type); - // DefinitionCache.CLASS_TYPE_CACHE.get(key).getLabels().forEach(System.out::print); - // System.out.println(); - // System.out.println(type + " already in cache"); - return DefinitionCache.CLASS_TYPE_CACHE.get(key); - } - // System.out.println("CREATING NEW TYPE " + type); - return createTypeDec(type, key, ast); - } - - public static NodeWrapper getExistingType(TypeMirror type) { - if (DefinitionCache.CLASS_TYPE_CACHE.containsKey(type)) { - - // System.out.println(type + " already in cache"); - return DefinitionCache.CLASS_TYPE_CACHE.get(type); - } - throw new IllegalArgumentException("Not Type dounf for " + type); - } - - public static NodeWrapper getOrCreateType(TypeMirror type, ASTAuxiliarStorage ast) { - // System.out.println("Creating type key for" + type); - // System.out.println("KEY WAS:\t" + type.accept(new KeyTypeVisitor(), - // null)); - return getOrCreateType(type, type.accept(new KeyTypeVisitor(), null), ast); - } - - public static NodeWrapper createTypeDec(TypeMirror typeSymbol, ASTAuxiliarStorage ast) { - // System.out.println("Creating type key for" + typeSymbol); - // System.out.println("KEY WAS:\t" + typeSymbol.accept(new - // KeyTypeVisitor(), null)); - return createTypeDec(typeSymbol, typeSymbol.accept(new KeyTypeVisitor(), null), ast); - } - - private static NodeWrapper createTypeDec(TypeMirror type, Object key, ASTAuxiliarStorage ast) { - // System.out.println("Creating " + typeSymbol); - // System.out.println("VREATING TYPE SPEC " + type); - NodeWrapper ret = type.accept(new TypeVisitor(ast), key); - - return ret; - } -} diff --git a/ProgQuery/src/database/DatabaseFachade.java b/ProgQuery/src/database/DatabaseFachade.java deleted file mode 100644 index a7486ac..0000000 --- a/ProgQuery/src/database/DatabaseFachade.java +++ /dev/null @@ -1,153 +0,0 @@ -package database; - -import java.util.Set; - -import javax.lang.model.element.Modifier; -import javax.lang.model.type.TypeMirror; - -import com.sun.source.tree.ClassTree; -import com.sun.source.tree.Tree; -import com.sun.source.tree.Tree.Kind; -import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Symbol.ClassSymbol; -import com.sun.tools.javac.code.Type.ClassType; -import com.sun.tools.javac.tree.JCTree; - -import database.nodes.NodeCategory; -import database.nodes.NodeTypes; -import node_wrappers.NodeWrapper; -import node_wrappers.WrapperUtils; -import utils.JavacInfo; - -public class DatabaseFachade { - private final InsertionStrategy insertionStrategy; - public static InsertionStrategy CURRENT_INSERTION_STRATEGY; - - public static DatabaseFachade CURRENT_DB_FACHADE; - - public static void init(InsertionStrategy current) { - CURRENT_INSERTION_STRATEGY = current; -// System.out.println(current); - CURRENT_DB_FACHADE = new DatabaseFachade(current); - // System.out.println(current); - } - - public DatabaseFachade(InsertionStrategy insertionStrategy) { - this.insertionStrategy = insertionStrategy; - } - - public NodeWrapper createNodeWithoutExplicitTree(NodeTypes type) { - return createNode(type, new Object[] {}); - } - - private NodeWrapper createNode(NodeTypes type, Object[] properties) { - NodeWrapper node = insertionStrategy.createNode(type, properties); - addMultiLabelHypernyms(node, type); - return node; - } - - private static void addMultiLabelHypernyms(NodeWrapper node, NodeTypes type) { - for (NodeCategory nodeCategory : type.hypernyms) - node.addLabel(nodeCategory); - } - - private static final int IMPLICIT_POSITION = -1; - - public NodeWrapper createSkeletonNode(Tree tree, NodeTypes nodeType) { - NodeWrapper node = createNodeWithoutExplicitTree(nodeType); - - node.setProperties( - ((JCTree)tree).pos==-1 - ? new Object[] { "lineNumber", IMPLICIT_POSITION, "column", IMPLICIT_POSITION, "position", - IMPLICIT_POSITION } - : getPosition(tree)); - return node; - } - - - public NodeWrapper createSkeletonNodeExplicitCats(Tree tree, NodeTypes nodeType, - NodeCategory... cats) { - NodeWrapper node = createSkeletonNode(tree, nodeType); - for (NodeCategory cat : cats) - node.addLabel(cat); - return node; - } - - - private static Object[] getPosition(Tree tree) { - return JavacInfo.getPosition(tree); - } - - /* - * public static Transaction beginTxXX() { return graphDb.beginTx(); } - * - * public static Node createNodeXX() { return graphDb.createNode(); } - * - * public static Node createNodeXX(NodeTypes nodeType) { Node node = - * graphDb.createNode(); node.addLabel(nodeType); return node; } - */ - private static Object[] getTypeDecProperties(String simpleName, String fullyQualifiedType, boolean declared) { - return new Object[] { "simpleName", WrapperUtils.stringToNeo4jQueryString(simpleName), "fullyQualifiedName", - WrapperUtils.stringToNeo4jQueryString(fullyQualifiedType), "isDeclared", declared }; - } - - private static Object[] getTypeDecProperties(String simpleName, String fullyQualifiedType, boolean declared, - boolean isFinal) { - return new Object[] { "simpleName", WrapperUtils.stringToNeo4jQueryString(simpleName), "fullyQualifiedName", - WrapperUtils.stringToNeo4jQueryString(fullyQualifiedType), "isDeclared", declared, "isFinal", isFinal }; - } - - private static Object[] getTypeDecProperties(ClassSymbol symbol, boolean isDeclared) { - Set modifiers = Flags.asModifierSet(symbol.flags_field); - return symbol.isEnum() - ? new Object[] { "simpleName", WrapperUtils.stringToNeo4jQueryString(symbol.getSimpleName().toString()), - "fullyQualifiedName", - WrapperUtils.stringToNeo4jQueryString(symbol.getQualifiedName().toString()), "isDeclared", - isDeclared, "isFinal", true, "isStatic", true, "accessLevel", "public" } - : symbol.isInterface() ? new Object[] { "simpleName", - WrapperUtils.stringToNeo4jQueryString(symbol.getSimpleName().toString()), "fullyQualifiedName", - WrapperUtils.stringToNeo4jQueryString(symbol.getQualifiedName().toString()), "isDeclared", - isDeclared, "isAbstract", modifiers.contains(Modifier.ABSTRACT), "accessLevel", - modifiers.contains(Modifier.PUBLIC) ? "public" : "package" } - : new Object[] { "simpleName", - WrapperUtils.stringToNeo4jQueryString(symbol.getSimpleName().toString()), - "fullyQualifiedName", - WrapperUtils.stringToNeo4jQueryString(symbol.getQualifiedName().toString()), - "isDeclared", isDeclared, "isAbstract", modifiers.contains(Modifier.ABSTRACT), - "isStatic", modifiers.contains(Modifier.STATIC), "isFinal", - modifiers.contains(Modifier.FINAL), "accessLevel", - modifiers.contains(Modifier.PUBLIC) ? "public" - : modifiers.contains(Modifier.PRIVATE) ? "private" : "package" }; - - } - - public NodeWrapper createTypeDecNode(ClassTree classTree, String simpleName, String fullyQualifiedType) { - NodeWrapper typeDef = createNode( - classTree.getKind() == Kind.CLASS ? NodeTypes.CLASS_DEF - : classTree.getKind() == Kind.INTERFACE ? NodeTypes.INTERFACE_DEF : NodeTypes.ENUM_DEF, - getTypeDecProperties(simpleName, fullyQualifiedType, true)); - typeDef.setProperties(getPosition(classTree)); - return typeDef; - } - - public NodeWrapper createNonDeclaredTypeDecNodeExplicitCats(TypeMirror t, NodeTypes type, - NodeCategory... categories) { - - NodeWrapper res = createNonDeclaredTypeDecNode(t, type); - for (NodeCategory cat : categories) - res.addLabel(cat); - return res; - } - - public NodeWrapper createNonDeclaredTypeDecNode(TypeMirror t, NodeTypes type) { - - String[] names = t.toString().split("\\."); - return createNode(type, getTypeDecProperties(names[names.length - 1], t.toString(), false)); - - } - - public NodeWrapper createNonDeclaredCLASSTypeDecNode(ClassType c, NodeTypes type) { - return createNode(type, getTypeDecProperties((ClassSymbol) c.tsym, false)); - - } -} diff --git a/ProgQuery/src/database/EmbeddedGGDBServiceInsertion.java b/ProgQuery/src/database/EmbeddedGGDBServiceInsertion.java deleted file mode 100644 index 440cc5c..0000000 --- a/ProgQuery/src/database/EmbeddedGGDBServiceInsertion.java +++ /dev/null @@ -1,72 +0,0 @@ -package database; - -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Transaction; - -import database.embedded.EmbeddedDBManager; -import database.nodes.NodeTypes; -import node_wrappers.Neo4jEmbeddedWrapperNode; - -public class EmbeddedGGDBServiceInsertion implements InsertionStrategy { - private GraphDatabaseService gDBService; - private Transaction t; - - public EmbeddedGGDBServiceInsertion() { -// System.out.println("EMBEDDED NO PATH"); - gDBService = EmbeddedDBManager.getNewEmbeddedDBService(); - } - - public EmbeddedGGDBServiceInsertion(String dbPath) { -// System.out.println("EMBEDDED " + dbPath); - gDBService = EmbeddedDBManager.getNewEmbeddedDBService(dbPath); - } - @Override - public Neo4jEmbeddedWrapperNode createNode() { - return new Neo4jEmbeddedWrapperNode(gDBService.createNode()); - } - - @Override - public Neo4jEmbeddedWrapperNode createNode(NodeTypes label) { - Node n = gDBService.createNode(); - n.addLabel(label); - return new Neo4jEmbeddedWrapperNode(n); - - } - - @Override - public Neo4jEmbeddedWrapperNode createNode(NodeTypes label, Object[] props) { - Node n = gDBService.createNode(); - n.addLabel(label); - for (int i = 0; i < props.length; i = i + 2) - n.setProperty(props[i].toString(), props[i + 1]); - - return new Neo4jEmbeddedWrapperNode(n); - } - - - @Override - public Neo4jEmbeddedWrapperNode createNode(Object[] props) { - Node n = gDBService.createNode(); - for (int i = 0; i < props.length; i = i + 2) - n.setProperty(props[i].toString(), props[i + 1]); - - return new Neo4jEmbeddedWrapperNode(n); - } - - @Override - public void startAnalysis() { - // System.out.println("S"); - t = gDBService.beginTx(); - } - - @Override - public void endAnalysis() { - // System.out.println("END"); -// System.out.println("BEFORE SHUTDOWN"); - t.success(); - t.close(); - gDBService.shutdown(); - } - -} diff --git a/ProgQuery/src/database/InsertionStrategy.java b/ProgQuery/src/database/InsertionStrategy.java deleted file mode 100644 index 120b861..0000000 --- a/ProgQuery/src/database/InsertionStrategy.java +++ /dev/null @@ -1,17 +0,0 @@ -package database; - -import database.nodes.NodeTypes; -import node_wrappers.NodeWrapper; - -public interface InsertionStrategy { - NodeWrapper createNode(); - NodeWrapper createNode(NodeTypes label); - - NodeWrapper createNode(NodeTypes label, Object[] props); - - NodeWrapper createNode(Object[] props); - - void startAnalysis(); - void endAnalysis(); - -} diff --git a/ProgQuery/src/database/Neo4jDriverLazyWrapperInsertion.java b/ProgQuery/src/database/Neo4jDriverLazyWrapperInsertion.java deleted file mode 100644 index 439eb70..0000000 --- a/ProgQuery/src/database/Neo4jDriverLazyWrapperInsertion.java +++ /dev/null @@ -1,61 +0,0 @@ -package database; - -import database.insertion.lazy.InfoToInsert; -import database.insertion.lazy.LazyInsertionManagerMultipleTrans; -import database.nodes.NodeTypes; -import node_wrappers.Neo4jLazyServerDriverNode; -import node_wrappers.NodeWrapper; - -public class Neo4jDriverLazyWrapperInsertion implements InsertionStrategy { - private final int MAX_NODES_PER_TRANSACTION; - private final String ADDRESS, USER, PASS; - - private static final int DEFAULT_MAX = 80_000; - - @Override - public NodeWrapper createNode() { - return new Neo4jLazyServerDriverNode(); - } - - public Neo4jDriverLazyWrapperInsertion(String connectionString) { - this(DEFAULT_MAX, connectionString); - } - - public Neo4jDriverLazyWrapperInsertion(int maxNodes, String connectionString) { - super(); - MAX_NODES_PER_TRANSACTION = maxNodes; - String[] connectionData = connectionString.split(";"); - ADDRESS = connectionData[2]; - USER = connectionData[0]; - PASS = connectionData[1]; - // System.out.println("SERVER " + maxNodes + " " + address); - } - - @Override - public NodeWrapper createNode(NodeTypes label) { - return new Neo4jLazyServerDriverNode(label); - } - - @Override - public NodeWrapper createNode(NodeTypes label, Object[] props) { - return new Neo4jLazyServerDriverNode(label, props); - } - - @Override - public NodeWrapper createNode(Object[] props) { - return new Neo4jLazyServerDriverNode(props); - } - - @Override - public void startAnalysis() { - - } - - @Override - public void endAnalysis() { - LazyInsertionManagerMultipleTrans.insertIntoNeo4jServerByDriver(InfoToInsert.INFO_TO_INSERT, ADDRESS, USER, - PASS, MAX_NODES_PER_TRANSACTION); - - } - -} diff --git a/ProgQuery/src/database/embedded/EmbeddedDBManager.java b/ProgQuery/src/database/embedded/EmbeddedDBManager.java deleted file mode 100644 index 0e049b5..0000000 --- a/ProgQuery/src/database/embedded/EmbeddedDBManager.java +++ /dev/null @@ -1,35 +0,0 @@ -package database.embedded; - -import java.io.File; - -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.factory.GraphDatabaseFactory; -import org.neo4j.graphdb.factory.GraphDatabaseSettings; - - -public class EmbeddedDBManager { - private static final String DEFAULT_DB_PATH = "./neo4j/data/ProgQuery.db"; - - public static GraphDatabaseService getNewEmbeddedDBService() { - return new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(new File(DEFAULT_DB_PATH)) - .setConfig(GraphDatabaseSettings.node_keys_indexable, "nodeType") - .setConfig(GraphDatabaseSettings.relationship_keys_indexable, "typeKind") - .setConfig(GraphDatabaseSettings.node_auto_indexing, "true") - .setConfig(GraphDatabaseSettings.relationship_auto_indexing, "true").newGraphDatabase(); - } - - public static GraphDatabaseService getNewEmbeddedDBService(String dbPath) { - return new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(new File(dbPath)) - .setConfig(GraphDatabaseSettings.node_keys_indexable, "nodeType") - .setConfig(GraphDatabaseSettings.relationship_keys_indexable, "typeKind") - .setConfig(GraphDatabaseSettings.node_auto_indexing, "true") - .setConfig(GraphDatabaseSettings.relationship_auto_indexing, "true").newGraphDatabase(); - } - - public static void setDB(GraphDatabaseService db) { - graphDb = db; - } - - private static GraphDatabaseService graphDb; - -} diff --git a/ProgQuery/src/database/insertion/lazy/LazyInsertionManagerMultipleTrans.java b/ProgQuery/src/database/insertion/lazy/LazyInsertionManagerMultipleTrans.java deleted file mode 100644 index 5446c7e..0000000 --- a/ProgQuery/src/database/insertion/lazy/LazyInsertionManagerMultipleTrans.java +++ /dev/null @@ -1,179 +0,0 @@ -package database.insertion.lazy; - -import static org.neo4j.driver.v1.Values.parameters; - -import java.util.List; -import java.util.function.BiConsumer; -import java.util.function.Function; - -import org.neo4j.driver.v1.AuthTokens; -import org.neo4j.driver.v1.Driver; -import org.neo4j.driver.v1.GraphDatabase; -import org.neo4j.driver.v1.Session; -import org.neo4j.driver.v1.StatementResult; -import org.neo4j.driver.v1.Transaction; -import org.neo4j.driver.v1.TransactionWork; - -import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NodeType; - -import database.nodes.NodeTypes; -import database.nodes.NodeUtils; -import node_wrappers.NodeWrapper; -import utils.dataTransferClasses.Pair; - -public class LazyInsertionManagerMultipleTrans { - private static final int REPETITIONS = 1; - - public static void insertIntoNeo4jServerByDriver(InfoToInsert info, final String SERVER_ADDRESS, final String USER, - final String PASS, final int MAX_NODES_PER_TRANSACTION) { - - - try (final Driver driver = GraphDatabase.driver(SERVER_ADDRESS, AuthTokens.basic(USER, PASS)); - Session session = driver.session()) { - - final List> nodeInfo = info.getNodeQueriesInfo(); - // System.out.println("AFTER ANALYSIS " + nodeInfo.size() + " nodes - // "); - int totalEdges = 0; - for (int i = 0; i < REPETITIONS; i++) { - // System.out.println("ITER " + i); - actionByParts(info.nodeSet.size(), MAX_NODES_PER_TRANSACTION, (s, e) -> executeNodesQuery(session, - info.nodeSet, nodeInfo, r -> r.list().get(0).values().get(0).asLong(), s, e)); - - final List> relInfo = info.getRelQueriesInfo(); - actionByParts(totalEdges = info.relSet.size(), MAX_NODES_PER_TRANSACTION, - (s, e) -> executeRelsQuery(session, relInfo, s, e)); - } - // System.out.println("AFTER ANALYSIS " + totalEdges + " edges"); - - } - } - - // private interface ActionByParts { - // void accept(T t, int start, int end); - // } - - public static void actionByParts(int listSize, int numberPerPart, BiConsumer action) { - - int i = 0; - while ((i + 1) * numberPerPart < listSize) - // { - // System.out.println("ITER " + i); - // System.out.println("FROM " + i * numberPerPart + " TO " + (i + 1) - // * numberPerPart); - action.accept(i++ * numberPerPart, i * numberPerPart); - // } - // System.out.println("LAST ITER " + i); - // System.out.println("FROM " + i * numberPerPart + " TO " + listSize); - - action.accept(i * numberPerPart, listSize); - - } - - /* - * private static T executeQuery(String query, Session session, - * Function resultF) { return - * session.writeTransaction(new TransactionWork() { - * - * @Override public T execute(Transaction tx) { // tx. - * - * StatementResult result = tx.run(query); // - * result.list().get(0).asMap().entrySet() // .forEach(e -> - * System.out.println(e.getKey() + "," + // e.getValue())); return - * resultF.apply(result); } - * - * }); } - */ - - private static T executeQuery(String query, Session session, Function resultF) { - return session.writeTransaction(new TransactionWork() { - - @Override - public T execute(Transaction tx) { - // tx. - - StatementResult result = tx.run(query); - // result.list().get(0).asMap().entrySet() - // .forEach(e -> System.out.println(e.getKey() + "," + - // e.getValue())); - return resultF.apply(result); - } - - }); - } - // - // private static List executeNodesQuery(Session session, - // List nodes, - // Function resultF) { - // return session.writeTransaction(new TransactionWork>() { - // - // @Override - // public List execute(Transaction tx) { - // List resultIds = new ArrayList(); - // - // // tx. - // for (NodeWrapper n : nodes) - // resultIds.add(resultF.apply(tx.run(createQueryFor(n)))); - // // result.list().get(0).asMap().entrySet() - // // .forEach(e -> System.out.println(e.getKey() + "," + - // // e.getValue())); - // return resultIds; - // } - // - // }); - // } - - private static Void executeNodesQuery(Session session, List nodes, - List> nodeQueries, Function resultF, int start, int end) { - return session.writeTransaction(new TransactionWork() { - - @Override - public Void execute(Transaction tx) { - - // tx. - for (int i = start; i < end; i++) { - NodeWrapper n = nodes.get(i); - Pair queryAndParams = nodeQueries.get(i); - n.setId(resultF.apply(tx.run(queryAndParams.getFirst(), parameters(queryAndParams.getSecond())))); - } - // result.list().get(0).asMap().entrySet() - // .forEach(e -> System.out.println(e.getKey() + "," + - // e.getValue())); - return null; - } - - }); - } - - private static Void executeRelsQuery(Session session, List> relsQueries, int start, - int end) { - return session.writeTransaction(new TransactionWork() { - - @Override - public Void execute(Transaction tx) { - for (int i = start; i < end; i++) { - Pair pair = relsQueries.get(i); - tx.run(pair.getFirst(), parameters(pair.getSecond())); - } - return null; - } - - }); - } - - // private static void storeNodes(Session session, InfoToInsert info) { - // - // for (NodeWrapper n : info.nodeSet) - // - // n.setId(executeQuery(createQueryFor(n), session, r -> - // r.list().get(0).values().get(0).asLong())); - // - // } - // - // private static void storeRels(Session session, InfoToInsert info) { - // for (RelationshipWrapper r : info.relSet) - // executeQuery(createQueryFor(r), session, result -> null); - // - // } - -} diff --git a/ProgQuery/src/database/nodes/NodeCategory.java b/ProgQuery/src/database/nodes/NodeCategory.java deleted file mode 100644 index 320d29c..0000000 --- a/ProgQuery/src/database/nodes/NodeCategory.java +++ /dev/null @@ -1,27 +0,0 @@ -package database.nodes; - -import org.neo4j.graphdb.Label; - -public enum NodeCategory implements Label { - //Categoria para annotation, package, compilation-unit?? - PQ_NODE, //TOP Category - AST_NODE, CFG_NODE, PDG_NODE,TYPE_NODE, PACKAGE_NODE, - - - AST_TYPE, - STATEMENT, - //BRANCH_STATEMENT, CONDITIONAL_STATEMENT??, UNCONDITIONAL_STATEMENT?? - - EXPRESSION, - DEFINITION, //SUPERCLASS FOR DECLARATION,TYPE_DEFINITION,CALLABLE_DEF - TYPE_DEFINITION,//SUPERCLASS FOR CLASS INTERFACE ENUM - VARIABLE_DEF, //SUPERCLASS FOR PARAM_DEC, VAR_DEC, ATTR_DEC - LOCAL_DEF,//SUPERCLASS FOR PARAM_DEC, VAR_DEC, - //MEMBER_DEF?? //SUPERCLASS FOR ATTR_DEC, CALLABLE_DEF, MEMBER_CLASS - CALLABLE_DEF - // SUPERCLASS FOR CONSTRUCTOR AND METHODS - , CALL //SUPERCLASS FOR METHOD_INV AND NEW_ - , LVALUE - - -} diff --git a/ProgQuery/src/database/nodes/NodeTypes.java b/ProgQuery/src/database/nodes/NodeTypes.java deleted file mode 100644 index ca542dc..0000000 --- a/ProgQuery/src/database/nodes/NodeTypes.java +++ /dev/null @@ -1,142 +0,0 @@ -package database.nodes; - -import java.util.ArrayList; -import java.util.List; - -import org.neo4j.graphdb.Label; - -public enum NodeTypes implements Label { - - ANNOTATION(NodeCategory.AST_NODE), ANNOTATED_TYPE(NodeCategory.AST_TYPE), ARRAY_ACCESS(NodeCategory.LVALUE, - NodeCategory.EXPRESSION), ARRAY_TYPE, ASSERT_STATEMENT(NodeCategory.STATEMENT), ASSIGNMENT( - NodeCategory.EXPRESSION), ATTR_DEF(NodeCategory.VARIABLE_DEF, - NodeCategory.DEFINITION), BINARY_OPERATION(NodeCategory.EXPRESSION), BLOCK( - NodeCategory.STATEMENT), BREAK_STATEMENT(NodeCategory.STATEMENT), CASE_STATEMENT( - - NodeCategory.STATEMENT), CATCH_BLOCK( - - NodeCategory.STATEMENT), CLASS_DEF(NodeCategory.TYPE_DEFINITION, - NodeCategory.DEFINITION, - NodeCategory.TYPE_NODE), COMPILATION_UNIT( - NodeCategory.AST_NODE), COMPOUND_ASSIGNMENT( - - NodeCategory.EXPRESSION), CONDITIONAL_EXPRESSION( - - NodeCategory.EXPRESSION), CONSTRUCTOR_DEF( - - NodeCategory.CALLABLE_DEF, - NodeCategory.DEFINITION), CONTINUE_STATEMENT( - - NodeCategory.STATEMENT), DO_WHILE_LOOP( - - NodeCategory.STATEMENT), ERROR_TYPE( - - NodeCategory.TYPE_NODE), EMPTY_STATEMENT( - - NodeCategory.STATEMENT), FOR_EACH_LOOP( - - NodeCategory.STATEMENT), ENUM_DEF( - - NodeCategory.TYPE_DEFINITION, - NodeCategory.DEFINITION, - NodeCategory.TYPE_NODE), ENUM_ELEMENT( - NodeCategory.AST_NODE), ERRONEOUS_NODE, CALLABLE_TYPE( - - NodeCategory.TYPE_NODE), EXPRESSION_STATEMENT( - - NodeCategory.STATEMENT), FINALLY_BLOCK( - - NodeCategory.STATEMENT), FOR_LOOP( - - NodeCategory.STATEMENT), IDENTIFIER( - NodeCategory.AST_NODE), IF_STATEMENT( - - NodeCategory.STATEMENT), IMPORT( - NodeCategory.AST_NODE), INSTANCE_OF( - - NodeCategory.EXPRESSION), INTERFACE_DEF( - NodeCategory.TYPE_DEFINITION, - NodeCategory.DEFINITION, - NodeCategory.TYPE_NODE), INTERSECTION_TYPE, LABELED_STATEMENT( - - NodeCategory.STATEMENT), LAMBDA_EXPRESSION( - - NodeCategory.EXPRESSION), LITERAL( - - NodeCategory.EXPRESSION), MEMBER_SELECTION( - NodeCategory.AST_NODE), MEMBER_REFERENCE( - - NodeCategory.EXPRESSION), METHOD_DEF( - - NodeCategory.CALLABLE_DEF, - NodeCategory.DEFINITION), METHOD_INVOCATION( - - NodeCategory.EXPRESSION, - NodeCategory.CALL), NEW_ARRAY( - - NodeCategory.EXPRESSION), NEW_INSTANCE( - - NodeCategory.EXPRESSION, - NodeCategory.CALL), NULL_TYPE( - - NodeCategory.TYPE_NODE), PACKAGE( - NodeCategory.PACKAGE_NODE), PACKAGE_TYPE( - - NodeCategory.TYPE_NODE), PARAMETER_DEF( - - NodeCategory.LOCAL_DEF, - NodeCategory.VARIABLE_DEF, - NodeCategory.DEFINITION), GENERIC_TYPE, PRIMITIVE_TYPE, RETURN_STATEMENT( - - NodeCategory.STATEMENT), SWITCH_STATEMENT( - - NodeCategory.STATEMENT), SYNCHRONIZED_BLOCK( - - NodeCategory.STATEMENT), THIS_REF( - NodeCategory.PDG_NODE), THROW_STATEMENT( - - NodeCategory.STATEMENT), TRY_STATEMENT( - - NodeCategory.STATEMENT), TYPE_CAST( - - NodeCategory.EXPRESSION), TYPE_PARAM, UNARY_OPERATION( - - NodeCategory.EXPRESSION), UNION_TYPE - - , LOCAL_VAR_DEF( - - NodeCategory.LOCAL_DEF, - NodeCategory.VARIABLE_DEF, - NodeCategory.DEFINITION, - NodeCategory.STATEMENT), WHILE_LOOP( - - NodeCategory.STATEMENT), WILDCARD_TYPE, VOID_TYPE( - - NodeCategory.TYPE_NODE), TYPE_VARIABLE( - NodeCategory.TYPE_NODE), UNKNOWN_TYPE( - - NodeCategory.TYPE_NODE) - - , INITIALIZATION(NodeCategory.PDG_NODE), CFG_NORMAL_END(NodeCategory.CFG_NODE), CFG_ENTRY(NodeCategory.CFG_NODE), CFG_EXCEPTIONAL_END(NodeCategory.CFG_NODE), CFG_LAST_STATEMENT_IN_FINALLY(NodeCategory.CFG_NODE), PROGRAM(NodeCategory.PACKAGE_NODE); - - private NodeTypes(NodeCategory... hypernyms) { - this(); - for (NodeCategory cat : hypernyms) { - if (cat == NodeCategory.STATEMENT || cat == NodeCategory.EXPRESSION || cat == NodeCategory.AST_TYPE - || cat == NodeCategory.CALLABLE_DEF || cat == NodeCategory.VARIABLE_DEF) - if (!this.hypernyms.contains(NodeCategory.AST_NODE)) - this.hypernyms.add(NodeCategory.AST_NODE); - this.hypernyms.add(cat); - } - } - - private NodeTypes() { - hypernyms = new ArrayList(); - hypernyms.add(NodeCategory.PQ_NODE); - } - - public final List hypernyms; - // public static final NodeCategory[] AST_TYPE_HYPER = { - // NodeCategory.AST_NODE, NodeCategory.AST_TYPE }; - -} diff --git a/ProgQuery/src/database/procedures/AnySucc.java b/ProgQuery/src/database/procedures/AnySucc.java deleted file mode 100644 index cf6f9a2..0000000 --- a/ProgQuery/src/database/procedures/AnySucc.java +++ /dev/null @@ -1,37 +0,0 @@ -package database.procedures; - -import java.util.ArrayList; -import java.util.List; - -import org.neo4j.graphdb.Node; -import org.neo4j.procedure.Name; -import org.neo4j.procedure.UserFunction; - -import database.relations.CFGRelationTypes; - -public class AnySucc { - - @UserFunction - public List getAnySucc(@Name("node") Node stmt) { - return new ArrayList(FunctionUtils.getAllNext(stmt, CFGRelationTypes.CFG_NEXT_STATEMENT, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, - CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, - CFGRelationTypes.CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION, CFGRelationTypes.CFG_NO_EXCEPTION, - CFGRelationTypes.CFG_CAUGHT_EXCEPTION, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, - CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE, CFGRelationTypes.CFG_MAY_THROW, CFGRelationTypes.CFG_THROWS)); - - } - @UserFunction - public List getAnySuccNotItself(@Name("node") Node stmt) { - List nodes=FunctionUtils.getAllNext(stmt, CFGRelationTypes.CFG_NEXT_STATEMENT, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, - CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, - CFGRelationTypes.CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION, CFGRelationTypes.CFG_NO_EXCEPTION, - CFGRelationTypes.CFG_CAUGHT_EXCEPTION, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, - CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE, CFGRelationTypes.CFG_MAY_THROW, CFGRelationTypes.CFG_THROWS); - nodes.remove(0); -return nodes; - } -} diff --git a/ProgQuery/src/database/procedures/EnclosingStmt.java b/ProgQuery/src/database/procedures/EnclosingStmt.java deleted file mode 100644 index b7614ed..0000000 --- a/ProgQuery/src/database/procedures/EnclosingStmt.java +++ /dev/null @@ -1,68 +0,0 @@ -package database.procedures; - -import java.util.Iterator; - -import org.neo4j.graphdb.Direction; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; -import org.neo4j.procedure.Name; -import org.neo4j.procedure.UserFunction; - -import database.relations.RelationTypes; - -public class EnclosingStmt { - - @UserFunction - public Node getEnclosingClass(@Name("node") Node stmtOrVarDef) { - - - stmtOrVarDef = getEnclosingMethod(stmtOrVarDef); - Iterator rels = stmtOrVarDef.getRelationships(RelationTypes.DECLARES_FIELD, RelationTypes.DECLARES_METHOD, - RelationTypes.DECLARES_CONSTRUCTOR, RelationTypes.HAS_STATIC_INIT).iterator(); - return rels.hasNext() ? rels.next().getStartNode() : null; - } - - @UserFunction - public Node getEnclosingMethod(@Name("node") Node stmtOrParam) { - - stmtOrParam = FunctionUtils.getLastNodeInRels(stmtOrParam, RelationTypes.CALLABLE_HAS_BODY, - RelationTypes.CALLABLE_HAS_PARAMETER, RelationTypes.CASE_STATEMENTS, RelationTypes.CATCH_ENCLOSES_BLOCK, - RelationTypes.CATCH_PARAM, RelationTypes.WHILE_STATEMENT, RelationTypes.DO_WHILE_STATEMENT, - RelationTypes.ENCLOSES, RelationTypes.FOREACH_STATEMENT, RelationTypes.FOREACH_VAR, - RelationTypes.FORLOOP_INIT, RelationTypes.FORLOOP_STATEMENT, RelationTypes.FORLOOP_UPDATE, - RelationTypes.CALLABLE_HAS_PARAMETER, RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.IF_THEN, - RelationTypes.IF_ELSE, RelationTypes.LABELED_STMT_ENCLOSES, RelationTypes.SWITCH_ENCLOSES_CASE, - RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, RelationTypes.TRY_BLOCK, RelationTypes.TRY_CATCH, - RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES); - return stmtOrParam; - } - - @UserFunction - public Node getEnclMethodFromExpr(@Name("node") Node expr) { - - return getEnclosingMethod(getEnclosingStmt(expr)); - } - - @UserFunction - public Node getEnclosingStmt(@Name("node") Node expr) { - - if (expr == null) - return null; - expr = FunctionUtils.getLastNodeInRels(expr, RelationTypes.ARRAYACCESS_EXPR, RelationTypes.ARRAYACCESS_INDEX, - RelationTypes.ASSIGNMENT_LHS, RelationTypes.ASSIGNMENT_RHS, RelationTypes.BINOP_LHS, - RelationTypes.BINOP_RHS, RelationTypes.CAST_ENCLOSES, RelationTypes.COMPOUND_ASSIGNMENT_LHS, - RelationTypes.COMPOUND_ASSIGNMENT_RHS, RelationTypes.CONDITIONAL_EXPR_CONDITION, - RelationTypes.CONDITIONAL_EXPR_THEN, RelationTypes.CONDITIONAL_EXPR_ELSE, - RelationTypes.INITIALIZATION_EXPR, RelationTypes.INSTANCE_OF_EXPR, - RelationTypes.MEMBER_REFERENCE_EXPRESSION, RelationTypes.MEMBER_SELECT_EXPR, - RelationTypes.METHODINVOCATION_ARGUMENTS, RelationTypes.METHODINVOCATION_METHOD_SELECT, - RelationTypes.NEW_CLASS_ARGUMENTS, RelationTypes.NEW_ARRAY_INIT, RelationTypes.NEW_ARRAY_DIMENSION, - RelationTypes.UNARY_ENCLOSES); - Iterator rels = expr.getRelationships(Direction.INCOMING, RelationTypes.ASSERT_CONDITION, - RelationTypes.DO_WHILE_CONDITION, RelationTypes.ENCLOSES_EXPR, RelationTypes.FOREACH_EXPR, - RelationTypes.FORLOOP_CONDITION, RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.IF_CONDITION, - RelationTypes.RETURN_EXPR, RelationTypes.SWITCH_EXPR, RelationTypes.SYNCHRONIZED_EXPR, - RelationTypes.THROW_EXPR, RelationTypes.WHILE_CONDITION).iterator(); - return rels.hasNext() ? rels.next().getStartNode() : null; - } -} diff --git a/ProgQuery/src/database/procedures/FunctionUtils.java b/ProgQuery/src/database/procedures/FunctionUtils.java deleted file mode 100644 index 9b8c6bf..0000000 --- a/ProgQuery/src/database/procedures/FunctionUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -package database.procedures; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.neo4j.graphdb.Direction; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; - -import database.relations.CFGRelationTypes; -import database.relations.RelationTypes; - -public class FunctionUtils { - - static Node getLastNodeInRels(Node node, RelationTypes... relTypes) { - if(node==null) - return null; - boolean outExprReached = false; - - while (!outExprReached) { - - Iterator rels = node.getRelationships(Direction.INCOMING, relTypes).iterator(); - if (rels.hasNext()) - node = rels.next().getStartNode(); - else - outExprReached = true; - } - return node; - } - - - - static List getAllNext(Node node, CFGRelationTypes... relTypes) { - List res = new ArrayList<>(); -// Set nodes = new HashSet(); - res.add(node); - // while - - int currentIndex = 0; - while (currentIndex < res.size()) { - - node = res.get(currentIndex++); -// System.out.println(node.getId()); - Iterable rels = node.getRelationships(Direction.OUTGOING, relTypes); - for (Relationship r : rels) - if (!res.contains(r.getEndNode())) - res.add(r.getEndNode()); - } - - return res; - } -} diff --git a/ProgQuery/src/database/queries/sa/bloch/BLOCH_11_75.java b/ProgQuery/src/database/queries/sa/bloch/BLOCH_11_75.java deleted file mode 100644 index 010ed49..0000000 --- a/ProgQuery/src/database/queries/sa/bloch/BLOCH_11_75.java +++ /dev/null @@ -1,47 +0,0 @@ -package database.queries.sa.bloch; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServices; -import database.relations.PDGRelationTypes; -import utils.dataTransferClasses.Pair; - -public class BLOCH_11_75 extends AbstractQuery { - - public BLOCH_11_75() { - super(true); - - } - - // WTIH ATTR, DECLARING TYPE - public static void main(String[] args) { - System.out.println(new BLOCH_11_75().queryToString()); - } - - @Override - protected void initiate() { - clauses = new Clause[] { - -new ClauseImpl("MATCH (cu)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->(typeDec)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]->( {fullyQualifiedName:'java.io.Serializable'})" - + "\n OPTIONAL MATCH (typeDec)-[:DECLARES_METHOD]->(method)-[:CALLABLE_HAS_THROWS]->(throwClause) " - + "\n WITH cu, typeDec, method, COLLECT(throwClause.actualType) as throws " - + "\n WHERE NOT( method.fullyQualifiedName ENDS WITH ':readObject(java.io.ObjectInputStream)void' AND method.accessLevel='private' AND SIZE(throws)=2 AND 'java.io.IOException' IN throws AND 'java.lang.ClassNotFoundException' IN throws AND NOT method.isStatic AND NOT method.isFinal AND NOT method.isSynchronized AND NOT method.isStrictfp AND NOT method.isNative " - + " OR method.fullyQualifiedName ENDS WITH ':readResolve()java.lang.Object' AND SIZE(throws)=1 AND throws[0]='java.io.ObjectStreamException')" - + "" - + "\n RETURN DISTINCT '[BLOCH-10.75;'+ cu.fileName +';type_definition;examples.test.rule_10_75.NC1;'+ typeDec.lineNumber +'; You must implement the standard readObject method (or, at least, the readResolve method) for all your classes implementing java.io.Serializable.]'") -}; - } - -} diff --git a/ProgQuery/src/database/queries/sa/bloch/BLOCH_8_45.java b/ProgQuery/src/database/queries/sa/bloch/BLOCH_8_45.java deleted file mode 100644 index b177c88..0000000 --- a/ProgQuery/src/database/queries/sa/bloch/BLOCH_8_45.java +++ /dev/null @@ -1,61 +0,0 @@ -package database.queries.sa.bloch; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServices; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import utils.dataTransferClasses.Pair; - -public class BLOCH_8_45 extends AbstractQuery { - - public BLOCH_8_45() { - super(true); - - } - - // WTIH ATTR, DECLARING TYPE - public static void main(String[] args) { - System.out.println(new BLOCH_8_45().queryToString()); - } - - @Override - protected void initiate() { - clauses = new Clause[] { -new ClauseImpl("MATCH (var_def:LOCAL_VAR_DEF)\r\n" + - "OPTIONAL MATCH (var_def)-[r:USED_BY| :STATE_MODIFIED_BY |:MODIFIED_BY | :STATE_MAY_BE_MODIFIED_BY]->(useExpr)//ANTES SIN RELACION STATE_MAY_BE_MODIFIED_BY\r\n" + - "WHERE //NOT useExpr:METHOD_INVOCATION \r\n" + - "NOT EXISTS((var_def)-[:CATCH_PARAM | :FOREACH_VAR | :TRY_RESOURCES]-())//EVITAMOS CONTABILIZAR LOS PARAMETROS DE LOS CATCH\r\n" + - "WITH var_def, useExpr ORDER BY useExpr.lineNumber, useExpr.column\r\n" + - "MATCH (fatherStmt)-[:CASE_STATEMENTS | :CATCH_BLOCK | :CATCH_PARAM | :ENCLOSES | :DO_WHILE_STATEMENT | :WHILE_STATEMENT | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :CALLABLE_HAS_PARAMETER | :HAS_STATIC_INIT | :HAS_VARIABLEDECL_INIT | :IF_THEN | :IF_ELSE | :LABELED_STATEMENT | :SWITCH_ENCLOSES_CASE | :SYNCHRONIZED_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES *]->(useStmt)-[:ASSERT_CONDITION | :DO_WHILE_CONDITION | :ENCLOSES_EXPR | :FOREACH_EXPR | :FORLOOP_CONDITION | :HAS_VARIABLEDECL_INIT | :IF_CONDITION | :SWITCH_EXPR | :SYNCHRONIZED_EXPR | :THROW_EXPR | :WHILE_CONDITION | :RETURN_EXPR ]->(expression_with_father_statement)-[:ARRAYACCESS_EXPR | :ARRAYACCESS_INDEX | :ASSIGNMENT_LHS | :ASSIGNMENT_RHS | :BINOP_LHS | :BINOP_RHS | :BINOP_COND_RHS | :CAST_ENCLOSES | :COMPOUND_ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_RHS | :CONDITIONAL_EXPR_CONDITION | :CONDITIONAL_EXPR_THEN | :CONDITIONAL_EXPR_ELSE | :INITIALIZATION_EXPR | :INSTANCE_OF_EXPRESSION | :MEMBER_REFERENCE_EXPRESSION | :MEMBER_SELECT_EXPR | :METHODINVOCATION_ARGUMENTS | :METHODINVOCATION_METHOD_SELECT | :NEW_CLASS_ARGUMENTS | :NEW_ARRAY_INIT | :NEW_ARRAY_DIMENSION | :UNARY_ENCLOSES*0..]->(useExpr)\r\n" + - "WITH var_def,useStmt,fatherStmt,useExpr ORDER BY fatherStmt.position\r\n" + - "WITH var_def,useStmt,COLLECT(fatherStmt) as fatherStmtsFromEachUse,useExpr ORDER BY useStmt.position\r\n" + - "WITH var_def,COLLECT(useStmt) AS useStmts,COLLECT(fatherStmtsFromEachUse) AS fatherStmtsFromAllUses,COLLECT(useExpr) AS useExprs\r\n" + - "WITH var_def,useStmts,fatherStmtsFromAllUses, HEAD(fatherStmtsFromAllUses) AS fatherStmtsFromFirstUse,useExprs\r\n" + - "WITH var_def, REDUCE(s = HEAD(fatherStmtsFromAllUses), n IN TAIL(fatherStmtsFromAllUses) | FILTER(b in s where b in n) ) AS commonFatherStmtsFromAllUses, HEAD(fatherStmtsFromAllUses) AS fatherStmtsFromFirstUse, LAST(HEAD(fatherStmtsFromAllUses)) AS InnerMostFatherStmtFromFirstUse, HEAD(useStmts) AS firstUseStmt,HEAD(useExprs) AS firstUseExpr\r\n" + - "WITH var_def,LAST(commonFatherStmtsFromAllUses) as InnerMostCommonFatherStmtFromAllUses,InnerMostFatherStmtFromFirstUse,fatherStmtsFromFirstUse,firstUseStmt,firstUseExpr\r\n" + - "WITH var_def,\r\n" + - "CASE \r\n" + - "WHEN InnerMostCommonFatherStmtFromAllUses=InnerMostFatherStmtFromFirstUse THEN firstUseStmt ELSE HEAD(FILTER(b IN fatherStmtsFromFirstUse WHERE EXISTS((InnerMostCommonFatherStmtFromAllUses)-[:CASE_STATEMENTS | :CATCH_BLOCK | :CATCH_PARAM | :ENCLOSES | :DO_WHILE_STATEMENT | :WHILE_STATEMENT | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :CALLABLE_HAS_PARAMETER | :HAS_STATIC_INIT | :HAS_VARIABLEDECL_INIT | :IF_THEN | :IF_ELSE | :LABELED_STATEMENT | :SWITCH_ENCLOSES_CASE | :SYNCHRONIZED_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES]->(b)))) END AS StmtAfterCorrectDeclarationPosition,InnerMostCommonFatherStmtFromAllUses\r\n" + - "//'StmtAfterCorrectDeclarationPosition' representa el statement situado a continuación de la nueva posición correcta de declaración. Si antes de entrar al else, el padre mas pequeño común a todos los usos coincide con el padre mas pequeño del primer uso (es decir,su padre directo), el primer uso sería el 'StmtAfterCorrectDeclarationPosition' . Si entramos al else, se obtiene el padre del primer uso (buscando entre todos los padres del primer uso) que sea hijo directo del InnerMostCommonStmt a todos los usos (utilizamos el HEAD para sacarlo de la lista). Este sería el 'StmtAfterCorrectDeclarationPosition'. \r\n" + - "MATCH (statement)-[:CFG_NEXT_STATEMENT | :CFG_NEXT_STATEMENT_IF_TRUE | :CFG_NEXT_STATEMENT_IF_FALSE | :CFG_FOR_EACH_HAS_NEXT | :CFG_FOR_EACH_NO_MORE_ELEMENTS | :CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION | :CFG_NO_EXCEPTION | :CFG_CAUGHT_EXCEPTION | :CFG_AFTER_FINALLY_PREVIOUS_BREAK | :CFG_AFTER_FINALLY_PREVIOUS_CONTINUE | :CFG_SWITCH_CASE_IS_EQUAL_TO | :CFG_SWITCH_DEFAULT_CASE | :CFG_MAY_THROW | :CFG_THROWS | :CFG_ENTRY ]->(StmtAfterCorrectDeclarationPosition)\r\n" + - "WHERE var_def<>statement // Comprobamos que el stmt situado antes de StmtAfterCorrectDeclarationPosition no es la propia declaración, ya que no tendríamos que lanzar el mensaje al encontrarse bien situada\r\n" + - "AND statement.lineNumber < StmtAfterCorrectDeclarationPosition.lineNumber //Esta segunda condición sirve para evitar que tenga en cuenta 'predecedores falsos' en bucles\r\n" + - "OPTIONAL MATCH (var_def)<-[:CASE_STATEMENTS | :CATCH_BLOCK | :CATCH_PARAM | :ENCLOSES | :DO_WHILE_STATEMENT | :WHILE_STATEMENT | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :CALLABLE_HAS_PARAMETER | :HAS_STATIC_INIT | :HAS_VARIABLEDECL_INIT | :IF_THEN | :IF_ELSE | :LABELED_STATEMENT | :SWITCH_ENCLOSES_CASE | :LABELED_STMT_ENCLOSES | :SYNCHRONIZED_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES |:CATCH_ENCLOSES_BLOCK *]-(a)<-[:CALLABLE_HAS_BODY]-(method)<-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]-(classType)<-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]-(enclosingCU:COMPILATION_UNIT) \r\n" + - "WITH '[BLOCH-8.45;'+enclosingCU.fileName+';variable_definition;'+var_def.name+';'+var_def.lineNumber+';You should move the declaration of local variable ['+var_def.name+'] in line '+var_def.lineNumber+' to inmediately before the statement in line '+ StmtAfterCorrectDeclarationPosition.lineNumber +' in method '+method.fullyQualifiedName+ ' in file '+enclosingCU.fileName +', avoiding any intermediate statement to keep it clear]' as message ORDER BY method.completeName\r\n" + - "RETURN DISTINCT message")}; - } - -} diff --git a/ProgQuery/src/database/queries/sa/bloch/BLOCH_8_45_V2.java b/ProgQuery/src/database/queries/sa/bloch/BLOCH_8_45_V2.java deleted file mode 100644 index 1414887..0000000 --- a/ProgQuery/src/database/queries/sa/bloch/BLOCH_8_45_V2.java +++ /dev/null @@ -1,61 +0,0 @@ -package database.queries.sa.bloch; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServices; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import utils.dataTransferClasses.Pair; - -public class BLOCH_8_45_V2 extends AbstractQuery { - - public BLOCH_8_45_V2() { - super(true); - - } - - // WTIH ATTR, DECLARING TYPE - public static void main(String[] args) { - System.out.println(new BLOCH_8_45_V2().queryToString()); - } - - @Override - protected void initiate() { - clauses = new Clause[] { -new ClauseImpl("MATCH (var_def:LOCAL_VAR_DEF)\r\n" + - "OPTIONAL MATCH (var_def)-[r:USED_BY| :STATE_MODIFIED_BY |:MODIFIED_BY | :STATE_MAY_BE_MODIFIED_BY]->(useExpr)//ANTES SIN RELACION STATE_MAY_BE_MODIFIED_BY\r\n" + - "WHERE //NOT useExpr:METHOD_INVOCATION \r\n" + - "NOT EXISTS((var_def)-[:CATCH_PARAM | :FOREACH_VAR | :TRY_RESOURCES]-())//EVITAMOS CONTABILIZAR LOS PARAMETROS DE LOS CATCH\r\n" + - "WITH var_def, useExpr ORDER BY useExpr.lineNumber, useExpr.column\r\n" + - "MATCH (fatherStmt)-[:CASE_STATEMENTS | :CATCH_BLOCK | :CATCH_PARAM | :ENCLOSES | :DO_WHILE_STATEMENT | :WHILE_STATEMENT | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :CALLABLE_HAS_PARAMETER | :HAS_STATIC_INIT | :HAS_VARIABLEDECL_INIT | :IF_THEN | :IF_ELSE | :LABELED_STATEMENT | :SWITCH_ENCLOSES_CASE | :SYNCHRONIZED_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES *]->(useStmt)-[:ASSERT_CONDITION | :DO_WHILE_CONDITION | :ENCLOSES_EXPR | :FOREACH_EXPR | :FORLOOP_CONDITION | :HAS_VARIABLEDECL_INIT | :IF_CONDITION | :SWITCH_EXPR | :SYNCHRONIZED_EXPR | :THROW_EXPR | :WHILE_CONDITION | :RETURN_EXPR ]->(expression_with_father_statement)-[:ARRAYACCESS_EXPR | :ARRAYACCESS_INDEX | :ASSIGNMENT_LHS | :ASSIGNMENT_RHS | :BINOP_LHS | :BINOP_RHS | :BINOP_COND_RHS | :CAST_ENCLOSES | :COMPOUND_ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_RHS | :CONDITIONAL_EXPR_CONDITION | :CONDITIONAL_EXPR_THEN | :CONDITIONAL_EXPR_ELSE | :INITIALIZATION_EXPR | :INSTANCE_OF_EXPRESSION | :MEMBER_REFERENCE_EXPRESSION | :MEMBER_SELECT_EXPR | :METHODINVOCATION_ARGUMENTS | :METHODINVOCATION_METHOD_SELECT | :NEW_CLASS_ARGUMENTS | :NEW_ARRAY_INIT | :NEW_ARRAY_DIMENSION | :UNARY_ENCLOSES*0..]->(useExpr)\r\n" + - "WITH var_def,useStmt,fatherStmt,useExpr ORDER BY fatherStmt.position\r\n" + - "WITH var_def,useStmt,COLLECT(fatherStmt) as fatherStmtsFromEachUse,useExpr ORDER BY useStmt.position\r\n" + - "WITH var_def,COLLECT(useStmt) AS useStmts,COLLECT(fatherStmtsFromEachUse) AS fatherStmtsFromAllUses,COLLECT(useExpr) AS useExprs\r\n" + - "WITH var_def,useStmts,fatherStmtsFromAllUses, HEAD(fatherStmtsFromAllUses) AS fatherStmtsFromFirstUse,useExprs\r\n" + - "WITH var_def, REDUCE(s = HEAD(fatherStmtsFromAllUses), n IN TAIL(fatherStmtsFromAllUses) | FILTER(b in s where b in n) ) AS commonFatherStmtsFromAllUses, HEAD(fatherStmtsFromAllUses) AS fatherStmtsFromFirstUse, LAST(HEAD(fatherStmtsFromAllUses)) AS InnerMostFatherStmtFromFirstUse, HEAD(useStmts) AS firstUseStmt,HEAD(useExprs) AS firstUseExpr\r\n" + - "WITH var_def,LAST(commonFatherStmtsFromAllUses) as InnerMostCommonFatherStmtFromAllUses,InnerMostFatherStmtFromFirstUse,fatherStmtsFromFirstUse,firstUseStmt,firstUseExpr\r\n" + - "WITH var_def,\r\n" + - "CASE \r\n" + - "WHEN InnerMostCommonFatherStmtFromAllUses=InnerMostFatherStmtFromFirstUse THEN firstUseStmt ELSE HEAD(FILTER(b IN fatherStmtsFromFirstUse WHERE EXISTS((InnerMostCommonFatherStmtFromAllUses)-[:CASE_STATEMENTS | :CATCH_BLOCK | :CATCH_PARAM | :ENCLOSES | :DO_WHILE_STATEMENT | :WHILE_STATEMENT | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :CALLABLE_HAS_PARAMETER | :HAS_STATIC_INIT | :HAS_VARIABLEDECL_INIT | :IF_THEN | :IF_ELSE | :LABELED_STATEMENT | :SWITCH_ENCLOSES_CASE | :SYNCHRONIZED_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES]->(b)))) END AS StmtAfterCorrectDeclarationPosition,InnerMostCommonFatherStmtFromAllUses\r\n" + - "//'StmtAfterCorrectDeclarationPosition' representa el statement situado a continuación de la nueva posición correcta de declaración. Si antes de entrar al else, el padre mas pequeño común a todos los usos coincide con el padre mas pequeño del primer uso (es decir,su padre directo), el primer uso sería el 'StmtAfterCorrectDeclarationPosition' . Si entramos al else, se obtiene el padre del primer uso (buscando entre todos los padres del primer uso) que sea hijo directo del InnerMostCommonStmt a todos los usos (utilizamos el HEAD para sacarlo de la lista). Este sería el 'StmtAfterCorrectDeclarationPosition'. \r\n" + - "MATCH (statement)-[:CFG_NEXT_STATEMENT | :CFG_NEXT_STATEMENT_IF_TRUE | :CFG_NEXT_STATEMENT_IF_FALSE | :CFG_FOR_EACH_HAS_NEXT | :CFG_FOR_EACH_NO_MORE_ELEMENTS | :CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION | :CFG_NO_EXCEPTION | :CFG_CAUGHT_EXCEPTION | :CFG_AFTER_FINALLY_PREVIOUS_BREAK | :CFG_AFTER_FINALLY_PREVIOUS_CONTINUE | :CFG_SWITCH_CASE_IS_EQUAL_TO | :CFG_SWITCH_DEFAULT_CASE | :CFG_MAY_THROW | :CFG_THROWS | :CFG_ENTRY ]->(StmtAfterCorrectDeclarationPosition)\r\n" + - "WHERE NOT statement:LOCAL_VAR_DEF // Comprobamos que el stmt situado antes de StmtAfterCorrectDeclarationPosition no es la propia declaración, ya que no tendríamos que lanzar el mensaje al encontrarse bien situada\r\n" + - "AND statement.lineNumber < StmtAfterCorrectDeclarationPosition.lineNumber //Esta segunda condición sirve para evitar que tenga en cuenta 'predecedores falsos' en bucles\r\n" + - "OPTIONAL MATCH (var_def)<-[:CASE_STATEMENTS | :CATCH_BLOCK | :CATCH_PARAM | :ENCLOSES | :DO_WHILE_STATEMENT | :WHILE_STATEMENT | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :CALLABLE_HAS_PARAMETER | :HAS_STATIC_INIT | :HAS_VARIABLEDECL_INIT | :IF_THEN | :IF_ELSE | :LABELED_STATEMENT | :SWITCH_ENCLOSES_CASE | :LABELED_STMT_ENCLOSES | :SYNCHRONIZED_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES |:CATCH_ENCLOSES_BLOCK *]-(a)<-[:CALLABLE_HAS_BODY]-(method)<-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]-(classType)<-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]-(enclosingCU:COMPILATION_UNIT) \r\n" + - "WITH '[BLOCH-8.45;'+enclosingCU.fileName+';variable_definition;'+var_def.name+';'+var_def.lineNumber+';You should move the declaration of local variable ['+var_def.name+'] in line '+var_def.lineNumber+' to inmediately before the statement in line '+ StmtAfterCorrectDeclarationPosition.lineNumber +' in method '+method.fullyQualifiedName+ ' in file '+enclosingCU.fileName +', avoiding any intermediate statement to keep it clear]' as message ORDER BY method.completeName\r\n" + - "RETURN DISTINCT message")}; - } - -} diff --git a/ProgQuery/src/database/querys/ServerQueryManager.java b/ProgQuery/src/database/querys/ServerQueryManager.java deleted file mode 100644 index 2747ef8..0000000 --- a/ProgQuery/src/database/querys/ServerQueryManager.java +++ /dev/null @@ -1,54 +0,0 @@ -package database.querys; - -import java.util.List; - -import org.neo4j.driver.v1.AuthTokens; -import org.neo4j.driver.v1.Driver; -import org.neo4j.driver.v1.GraphDatabase; -import org.neo4j.driver.v1.Record; -import org.neo4j.driver.v1.Session; -import org.neo4j.driver.v1.StatementResult; -import org.neo4j.driver.v1.Transaction; -import org.neo4j.driver.v1.TransactionWork; - -public class ServerQueryManager implements AutoCloseable { - public static ServerQueryManager SERVER_MANAGER; - - // private static final String ADDRESS = "https://156.35.94.128:7474"; - final Driver driver; - Session session ; - - public ServerQueryManager(String user, String pass, String address) { - driver = GraphDatabase.driver(address, AuthTokens.basic(user, pass)); - session= driver.session(); - } - - public List executeQuery(String query) { - // Transaction t = session.beginTransaction(); - // System.err.println("EXECUTING:\n" + query); - return session.writeTransaction(new TransactionWork>() { - - @Override - public List execute(Transaction tx) { - // tx. - - StatementResult result = tx.run(query); - // result.list().get(0).asMap().entrySet() - // .forEach(e -> System.out.println(e.getKey() + "," + - // e.getValue())); - // return result.list().stream().map(r -> - // r.get(0).asString()).collect( Collectors.toList()); - return result.list(); - - } - - }); - } - - @Override - public void close() throws Exception { - session.close(); - driver.close(); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/AbstractQuery.java b/ProgQuery/src/database/querys/cypherWrapper/AbstractQuery.java deleted file mode 100644 index 0c0e2c1..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/AbstractQuery.java +++ /dev/null @@ -1,49 +0,0 @@ -package database.querys.cypherWrapper; - -import database.querys.eval.Query; -import database.querys.services.AssignmentServices; -import database.querys.services.CFGServices; -import database.querys.services.ExpressionServices; -import database.querys.services.PDGServices; -import database.querys.services.StatementServices; - -public abstract class AbstractQuery implements Query { - protected Clause[] clauses; - public boolean isProgQuery; - - public AbstractQuery(boolean isProgQuery) { - super(); - this.isProgQuery = isProgQuery; - } - - public ExpressionServices getExpressionServices() { - return isProgQuery ? ExpressionServices.PROG_QUERY : ExpressionServices.WIGGLE; - } - - public PDGServices getPDGServices() { - return isProgQuery ? PDGServices.PROG_QUERY : PDGServices.WIGGLE; - } - - public CFGServices getCFGServices() { - return isProgQuery ? CFGServices.PROG_QUERY : CFGServices.WIGGLE; - } - - public AssignmentServices getAssignmentServices() { - return isProgQuery ? AssignmentServices.PROG_QUERY : AssignmentServices.WIGGLE; - } - - public StatementServices getStatementServices() { - return isProgQuery ? StatementServices.PROG_QUERY : StatementServices.WIGGLE; - } - @Override - public String queryToString() { - initiate(); - String res = ""; - for (Clause clause : clauses) - res += clause.clauseToString() + "\n"; - return res; - } - - protected abstract void initiate(); - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/All.java b/ProgQuery/src/database/querys/cypherWrapper/All.java deleted file mode 100644 index e2504c7..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/All.java +++ /dev/null @@ -1,34 +0,0 @@ -package database.querys.cypherWrapper; - -public class All extends Extract { - - public All(String list, String map, String var) { - super(list, map, var); - // TODO Auto-generated constructor stub - } - - public All(Expression list, Expression map, String var) { - super(list, map, var); - // TODO Auto-generated constructor stub - } - public All(String list, String map) { - super(list, map); - // TODO Auto-generated constructor stub - } - - public All(String list, Expression map) { - super(list, map); - // TODO Auto-generated constructor stub - } - - public All(Expression list, Expression map) { - super(list, map, ""); - // TODO Auto-generated constructor stub - } - - @Override - public String expToString() { - return "ALL" + "(" + var + " IN " + list.expToString() + " WHERE " + map.expToString() + " )"; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/AnonymousNode.java b/ProgQuery/src/database/querys/cypherWrapper/AnonymousNode.java deleted file mode 100644 index 8010fe7..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/AnonymousNode.java +++ /dev/null @@ -1,20 +0,0 @@ -package database.querys.cypherWrapper; - -public class AnonymousNode implements Node { - - @Override - public String matchToString() { - return "()"; - } - - @Override - public Node getLastNode() { - return this; - } - - @Override - public String getName() { - throw new IllegalStateException(); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Any.java b/ProgQuery/src/database/querys/cypherWrapper/Any.java deleted file mode 100644 index b3fd106..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Any.java +++ /dev/null @@ -1,28 +0,0 @@ -package database.querys.cypherWrapper; - -public class Any implements Expression { - - private Expression list; - private Expression condition; - - public Any(Expression list, Expression condition) { - super(); - this.list = list; - this.condition = condition; - } - - public Any(String list, String condition) { - super(); - this.list = new ExprImpl(list); - this.condition = new ExprImpl(condition); - } - - @Override - public String expToString() { - return "ANY( x IN " + list.expToString() + " WHERE " + condition.expToString() + " )"; - } - - public static Any collectAndAny(String rowsToCollect, String condition) { - return new Any(new ExprImpl("COLLECT(" + rowsToCollect + ")"), new ExprImpl(condition)); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Binop.java b/ProgQuery/src/database/querys/cypherWrapper/Binop.java deleted file mode 100644 index c827476..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Binop.java +++ /dev/null @@ -1,34 +0,0 @@ -package database.querys.cypherWrapper; - -public class Binop implements Expression { - private String operator; - - private Expression left, right; - - public Binop(String operator, Expression left, Expression right) { - this.operator = operator; - this.left = left; - this.right = right; - } - - @Override - public String expToString() { - return left.expToString() + " " + operator + " " + right.expToString(); - } - - static Expression andExpression(Expression... exprs) { - return consecutiveExprs("AND", exprs); - } - - static Expression orExpression(Expression... exprs) { - return consecutiveExprs(" OR ", exprs); - } - - private static Expression consecutiveExprs(String op, Expression... exprs) { - Expression exp = exprs[0]; - for (int i = 1; i < exprs.length; i++) - exp = new Binop(op, exp, exprs[i]); - return exp; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Cardinalidad.java b/ProgQuery/src/database/querys/cypherWrapper/Cardinalidad.java deleted file mode 100644 index f836a16..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Cardinalidad.java +++ /dev/null @@ -1,45 +0,0 @@ -package database.querys.cypherWrapper; - -import java.util.function.BiFunction; - -public class Cardinalidad { - public static final Cardinalidad JUST_ONE = new Cardinalidad((min, max) -> ""), - ONE_TO_INF = new Cardinalidad((min, max) -> "*"); - - - private BiFunction toString; - private int min, max; - - private Cardinalidad(BiFunction toString, int min, int max) { - this.toString = toString; - this.min = min; - this.max = max; - } - - private Cardinalidad(BiFunction toString, int min) { - this.toString = toString; - this.min = min; - this.max = -1; - } - - private Cardinalidad(BiFunction toString) { - this.toString = toString; - } - - public static Cardinalidad MIN_TO_INF(int minimum) { - return new Cardinalidad((min, max) -> "*" + min + "..", minimum); - } - - public static Cardinalidad MIN_TO_MAX(int minimum, int maximum) { - return new Cardinalidad((min, max) -> "*" + min + ".." + max, minimum, maximum); - } - - public static Cardinalidad ONE_TO_MAX(int maximum) { - return new Cardinalidad((min, max) -> "*.." + max, -1, maximum); - } - - public String toString() { - return toString.apply(min, max); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Case.java b/ProgQuery/src/database/querys/cypherWrapper/Case.java deleted file mode 100644 index 229f946..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Case.java +++ /dev/null @@ -1,30 +0,0 @@ -package database.querys.cypherWrapper; - -public class Case implements Expression { - - private Expression condition, ifExpr, elseExpr; - - public Case(Expression condition, Expression ifExpr, Expression elseExpr) { - this.condition = condition; - this.ifExpr = ifExpr; - this.elseExpr = elseExpr; - } - - public Case(String condition, String ifExpr, String elseExpr) { - this.condition = new ExprImpl(condition); - this.ifExpr = new ExprImpl(ifExpr); - this.elseExpr = new ExprImpl(elseExpr); - } - - public Case(String condition, Expression ifExpr, String elseExpr) { - this(new ExprImpl(condition), ifExpr, new ExprImpl(elseExpr)); - } - - @Override - public String expToString() { - - return "(CASE WHEN " + condition.expToString() + " THEN " + ifExpr.expToString() + " ELSE " - + elseExpr.expToString() + " END)"; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Clause.java b/ProgQuery/src/database/querys/cypherWrapper/Clause.java deleted file mode 100644 index 5c1c43d..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Clause.java +++ /dev/null @@ -1,24 +0,0 @@ -package database.querys.cypherWrapper; - -public interface Clause extends Element { - - String clauseToString(); - - default Clause append(Element e) { - return e.beAppendedTo(this); - } - - default Clause beAppendedTo(MatchClause clause) { - - return beAppendedTo((Clause) clause); - } - - @Override - default Clause beAppendedTo(Clause e) { - return new MultipleClauses(e, this); - } - - default MatchElement beAppendedTo(MatchElement matchElement){ - return new PathEnd(matchElement, this); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/ClauseImpl.java b/ProgQuery/src/database/querys/cypherWrapper/ClauseImpl.java deleted file mode 100644 index 6448b70..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/ClauseImpl.java +++ /dev/null @@ -1,16 +0,0 @@ -package database.querys.cypherWrapper; - -public class ClauseImpl implements Clause { - private String clause; - - public ClauseImpl(String clause) { - super(); - this.clause = clause; - } - - @Override - public String clauseToString() { - return clause; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/CompleteNode.java b/ProgQuery/src/database/querys/cypherWrapper/CompleteNode.java deleted file mode 100644 index 7cae2d6..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/CompleteNode.java +++ /dev/null @@ -1,57 +0,0 @@ -package database.querys.cypherWrapper; - -import database.nodes.NodeTypes; -import utils.dataTransferClasses.Pair; - -public class CompleteNode extends NodeVar { - - private NodeTypes label; - - private Pair[] property; - - public CompleteNode(String name, NodeTypes label, Pair... property) { - super(name); - this.label = label; - this.property = property; - } - - public CompleteNode(NodeTypes label, Pair... property) { - super(""); - this.label = label; - this.property = property; - } - - public CompleteNode(String name, Pair... property) { - this(name, null, property); - } - - public CompleteNode(String name, NodeTypes label) { - this(name, label, new Pair[0]); - } - - public CompleteNode(Pair... property) { - this("", null, property); - } - - public CompleteNode(NodeTypes label) { - this("", label, new Pair[0]); - } - - @Override - public String matchToString() { - return "(" + name + (label == null ? "" : ":" + label) + propertiesToString() + ")"; - } - - private String propertiesToString() { - if (property.length == 0) - return ""; - - String res = "{"; - for (Pair p : property) - - res += p.getFirst().toString() + ":" + (p.getSecond() instanceof String - ? "'" + p.getSecond().toString() + "'" : p.getSecond().toString()) + ","; - - return res.substring(0, res.length() - 1) + "}"; - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/CreateClause.java b/ProgQuery/src/database/querys/cypherWrapper/CreateClause.java deleted file mode 100644 index c7dbb73..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/CreateClause.java +++ /dev/null @@ -1,30 +0,0 @@ -package database.querys.cypherWrapper; - -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class CreateClause implements Clause { - - MatchElement[] elements; - - public CreateClause(MatchElement... elements) { - super(); - this.elements = elements; - } - - public CreateClause(String... elements) { - super(); - this.elements = new MatchElement[elements.length]; - this.elements = Stream.of(elements).map(s -> new MatchImpl(s)).collect(Collectors.toList()) - .toArray(this.elements); - } - - @Override - public String clauseToString() { - String res = "CREATE "; - for (MatchElement match : elements) - res += match.matchToString(); - return res; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Edge.java b/ProgQuery/src/database/querys/cypherWrapper/Edge.java deleted file mode 100644 index 6bdd23d..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Edge.java +++ /dev/null @@ -1,6 +0,0 @@ -package database.querys.cypherWrapper; - -public interface Edge { - - String edgeToString(); -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/EdgeDirection.java b/ProgQuery/src/database/querys/cypherWrapper/EdgeDirection.java deleted file mode 100644 index 6e086bd..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/EdgeDirection.java +++ /dev/null @@ -1,22 +0,0 @@ -package database.querys.cypherWrapper; - -public enum EdgeDirection { - - UNDIRECTED("-[", "]-"), INCOMING("-[", "]->"), OUTGOING("<-[", "]-"); - - private String directionToStringPart1, directionToStringPart2; - - private EdgeDirection(String directionToStringPart1, String directionToStringPart2) { - this.directionToStringPart1 = directionToStringPart1; - this.directionToStringPart2 = directionToStringPart2; - } - - public String getDirectionToStringPart1() { - return directionToStringPart1; - } - - public String getDirectionToStringPart2() { - return directionToStringPart2; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/EdgeImpl.java b/ProgQuery/src/database/querys/cypherWrapper/EdgeImpl.java deleted file mode 100644 index c995a5c..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/EdgeImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -package database.querys.cypherWrapper; - -import database.relations.RelationTypesInterface; -import utils.dataTransferClasses.Pair; - -public class EdgeImpl implements Edge { - - private EdgeDirection direction; - private String name; - private RelationTypesInterface[] relLabel; - private Cardinalidad cardinalidad; - private Pair[] property = new Pair[0]; - - public EdgeImpl(EdgeDirection direction, String name, Cardinalidad cardinalidad, - RelationTypesInterface... relLabel) { - this.direction = direction; - this.name = name; - this.relLabel = relLabel; - this.cardinalidad = cardinalidad; - } - - public EdgeImpl(String name, Cardinalidad cardinalidad, RelationTypesInterface... relLabel) { - this(EdgeDirection.INCOMING, name, cardinalidad, relLabel); - } - - public EdgeImpl() { - this(EdgeDirection.INCOMING, "", Cardinalidad.JUST_ONE); - } - - public EdgeImpl(String name) { - this(EdgeDirection.INCOMING, name, Cardinalidad.JUST_ONE); - } - - public EdgeImpl(EdgeDirection direction) { - this(direction, "", Cardinalidad.JUST_ONE); - } - - public EdgeImpl(EdgeDirection direction, RelationTypesInterface... relLabel) { - this(direction, "", Cardinalidad.JUST_ONE, relLabel); - } - - public EdgeImpl(RelationTypesInterface... relLabel) { - this(EdgeDirection.INCOMING, "", Cardinalidad.JUST_ONE, relLabel); - } - - public EdgeImpl(String name, RelationTypesInterface... relLabel) { - this(EdgeDirection.INCOMING, name, Cardinalidad.JUST_ONE, relLabel); - } - - public EdgeImpl(Cardinalidad c, RelationTypesInterface... relLabel) { - this(EdgeDirection.INCOMING, "", c, relLabel); - } - - public EdgeImpl setDirection(EdgeDirection direction) { - this.direction = direction; - return this; - } - - public EdgeImpl setName(String name) { - this.name = name; - return this; - } - - public EdgeImpl setRelLabel(RelationTypesInterface[] relLabel) { - this.relLabel = relLabel; - return this; - } - - public EdgeImpl setCardinalidad(Cardinalidad cardinalidad) { - this.cardinalidad = cardinalidad; - return this; - } - - public EdgeImpl setProperty(Pair... property) { - this.property = property; - return this; - } - - @Override - public String edgeToString() { - return direction.getDirectionToStringPart1() + name + labelsToString() + propertiesToString() - + cardinalidad.toString() + direction.getDirectionToStringPart2(); - } - - private String labelsToString() { - if (relLabel.length == 0) - return ""; - String res = ":"; - for (RelationTypesInterface r : relLabel) - res += r.toString() + "|"; - return res.substring(0, res.length() - 1); - } - - private String propertiesToString() { - if (property.length == 0) - return ""; - String res = "{"; - for (Pair p : property) - res += p.getFirst().toString() + "=" + (p.getSecond() instanceof String - ? "'" + p.getSecond().toString() + "'" : p.getSecond().toString()) + ","; - return res.substring(0, res.length() - 1) + "}"; - } - - public EdgeImpl changeDirection() { - direction = direction == EdgeDirection.UNDIRECTED ? direction - : direction == EdgeDirection.INCOMING ? EdgeDirection.OUTGOING : EdgeDirection.INCOMING; - return this; - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Element.java b/ProgQuery/src/database/querys/cypherWrapper/Element.java deleted file mode 100644 index 0f7229e..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Element.java +++ /dev/null @@ -1,11 +0,0 @@ -package database.querys.cypherWrapper; - -public interface Element { - - Clause beAppendedTo(Clause clause); - - Clause beAppendedTo(MatchClause clause); - - MatchElement beAppendedTo(MatchElement matchElement); - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/ExprAndLabels.java b/ProgQuery/src/database/querys/cypherWrapper/ExprAndLabels.java deleted file mode 100644 index 9c165ed..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/ExprAndLabels.java +++ /dev/null @@ -1,21 +0,0 @@ -package database.querys.cypherWrapper; - -public class ExprAndLabels implements Expression { - private Expression exp; - - public ExprAndLabels(Expression exp) { - super(); - this.exp = exp; - } - - public ExprAndLabels(String exp) { - super(); - this.exp = new ExprImpl(exp); - } - - @Override - public String expToString() { - return exp.expToString() + ", LABELS(" + exp.expToString() + ")"; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/ExprImpl.java b/ProgQuery/src/database/querys/cypherWrapper/ExprImpl.java deleted file mode 100644 index adf4f27..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/ExprImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package database.querys.cypherWrapper; - -public class ExprImpl implements Expression { - - private String exprString; - - public ExprImpl(String exprString) { - super(); - this.exprString = exprString; - } - @Override - public String expToString() { - // TODO Auto-generated method stub - return exprString; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Expression.java b/ProgQuery/src/database/querys/cypherWrapper/Expression.java deleted file mode 100644 index 4a4c008..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Expression.java +++ /dev/null @@ -1,6 +0,0 @@ -package database.querys.cypherWrapper; - -public interface Expression { - - String expToString(); -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Extract.java b/ProgQuery/src/database/querys/cypherWrapper/Extract.java deleted file mode 100644 index ee53e6b..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Extract.java +++ /dev/null @@ -1,51 +0,0 @@ -package database.querys.cypherWrapper; - -public class Extract implements Expression { - - protected Expression list; - protected Expression map; - protected String var = "x"; - - public Extract(Expression list, Expression map, String var) { - super(); - this.list = list; - this.map = map; - this.var = var; - } - - public Extract(String list, String map) { - super(); - this.list = new ExprImpl(list); - this.map = new ExprImpl(map); - } - - public Extract(Expression list, String map) { - super(); - this.list = list; - this.map = new ExprImpl(map); - } - public Extract(String list, String map, String var) { - super(); - this.list = new ExprImpl(list); - this.map = new ExprImpl(map); - this.var = var; - } - - public Extract(String list, Expression map) { - super(); - this.list = new ExprImpl(list); - this.map = map; - } - - public Extract(Filter list, String map, String var) { - this.map = new ExprImpl(map); - this.list = list; - this.var = var; - } - - @Override - public String expToString() { - return "EXTRACT(" + var + " IN " + list.expToString() + " | " + map.expToString() + " )"; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Filter.java b/ProgQuery/src/database/querys/cypherWrapper/Filter.java deleted file mode 100644 index 4a2f562..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Filter.java +++ /dev/null @@ -1,34 +0,0 @@ -package database.querys.cypherWrapper; - -public class Filter extends Extract { - - public Filter(String list, String map, String var) { - super(list, map, var); - // TODO Auto-generated constructor stub - } - - public Filter(Expression list, Expression map, String var) { - super(list, map, var); - // TODO Auto-generated constructor stub - } - public Filter(String list, String map) { - super(list, map); - // TODO Auto-generated constructor stub - } - - public Filter(String list, Expression map) { - super(list, map); - // TODO Auto-generated constructor stub - } - - public Filter(Expression list, Expression map) { - super(list, map, ""); - // TODO Auto-generated constructor stub - } - - @Override - public String expToString() { - return "FILTER" + "(" + var + " IN " + list.expToString() + " WHERE " + map.expToString() + " )"; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/ForEach.java b/ProgQuery/src/database/querys/cypherWrapper/ForEach.java deleted file mode 100644 index 7228658..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/ForEach.java +++ /dev/null @@ -1,28 +0,0 @@ -package database.querys.cypherWrapper; - -public class ForEach implements Clause { - - private String name; - private Expression list; - private Clause clause; - - public ForEach(String name, Expression list, Clause clause) { - super(); - this.name = name; - this.list = list; - this.clause = clause; - } - - public ForEach(String name, String list, Clause clause) { - super(); - this.name = name; - this.list = new ExprImpl(list); - this.clause = clause; - } - - @Override - public String clauseToString() { - return "FOREACH (" + name + " IN " + list.expToString() + " | " + clause.clauseToString() + ") "; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Function.java b/ProgQuery/src/database/querys/cypherWrapper/Function.java deleted file mode 100644 index 4009e8c..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Function.java +++ /dev/null @@ -1,23 +0,0 @@ -package database.querys.cypherWrapper; - -public class Function implements Expression { - private String name; - - private Expression[] exprs; - - public Function(String name, Expression... exprs) { - super(); - this.name = name; - this.exprs = exprs; - } - - @Override - public String expToString() { - String res = name + "("; - for (Expression expr : exprs) - res += expr.expToString() + ","; - return res.substring(0, res.length() - 1) + ")"; - - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/HasLabel.java b/ProgQuery/src/database/querys/cypherWrapper/HasLabel.java deleted file mode 100644 index ada6008..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/HasLabel.java +++ /dev/null @@ -1,25 +0,0 @@ -package database.querys.cypherWrapper; - -import database.nodes.NodeTypes; - -public class HasLabel implements Expression { - - private Expression exp; - private NodeTypes nodeType; - - public HasLabel(Expression exp, NodeTypes nodeType) { - this.exp = exp; - this.nodeType = nodeType; - } - - public HasLabel(String exp, NodeTypes nodeType) { - this.exp = new ExprImpl(exp); - this.nodeType = nodeType; - } - - @Override - public String expToString() { - return exp.toString() + ":" + nodeType.name(); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/MatchClause.java b/ProgQuery/src/database/querys/cypherWrapper/MatchClause.java deleted file mode 100644 index aaf0c75..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/MatchClause.java +++ /dev/null @@ -1,36 +0,0 @@ -package database.querys.cypherWrapper; - -public class MatchClause extends CreateClause { - - boolean isOptional; - - public MatchClause(MatchElement... elements) { - super(elements); - } - - public MatchClause(boolean isOptional, MatchElement... elements) { - super(elements); - this.isOptional = isOptional; - } - - public MatchClause(boolean isOptional, String content) { - super(new MatchImpl(content)); - this.isOptional = isOptional; - } - - @Override - public String clauseToString() { - String res = (isOptional ? "OPTIONAL " : "") + "MATCH "; - for (MatchElement match : elements) - // if (match instanceof EmptyElement) - // res = res.substring(0, res.length() - 2); - res += match.matchToString() + ",\n"; - - return res.substring(0, res.length() - 2); - } - - @Override - public Clause append(Element e) { - return e.beAppendedTo(this); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/MatchElement.java b/ProgQuery/src/database/querys/cypherWrapper/MatchElement.java deleted file mode 100644 index 67e5b12..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/MatchElement.java +++ /dev/null @@ -1,33 +0,0 @@ -package database.querys.cypherWrapper; - -import utils.dataTransferClasses.Pair; - -public interface MatchElement extends Element { - - String matchToString(); - - default Path append(Pair... subPath) { - return new Path(this, subPath); - } - - default MatchElements appendNewElement(MatchElement m) { - return new MatchElements(this, m); - } - - Node getLastNode(); - - default Clause beAppendedTo(Clause e) { - return new MultipleClauses(e, new MatchClause(this)); - } - - default Clause beAppendedTo(MatchClause clause) { - - return new MatchClause(clause.isOptional, new MatchElements(clause.elements), this); - } - - default MatchElement beAppendedTo(MatchElement matchElement) { - - // también podría ser PAth - return new MatchElements(matchElement, this); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/MatchElements.java b/ProgQuery/src/database/querys/cypherWrapper/MatchElements.java deleted file mode 100644 index 8ad4ed0..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/MatchElements.java +++ /dev/null @@ -1,26 +0,0 @@ -package database.querys.cypherWrapper; - -public class MatchElements implements MatchElement { - private MatchElement[] elements; - - public MatchElements(MatchElement... elements) { - this.elements = elements; - } - - @Override - public String matchToString() { - String res = ""; - if (elements.length == 0) - return res; - for (MatchElement element : elements) - res += element.matchToString() + ","; - return res.substring(0, res.length() - 1); - } - - @Override - public Node getLastNode() { - return elements[elements.length - 1].getLastNode(); - } - - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/MatchImpl.java b/ProgQuery/src/database/querys/cypherWrapper/MatchImpl.java deleted file mode 100644 index fcdcb71..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/MatchImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package database.querys.cypherWrapper; - -public class MatchImpl implements MatchElement { - private String string; - private String lastNode; - public MatchImpl(String string) { - super(); - this.string = string; - } - - public MatchImpl(String string, String lastNode) { - super(); - this.string = string; - this.lastNode = lastNode; - } - - @Override - public String matchToString() { - // TODO Auto-generated method stub - return string; - } - - @Override - public Node getLastNode() { - return new NodeVar(lastNode); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/MultipleClauses.java b/ProgQuery/src/database/querys/cypherWrapper/MultipleClauses.java deleted file mode 100644 index 8da9c01..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/MultipleClauses.java +++ /dev/null @@ -1,19 +0,0 @@ -package database.querys.cypherWrapper; - -public class MultipleClauses implements Clause { - private Clause[] clauses; - - @Override - public String clauseToString() { - String res = ""; - for (Clause clause : clauses) - res += clause.clauseToString() + "\n"; - return res; - } - - public MultipleClauses(Clause... clauses) { - - this.clauses = clauses; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Node.java b/ProgQuery/src/database/querys/cypherWrapper/Node.java deleted file mode 100644 index 170a2ae..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Node.java +++ /dev/null @@ -1,49 +0,0 @@ -package database.querys.cypherWrapper; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import database.nodes.NodeTypes; -import utils.dataTransferClasses.Pair; - -public interface Node extends MatchElement { - static final Map PQNodeTypeToWiggle = getPQNodeTypeToWiggle(); - - public static Node nodeForWiggle(String name, NodeTypes label, Pair... property) { - List props = new ArrayList(Arrays.asList(property)); - props.add(Pair.create("nodeType", PQNodeTypeToWiggle.get(label))); - return new CompleteNode(name, props.toArray(new Pair[] {})); - } - - public static Node nodeForWiggle(NodeTypes label, Pair... property) { - return nodeForWiggle("", label, property); - } - - String getName(); - public static Node nodeForWiggle(String name, NodeTypes label) { - return nodeForWiggle(name, label, new Pair[] {}); - } - static Map getPQNodeTypeToWiggle() { - Map res = new HashMap(); - res.put(NodeTypes.IDENTIFIER, "JCIdent"); - res.put(NodeTypes.ASSIGNMENT, "JCAssign"); - res.put(NodeTypes.LITERAL, "JCLiteral"); - res.put(NodeTypes.LOCAL_VAR_DEF, "JCVariableDecl"); - res.put(NodeTypes.ATTR_DEF, "JCVariableDecl"); - - res.put(NodeTypes.PARAMETER_DEF, "JCVariableDecl"); - res.put(NodeTypes.METHOD_DEF, "JCMethodDecl"); - res.put(NodeTypes.BREAK_STATEMENT, "JCBreak"); - - res.put(NodeTypes.FOR_LOOP, "JCForLoop"); - res.put(NodeTypes.DO_WHILE_LOOP, "JCDoWhileLoop"); - res.put(NodeTypes.WHILE_LOOP, "JCWhileLoop"); - res.put(NodeTypes.FOR_EACH_LOOP, "JCEnhancedForLoop"); - res.put(NodeTypes.MEMBER_SELECTION, "JCFieldAccess"); - - return res; - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/NodeVar.java b/ProgQuery/src/database/querys/cypherWrapper/NodeVar.java deleted file mode 100644 index 4489835..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/NodeVar.java +++ /dev/null @@ -1,21 +0,0 @@ -package database.querys.cypherWrapper; - -public class NodeVar extends AnonymousNode { - - protected String name; - - public NodeVar(String name) { - super(); - this.name = name; - } - - @Override - public String matchToString() { - return "(" + name + ")"; - } - - @Override - public String getName() { - return name; - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/OrderByClause.java b/ProgQuery/src/database/querys/cypherWrapper/OrderByClause.java deleted file mode 100644 index f4f5fad..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/OrderByClause.java +++ /dev/null @@ -1,27 +0,0 @@ -package database.querys.cypherWrapper; - -public class OrderByClause implements Clause { - private Expression[] exprs; - - public OrderByClause(Expression... exprs) { - super(); - this.exprs = exprs; - } - - public OrderByClause(String... exprTexts) { - super(); - exprs = new Expression[exprTexts.length]; - for (int i = 0; i < exprs.length; i++) - exprs[i] = new ExprImpl(exprTexts[i]); - } - - @Override - public String clauseToString() { - - String res = "ORDER BY "; - for (Expression exp : exprs) - res += exp.expToString() + ", "; - return res.substring(0, res.length() - 2); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Path.java b/ProgQuery/src/database/querys/cypherWrapper/Path.java deleted file mode 100644 index 3e66861..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Path.java +++ /dev/null @@ -1,35 +0,0 @@ -package database.querys.cypherWrapper; - -import utils.dataTransferClasses.Pair; - -public class Path implements MatchElement { - MatchElement initialNode; - Pair[] path; - String name; - - public Path(MatchElement initialNode, Pair... path) { - this.initialNode = initialNode; - this.path = path; - name = ""; - } - - public Path(MatchElement initialNode, String name, Pair... path) { - this.initialNode = initialNode; - this.path = path; - this.name = name + "="; - } - - public String matchToString() { - - String res = name + initialNode.matchToString(); - for (Pair pair : path) - res += pair.getFirst().edgeToString() + pair.getSecond().matchToString(); - return res; - } - - - @Override - public Node getLastNode() { - return path[path.length - 1].getSecond().getLastNode(); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/PathEnd.java b/ProgQuery/src/database/querys/cypherWrapper/PathEnd.java deleted file mode 100644 index b096000..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/PathEnd.java +++ /dev/null @@ -1,30 +0,0 @@ -package database.querys.cypherWrapper; - -public class PathEnd implements MatchElement { - private Clause[] endClause; - - private MatchElement element; - - public PathEnd(MatchElement element, Clause... endClause) { - this.endClause = endClause; - this.element = element; - } - - - public String matchToString() { - - String res = element.matchToString(); - for (Clause clause : endClause) - res += "\n" + clause.clauseToString(); - return res; - } - - @Override - public Node getLastNode() { - return element.getLastNode(); - } - - public void setEndClause(Clause c) { - endClause[endClause.length - 1] = c; - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Reduce.java b/ProgQuery/src/database/querys/cypherWrapper/Reduce.java deleted file mode 100644 index 48210c6..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Reduce.java +++ /dev/null @@ -1,37 +0,0 @@ -package database.querys.cypherWrapper; - -public class Reduce extends Extract { - - private String seed; - - public Reduce(String list, String map, String var, String seed) { - super(list, map, var); - this.seed = seed; - } - - public Reduce(String list, String map, String seed) { - super(list, map); - this.seed = seed; - } - - public Reduce(String list, Expression map, String seed) { - super(list, map); - this.seed = seed; - } - - public Reduce(Expression list, Expression map, String var, String seed) { - super(list, map, var); - this.seed = seed; - } - - public Reduce(String list, Expression map, String var, String seed) { - super(new ExprImpl(list), map, var); - this.seed = seed; - } - - @Override - public String expToString() { - return "REDUCE(" + seed + "," + var + " IN " + list.expToString() + " | " + map.expToString() + " )"; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/Relationship.java b/ProgQuery/src/database/querys/cypherWrapper/Relationship.java deleted file mode 100644 index d748a11..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/Relationship.java +++ /dev/null @@ -1,10 +0,0 @@ -package database.querys.cypherWrapper; - -public interface Relationship extends MatchElement { - - String relToString(); - - default String matchToString() { - return relToString(); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/RelationshipImpl.java b/ProgQuery/src/database/querys/cypherWrapper/RelationshipImpl.java deleted file mode 100644 index e371be5..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/RelationshipImpl.java +++ /dev/null @@ -1,48 +0,0 @@ -package database.querys.cypherWrapper; - -import database.relations.RelationTypesInterface; - -public class RelationshipImpl implements Relationship { - - private MatchElement start, end; - private Edge edge; - - public RelationshipImpl(MatchElement start, MatchElement end, Edge edge) { - super(); - this.start = start; - this.end = end; - this.edge = edge; - } - - public RelationshipImpl(MatchElement start, Edge edge) { - super(); - this.start = start; - this.end = new AnonymousNode(); - this.edge = edge; - } - - public RelationshipImpl(MatchElement start, RelationTypesInterface... rels) { - super(); - this.start = start; - this.end = new AnonymousNode(); - this.edge = new EdgeImpl(rels); - } - - public RelationshipImpl(MatchElement start, MatchElement end, RelationTypesInterface... rels) { - super(); - this.start = start; - this.end = end; - this.edge = new EdgeImpl(rels); - } - // Posible patrón state si fuera necesario - @Override - public String relToString() { - return start.matchToString() + edge.edgeToString() + end.matchToString(); - } - - @Override - public Node getLastNode() { - return end.getLastNode(); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/ReturnClause.java b/ProgQuery/src/database/querys/cypherWrapper/ReturnClause.java deleted file mode 100644 index 64d8851..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/ReturnClause.java +++ /dev/null @@ -1,41 +0,0 @@ -package database.querys.cypherWrapper; - -public class ReturnClause implements Clause { - - private Expression[] exprs; - private String[] renames; - - public ReturnClause(String... exprs) { - super(); - this.exprs = new Expression[exprs.length]; - int i = 0; - for (String s : exprs) - this.exprs[i++] = new ExprImpl(s); - } - - public ReturnClause(Expression... exprs) { - super(); - this.exprs = exprs; - } - - public static ReturnClause fromStringsToReturnWithExprs(String... exprs) { - Expression[] exps = new Expression[exprs.length]; - for (int i = 0; i < exprs.length; i++) - exps[i] = new ExprImpl(exprs[i]); - return new ReturnClause(exps); - } - - public ReturnClause(Expression[] exprs, String... renames) { - super(); - this.exprs = exprs; - this.renames = renames; - } - - @Override - public String clauseToString() { - String res = "RETURN "; - for (int i = 0; i < exprs.length; i++) - res += exprs[i].expToString() + (renames != null ? " as " + renames[i] : "") + ", "; - return res.substring(0, res.length() - 2); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/SeparationClause.java b/ProgQuery/src/database/querys/cypherWrapper/SeparationClause.java deleted file mode 100644 index eee3804..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/SeparationClause.java +++ /dev/null @@ -1,10 +0,0 @@ -package database.querys.cypherWrapper; - -public class SeparationClause implements Clause { - - @Override - public String clauseToString() { - return ";"; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/SetClause.java b/ProgQuery/src/database/querys/cypherWrapper/SetClause.java deleted file mode 100644 index 966080d..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/SetClause.java +++ /dev/null @@ -1,26 +0,0 @@ -package database.querys.cypherWrapper; - -public class SetClause implements Clause { - private Expression[] exps; - - public SetClause(Expression... exps) { - super(); - this.exps = exps; - } - - public SetClause(String... exps) { - this.exps = new Expression[exps.length]; - for (int i = 0; i < exps.length; i++) - this.exps[i] = new ExprImpl(exps[i]); - - } - - @Override - public String clauseToString() { - String res = "SET "; - for (int i = 0; i < exps.length; i += 2) - res += exps[i].expToString() + " = " + exps[i + 1].expToString() + ", "; - return res.substring(0, res.length() - 2); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/SimpleWithClause.java b/ProgQuery/src/database/querys/cypherWrapper/SimpleWithClause.java deleted file mode 100644 index d0cf099..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/SimpleWithClause.java +++ /dev/null @@ -1,24 +0,0 @@ -package database.querys.cypherWrapper; - -public class SimpleWithClause implements Clause { - String[] renames; - boolean distinct; - - public SimpleWithClause(String... renames) { - this.renames = renames; - } - - public SimpleWithClause(boolean distinct,String... renames) { - super(); - this.renames = renames; - this.distinct = distinct; - } - - @Override - public String clauseToString() { - String res = "WITH " + (distinct ? " DISTINCT " : ""); - for (int i = 0; i < renames.length; i++) - res += renames[i] + ", "; - return res.substring(0, res.length() - 2); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/UnwindClause.java b/ProgQuery/src/database/querys/cypherWrapper/UnwindClause.java deleted file mode 100644 index f4b057a..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/UnwindClause.java +++ /dev/null @@ -1,24 +0,0 @@ -package database.querys.cypherWrapper; - -public class UnwindClause implements Clause { - private Expression list; - private String name; - - public UnwindClause(Expression list, String name) { - super(); - this.list = list; - this.name = name; - } - - public UnwindClause(String list, String name) { - super(); - this.list = new ExprImpl(list); - this.name = name; - } - - @Override - public String clauseToString() { - return "UNWIND " + list.expToString() + " as " + name; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/WhereClause.java b/ProgQuery/src/database/querys/cypherWrapper/WhereClause.java deleted file mode 100644 index b48744b..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/WhereClause.java +++ /dev/null @@ -1,42 +0,0 @@ -package database.querys.cypherWrapper; - -import database.nodes.NodeTypes; - -public class WhereClause implements Clause { - private Expression expression; - - public WhereClause(Expression expression) { - this.expression = expression; - } - - public WhereClause(String expression) { - this.expression = new ExprImpl(expression); - } - - @Override - public String clauseToString() { - return " WHERE " + expression.expToString(); - } - - public Clause[] addToClauses(Clause... clauses) { - Clause[] res = new Clause[clauses.length + 1]; - for (int i = 0; i < clauses.length; i++) - res[i] = clauses[i]; - res[clauses.length] = this; - return res; - } - - public static WhereClause getFilterOnNodeLabels(String nodeId, NodeTypes... labels) { - String exp = ""; - for (NodeTypes label : labels) - exp += nodeId + ":" + label.name() + " OR "; - return new WhereClause(new ExprImpl(exp.substring(0, exp.length() - 4))); - } - - public static Expression isElementOfWiggleType(String element, NodeTypes... types) { - String res = ""; - for (NodeTypes t : types) - res += element + ".nodeType='" + Node.PQNodeTypeToWiggle.get(t) + "' OR "; - return new ExprImpl(res.substring(0, res.length() - 4)); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/WithClause.java b/ProgQuery/src/database/querys/cypherWrapper/WithClause.java deleted file mode 100644 index f5f55f0..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/WithClause.java +++ /dev/null @@ -1,43 +0,0 @@ -package database.querys.cypherWrapper; - -import utils.dataTransferClasses.Pair; - -public class WithClause extends SimpleWithClause { - - Expression[] exprs; - - public WithClause(String[] renames, Expression... exprs) { - super(renames); - this.exprs = exprs; - } - - public WithClause(String[] renames, Pair... exprs) { - super(getArray(renames, exprs)); - initExprArray(renames, exprs); - } - - private static String[] getArray(String[] renames, Pair... exprs) { - String[] res = new String[renames.length + exprs.length]; - for (int i = 0; i < renames.length; i++) - res[i] = renames[i]; - for (int i = 0; i < exprs.length; i++) - res[renames.length + i] = exprs[i].getFirst(); - return res; - } - - private void initExprArray(String[] renames, Pair... exprs) { - this.exprs = new Expression[renames.length + exprs.length]; - for (int i = 0; i < renames.length; i++) - this.exprs[i] = null; - for (int i = 0; i < exprs.length; i++) - this.exprs[renames.length + i] = exprs[i].getSecond(); - } - @Override - public String clauseToString() { - String res = "WITH "; - for (int i = 0; i < exprs.length; i++) - res += (exprs[i] != null ? exprs[i].expToString() + " as " : "") + renames[i] + ", "; - return res.substring(0, res.length() - 2); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50.java deleted file mode 100644 index 1abdd58..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50.java +++ /dev/null @@ -1,106 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Binop; -import database.querys.cypherWrapper.Case; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.CreateClause; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.ForEach; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SetClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.cypherWrapper.WithClause; -import database.querys.services.FieldServices; -import database.querys.services.InmutabilityServicesPQ; -import utils.dataTransferClasses.Pair; - -public class OBJ50 extends AbstractQuery { - - private static final Expression ATTR_PROPERTIES = new ExprImpl(" attr.isFinal "); - - private static final Clause[] DECLARED_TYPES_AND_DECLARED_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServices.typesAndDeclaredFieldsAndTypes( - new CompleteNode("declaringType", Pair.create("isDeclared", "true")))); - - // public OBJ50() { - // - // super(new Clause[] { PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS[0], - // PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS[1], - // new SimpleWithClause("attr", "declaringType", "typeDec"), - // new MatchClause(InmutabilityServices.getTypesAndFieldsTransitive(new - // NodeVar("typeDec"))), - // WhereClause.getFilterOnNodeLabels("typeDec", NodeTypes.CLASS_DECLARATION, - // NodeTypes.ENUM_DECLARATION), - // new CreateClause(new CompleteNode("res", Pair.create("res", true))), - // new WithClause(new String[] { "attr", "declaringType", "length", "res", - // "nodesView", "nodes" }, - // new Expression[] { new ExprImpl("attr"), new ExprImpl("declaringType"), - // new ExprImpl("LENGTH(p)"), new ExprImpl("res"), - // new ExprImpl( - // "extract(x IN nodes(p) | CASE WHEN x:ATTR_DEC THEN x.name ELSE - // x.fullyQualifiedName END)"), - // new ExprImpl(" nodes(p) ") }), - // ListsServices.forAllEvensInList("length", 2, "res.res", - // "NOT(nodes[i].accessLevel='public' AND nodes[i+1].accessLevel='public' - // AND NOT nodes[i+1].isFinal AND NOT nodes[i+1].isStatic)"), - // new SimpleWithClause("attr", "declaringType", "nodes", "res", - // "nodesView"), - // InmutabilityServices.getOptionalMutationsOfFields(), - // new WhereClause(new ExprImpl("field IN nodes AND NOT - // ass:INITIALIZATION")), - // // new WithClause(new String[] { "attr", "declaringType", - // // "nodes", "res" }, null, null, null, - // // new ExprImpl("COUNT(mutationRel)=0 AND res.res")), - // ReturnClause.fromStringsToReturnWithExprs("attr", "declaringType", - // "nodesView", - // "COUNT(ass), COLLECT([ass, LABELS(ass)]) , res.res"), - // new OrderByClause("attr", "declaringType") }); - // - // } - // new Extract("NODES(p)", new Case("x:ATTR_DEC", "x.name", - // "x.fullyQualifiedName"))), - - public OBJ50(boolean isProgQuery) { - super(isProgQuery); - - } - - // WTIH ATTR, DECLARING TYPE - public static void main(String[] args) { - System.out.println(new OBJ50(true).queryToString()); - } - - @Override - protected void initiate() { - clauses = new Clause[] { DECLARED_TYPES_AND_DECLARED_FIELDS[0], DECLARED_TYPES_AND_DECLARED_FIELDS[1], - new SimpleWithClause("attr", "declaringType", "typeDec"), - new MatchClause(InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(new NodeVar("typeDec"))), - new WithClause(new String[] { "attr", "declaringType", "typeDec" }, - Pair.create("nodes", new ExprImpl("NODES(p)"))), - new CreateClause(new CompleteNode("res", Pair.create("res", true))), - new ForEach("i", "RANGE(1,SIZE(nodes),1)", - new SetClause(new ExprImpl("res.res"), - new Binop("AND", new ExprImpl("res.res"), new Case("nodes[i]:ATTR_DEC", - InmutabilityServicesPQ.isInmutableField("nodes[i]", "nodes[i-1]"), "TRUE")))), - new SimpleWithClause("attr", "declaringType", "typeDec", "nodes", "res"), - // InmutabilityServices.getOptionalMutationsOfFields(), - InmutabilityServicesPQ.getOptionalModificationsOfFields(), - new WhereClause(new ExprImpl("field IN nodes AND NOT ass:INITIALIZATION")), - new WithClause(new String[] { "attr", "declaringType", "res", "typeDec" }, - Pair.create("hasAnyMutationRel", new ExprImpl("COUNT(mutationRel)>0"))), - new WithClause(new String[] { "attr", "declaringType", "typeDec, res" }, - Pair.create("isMutable", Any.collectAndAny(" NOT res.res OR hasAnyMutationRel", "x"))), - new ClauseImpl("DELETE res"), new SimpleWithClause("attr", "declaringType", "typeDec", "isMutable"), - new WhereClause("isMutable"), new ReturnClause( - " DISTINCT 'Warning [CMU-OBJ50] Attribute '+ attr.name+' declared in '+declaringType.fullyQualifiedName+ ' is not actually final, only the reference. This is due to the type '+ typeDec.fullyQualifiedName+' is mutable ( the state of the attributes change in the program or may potentially be changed by a client).'") }; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50_SIMPLIFIED.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50_SIMPLIFIED.java deleted file mode 100644 index 8dcbd3a..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50_SIMPLIFIED.java +++ /dev/null @@ -1,63 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServices; -import database.relations.PDGRelationTypes; -import utils.dataTransferClasses.Pair; - -public class OBJ50_SIMPLIFIED extends AbstractQuery { - - private static final Expression ATTR_PROPERTIES = new ExprImpl(" attr.isFinal "); - - private static final Clause[] DECLARED_TYPES_AND_DECLARED_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServices.typesAndDeclaredFieldsAndTypes( - new CompleteNode("declaringType", Pair.create("isDeclared", "true")))); - - public OBJ50_SIMPLIFIED() { - super(true); - - } - - // WTIH ATTR, DECLARING TYPE - public static void main(String[] args) { - System.out.println(new OBJ50_SIMPLIFIED().queryToString()); - } - - @Override - protected void initiate() { - clauses = new Clause[] { - // (NOT EXISTS(mutatorExpr.isInit) OR NOT mutatorExpr.isInit) - - new MatchClause( - new RelationshipImpl(new NodeVar("declaration{isFinal:true}"), new NodeVar("mutatorExpr"), - new EdgeImpl("r", PDGRelationTypes.STATE_MODIFIED_BY, - PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY))), - new WhereClause(" NOT mutatorExpr:INITIALIZATION "), - new MatchClause(new MatchImpl(getStatementServices() - .getMethodFromStatement(getExpressionServices().getStatementFromExp(new NodeVar("mutatorExpr"))).matchToString() - + "<-[:DECLARES_FIELD|DECLARES_METHOD|DECLARES_CONSTRUCTOR|HAS_STATIC_INIT]-(exprEnclClass)")), - new WhereClause(" r.isOwnAccess IS NULL OR r.isOwnAccess=FALSE OR NOT method.isInitializer "), - new SimpleWithClause("declaration, mutatorExpr,exprEnclClass "), - new MatchClause(getStatementServices().getEnclosingClassFromDeclaration(new NodeVar("declaration"))), - new SimpleWithClause( - "declaration, enclClass,COLLECT(HEAD(LABELS(mutatorExpr))+', line '+mutatorExpr.lineNumber+ ', class '+ exprEnclClass.fullyQualifiedName" - + ") as mutatorsMessage"), - new ReturnClause( - "'Warning [CMU-OBJ50] Declaration with name '+ declaration.name+ '( in line ' + declaration.lineNumber +', class ' +enclClass.fullyQualifiedName " - + "+ ') is not actually final, only the reference. Concretely, '+ declaration.name +' may be mutated in '+mutatorsMessage") }; - - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50_V2_04.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50_V2_04.java deleted file mode 100644 index f3fd8e2..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ50_V2_04.java +++ /dev/null @@ -1,106 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Binop; -import database.querys.cypherWrapper.Case; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.CreateClause; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.ForEach; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SetClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.cypherWrapper.WithClause; -import database.querys.services.FieldServices; -import database.querys.services.InmutabilityServicesPQ; -import utils.dataTransferClasses.Pair; - -public class OBJ50_V2_04 extends AbstractQuery { - - private static final Expression ATTR_PROPERTIES = new ExprImpl(" attr.isFinal AND attr.accessLevel='public' "); - - private static final Clause[] PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServices.typesAndDeclaredFieldsAndTypes( - new CompleteNode("declaringType", Pair.create("accessLevel", "public")))); - - // public OBJ50() { - // - // super(new Clause[] { PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS[0], - // PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS[1], - // new SimpleWithClause("attr", "declaringType", "typeDec"), - // new MatchClause(InmutabilityServices.getTypesAndFieldsTransitive(new - // NodeVar("typeDec"))), - // WhereClause.getFilterOnNodeLabels("typeDec", NodeTypes.CLASS_DECLARATION, - // NodeTypes.ENUM_DECLARATION), - // new CreateClause(new CompleteNode("res", Pair.create("res", true))), - // new WithClause(new String[] { "attr", "declaringType", "length", "res", - // "nodesView", "nodes" }, - // new Expression[] { new ExprImpl("attr"), new ExprImpl("declaringType"), - // new ExprImpl("LENGTH(p)"), new ExprImpl("res"), - // new ExprImpl( - // "extract(x IN nodes(p) | CASE WHEN x:ATTR_DEC THEN x.name ELSE - // x.fullyQualifiedName END)"), - // new ExprImpl(" nodes(p) ") }), - // ListsServices.forAllEvensInList("length", 2, "res.res", - // "NOT(nodes[i].accessLevel='public' AND nodes[i+1].accessLevel='public' - // AND NOT nodes[i+1].isFinal AND NOT nodes[i+1].isStatic)"), - // new SimpleWithClause("attr", "declaringType", "nodes", "res", - // "nodesView"), - // InmutabilityServices.getOptionalMutationsOfFields(), - // new WhereClause(new ExprImpl("field IN nodes AND NOT - // ass:INITIALIZATION")), - // // new WithClause(new String[] { "attr", "declaringType", - // // "nodes", "res" }, null, null, null, - // // new ExprImpl("COUNT(mutationRel)=0 AND res.res")), - // ReturnClause.fromStringsToReturnWithExprs("attr", "declaringType", - // "nodesView", - // "COUNT(ass), COLLECT([ass, LABELS(ass)]) , res.res"), - // new OrderByClause("attr", "declaringType") }); - // - // } - // new Extract("NODES(p)", new Case("x:ATTR_DEC", "x.name", - // "x.fullyQualifiedName"))), - - public OBJ50_V2_04(boolean isProgQuery) { - super(isProgQuery); - - } - - // WTIH ATTR, DECLARING TYPE - public static void main(String[] args) { - System.out.println(new OBJ50_V2_04(true).queryToString()); - } - - @Override - protected void initiate() { - clauses = new Clause[] { PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS[0], PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS[1], - new SimpleWithClause("attr", "declaringType", "typeDec"), - new MatchClause(InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(new NodeVar("typeDec"))), - new WithClause(new String[] { "attr", "declaringType", "typeDec" }, - Pair.create("nodes", new ExprImpl("NODES(p)"))), - new CreateClause(new CompleteNode("res", Pair.create("res", true))), - new ForEach("i", "RANGE(1,SIZE(nodes),1)", - new SetClause(new ExprImpl("res.res"), - new Binop("AND", new ExprImpl("res.res"), new Case("nodes[i]:ATTR_DEC", - InmutabilityServicesPQ.isInmutableField("nodes[i]", "nodes[i-1]"), "TRUE")))), - new SimpleWithClause("attr", "declaringType", "typeDec", "nodes", "res"), - // InmutabilityServices.getOptionalMutationsOfFields(), - InmutabilityServicesPQ.getOptionalModificationsOfFields(), - new WhereClause(new ExprImpl("field IN nodes AND NOT ass:INITIALIZATION")), - new WithClause(new String[] { "attr", "declaringType", "res", "typeDec" }, - Pair.create("hasAnyMutationRel", new ExprImpl("COUNT(mutationRel)>0"))), - new WithClause(new String[] { "attr", "declaringType", "typeDec, res" }, - Pair.create("isMutable", Any.collectAndAny(" NOT res.res OR hasAnyMutationRel", "x"))), - new ClauseImpl("DELETE res"), new SimpleWithClause("attr", "declaringType", "typeDec", "isMutable"), - new WhereClause("isMutable"), new ReturnClause( - " DISTINCT 'Warning [CMU-OBJ50] Attribute '+ attr.name+' declared in '+declaringType.fullyQualifiedName+ ' is not actually final, only the reference. This is due to the type '+ typeDec.fullyQualifiedName+' is mutable ( the state of the attributes change in the program or may potentially be changed by a client).'") }; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ54.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ54.java deleted file mode 100644 index 369b64b..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ54.java +++ /dev/null @@ -1,72 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import java.io.IOException; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.cypherWrapper.WithClause; -import database.querys.services.AssignmentServicesProgQueryImpl; -import utils.dataTransferClasses.Pair; - -public class OBJ54 extends AbstractQuery { - /* - * private static final String OBJ54_DONT_TRY_HELP_GC_SETTING_REFS_TO_NULL = - * "MATCH - * (:LITERAL{typeKind:'NULL'})<-[:ASSIGNMENT_RHS]-(ass:ASSIGNMENT)<-[: - * MODIFIED_BY | STATE_MODIFIED_BY]-(localVar:VAR_DEC{typeKind:'DECLARED'}) - * + " (ass)<-[" + assignToOutExprQuery + "*0..]-(expr)<-[" + - * exprToStatQuery + "]-(assignStat) " + - * - * -[:USED_BY]->(use)<-[" + exprToOutExprQuery + "*]-(outExpr)<-[" + - * exprToStatQuery + "]-(useStat)," - * - * " WITH COLLECT(useStat) AS useStats, localVar, assignStat " + - * " OPTIONAL MATCH (assignStat)-[" + cfgSuccesor + "*0..]->(useStat) " + - * " WHERE useStat IN useStats" + - * " WITH localVar, COLLECT(DISTINCT useStat) AS reachableUseStats, assignStat " - * + " WHERE SIZE(reachableUseStats)=0" + - * " RETURN 'Warning [CMU-OBJ54] You must not try to help garbage collector setting references to null when they are no longer used. To make your code clearer, just delete the assignment in line ' + assignStat.lineNumber + ' of the varaible ' +localVar.name+ ' declared in line ' +localVar.lineNumber+'.'" - * ; - */ - public OBJ54(boolean isProgQuery) { - super(isProgQuery); - } - - @Override - protected void initiate() { - clauses = new Clause[] { - new MatchClause( - ((AssignmentServicesProgQueryImpl) getAssignmentServices()) - .getRightPartAssignmentsAndVarDeclarations( - new CompleteNode("varDec"), - new CompleteNode(NodeTypes.LITERAL, Pair.create("typeKind", "NULL"))), - getExpressionServices().getStatementFromExp(new NodeVar("ass"), new NodeVar("assStat"))), - new WhereClause("varDec:LOCAL_VAR_DEF OR varDec:PARAMETER_DEF"), - getPDGServices().getOptionalUsesAndStateModsAndStatementsOf(new NodeVar("varDec")), - new WithClause(new String[] { "varDec", "assStat" }, - Pair.create("useStats", new ExprImpl("COLLECT(stat)"))), - new MatchClause(true, (MatchElement) getCFGServices().getCFGSuccesorsOf(new NodeVar("assStat"))), - new WhereClause("succ IN useStats"), - new WithClause(new String[] { "varDec", "assStat", "useStats" }, - Pair.create("numberOfReachableUseStats", new ExprImpl("COUNT(succ)"))), - new WhereClause("numberOfReachableUseStats=0"), - new MatchClause(false, getStatementServices().getEnclosingClassFromDeclaration(new NodeVar("varDec"))), - new ReturnClause( - // "varDec, assStat, useStats, enclClass" - "'Warning [CMU-OBJ54] You must not try to help garbage collector setting references to null when they are no longer used. To make your code clearer, just delete the assignment in line ' + assStat.lineNumber + ' of the variable ' +varDec.name+ ' declared in line '+varDec.lineNumber+ ',class '+enclClass.fullyQualifiedName+'.'" - ) - }; - } - - public static void main(String[] args) throws IOException { - System.out.println(new OBJ54(true).queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ54_SA.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ54_SA.java deleted file mode 100644 index 23593f2..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ54_SA.java +++ /dev/null @@ -1,80 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import java.io.IOException; - -import com.sun.javafx.scene.traversal.Direction; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.cypherWrapper.WithClause; -import database.querys.services.AssignmentServicesProgQueryImpl; -import database.relations.CDGRelationTypes; -import database.relations.RelationTypes; -import utils.dataTransferClasses.Pair; - -public class OBJ54_SA extends AbstractQuery { - /* - * private static final String OBJ54_DONT_TRY_HELP_GC_SETTING_REFS_TO_NULL = - * "MATCH - * (:LITERAL{typeKind:'NULL'})<-[:ASSIGNMENT_RHS]-(ass:ASSIGNMENT)<-[: - * MODIFIED_BY | STATE_MODIFIED_BY]-(localVar:VAR_DEC{typeKind:'DECLARED'}) - * + " (ass)<-[" + assignToOutExprQuery + "*0..]-(expr)<-[" + - * exprToStatQuery + "]-(assignStat) " + - * - * -[:USED_BY]->(use)<-[" + exprToOutExprQuery + "*]-(outExpr)<-[" + - * exprToStatQuery + "]-(useStat)," - * - * " WITH COLLECT(useStat) AS useStats, localVar, assignStat " + - * " OPTIONAL MATCH (assignStat)-[" + cfgSuccesor + "*0..]->(useStat) " + - * " WHERE useStat IN useStats" + - * " WITH localVar, COLLECT(DISTINCT useStat) AS reachableUseStats, assignStat " - * + " WHERE SIZE(reachableUseStats)=0" + - * " RETURN 'Warning [CMU-OBJ54] You must not try to help garbage collector setting references to null when they are no longer used. To make your code clearer, just delete the assignment in line ' + assignStat.lineNumber + ' of the varaible ' +localVar.name+ ' declared in line ' +localVar.lineNumber+'.'" - * ; - */ - public OBJ54_SA(boolean isProgQuery) { - super(isProgQuery); - } - - @Override - protected void initiate() { - clauses = new Clause[] { - new MatchClause( - ((AssignmentServicesProgQueryImpl) getAssignmentServices()) - .getRightPartAssignmentsAndVarDeclarations( - new CompleteNode("varDec"), - new CompleteNode(NodeTypes.LITERAL, Pair.create("typeKind", "NULL"))), - getExpressionServices().getStatementFromExp(new NodeVar("ass"), new NodeVar("assStat"))), - new WhereClause("varDec:LOCAL_VAR_DEF OR varDec:PARAMETER_DEF"), - getPDGServices().getOptionalUsesAndStateModsAndStatementsOf(new NodeVar("varDec")), - new WithClause(new String[] { "varDec", "assStat" }, - Pair.create("useStats", new ExprImpl("COLLECT(stat)"))), - new MatchClause(true, (MatchElement) getCFGServices().getCFGSuccesorsOf(new NodeVar("assStat"))), - new WhereClause("succ IN useStats"), - new WithClause(new String[] { "varDec", "assStat", "useStats" }, - Pair.create("numberOfReachableUseStats", new ExprImpl("COUNT(succ)"))), - new WhereClause("numberOfReachableUseStats=0"), - new MatchClause(false, getStatementServices().getEnclosingClassFromDeclaration(new NodeVar("varDec")).append( Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.HAS_TYPE_DEF, CDGRelationTypes.HAS_INNER_TYPE_DEF), new NodeVar("cu")))), - new ReturnClause( - // "varDec, assStat, useStats, enclClass" - "'[CMU-OBJ54;'+cu.fileName+';expression;ASSIGNMENT;'+assStat.lineNumber+'; You must not try to help garbage collector setting references to null when they are no longer used. To make your code clearer, just delete the assignment in line ' + assStat.lineNumber + ' of the variable ' +varDec.name+ ' declared in line '+varDec.lineNumber+ ',class '+enclClass.fullyQualifiedName+'.]'" - ) - }; - } - //[BLOCH-6.36;C:\Users\admp1\Escritorio\StaticCodeAnalysis\Programs\ExampleClasses\src\main\java\examples\test\rule_3_10\B1.java; - //method_definition;examples.test.rule_3_10.B1:toString()java.lang.String;10;You must use the Override annotation in method toString (line 10) since it is actually overriding the method java.lang.Object:toString()java.lang.String] - - public static void main(String[] args) throws IOException { - System.out.println(new OBJ54_SA(true).queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56.java deleted file mode 100644 index d7508fa..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56.java +++ /dev/null @@ -1,206 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.Case; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.Extract; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.Reduce; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.InmutabilityServicesPQ; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56 extends AbstractQuery { - - public OBJ56(boolean isProgQuery) { - super(isProgQuery); - - } - - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - new MatchClause( - getStatementServices().getMethodFromStatement( - new MatchImpl( - "(enclosingType{accessLevel:'public'})-[:DECLARES_FIELD]->(field)-[:USED_BY]->(id)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", NodeTypes.METHOD_DEF)), - new MatchImpl( - "(field)-[:ITS_TYPE_IS]->()<-[:IS_SUBTYPE_EXTENDS|IS_SUBTYPE_IMPLEMENTS*0..]-(typeDec)")), - new WhereClause("NOT field.accessLevel='public' AND method.accessLevel='public'"), - new SimpleWithClause("DISTINCT typeDec,enclosingType, field, method"), - - new MatchClause(true, InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(typeDec)), - - new SimpleWithClause( - "DISTINCT typeDec,enclosingType, field, method,p, CASE WHEN p IS NULL THEN [typeDec] else NODES(p) END as nodes"), - new UnwindClause("nodes", "nodeInP"), - new SimpleWithClause("enclosingType, field, method, typeDec, nodeInP,p"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), TypeRelations.IS_SUBTYPE_EXTENDS, - TypeRelations.IS_SUBTYPE_IMPLEMENTS), new AnonymousNode()), - Pair.createP("f", RelationTypes.DECLARES_FIELD), - - Pair.createP("mod", PDGRelationTypes.MODIFIED_BY, - PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY, - PDGRelationTypes.STATE_MODIFIED_BY)), - getExpressionServices().getMethodFromExp(new NodeVar("mod"), new CompleteNode("setMethod", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"), Pair.create("isStatic", false))), - - new MatchImpl("(nodeInP)-[:DECLARES_METHOD]->(setMethod)") - ), - - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,p, CASE WHEN setMethod IS NULL THEN [] ELSE COLLECT(setMethod) END as setters"), - - - new MatchClause(true, - new MatchImpl(new RelationshipImpl(new NodeVar("nodeInP"), new AnonymousNode(), - new EdgeImpl(RelationTypes.DECLARES_METHOD)).relToString() - + "-[:OVERRIDES]->(ovMethod)")), - // new WhereClause("publicMethod.accessLevel='public'"), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,p, setters, COLLECT(ovMethod) as methodsOverridenByThisType"), - - new MatchClause(true, - new MatchImpl( - "(nodeInP)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->()-[:DECLARES_METHOD]->(getMethod)"), - getStatementServices().getMethodFromStatement( - new Path(new NodeVar("nodeInP"), Pair.createP("f", RelationTypes.DECLARES_FIELD), - Pair.createP("", PDGRelationTypes.USED_BY), - Pair.createInv("", RelationTypes.RETURN_EXPR)), - new CompleteNode("getMethod", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"), Pair.create("isStatic", false)))), - new MatchClause(true, - - new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS))), - - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,p, setters,methodsOverridenByThisType, COLLECT(DISTINCT getMethod) as getters, COLLECT(DISTINCT fType) as getterTypes"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.createP(new CompleteNode("f", Pair.create("isStatic", false), - Pair.create("accessLevel", "public")), RelationTypes.DECLARES_FIELD), - Pair.create(new EdgeImpl(TypeRelations.ITS_TYPE_IS), new NodeVar("fType")))), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,p,methodsOverridenByThisType, setters, getters,getterTypes, COLLECT(DISTINCT [f,fType]) as otherMutableDependencies "), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP, p, setters,methodsOverridenByThisType, getters,getterTypes, " - + new Extract(new Filter("otherMutableDependencies", "x[0].isFinal"), "y[1]", "y") - .expToString() - + " as mutableDependenciesBis, " - + new Any("otherMutableDependencies", "NOT x[0].isFinal").expToString() - + " as isMutableDueToPublicField "), - // new ReturnClause("enclosingType, field, method, typeDec, - // nodeInP, p, setters") - // new WhereClause("SIZE(NODES(p))=12"), - new SimpleWithClause("enclosingType, field, method, typeDec,p" - - + ", COLLECT([ID(nodeInP),[isMutableDueToPublicField,mutableDependenciesBis,methodsOverridenByThisType,setters, getters,getterTypes ]]) as map " - - ), new SimpleWithClause("enclosingType, field, method, typeDec,p" - - + "," - + new Extract("NODES(p)", - "x+HEAD(" + new Filter("map", "y[0]=ID(x)", "y").expToString() + ")[1]").expToString() - + " as nodes" - - ), new SimpleWithClause("enclosingType, field, method, typeDec,p, " + new Extract("nodes", "[x[0],CASE WHEN x[1] IS NULL THEN FALSE ELSE x[1] END, CASE WHEN x[2] IS NULL THEN [] ELSE x[2] END, CASE WHEN x[3] IS NULL THEN [] ELSE x[3] END, CASE WHEN x[4] IS NULL THEN [] ELSE x[4] END,CASE WHEN x[5] IS NULL THEN [] ELSE x[5] END, CASE WHEN x[6] IS NULL THEN [] ELSE x[6] END]").expToString() + " as nodes" - - ), new SimpleWithClause("enclosingType, field, method, typeDec,p, CASE WHEN nodes IS NULL THEN [] ELSE nodes END as nodes "), - - new SimpleWithClause( - "enclosingType, field, method, typeDec,p, nodes, RANGE(0,SIZE(nodes)-1,1) as indexes"), - new SimpleWithClause( - "enclosingType, field, method, typeDec,p, nodes, indexes, EXTRACT(index IN indexes | CASE WHEN SIZE(FILTER(i IN indexes WHERE i=lastAttrIndexes[index]", "i").expToString(), - "s+nodes[x][3]", "s=[]").expToString() - - , "index").expToString() + " as overrides, indexes, lastAttrIndexes"), - new SimpleWithClause("enclosingType, field, method, typeDec,p, " + new Extract("indexes", - "[nodes[x][0], nodes[x][1] OR ANY(setter IN nodes[x][4] WHERE NOT setter IN overrides[x]) " - - + ", nodes[x][2]+ EXTRACT( getterIndex IN FILTER(gf IN RANGE(0,SIZE(nodes[x][5])-1,1) " - + "WHERE NOT nodes[x][5][gf] IN overrides[x]) | nodes[x][6][getterIndex])] ") - .expToString() - + " as nodes, indexes"), -// new SimpleWithClause("enclosingType, field, method, typeDec,p, " + new Extract("indexes", -// "[nodes[x][0], nodes[x][1]," + new Case("x>0 AND NOT nodes[x+1] IS NULL", -// "CASE WHEN nodes[x][0]:ATTR_DEC THEN nodes[x+1][0] IN nodes[x-1][2] ELSE TRUE END", -// "TRUE").expToString() + "] ").expToString() -// + " as nodes"), - new SimpleWithClause( - "enclosingType, field, method, typeDec,p,indexes, " + new Extract("indexes", - "[nodes[x][0], nodes[x][1]," - + new Case("x>1 AND nodes[x-1][0]:ATTR_DEC", - " ANY(dep IN nodes[x-2][2] WHERE dep =nodes[x][0])", - "TRUE").expToString() + "] ").expToString() - + " as nodes"), - new SimpleWithClause("enclosingType, field, method, typeDec,p, " + new Extract("indexes", - "[nodes[x][0], nodes[x][1]," - + "NOT ANY(i IN indexes WHERE i<=x AND NOT nodes[i][2]) ]").expToString() - + " as nodes"), - // new SimpleWithClause( - // "enclosingType, field, method,typeDec,p, CASE WHEN - // SIZE(nodes)=0 THEN []+typeDec ELSE nodes END as nodes "), - // new WhereClause("SIZE(nodes)=0"), - new SimpleWithClause( - "enclosingType, field, method, typeDec," - + new Reduce("nodes", - "s AND CASE WHEN x[0]:ATTR_DEC THEN TRUE ELSE NOT x[2] OR (NOT x[0]:ARRAY_TYPE AND NOT x[1]) END ", - "s=true") - .expToString() - + " AND NOT typeDec:ARRAY_TYPE as res" - - ), new SimpleWithClause("enclosingType, field,method, typeDec,ANY (x IN COLLECT(res) WHERE NOT x) as isMutable"), new SimpleWithClause("enclosingType, field,COLLECT(method) as methods, typeDec,isMutable"), - - new WhereClause("isMutable") - // FILTRAR - , new SimpleWithClause("COLLECT([enclosingType, field, methods, typeDec]) as res"), - new UnwindClause("res", "typeRes"), - new SimpleWithClause( - "typeRes[1] as field, typeRes[3] as typeDec, typeRes[0] as enclosingType,typeRes[2] as methods, res"), - new MatchClause(true, - new MatchImpl("(typeDec)<-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]-(subType)")) - , new SimpleWithClause("typeDec,methods,enclosingType,field,res, COLLECT(subType) as subtypes") - , - new SimpleWithClause( - "typeDec,EXTRACT(m IN methods | m.fullyQualifiedName) as methods,enclosingType,field,res, FILTER(y IN subtypes WHERE NOT y IN EXTRACT(x IN res | x[3])) as nonMutableSubTypes"), - new ReturnClause( - " 'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ methods+'. The problem is that the type '+typeDec.fullyQualifiedName+' can be mutated by a malicious client.'+CASE WHEN SIZE(nonMutableSubTypes)=0 THEN ' You should use an appropiate inmutable subtype as a wrapper for your attribute.'ELSE 'Remember to use an appropiate inmutable subtype (such as '+EXTRACT(x IN nonMutableSubTypes | x.fullyQualifiedName)+') as a wrapper for your attribute.'END " - ) - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, " - // + new Extract("nodesWithInfo", "x[0]").expToString() - // + ",p, SIZE(NODES(p)), SIZE(nodesWithInfo)") - - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, NODES(p) ") - }; - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56NOT_LONG.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56NOT_LONG.java deleted file mode 100644 index b2c69b4..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56NOT_LONG.java +++ /dev/null @@ -1,99 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.Extract; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.services.InmutabilityServicesPQ; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56NOT_LONG extends AbstractQuery { - - public OBJ56NOT_LONG(boolean isProgQuery) { - super(isProgQuery); - - } - - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - new MatchClause( - getStatementServices().getMethodFromStatement( - new MatchImpl( - "(enclosingType{accessLevel:'public'})-[:DECLARES_FIELD]->(field)-[:USED_BY]->(id)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", NodeTypes.METHOD_DEF)), - new RelationshipImpl(new NodeVar("field"), typeDec, new EdgeImpl(TypeRelations.ITS_TYPE_IS))), - InmutabilityServicesPQ.typeIsExternallyMutable(typeDec), - - new UnwindClause("CASE WHEN p IS NULL THEN [] ELSE NODES(p) END", "nodeInP"), - new SimpleWithClause( - "enclosingType, field, method, typeDec,p, nodeInP"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.create(new EdgeImpl(PDGRelationTypes.HAS_THIS_REFERENCE), new AnonymousNode()), - Pair.create( - new EdgeImpl(PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY, - PDGRelationTypes.STATE_MODIFIED_BY), - new CompleteNode("setMethod", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"), Pair.create("isStatic", false)))), - new RelationshipImpl(new NodeVar("nodeInP"), new NodeVar("setMethod"), - new EdgeImpl(RelationTypes.DECLARES_METHOD)) - - ), - - new MatchClause(true, - getStatementServices().getMethodFromStatement( - new Path(new NodeVar("nodeInP"), Pair.createP("f", RelationTypes.DECLARES_FIELD), - Pair.createP("", PDGRelationTypes.USED_BY), - Pair.createInv("", RelationTypes.RETURN_EXPR)), - new CompleteNode("getMethod", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"), Pair.create("isStatic", false))), - new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS))), - - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,p, setMethod, COLLECT(DISTINCT fType) as mutableDependencies"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.createP(new CompleteNode("f", Pair.create("isStatic", false), - Pair.create("accessLevel", "public")), RelationTypes.DECLARES_FIELD), - Pair.create(new EdgeImpl(TypeRelations.ITS_TYPE_IS), new NodeVar("fType")))), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,p, SIZE( COLLECT( setMethod))>0 as isThereASetMethod, mutableDependencies, COLLECT(DISTINCT [f,fType]) as otherMutableDependencies "), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,p, isThereASetMethod, mutableDependencies, " - + new Extract(new Filter("otherMutableDependencies", "x[0].isFinal"), "y[1]", "y") - .expToString() - + " as mutableDependenciesBis, " - + new Any("otherMutableDependencies", "NOT x[0].isFinal").expToString() - + " as isMutableDueToPublicField "), - new SimpleWithClause( - "enclosingType, field, method, typeDec,p, COLLECT([nodeInP, isThereASetMethod,isMutableDueToPublicField,mutableDependenciesBis,mutableDependencies]) as nodesWithInfo "), - new ReturnClause( - "enclosingType.fullyQualifiedName, field.name, method.name, typeDec.fullyQualifiedName, " - + new Extract("nodesWithInfo", "x[0]").expToString() - + ",p, SIZE(NODES(p)), SIZE(nodesWithInfo)") - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, NODES(p) ") - }; - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_LONG.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_LONG.java deleted file mode 100644 index 75e21e8..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_LONG.java +++ /dev/null @@ -1,103 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.Extract; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.services.InmutabilityServicesPQ; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56_LONG extends AbstractQuery { - - public OBJ56_LONG(boolean isProgQuery) { - super(isProgQuery); - - } - - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - new MatchClause( - getStatementServices().getMethodFromStatement( - new MatchImpl( - "(enclosingType{accessLevel:'public'})-[:DECLARES_FIELD]->(field)-[:USED_BY]->(id)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", NodeTypes.METHOD_DEF)), - new RelationshipImpl(new NodeVar("field"), typeDec, new EdgeImpl(TypeRelations.ITS_TYPE_IS))), - InmutabilityServicesPQ.typeIsExternallyMutable(typeDec), - - new SimpleWithClause( - "enclosingType, field, method, typeDec,p,CASE WHEN p IS NULL THEN [] ELSE NODES(p) END as nodes"), - - new SimpleWithClause("enclosingType, field, method,p, typeDec," - + new Extract("RANGE(0,SIZE(nodes),1)", "[x, nodes[x]]").expToString() + " as nodes"), - new UnwindClause("nodes", "nodeInP"), - new SimpleWithClause( - "enclosingType, field, method, typeDec,p, nodeInP[1] as nodeInP, nodeInP[0] as order"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.create(new EdgeImpl(PDGRelationTypes.HAS_THIS_REFERENCE), new AnonymousNode()), - Pair.create( - new EdgeImpl(PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY, - PDGRelationTypes.STATE_MODIFIED_BY), - new CompleteNode("setMethod", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"), Pair.create("isStatic", false)))), - new RelationshipImpl(new NodeVar("nodeInP"), new NodeVar("setMethod"), - new EdgeImpl(RelationTypes.DECLARES_METHOD)) - - ), - - new MatchClause(true, - getStatementServices().getMethodFromStatement( - new Path(new NodeVar("nodeInP"), Pair.createP("f", RelationTypes.DECLARES_FIELD), - Pair.createP("", PDGRelationTypes.USED_BY), - Pair.createInv("", RelationTypes.RETURN_EXPR)), - new CompleteNode("getMethod", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"), Pair.create("isStatic", false))), - new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS))), - - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,order,p, setMethod, COLLECT(DISTINCT fType) as mutableDependencies"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.createP(new CompleteNode("f", Pair.create("isStatic", false), - Pair.create("accessLevel", "public")), RelationTypes.DECLARES_FIELD), - Pair.create(new EdgeImpl(TypeRelations.ITS_TYPE_IS), new NodeVar("fType")))), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,order,p, SIZE( COLLECT( setMethod))>0 as isThereASetMethod, mutableDependencies, COLLECT(DISTINCT [f,fType]) as otherMutableDependencies "), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP, order,p, isThereASetMethod, mutableDependencies, " - + new Extract(new Filter("otherMutableDependencies", "x[0].isFinal"), "y[1]", "y") - .expToString() - + " as mutableDependenciesBis, " - + new Any("otherMutableDependencies", "NOT x[0].isFinal").expToString() - + " as isMutableDueToPublicField ORDER BY order"), - new SimpleWithClause( - "enclosingType, field, method, typeDec,p, COLLECT([nodeInP, isThereASetMethod,isMutableDueToPublicField,mutableDependenciesBis,mutableDependencies]) as nodesWithInfo "), - new ReturnClause( - "enclosingType.fullyQualifiedName, field.name, method.name, typeDec.fullyQualifiedName, " - + new Extract("nodesWithInfo", "x[0]").expToString()) - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, NODES(p) ") - }; - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED.java deleted file mode 100644 index b0fb125..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED.java +++ /dev/null @@ -1,398 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56_SIMPLIFIED extends AbstractQuery { - - public OBJ56_SIMPLIFIED() { - super(true); - } - public static void main(String[] args) { - System.out.println(new OBJ56_SIMPLIFIED().queryToString()); - } - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - new MatchClause(getStatementServices() - .getMethodFromStatement( - new MatchImpl( - "(enclosingType)-[:DECLARES_FIELD]->(field:ATTR_DEF)-[:USED_BY]->(retExpr)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", NodeTypes.METHOD_DEF, Pair.create("accessLevel", "public"))) - .append(Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD), - new NodeVar("classExposingF{accessLevel:'public', isAbstract:false}")))), - // DECLARED IN A PUBLIC TYPE - // new MatchImpl( - // "(field)-[:ITS_TYPE_IS]->()<-[:IS_SUBTYPE_EXTENDS|IS_SUBTYPE_IMPLEMENTS*0..]-(typeDec)")) - - new WhereClause("NOT field.accessLevel='public' AND (NOT field.accessLevel='protected' OR classExposingF.isFinal)"), - // LUEGO HAY QUE METER EL CASO DE LOS ARRAYS - new MatchClause(new RelationshipImpl(new NodeVar("field"), new NodeVar("fieldType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS)) - .append(Pair.create( - new EdgeImpl(EdgeDirection.OUTGOING, TypeRelations.IS_SUBTYPE_EXTENDS, - TypeRelations.IS_SUBTYPE_IMPLEMENTS) - .setCardinalidad(Cardinalidad.MIN_TO_INF(0)), - new NodeVar("fieldTypeOrSubtype"))), - new Path(new NodeVar("fieldTypeOrSubtype"), "accessibleMembers", - Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), RelationTypes.DECLARES_FIELD, - TypeRelations.ITS_TYPE_IS, TypeRelations.INHERITS_FIELD), - new NodeVar("accessibleMember")))), - new SimpleWithClause( - "field,fieldType=fieldTypeOrSubtype as isFieldType,enclosingType, method,accessibleMember,fieldTypeOrSubtype, NODES(accessibleMembers) as accessibleMembers"), - new SimpleWithClause( - "field,isFieldType,enclosingType, accessibleMembers,accessibleMember,fieldTypeOrSubtype, COLLECT(DISTINCT method.fullyQualifiedName+'( line '+method.lineNumber+')') as publicGetters, EXTRACT(index IN RANGE(0,SIZE( accessibleMembers)-1,1) | [CASE WHEN index=0 THEN field ELSE accessibleMembers[index-1] END, accessibleMembers[index]]) as accessibleMembersAndPrevs"), - new SimpleWithClause( - "field,isFieldType,enclosingType, accessibleMember,fieldTypeOrSubtype, publicGetters, accessibleMembersAndPrevs,LAST(accessibleMembersAndPrevs)[0] as accessibleMemberPrev"), - - new UnwindClause("accessibleMembersAndPrevs", "accMemberAndPrev"), - new MatchClause(true, - getStatementServices() - .getMethodFromStatement( - new MatchImpl("(accesibleField)-[:USED_BY]->(fieldExpr)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", Pair.create("accessLevel", "public"))) - .append(Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD, - TypeRelations.INHERITS_METHOD), new NodeVar("accessibleType")))), - new WhereClause( - "ID(accesibleField)=ID(accMemberAndPrev[1]) AND ID(accessibleType)=ID(accMemberAndPrev[0])"), - new SimpleWithClause( - " field,isFieldType,enclosingType, method,publicGetters,accMemberAndPrev as accMemberOrType, accessibleMember,accessibleMemberPrev,fieldTypeOrSubtype, COLLECT(method) as gettersForCurrentMember"), - - new SimpleWithClause( - "DISTINCT field,isFieldType,enclosingType,fieldTypeOrSubtype,publicGetters,accessibleMember,accessibleMemberPrev, ALL( isAccHere IN COLLECT( CASE WHEN accMemberOrType[1]:ATTR_DEF THEN NOT accMemberOrType[1].isStatic AND (accMemberOrType[1].accessLevel='public' OR SIZE(gettersForCurrentMember)>0) ELSE CASE WHEN accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE EXISTS(accMemberOrType[1].accessLevel) AND accMemberOrType[1].accessLevel='public' END END) WHERE isAccHere) as isExternallyAcc "), - - // new ReturnClause( - // "field,enclosingType,fieldTypeOrSubtype,publicGetters,accessibleMembers,accessibleMember, - // COLLECT( CASE WHEN accMemberOrType[1]:ATTR_DEC THEN NOT - // accMemberOrType[1].isStatic AND - // (accMemberOrType[1].accessLevel='public' OR - // SIZE(relevantGetters)>0) ELSE CASE WHEN - // accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE - // accMemberOrType[1].accessLevel='public' END END ) as - // accMemberOrTypesInfo"), - // new WhereClause("ALL( isAccHere IN isAccesible WHERE - // isAccHere)"), -// new SimpleWithClause( -// "DISTINCT field,isFieldType,fieldTypeOrSubtype, enclosingType, publicGetters, accessibleMember,accessibleMemberPrev, ALL( isAccHere IN isAccesible WHERE isAccHere) as isExternallyAcc"), - - // new SimpleWithClause( - // "DISTINCT field,isFieldType,fieldTypeOrSubtype, - // enclosingType, publicGetters, - // accessibleMember,accessibleMemberPrev, isExternallyAcc"), - new MatchClause(true, new RelationshipImpl(new NodeVar("accessibleMember"), - new CompleteNode("mutator", NodeTypes.METHOD_DEF, Pair.create("accessLevel", "public")), - RelationTypes.DECLARES_METHOD, TypeRelations.INHERITS_METHOD) - .append(Pair.create( - new EdgeImpl(EdgeDirection.OUTGOING, PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY, - PDGRelationTypes.STATE_MODIFIED_BY), - new CompleteNode(NodeTypes.THIS_REF)))), - - // new SimpleWithClause( "field, enclosingType, publicGetters, - // accessibleMember, COLLECT(mutator) as mutators"), - new SimpleWithClause( - "field,isFieldType,fieldTypeOrSubtype,enclosingType, publicGetters,COLLECT(DISTINCT 'MUTATOR METHOD '+mutator.fullyQualifiedName+'( line '+mutator.lineNumber +')') as allMut, EXTRACT(accField IN FILTER(accMember IN COLLECT(DISTINCT accessibleMember) WHERE accMember:ATTR_DEF AND NOT accMember.isStatic AND NOT accMember.isFinal AND accMember.accessLevel='public') | 'PUBLIC NON-FINAL FIELD '+accField.name+'( line'+accField.lineNumber+')') as externallyMutableFields,FILTER(x IN COLLECT( DISTINCT [accessibleMember:ARRAY_TYPE AND isExternallyAcc,'ACCESIBLE ARRAY FIELD ' + accessibleMemberPrev.name+' (line ' +accessibleMemberPrev.lineNumber+')']) WHERE x[0]) as arrayFieldsExposed"), - - new SimpleWithClause( - "field,isFieldType,enclosingType,publicGetters,fieldTypeOrSubtype.fullyQualifiedName as fieldTypeOrSubtype,allMut,externallyMutableFields, arrayFieldsExposed, SIZE(allMut)>0 OR SIZE(externallyMutableFields)>0 OR SIZE(arrayFieldsExposed)>0 as isExtMutable"), - new WhereClause("CASE WHEN isFieldType THEN isExtMutable ELSE NOT isExtMutable END "), - - new SimpleWithClause( - "field,enclosingType,publicGetters,EXTRACT(subtypeNameInfo IN FILTER(subtypeNameInfo IN COLLECT([isFieldType,fieldTypeOrSubtype]) WHERE NOT subtypeNameInfo[0])| subtypeNameInfo[1]) as immutableSubtypes,FILTER(subTypePair IN COLLECT([isFieldType, allMut+externallyMutableFields+arrayFieldsExposed]) WHERE subTypePair[0])[0][1] as mutabilityInfo"), - new WhereClause("NOT mutabilityInfo IS NULL"), - - new ReturnClause( - "'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ publicGetters+'. The problem is that there is at least one member ( like '+mutabilityInfo+')that can be accessed by a client to change the state of the field '+field.name + CASE WHEN SIZE(immutableSubtypes)=0 THEN '. You should implement an appropiate inmutable subtype as a wrapper for your attribute, as you have not created any yet.'ELSE '. Remember to use an appropiate inmutable subtype (such as '+immutableSubtypes+') as a wrapper for your attribute.'END") - // CASE WHEN ANY(x IN COLLECT(accessibleMember:ARRAY_TYPE AND - // isExternallyAcc) WHERE x) THEN 'ARRAY FIELD EXPOSED' ELSE '' - // END - // new ReturnClause(exprs) - /* - * new - * WhereClause("SIZE(allMut)>0 OR SIZE(externallyMutableFields)>0" - * ), new ReturnClause( - * "field.name, fieldTypeOrSubtype.fullyQualifiedName, 'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ publicGetters+'. The problem is that there is at least one member ( like '+EXTRACT(mutator IN allMut | 'MUTATOR METHOD '+mutator.fullyQualifiedName+'( line '+mutator.lineNumber +')')+externallyMutableFields+')that can be accessed by a client to change the state of the field '+field.name" - * ) - */ - - // new ReturnClause( - // "field.name,publicGetters,accessibleMember, - // accessibleMembers,accMemberInfo, ALL(accMemberOrType IN - // accMemberInfo WHERE CASE WHEN accMemberOrType[1]:ATTR_DEC - // THEN NOT accMemberOrType[1].isStatic AND - // (accMemberOrType[1].accessLevel='public' OR NOT - // accMemberOrType[2] is NULL) ELSE CASE WHEN - // accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE FALSE END END - // )") - // , - // new WhereClause(new All("accessibleMembersAndPrevs", - // " memberOrType[1]:ATTR_DEC AND (memberOrType[1].isStatic AND - // ( memberOrType[1].accessLevel='public' ) )", - // "memberOrType")) - // , new - // ReturnClause("field,publicGetters,accessibleMembersAndPrevs") - // BIEN - // new MatchClause(true, - // InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(typeDec)), - // - // new SimpleWithClause( - // "DISTINCT typeDec,enclosingType, field, method,p, CASE WHEN p - // IS NULL THEN [typeDec] else NODES(p) END as nodes"), - // new UnwindClause("nodes", "nodeInP"), - // new SimpleWithClause("enclosingType, field, method, typeDec, - // nodeInP,nodes"), - // new MatchClause(true, - // new Path(new NodeVar("nodeInP"), - // Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), - // RelationTypes.IS_SUBTYPE_EXTENDS, - // RelationTypes.IS_SUBTYPE_IMPLEMENTS), new AnonymousNode()), - // Pair.createP("f", RelationTypes.DECLARES_FIELD), - // - // Pair.createP("mod", PDGRelationTypes.MODIFIED_BY, - // PDGRelationTypes.STATE_MAY_BE_MODIFIED, - // PDGRelationTypes.STATE_MODIFIED_BY)), - // getExpressionServices().getMethodFromExp(new NodeVar("mod"), - // new CompleteNode("setMethod", NodeTypes.METHOD_DEC, - // Pair.create("accessLevel", "public"), Pair.create("isStatic", - // false))), - // - // new MatchImpl("(nodeInP)-[:DECLARES_METHOD]->(setMethod)")), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, CASE - // WHEN setMethod IS NULL THEN [] ELSE COLLECT(setMethod) END as - // setters"), - // - // new MatchClause(true, - // new MatchImpl(new RelationshipImpl(new NodeVar("nodeInP"), - // new AnonymousNode(), - // new EdgeImpl(RelationTypes.DECLARES_METHOD)).relToString() - // + "-[:OVERRIDES]->(ovMethod)")), - // // new WhereClause("publicMethod.accessLevel='public'"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, - // setters, COLLECT(ovMethod) as methodsOverridenByThisType"), - // - // new MatchClause(true, - // new MatchImpl( - // "(nodeInP)-[:IS_SUBTYPE_EXTENDS | - // :IS_SUBTYPE_IMPLEMENTS*0..]->()-[:DECLARES_METHOD]->(getMethod)"), - // getStatementServices().getMethodFromStatement( - // new Path(new NodeVar("nodeInP"), Pair.createP("f", - // RelationTypes.DECLARES_FIELD), - // Pair.createP("", PDGRelationTypes.USED_BY), - // Pair.createInv("", RelationTypes.RETURN_EXPR)), - // new CompleteNode("getMethod", NodeTypes.METHOD_DEC, - // Pair.create("accessLevel", "public"), Pair.create("isStatic", - // false)))), - // new MatchClause(true, - // - // new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - // new EdgeImpl(RelationTypes.ITS_TYPE_IS))), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, - // setters,methodsOverridenByThisType, COLLECT(DISTINCT - // getMethod) as getters, COLLECT(DISTINCT fType) as - // getterTypes"), - // new MatchClause(true, - // new Path(new NodeVar("nodeInP"), - // Pair.createP(new CompleteNode("f", Pair.create("isStatic", - // false), - // Pair.create("accessLevel", "public")), - // RelationTypes.DECLARES_FIELD), - // Pair.create(new EdgeImpl(RelationTypes.ITS_TYPE_IS), new - // NodeVar("fType")))), - // new SimpleWithClause( - // "enclosingType, field, method, - // typeDec,nodeInP,nodes,methodsOverridenByThisType, setters, - // getters,getterTypes, COLLECT(DISTINCT [f,fType]) as - // otherMutableDependencies "), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP, nodes, - // setters,methodsOverridenByThisType, getters,getterTypes, " - // + new Extract(new Filter("otherMutableDependencies", - // "x[0].isFinal"), "y[1]", "y") - // .expToString() - // + " as mutableDependenciesBis, " - // + new Any("otherMutableDependencies", "NOT - // x[0].isFinal").expToString() - // + " as isMutableDueToPublicField "), - // // new ReturnClause("enclosingType, field, method, typeDec, - // // nodeInP, p, setters") - // // new WhereClause("SIZE(NODES(p))=12"), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec, nodes" - //// - // + ", - // COLLECT([ID(nodeInP),[isMutableDueToPublicField,mutableDependenciesBis,methodsOverridenByThisType,setters, - // getters,getterTypes ]]) as map " - //// - // ), - // new SimpleWithClause("enclosingType, field, - // method,typeDec,nodes as prevNodes" - // - // + "," - // + new Extract("nodes", - // "x+HEAD(" + new Filter("map", "y[0]=ID(x)", - // "y").expToString() + ")[1]").expToString() - // + " as nodes" - // - // ), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec,prevNodes, " + new Extract("nodes", - // "[x[0],CASE WHEN x[1] IS NULL THEN FALSE ELSE x[1] END, CASE - // WHEN x[2] IS NULL THEN [] ELSE x[2] END, CASE WHEN x[3] IS - // NULL THEN [] ELSE x[3] END, CASE WHEN x[4] IS NULL THEN [] - // ELSE x[4] END,CASE WHEN x[5] IS NULL THEN [] ELSE x[5] END, - // CASE WHEN x[6] IS NULL THEN [] ELSE x[6] END]") - // .expToString() - // + " as nodes" - //// - // ) - // , new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, CASE WHEN - // nodes IS NULL THEN [] ELSE nodes END as nodes "), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, nodes, - // RANGE(0,SIZE(nodes)-1,1) as indexes"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, nodes, - // indexes, EXTRACT(index IN indexes | CASE WHEN SIZE(FILTER(i - // IN indexes WHERE i=lastAttrIndexes[index]", "i").expToString(), - // "s+nodes[x][3]", "s=[]").expToString() - // - // , "index").expToString() + " as overrides, indexes, - // lastAttrIndexes"), - // new SimpleWithClause("enclosingType, field, method, - // typeDec,prevNodes, " + new Extract("indexes", - // "[nodes[x][0], nodes[x][1] OR ANY(setter IN nodes[x][4] WHERE - // NOT setter IN overrides[x]) " - // - // + ", nodes[x][2]+ EXTRACT( getterIndex IN FILTER(gf IN - // RANGE(0,SIZE(nodes[x][5])-1,1) " - // + "WHERE NOT nodes[x][5][gf] IN overrides[x]) | - // nodes[x][6][getterIndex])] ") - // .expToString() - // + " as nodes, indexes"), - //// new SimpleWithClause("enclosingType, field, method, - // typeDec,p, " + new Extract("indexes", - // // "[nodes[x][0], nodes[x][1]," + new Case("x>0 AND NOT - // // nodes[x+1] IS NULL", - // // "CASE WHEN nodes[x][0]:ATTR_DEC THEN nodes[x+1][0] IN - // // nodes[x-1][2] ELSE TRUE END", - //// "TRUE").expToString() + "] ").expToString() - //// + " as nodes"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes,indexes, " + - // new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," + new Case("x>1 AND - // nodes[x-1][0]:ATTR_DEC", - // " ANY(dep IN nodes[x-2][2] WHERE dep =nodes[x][0])", - // "TRUE").expToString() - // + "] ").expToString() - // + " as nodes"), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec, " - // + new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," - // + "NOT ANY(i IN indexes WHERE i<=x AND NOT nodes[i][2]) - // ]").expToString() - // + " as nodes ORDER BY typeDec"), - // // new SimpleWithClause( - // // "enclosingType, field, method,typeDec,p, CASE WHEN - // // SIZE(nodes)=0 THEN []+typeDec ELSE nodes END as nodes "), - // // new WhereClause("SIZE(nodes)=0"), - // new SimpleWithClause( - // "DISTINCT enclosingType, field, method, typeDec," - // + new Reduce("nodes", - // "s AND CASE WHEN x[0]:ATTR_DEC THEN TRUE ELSE NOT x[2] OR - // (NOT x[0]:ARRAY_TYPE AND NOT x[1]) END ", - // "s=true") - // .expToString() - // + " AND NOT typeDec:ARRAY_TYPE as res" - // - // ), - // new SimpleWithClause( - // "enclosingType, field,method, typeDec,ANY (x IN COLLECT(res) - // WHERE NOT x) as isMutable"), - // new SimpleWithClause("enclosingType, field,COLLECT(method) as - // methods, typeDec,isMutable"), - // - // new WhereClause("isMutable"), - // // FILTRAR - // // , - // new SimpleWithClause("COLLECT([enclosingType, field, methods, - // typeDec]) as res"), - // new UnwindClause("res", "typeRes"), - // new SimpleWithClause( - // "typeRes[1] as field, typeRes[3] as typeDec, typeRes[0] as - // enclosingType,typeRes[2] as methods, res"), - // new MatchClause(true, - // new MatchImpl("(typeDec)<-[:IS_SUBTYPE_EXTENDS | - // :IS_SUBTYPE_IMPLEMENTS*0..]-(subType)")), - // new - // SimpleWithClause("typeDec,methods,enclosingType,field,res, - // COLLECT(subType) as subtypes"), - // new SimpleWithClause( - // "typeDec,EXTRACT(m IN methods | m.fullyQualifiedName) as - // methods,enclosingType,field,res, FILTER(y IN subtypes WHERE - // NOT y IN EXTRACT(x IN res | x[3])) as nonMutableSubTypes"), - // new ReturnClause( - // " 'Warning[OBJ-56] Field ' +field.name+' declared in line ' - // +field.lineNumber+' in class - // '+enclosingType.fullyQualifiedName+' is not public, but it is - // exposed in public methods such as '+ methods+'. The problem - // is that the type '+typeDec.fullyQualifiedName+' (a posible - // class of the field '+field.name+') can be mutated by a - // malicious client.'+CASE WHEN SIZE(nonMutableSubTypes)=0 THEN - // ' You should implement an appropiate inmutable subtype as a - // wrapper for your attribute, as you have not created any - // yet.'ELSE 'Remember to use an appropiate inmutable subtype - // (such as '+EXTRACT(x IN nonMutableSubTypes | - // x.fullyQualifiedName)+') as a wrapper for your attribute.'END - // ") - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, " - // + new Extract("nodesWithInfo", "x[0]").expToString() - // + ",p, SIZE(NODES(p)), SIZE(nodesWithInfo)") - - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, NODES(p) ") - }; - } - - // WTIH ATTR, DECLARING TYPE - // public static void main(String[] args) { - // System.out.println(new OBJ56_SIMPLIFIED().queryToString()); - // } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_PREV.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_PREV.java deleted file mode 100644 index 5530163..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_PREV.java +++ /dev/null @@ -1,358 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56_SIMPLIFIED_PREV extends AbstractQuery { - - public OBJ56_SIMPLIFIED_PREV() { - super(true); - - } - - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - new MatchClause( - getStatementServices() - .getMethodFromStatement( - new MatchImpl("(enclosingType)-[:DECLARES_FIELD]->(field:ATTR_DEC)-[:USED_BY]->(retExpr)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"))) - .append(Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD), - new NodeVar("{accessLevel:'public'}")))), - // DECLARED IN A PUBLIC TYPE - // new MatchImpl( - // "(field)-[:ITS_TYPE_IS]->()<-[:IS_SUBTYPE_EXTENDS|IS_SUBTYPE_IMPLEMENTS*0..]-(typeDec)")) - - new WhereClause("NOT field.accessLevel='public' "), - // LUEGO HAY QUE METER EL CASO DE LOS ARRAYS - new MatchClause(new RelationshipImpl(new NodeVar("field"), new NodeVar("fieldType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS)), - new Path(new NodeVar("fieldType"), "accessibleMembers", - Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), RelationTypes.DECLARES_FIELD, - TypeRelations.ITS_TYPE_IS, TypeRelations.INHERITS_FIELD), - new NodeVar("accessibleMember")))), - new SimpleWithClause( - "field,enclosingType, method,accessibleMember, NODES(accessibleMembers) as accessibleMembers"), - new SimpleWithClause( - "field,enclosingType, accessibleMembers,accessibleMember, COLLECT(DISTINCT method.fullyQualifiedName+'( line '+method.lineNumber+')') as publicGetters, EXTRACT(index IN RANGE(0,SIZE( accessibleMembers)-1,1) | [CASE WHEN index=0 THEN field ELSE accessibleMembers[index-1] END, accessibleMembers[index]]) as accessibleMembersAndPrevs"), - new UnwindClause("accessibleMembersAndPrevs", "accMemberAndPrev"), - new MatchClause(true, - getStatementServices() - .getMethodFromStatement( - new MatchImpl("(accesibleField)-[:USED_BY]->(fieldExpr)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", Pair.create("accessLevel", "public"))) - .append(Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD, - TypeRelations.INHERITS_METHOD), new NodeVar("accessibleType")))), - new WhereClause( - "ID(accesibleField)=ID(accMemberAndPrev[1]) AND ID(accessibleType)=ID(accMemberAndPrev[0])"), - new SimpleWithClause( - " field,enclosingType, method,publicGetters,accMemberAndPrev, accessibleMembers, accessibleMember, CASE WHEN method IS NULL THEN [NULL] ELSE COLLECT(method) END as gettersForCurrentMember"), - - new SimpleWithClause( - "field,enclosingType,publicGetters,accessibleMembers,accessibleMember,accMemberAndPrev+ gettersForCurrentMember as accMemberOrType"), - - new SimpleWithClause( - "field,enclosingType,publicGetters,accessibleMembers,accessibleMember, COLLECT( CASE WHEN accMemberOrType[1]:ATTR_DEC THEN NOT accMemberOrType[1].isStatic AND (accMemberOrType[1].accessLevel='public' OR NOT accMemberOrType[2] is NULL) ELSE CASE WHEN accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE accMemberOrType[1].accessLevel='public' END END + accMemberOrType) as accMemberOrTypes"), - new WhereClause("ALL( accMemberOrType IN accMemberOrTypes WHERE accMemberOrType[0])"), - new SimpleWithClause("DISTINCT field, enclosingType, publicGetters, accessibleMember "), - new MatchClause(true, new RelationshipImpl(new NodeVar("accessibleMember"), - new CompleteNode("mutator", NodeTypes.METHOD_DEF, Pair.create("accessLevel", "public")), - RelationTypes.DECLARES_METHOD, TypeRelations.INHERITS_METHOD) - .append(Pair.create( - new EdgeImpl(EdgeDirection.OUTGOING, PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY, - PDGRelationTypes.STATE_MODIFIED_BY), - new CompleteNode(NodeTypes.THIS_REF)))), - - new SimpleWithClause( - "field, enclosingType, publicGetters, accessibleMember, COLLECT(mutator) as mutators"), - new SimpleWithClause( - "field,enclosingType, mutators,publicGetters, EXTRACT(accField IN FILTER(accMember IN COLLECT(accessibleMember) WHERE accMember:ATTR_DEC AND NOT accMember.isFinal AND accMember.accessLevel='public') | 'PUBLIC NON-FINAL FIELD '+accField.name+'( line'+accField.lineNumber+')') as externallyMutableFields"), - - new WhereClause( - "SIZE(mutators)>0 OR SIZE(externallyMutableFields)>0"), - new ReturnClause( - " 'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ publicGetters+'. The problem is that there is at least one member ( like '+EXTRACT(mutator IN mutators | 'MUTATOR METHOD '+mutator.fullyQualifiedName+'( line '+mutator.lineNumber +')')+externallyMutableFields+')that can be accessed by a client to change the state of the field '+field.name") - // new ReturnClause( - // "field.name,publicGetters,accessibleMember, - // accessibleMembers,accMemberInfo, ALL(accMemberOrType IN - // accMemberInfo WHERE CASE WHEN accMemberOrType[1]:ATTR_DEC - // THEN NOT accMemberOrType[1].isStatic AND - // (accMemberOrType[1].accessLevel='public' OR NOT - // accMemberOrType[2] is NULL) ELSE CASE WHEN - // accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE FALSE END END - // )") - // , - // new WhereClause(new All("accessibleMembersAndPrevs", - // " memberOrType[1]:ATTR_DEC AND (memberOrType[1].isStatic AND - // ( memberOrType[1].accessLevel='public' ) )", - // "memberOrType")) - // , new - // ReturnClause("field,publicGetters,accessibleMembersAndPrevs") - // BIEN - // new MatchClause(true, - // InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(typeDec)), - // - // new SimpleWithClause( - // "DISTINCT typeDec,enclosingType, field, method,p, CASE WHEN p - // IS NULL THEN [typeDec] else NODES(p) END as nodes"), - // new UnwindClause("nodes", "nodeInP"), - // new SimpleWithClause("enclosingType, field, method, typeDec, - // nodeInP,nodes"), - // new MatchClause(true, - // new Path(new NodeVar("nodeInP"), - // Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), - // RelationTypes.IS_SUBTYPE_EXTENDS, - // RelationTypes.IS_SUBTYPE_IMPLEMENTS), new AnonymousNode()), - // Pair.createP("f", RelationTypes.DECLARES_FIELD), - // - // Pair.createP("mod", PDGRelationTypes.MODIFIED_BY, - // PDGRelationTypes.STATE_MAY_BE_MODIFIED, - // PDGRelationTypes.STATE_MODIFIED_BY)), - // getExpressionServices().getMethodFromExp(new NodeVar("mod"), - // new CompleteNode("setMethod", NodeTypes.METHOD_DEF, - // Pair.create("accessLevel", "public"), Pair.create("isStatic", - // false))), - // - // new MatchImpl("(nodeInP)-[:DECLARES_METHOD]->(setMethod)")), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, CASE - // WHEN setMethod IS NULL THEN [] ELSE COLLECT(setMethod) END as - // setters"), - // - // new MatchClause(true, - // new MatchImpl(new RelationshipImpl(new NodeVar("nodeInP"), - // new AnonymousNode(), - // new EdgeImpl(RelationTypes.DECLARES_METHOD)).relToString() - // + "-[:OVERRIDES]->(ovMethod)")), - // // new WhereClause("publicMethod.accessLevel='public'"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, - // setters, COLLECT(ovMethod) as methodsOverridenByThisType"), - // - // new MatchClause(true, - // new MatchImpl( - // "(nodeInP)-[:IS_SUBTYPE_EXTENDS | - // :IS_SUBTYPE_IMPLEMENTS*0..]->()-[:DECLARES_METHOD]->(getMethod)"), - // getStatementServices().getMethodFromStatement( - // new Path(new NodeVar("nodeInP"), Pair.createP("f", - // RelationTypes.DECLARES_FIELD), - // Pair.createP("", PDGRelationTypes.USED_BY), - // Pair.createInv("", RelationTypes.RETURN_EXPR)), - // new CompleteNode("getMethod", NodeTypes.METHOD_DEF, - // Pair.create("accessLevel", "public"), Pair.create("isStatic", - // false)))), - // new MatchClause(true, - // - // new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - // new EdgeImpl(RelationTypes.ITS_TYPE_IS))), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, - // setters,methodsOverridenByThisType, COLLECT(DISTINCT - // getMethod) as getters, COLLECT(DISTINCT fType) as - // getterTypes"), - // new MatchClause(true, - // new Path(new NodeVar("nodeInP"), - // Pair.createP(new CompleteNode("f", Pair.create("isStatic", - // false), - // Pair.create("accessLevel", "public")), - // RelationTypes.DECLARES_FIELD), - // Pair.create(new EdgeImpl(RelationTypes.ITS_TYPE_IS), new - // NodeVar("fType")))), - // new SimpleWithClause( - // "enclosingType, field, method, - // typeDec,nodeInP,nodes,methodsOverridenByThisType, setters, - // getters,getterTypes, COLLECT(DISTINCT [f,fType]) as - // otherMutableDependencies "), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP, nodes, - // setters,methodsOverridenByThisType, getters,getterTypes, " - // + new Extract(new Filter("otherMutableDependencies", - // "x[0].isFinal"), "y[1]", "y") - // .expToString() - // + " as mutableDependenciesBis, " - // + new Any("otherMutableDependencies", "NOT - // x[0].isFinal").expToString() - // + " as isMutableDueToPublicField "), - // // new ReturnClause("enclosingType, field, method, typeDec, - // // nodeInP, p, setters") - // // new WhereClause("SIZE(NODES(p))=12"), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec, nodes" - //// - // + ", - // COLLECT([ID(nodeInP),[isMutableDueToPublicField,mutableDependenciesBis,methodsOverridenByThisType,setters, - // getters,getterTypes ]]) as map " - //// - // ), - // new SimpleWithClause("enclosingType, field, - // method,typeDec,nodes as prevNodes" - // - // + "," - // + new Extract("nodes", - // "x+HEAD(" + new Filter("map", "y[0]=ID(x)", - // "y").expToString() + ")[1]").expToString() - // + " as nodes" - // - // ), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec,prevNodes, " + new Extract("nodes", - // "[x[0],CASE WHEN x[1] IS NULL THEN FALSE ELSE x[1] END, CASE - // WHEN x[2] IS NULL THEN [] ELSE x[2] END, CASE WHEN x[3] IS - // NULL THEN [] ELSE x[3] END, CASE WHEN x[4] IS NULL THEN [] - // ELSE x[4] END,CASE WHEN x[5] IS NULL THEN [] ELSE x[5] END, - // CASE WHEN x[6] IS NULL THEN [] ELSE x[6] END]") - // .expToString() - // + " as nodes" - //// - // ) - // , new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, CASE WHEN - // nodes IS NULL THEN [] ELSE nodes END as nodes "), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, nodes, - // RANGE(0,SIZE(nodes)-1,1) as indexes"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, nodes, - // indexes, EXTRACT(index IN indexes | CASE WHEN SIZE(FILTER(i - // IN indexes WHERE i=lastAttrIndexes[index]", "i").expToString(), - // "s+nodes[x][3]", "s=[]").expToString() - // - // , "index").expToString() + " as overrides, indexes, - // lastAttrIndexes"), - // new SimpleWithClause("enclosingType, field, method, - // typeDec,prevNodes, " + new Extract("indexes", - // "[nodes[x][0], nodes[x][1] OR ANY(setter IN nodes[x][4] WHERE - // NOT setter IN overrides[x]) " - // - // + ", nodes[x][2]+ EXTRACT( getterIndex IN FILTER(gf IN - // RANGE(0,SIZE(nodes[x][5])-1,1) " - // + "WHERE NOT nodes[x][5][gf] IN overrides[x]) | - // nodes[x][6][getterIndex])] ") - // .expToString() - // + " as nodes, indexes"), - //// new SimpleWithClause("enclosingType, field, method, - // typeDec,p, " + new Extract("indexes", - // // "[nodes[x][0], nodes[x][1]," + new Case("x>0 AND NOT - // // nodes[x+1] IS NULL", - // // "CASE WHEN nodes[x][0]:ATTR_DEC THEN nodes[x+1][0] IN - // // nodes[x-1][2] ELSE TRUE END", - //// "TRUE").expToString() + "] ").expToString() - //// + " as nodes"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes,indexes, " + - // new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," + new Case("x>1 AND - // nodes[x-1][0]:ATTR_DEC", - // " ANY(dep IN nodes[x-2][2] WHERE dep =nodes[x][0])", - // "TRUE").expToString() - // + "] ").expToString() - // + " as nodes"), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec, " - // + new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," - // + "NOT ANY(i IN indexes WHERE i<=x AND NOT nodes[i][2]) - // ]").expToString() - // + " as nodes ORDER BY typeDec"), - // // new SimpleWithClause( - // // "enclosingType, field, method,typeDec,p, CASE WHEN - // // SIZE(nodes)=0 THEN []+typeDec ELSE nodes END as nodes "), - // // new WhereClause("SIZE(nodes)=0"), - // new SimpleWithClause( - // "DISTINCT enclosingType, field, method, typeDec," - // + new Reduce("nodes", - // "s AND CASE WHEN x[0]:ATTR_DEC THEN TRUE ELSE NOT x[2] OR - // (NOT x[0]:ARRAY_TYPE AND NOT x[1]) END ", - // "s=true") - // .expToString() - // + " AND NOT typeDec:ARRAY_TYPE as res" - // - // ), - // new SimpleWithClause( - // "enclosingType, field,method, typeDec,ANY (x IN COLLECT(res) - // WHERE NOT x) as isMutable"), - // new SimpleWithClause("enclosingType, field,COLLECT(method) as - // methods, typeDec,isMutable"), - // - // new WhereClause("isMutable"), - // // FILTRAR - // // , - // new SimpleWithClause("COLLECT([enclosingType, field, methods, - // typeDec]) as res"), - // new UnwindClause("res", "typeRes"), - // new SimpleWithClause( - // "typeRes[1] as field, typeRes[3] as typeDec, typeRes[0] as - // enclosingType,typeRes[2] as methods, res"), - // new MatchClause(true, - // new MatchImpl("(typeDec)<-[:IS_SUBTYPE_EXTENDS | - // :IS_SUBTYPE_IMPLEMENTS*0..]-(subType)")), - // new - // SimpleWithClause("typeDec,methods,enclosingType,field,res, - // COLLECT(subType) as subtypes"), - // new SimpleWithClause( - // "typeDec,EXTRACT(m IN methods | m.fullyQualifiedName) as - // methods,enclosingType,field,res, FILTER(y IN subtypes WHERE - // NOT y IN EXTRACT(x IN res | x[3])) as nonMutableSubTypes"), - // new ReturnClause( - // " 'Warning[OBJ-56] Field ' +field.name+' declared in line ' - // +field.lineNumber+' in class - // '+enclosingType.fullyQualifiedName+' is not public, but it is - // exposed in public methods such as '+ methods+'. The problem - // is that the type '+typeDec.fullyQualifiedName+' (a posible - // class of the field '+field.name+') can be mutated by a - // malicious client.'+CASE WHEN SIZE(nonMutableSubTypes)=0 THEN - // ' You should implement an appropiate inmutable subtype as a - // wrapper for your attribute, as you have not created any - // yet.'ELSE 'Remember to use an appropiate inmutable subtype - // (such as '+EXTRACT(x IN nonMutableSubTypes | - // x.fullyQualifiedName)+') as a wrapper for your attribute.'END - // ") - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, " - // + new Extract("nodesWithInfo", "x[0]").expToString() - // + ",p, SIZE(NODES(p)), SIZE(nodesWithInfo)") - - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, NODES(p) ") - }; - } - - // WTIH ATTR, DECLARING TYPE - // public static void main(String[] args) { - // System.out.println(new OBJ56_SIMPLIFIED().queryToString()); - // } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_PREV_V1.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_PREV_V1.java deleted file mode 100644 index 6d26d03..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_PREV_V1.java +++ /dev/null @@ -1,358 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56_SIMPLIFIED_PREV_V1 extends AbstractQuery { - - public OBJ56_SIMPLIFIED_PREV_V1() { - super(true); - - } - - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - new MatchClause( - getStatementServices() - .getMethodFromStatement( - new MatchImpl("(enclosingType)-[:DECLARES_FIELD]->(field:ATTR_DEC)-[:USED_BY]->(retExpr)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"))) - .append(Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD), - new NodeVar("{accessLevel:'public'}")))), - // DECLARED IN A PUBLIC TYPE - // new MatchImpl( - // "(field)-[:ITS_TYPE_IS]->()<-[:IS_SUBTYPE_EXTENDS|IS_SUBTYPE_IMPLEMENTS*0..]-(typeDec)")) - - new WhereClause("NOT field.accessLevel='public' "), - // LUEGO HAY QUE METER EL CASO DE LOS ARRAYS - new MatchClause(new RelationshipImpl(new NodeVar("field"), new NodeVar("fieldType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS)), - new Path(new NodeVar("fieldType"), "accessibleMembers", - Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), RelationTypes.DECLARES_FIELD, - TypeRelations.ITS_TYPE_IS, TypeRelations.INHERITS_FIELD), - new NodeVar("accessibleMember")))), - new SimpleWithClause( - "field,enclosingType, method,accessibleMember, NODES(accessibleMembers) as accessibleMembers"), - new SimpleWithClause( - "field,enclosingType, accessibleMembers,accessibleMember, COLLECT(DISTINCT method.fullyQualifiedName+'( line '+method.lineNumber+')') as publicGetters, EXTRACT(index IN RANGE(0,SIZE( accessibleMembers)-1,1) | [CASE WHEN index=0 THEN field ELSE accessibleMembers[index-1] END, accessibleMembers[index]]) as accessibleMembersAndPrevs"), - new UnwindClause("accessibleMembersAndPrevs", "accMemberAndPrev"), - new MatchClause(true, - getStatementServices() - .getMethodFromStatement( - new MatchImpl("(accesibleField)-[:USED_BY]->(fieldExpr)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", Pair.create("accessLevel", "public"))) - .append(Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD, - TypeRelations.INHERITS_METHOD), new NodeVar("accessibleType")))), - new WhereClause( - "ID(accesibleField)=ID(accMemberAndPrev[1]) AND ID(accessibleType)=ID(accMemberAndPrev[0])"), - new SimpleWithClause( - " field,enclosingType, method,publicGetters,accMemberAndPrev as accMemberOrType, accessibleMembers, accessibleMember, COLLECT(method) as gettersForCurrentMember"), - - new SimpleWithClause( - "field,enclosingType,publicGetters,accessibleMembers,accessibleMember,accMemberOrType, COLLECT( CASE WHEN accMemberOrType[1]:ATTR_DEC THEN [NOT accMemberOrType[1].isStatic AND (accMemberOrType[1].accessLevel='public' OR SIZE(gettersForCurrentMember)>0),CASE WHEN NOT accMemberOrType[1].isStatic AND accMemberOrType[1].accessLevel<>'public' THEN gettersForCurrentMember ELSE []END] ELSE CASE WHEN accMemberOrType[1]:ARRAY_TYPE THEN [TRUE,[]] ELSE [EXISTS(accMemberOrType[1].accessLevel) AND accMemberOrType[1].accessLevel='public',[]] END END) as relevantInfoAndGetters "), - -// new SimpleWithClause( -// "field,enclosingType,publicGetters,accessibleMembers,accessibleMember, COLLECT( CASE WHEN accMemberOrType[1]:ATTR_DEC THEN NOT accMemberOrType[1].isStatic AND (accMemberOrType[1].accessLevel='public' OR SIZE(relevantGetters)>0) ELSE CASE WHEN accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE accMemberOrType[1].accessLevel='public' END END ) as accMemberOrTypesInfo"), - new WhereClause("ALL( accMemberOrTypeInfo IN relevantInfoAndGetters WHERE accMemberOrTypeInfo[0])"), - new SimpleWithClause( - "DISTINCT field, enclosingType, publicGetters, accessibleMember, EXTRACT(relevantInfo IN relevantInfoAndGetters| relevantInfo[1]) as relevantGetters"), - new MatchClause(true, new RelationshipImpl(new NodeVar("accessibleMember"), - new CompleteNode("mutator", NodeTypes.METHOD_DEF, Pair.create("accessLevel", "public")), - RelationTypes.DECLARES_METHOD, TypeRelations.INHERITS_METHOD) - .append(Pair.create( - new EdgeImpl(EdgeDirection.OUTGOING, PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY, - PDGRelationTypes.STATE_MODIFIED_BY), - new CompleteNode(NodeTypes.THIS_REF)))), - - // new SimpleWithClause( - // "field, enclosingType, publicGetters, accessibleMember, - // COLLECT(mutator) as mutators"), - new SimpleWithClause( - "REDUCE(allRelGettters=[], getter IN relevantGetters |allRelGettters+getter)as relevantGetters,field,enclosingType, publicGetters,COLLECT(DISTINCT mutator) as allMut, EXTRACT(accField IN FILTER(accMember IN COLLECT(accessibleMember) WHERE accMember:ATTR_DEC AND NOT accMember.isStatic AND NOT accMember.isFinal AND accMember.accessLevel='public') | 'PUBLIC NON-FINAL FIELD '+accField.name+'( line'+accField.lineNumber+')') as externallyMutableFields"), - - new WhereClause("SIZE(allMut)>0 OR SIZE(externallyMutableFields)>0"), new ReturnClause( - " relevantGetters, 'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ publicGetters+'. The problem is that there is at least one member ( like '+EXTRACT(mutator IN allMut | 'MUTATOR METHOD '+mutator.fullyQualifiedName+'( line '+mutator.lineNumber +')')+externallyMutableFields+')that can be accessed by a client to change the state of the field '+field.name") - // new ReturnClause( - // "field.name,publicGetters,accessibleMember, - // accessibleMembers,accMemberInfo, ALL(accMemberOrType IN - // accMemberInfo WHERE CASE WHEN accMemberOrType[1]:ATTR_DEC - // THEN NOT accMemberOrType[1].isStatic AND - // (accMemberOrType[1].accessLevel='public' OR NOT - // accMemberOrType[2] is NULL) ELSE CASE WHEN - // accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE FALSE END END - // )") - // , - // new WhereClause(new All("accessibleMembersAndPrevs", - // " memberOrType[1]:ATTR_DEC AND (memberOrType[1].isStatic AND - // ( memberOrType[1].accessLevel='public' ) )", - // "memberOrType")) - // , new - // ReturnClause("field,publicGetters,accessibleMembersAndPrevs") - // BIEN - // new MatchClause(true, - // InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(typeDec)), - // - // new SimpleWithClause( - // "DISTINCT typeDec,enclosingType, field, method,p, CASE WHEN p - // IS NULL THEN [typeDec] else NODES(p) END as nodes"), - // new UnwindClause("nodes", "nodeInP"), - // new SimpleWithClause("enclosingType, field, method, typeDec, - // nodeInP,nodes"), - // new MatchClause(true, - // new Path(new NodeVar("nodeInP"), - // Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), - // RelationTypes.IS_SUBTYPE_EXTENDS, - // RelationTypes.IS_SUBTYPE_IMPLEMENTS), new AnonymousNode()), - // Pair.createP("f", RelationTypes.DECLARES_FIELD), - // - // Pair.createP("mod", PDGRelationTypes.MODIFIED_BY, - // PDGRelationTypes.STATE_MAY_BE_MODIFIED, - // PDGRelationTypes.STATE_MODIFIED_BY)), - // getExpressionServices().getMethodFromExp(new NodeVar("mod"), - // new CompleteNode("setMethod", NodeTypes.METHOD_DEF, - // Pair.create("accessLevel", "public"), Pair.create("isStatic", - // false))), - // - // new MatchImpl("(nodeInP)-[:DECLARES_METHOD]->(setMethod)")), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, CASE - // WHEN setMethod IS NULL THEN [] ELSE COLLECT(setMethod) END as - // setters"), - // - // new MatchClause(true, - // new MatchImpl(new RelationshipImpl(new NodeVar("nodeInP"), - // new AnonymousNode(), - // new EdgeImpl(RelationTypes.DECLARES_METHOD)).relToString() - // + "-[:OVERRIDES]->(ovMethod)")), - // // new WhereClause("publicMethod.accessLevel='public'"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, - // setters, COLLECT(ovMethod) as methodsOverridenByThisType"), - // - // new MatchClause(true, - // new MatchImpl( - // "(nodeInP)-[:IS_SUBTYPE_EXTENDS | - // :IS_SUBTYPE_IMPLEMENTS*0..]->()-[:DECLARES_METHOD]->(getMethod)"), - // getStatementServices().getMethodFromStatement( - // new Path(new NodeVar("nodeInP"), Pair.createP("f", - // RelationTypes.DECLARES_FIELD), - // Pair.createP("", PDGRelationTypes.USED_BY), - // Pair.createInv("", RelationTypes.RETURN_EXPR)), - // new CompleteNode("getMethod", NodeTypes.METHOD_DEF, - // Pair.create("accessLevel", "public"), Pair.create("isStatic", - // false)))), - // new MatchClause(true, - // - // new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - // new EdgeImpl(RelationTypes.ITS_TYPE_IS))), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, - // setters,methodsOverridenByThisType, COLLECT(DISTINCT - // getMethod) as getters, COLLECT(DISTINCT fType) as - // getterTypes"), - // new MatchClause(true, - // new Path(new NodeVar("nodeInP"), - // Pair.createP(new CompleteNode("f", Pair.create("isStatic", - // false), - // Pair.create("accessLevel", "public")), - // RelationTypes.DECLARES_FIELD), - // Pair.create(new EdgeImpl(RelationTypes.ITS_TYPE_IS), new - // NodeVar("fType")))), - // new SimpleWithClause( - // "enclosingType, field, method, - // typeDec,nodeInP,nodes,methodsOverridenByThisType, setters, - // getters,getterTypes, COLLECT(DISTINCT [f,fType]) as - // otherMutableDependencies "), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP, nodes, - // setters,methodsOverridenByThisType, getters,getterTypes, " - // + new Extract(new Filter("otherMutableDependencies", - // "x[0].isFinal"), "y[1]", "y") - // .expToString() - // + " as mutableDependenciesBis, " - // + new Any("otherMutableDependencies", "NOT - // x[0].isFinal").expToString() - // + " as isMutableDueToPublicField "), - // // new ReturnClause("enclosingType, field, method, typeDec, - // // nodeInP, p, setters") - // // new WhereClause("SIZE(NODES(p))=12"), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec, nodes" - //// - // + ", - // COLLECT([ID(nodeInP),[isMutableDueToPublicField,mutableDependenciesBis,methodsOverridenByThisType,setters, - // getters,getterTypes ]]) as map " - //// - // ), - // new SimpleWithClause("enclosingType, field, - // method,typeDec,nodes as prevNodes" - // - // + "," - // + new Extract("nodes", - // "x+HEAD(" + new Filter("map", "y[0]=ID(x)", - // "y").expToString() + ")[1]").expToString() - // + " as nodes" - // - // ), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec,prevNodes, " + new Extract("nodes", - // "[x[0],CASE WHEN x[1] IS NULL THEN FALSE ELSE x[1] END, CASE - // WHEN x[2] IS NULL THEN [] ELSE x[2] END, CASE WHEN x[3] IS - // NULL THEN [] ELSE x[3] END, CASE WHEN x[4] IS NULL THEN [] - // ELSE x[4] END,CASE WHEN x[5] IS NULL THEN [] ELSE x[5] END, - // CASE WHEN x[6] IS NULL THEN [] ELSE x[6] END]") - // .expToString() - // + " as nodes" - //// - // ) - // , new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, CASE WHEN - // nodes IS NULL THEN [] ELSE nodes END as nodes "), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, nodes, - // RANGE(0,SIZE(nodes)-1,1) as indexes"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, nodes, - // indexes, EXTRACT(index IN indexes | CASE WHEN SIZE(FILTER(i - // IN indexes WHERE i=lastAttrIndexes[index]", "i").expToString(), - // "s+nodes[x][3]", "s=[]").expToString() - // - // , "index").expToString() + " as overrides, indexes, - // lastAttrIndexes"), - // new SimpleWithClause("enclosingType, field, method, - // typeDec,prevNodes, " + new Extract("indexes", - // "[nodes[x][0], nodes[x][1] OR ANY(setter IN nodes[x][4] WHERE - // NOT setter IN overrides[x]) " - // - // + ", nodes[x][2]+ EXTRACT( getterIndex IN FILTER(gf IN - // RANGE(0,SIZE(nodes[x][5])-1,1) " - // + "WHERE NOT nodes[x][5][gf] IN overrides[x]) | - // nodes[x][6][getterIndex])] ") - // .expToString() - // + " as nodes, indexes"), - //// new SimpleWithClause("enclosingType, field, method, - // typeDec,p, " + new Extract("indexes", - // // "[nodes[x][0], nodes[x][1]," + new Case("x>0 AND NOT - // // nodes[x+1] IS NULL", - // // "CASE WHEN nodes[x][0]:ATTR_DEC THEN nodes[x+1][0] IN - // // nodes[x-1][2] ELSE TRUE END", - //// "TRUE").expToString() + "] ").expToString() - //// + " as nodes"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes,indexes, " + - // new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," + new Case("x>1 AND - // nodes[x-1][0]:ATTR_DEC", - // " ANY(dep IN nodes[x-2][2] WHERE dep =nodes[x][0])", - // "TRUE").expToString() - // + "] ").expToString() - // + " as nodes"), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec, " - // + new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," - // + "NOT ANY(i IN indexes WHERE i<=x AND NOT nodes[i][2]) - // ]").expToString() - // + " as nodes ORDER BY typeDec"), - // // new SimpleWithClause( - // // "enclosingType, field, method,typeDec,p, CASE WHEN - // // SIZE(nodes)=0 THEN []+typeDec ELSE nodes END as nodes "), - // // new WhereClause("SIZE(nodes)=0"), - // new SimpleWithClause( - // "DISTINCT enclosingType, field, method, typeDec," - // + new Reduce("nodes", - // "s AND CASE WHEN x[0]:ATTR_DEC THEN TRUE ELSE NOT x[2] OR - // (NOT x[0]:ARRAY_TYPE AND NOT x[1]) END ", - // "s=true") - // .expToString() - // + " AND NOT typeDec:ARRAY_TYPE as res" - // - // ), - // new SimpleWithClause( - // "enclosingType, field,method, typeDec,ANY (x IN COLLECT(res) - // WHERE NOT x) as isMutable"), - // new SimpleWithClause("enclosingType, field,COLLECT(method) as - // methods, typeDec,isMutable"), - // - // new WhereClause("isMutable"), - // // FILTRAR - // // , - // new SimpleWithClause("COLLECT([enclosingType, field, methods, - // typeDec]) as res"), - // new UnwindClause("res", "typeRes"), - // new SimpleWithClause( - // "typeRes[1] as field, typeRes[3] as typeDec, typeRes[0] as - // enclosingType,typeRes[2] as methods, res"), - // new MatchClause(true, - // new MatchImpl("(typeDec)<-[:IS_SUBTYPE_EXTENDS | - // :IS_SUBTYPE_IMPLEMENTS*0..]-(subType)")), - // new - // SimpleWithClause("typeDec,methods,enclosingType,field,res, - // COLLECT(subType) as subtypes"), - // new SimpleWithClause( - // "typeDec,EXTRACT(m IN methods | m.fullyQualifiedName) as - // methods,enclosingType,field,res, FILTER(y IN subtypes WHERE - // NOT y IN EXTRACT(x IN res | x[3])) as nonMutableSubTypes"), - // new ReturnClause( - // " 'Warning[OBJ-56] Field ' +field.name+' declared in line ' - // +field.lineNumber+' in class - // '+enclosingType.fullyQualifiedName+' is not public, but it is - // exposed in public methods such as '+ methods+'. The problem - // is that the type '+typeDec.fullyQualifiedName+' (a posible - // class of the field '+field.name+') can be mutated by a - // malicious client.'+CASE WHEN SIZE(nonMutableSubTypes)=0 THEN - // ' You should implement an appropiate inmutable subtype as a - // wrapper for your attribute, as you have not created any - // yet.'ELSE 'Remember to use an appropiate inmutable subtype - // (such as '+EXTRACT(x IN nonMutableSubTypes | - // x.fullyQualifiedName)+') as a wrapper for your attribute.'END - // ") - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, " - // + new Extract("nodesWithInfo", "x[0]").expToString() - // + ",p, SIZE(NODES(p)), SIZE(nodesWithInfo)") - - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, NODES(p) ") - }; - } - - // WTIH ATTR, DECLARING TYPE - // public static void main(String[] args) { - // System.out.println(new OBJ56_SIMPLIFIED().queryToString()); - // } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_SA.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_SA.java deleted file mode 100644 index 9d0a5cf..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_SIMPLIFIED_SA.java +++ /dev/null @@ -1,414 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56_SIMPLIFIED_SA extends AbstractQuery { - - public OBJ56_SIMPLIFIED_SA() { - super(true); - } - public static void main(String[] args) { - System.out.println(new OBJ56_SIMPLIFIED_SA().queryToString()); - } - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - new MatchClause(getStatementServices() - .getMethodFromStatement( - new MatchImpl( - "(enclosingType)-[:DECLARES_FIELD]->(field:ATTR_DEF)-[:USED_BY]->(retExpr)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", NodeTypes.METHOD_DEF, Pair.create("accessLevel", "public"))) - .append(Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD), - new NodeVar("classExposingF{accessLevel:'public', isAbstract:false}")))), - // DECLARED IN A PUBLIC TYPE - // new MatchImpl( - // "(field)-[:ITS_TYPE_IS]->()<-[:IS_SUBTYPE_EXTENDS|IS_SUBTYPE_IMPLEMENTS*0..]-(typeDec)")) - - new WhereClause("NOT field.accessLevel='public' AND (NOT field.accessLevel='protected' OR classExposingF.isFinal)"), - // LUEGO HAY QUE METER EL CASO DE LOS ARRAYS - new MatchClause(new RelationshipImpl(new NodeVar("field"), new NodeVar("fieldType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS)) - .append(Pair.create( - new EdgeImpl(EdgeDirection.OUTGOING, TypeRelations.IS_SUBTYPE_EXTENDS, - TypeRelations.IS_SUBTYPE_IMPLEMENTS) - .setCardinalidad(Cardinalidad.MIN_TO_INF(0)), - new NodeVar("fieldTypeOrSubtype"))), - new Path(new NodeVar("fieldTypeOrSubtype"), "accessibleMembers", - Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), RelationTypes.DECLARES_FIELD, - TypeRelations.ITS_TYPE_IS, TypeRelations.INHERITS_FIELD), - new NodeVar("accessibleMember")))), - new SimpleWithClause( - "field,fieldType=fieldTypeOrSubtype as isFieldType,enclosingType, method,accessibleMember,fieldTypeOrSubtype, NODES(accessibleMembers) as accessibleMembers"), - new SimpleWithClause( - "field,isFieldType,enclosingType, accessibleMembers,accessibleMember,fieldTypeOrSubtype, COLLECT(DISTINCT method.fullyQualifiedName+'( line '+method.lineNumber+')') as publicGetters, EXTRACT(index IN RANGE(0,SIZE( accessibleMembers)-1,1) | [CASE WHEN index=0 THEN field ELSE accessibleMembers[index-1] END, accessibleMembers[index]]) as accessibleMembersAndPrevs"), - new SimpleWithClause( - "field,isFieldType,enclosingType, accessibleMember,fieldTypeOrSubtype, publicGetters, accessibleMembersAndPrevs,LAST(accessibleMembersAndPrevs)[0] as accessibleMemberPrev"), - - new UnwindClause("accessibleMembersAndPrevs", "accMemberAndPrev"), - new MatchClause(true, - getStatementServices() - .getMethodFromStatement( - new MatchImpl("(accesibleField)-[:USED_BY]->(fieldExpr)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", Pair.create("accessLevel", "public"))) - .append(Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD, - TypeRelations.INHERITS_METHOD), new NodeVar("accessibleType")))), - new WhereClause( - "ID(accesibleField)=ID(accMemberAndPrev[1]) AND ID(accessibleType)=ID(accMemberAndPrev[0])"), - new SimpleWithClause( - " field,isFieldType,enclosingType, method,publicGetters,accMemberAndPrev as accMemberOrType, accessibleMember,accessibleMemberPrev,fieldTypeOrSubtype, COLLECT(method) as gettersForCurrentMember"), - - new SimpleWithClause( - "DISTINCT field,isFieldType,enclosingType,fieldTypeOrSubtype,publicGetters,accessibleMember,accessibleMemberPrev, ALL( isAccHere IN COLLECT( CASE WHEN accMemberOrType[1]:ATTR_DEF THEN NOT accMemberOrType[1].isStatic AND (accMemberOrType[1].accessLevel='public' OR SIZE(gettersForCurrentMember)>0) ELSE CASE WHEN accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE EXISTS(accMemberOrType[1].accessLevel) AND accMemberOrType[1].accessLevel='public' END END) WHERE isAccHere) as isExternallyAcc "), - - // new ReturnClause( - // "field,enclosingType,fieldTypeOrSubtype,publicGetters,accessibleMembers,accessibleMember, - // COLLECT( CASE WHEN accMemberOrType[1]:ATTR_DEC THEN NOT - // accMemberOrType[1].isStatic AND - // (accMemberOrType[1].accessLevel='public' OR - // SIZE(relevantGetters)>0) ELSE CASE WHEN - // accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE - // accMemberOrType[1].accessLevel='public' END END ) as - // accMemberOrTypesInfo"), - // new WhereClause("ALL( isAccHere IN isAccesible WHERE - // isAccHere)"), -// new SimpleWithClause( -// "DISTINCT field,isFieldType,fieldTypeOrSubtype, enclosingType, publicGetters, accessibleMember,accessibleMemberPrev, ALL( isAccHere IN isAccesible WHERE isAccHere) as isExternallyAcc"), - - // new SimpleWithClause( - // "DISTINCT field,isFieldType,fieldTypeOrSubtype, - // enclosingType, publicGetters, - // accessibleMember,accessibleMemberPrev, isExternallyAcc"), - new MatchClause(true, new RelationshipImpl(new NodeVar("accessibleMember"), - new CompleteNode("mutator", NodeTypes.METHOD_DEF, Pair.create("accessLevel", "public")), - RelationTypes.DECLARES_METHOD, TypeRelations.INHERITS_METHOD) - .append(Pair.create( - new EdgeImpl(EdgeDirection.OUTGOING, PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY, - PDGRelationTypes.STATE_MODIFIED_BY), - new CompleteNode(NodeTypes.THIS_REF)))), - - // new SimpleWithClause( "field, enclosingType, publicGetters, - // accessibleMember, COLLECT(mutator) as mutators"), - new SimpleWithClause( - "field,isFieldType,fieldTypeOrSubtype,enclosingType, publicGetters,COLLECT(DISTINCT 'MUTATOR METHOD '+mutator.fullyQualifiedName+'( line '+mutator.lineNumber +')') as allMut, EXTRACT(accField IN FILTER(accMember IN COLLECT(DISTINCT accessibleMember) WHERE accMember:ATTR_DEF AND NOT accMember.isStatic AND NOT accMember.isFinal AND accMember.accessLevel='public') | 'PUBLIC NON-FINAL FIELD '+accField.name+'( line'+accField.lineNumber+')') as externallyMutableFields,FILTER(x IN COLLECT( DISTINCT [accessibleMember:ARRAY_TYPE AND isExternallyAcc,'ACCESIBLE ARRAY FIELD ' + accessibleMemberPrev.name+' (line ' +accessibleMemberPrev.lineNumber+')']) WHERE x[0]) as arrayFieldsExposed"), - - new SimpleWithClause( - "field,isFieldType,enclosingType,publicGetters,fieldTypeOrSubtype.fullyQualifiedName as fieldTypeOrSubtype,allMut,externallyMutableFields, arrayFieldsExposed, SIZE(allMut)>0 OR SIZE(externallyMutableFields)>0 OR SIZE(arrayFieldsExposed)>0 as isExtMutable"), - new WhereClause("CASE WHEN isFieldType THEN isExtMutable ELSE NOT isExtMutable END "), - - new SimpleWithClause( - "field,enclosingType,publicGetters,EXTRACT(subtypeNameInfo IN FILTER(subtypeNameInfo IN COLLECT([isFieldType,fieldTypeOrSubtype]) WHERE NOT subtypeNameInfo[0])| subtypeNameInfo[1]) as immutableSubtypes,FILTER(subTypePair IN COLLECT([isFieldType, allMut+externallyMutableFields+EXTRACT( pair IN arrayFieldsExposed | pair[1])]) WHERE subTypePair[0])[0][1] as mutabilityInfo"), - new WhereClause("NOT mutabilityInfo IS NULL"), - new ClauseImpl("MATCH (cu)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->(enclosingType)") -, - new ReturnClause( - "'[CMU-OBJ56;'+cu.fileName+';field_definition;'+field.actualType+'-'+field.name+';'+field.lineNumber+'; Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ " - + "REDUCE(acum='{'+publicGetters[0], string IN TAIL(publicGetters) | acum+','+string)+'}. The problem is that there is at least one member ( like '+ " -// + "REDUCE(acum='{', string IN EXTRACT(e IN mutabilityInfo | CASE WHEN NOT (e[0] IS NULL) THEN e[1] ELSE e END ) - - + "REDUCE( acum='{'+mutabilityInfo[0], string IN TAIL(mutabilityInfo) | acum +','+string)+" -// + "EXTRACT(index IN " -// + "RANGE(0,SIZE(mutabilityInfo)-1) " -// + "| [index+10 OR SIZE(externallyMutableFields)>0" - * ), new ReturnClause( - * "field.name, fieldTypeOrSubtype.fullyQualifiedName, 'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ publicGetters+'. The problem is that there is at least one member ( like '+EXTRACT(mutator IN allMut | 'MUTATOR METHOD '+mutator.fullyQualifiedName+'( line '+mutator.lineNumber +')')+externallyMutableFields+')that can be accessed by a client to change the state of the field '+field.name" - * ) - */ - - // new ReturnClause( - // "field.name,publicGetters,accessibleMember, - // accessibleMembers,accMemberInfo, ALL(accMemberOrType IN - // accMemberInfo WHERE CASE WHEN accMemberOrType[1]:ATTR_DEC - // THEN NOT accMemberOrType[1].isStatic AND - // (accMemberOrType[1].accessLevel='public' OR NOT - // accMemberOrType[2] is NULL) ELSE CASE WHEN - // accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE FALSE END END - // )") - // , - // new WhereClause(new All("accessibleMembersAndPrevs", - // " memberOrType[1]:ATTR_DEC AND (memberOrType[1].isStatic AND - // ( memberOrType[1].accessLevel='public' ) )", - // "memberOrType")) - // , new - // ReturnClause("field,publicGetters,accessibleMembersAndPrevs") - // BIEN - // new MatchClause(true, - // InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(typeDec)), - // - // new SimpleWithClause( - // "DISTINCT typeDec,enclosingType, field, method,p, CASE WHEN p - // IS NULL THEN [typeDec] else NODES(p) END as nodes"), - // new UnwindClause("nodes", "nodeInP"), - // new SimpleWithClause("enclosingType, field, method, typeDec, - // nodeInP,nodes"), - // new MatchClause(true, - // new Path(new NodeVar("nodeInP"), - // Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), - // RelationTypes.IS_SUBTYPE_EXTENDS, - // RelationTypes.IS_SUBTYPE_IMPLEMENTS), new AnonymousNode()), - // Pair.createP("f", RelationTypes.DECLARES_FIELD), - // - // Pair.createP("mod", PDGRelationTypes.MODIFIED_BY, - // PDGRelationTypes.STATE_MAY_BE_MODIFIED, - // PDGRelationTypes.STATE_MODIFIED_BY)), - // getExpressionServices().getMethodFromExp(new NodeVar("mod"), - // new CompleteNode("setMethod", NodeTypes.METHOD_DEC, - // Pair.create("accessLevel", "public"), Pair.create("isStatic", - // false))), - // - // new MatchImpl("(nodeInP)-[:DECLARES_METHOD]->(setMethod)")), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, CASE - // WHEN setMethod IS NULL THEN [] ELSE COLLECT(setMethod) END as - // setters"), - // - // new MatchClause(true, - // new MatchImpl(new RelationshipImpl(new NodeVar("nodeInP"), - // new AnonymousNode(), - // new EdgeImpl(RelationTypes.DECLARES_METHOD)).relToString() - // + "-[:OVERRIDES]->(ovMethod)")), - // // new WhereClause("publicMethod.accessLevel='public'"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, - // setters, COLLECT(ovMethod) as methodsOverridenByThisType"), - // - // new MatchClause(true, - // new MatchImpl( - // "(nodeInP)-[:IS_SUBTYPE_EXTENDS | - // :IS_SUBTYPE_IMPLEMENTS*0..]->()-[:DECLARES_METHOD]->(getMethod)"), - // getStatementServices().getMethodFromStatement( - // new Path(new NodeVar("nodeInP"), Pair.createP("f", - // RelationTypes.DECLARES_FIELD), - // Pair.createP("", PDGRelationTypes.USED_BY), - // Pair.createInv("", RelationTypes.RETURN_EXPR)), - // new CompleteNode("getMethod", NodeTypes.METHOD_DEC, - // Pair.create("accessLevel", "public"), Pair.create("isStatic", - // false)))), - // new MatchClause(true, - // - // new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - // new EdgeImpl(RelationTypes.ITS_TYPE_IS))), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP,nodes, - // setters,methodsOverridenByThisType, COLLECT(DISTINCT - // getMethod) as getters, COLLECT(DISTINCT fType) as - // getterTypes"), - // new MatchClause(true, - // new Path(new NodeVar("nodeInP"), - // Pair.createP(new CompleteNode("f", Pair.create("isStatic", - // false), - // Pair.create("accessLevel", "public")), - // RelationTypes.DECLARES_FIELD), - // Pair.create(new EdgeImpl(RelationTypes.ITS_TYPE_IS), new - // NodeVar("fType")))), - // new SimpleWithClause( - // "enclosingType, field, method, - // typeDec,nodeInP,nodes,methodsOverridenByThisType, setters, - // getters,getterTypes, COLLECT(DISTINCT [f,fType]) as - // otherMutableDependencies "), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec, nodeInP, nodes, - // setters,methodsOverridenByThisType, getters,getterTypes, " - // + new Extract(new Filter("otherMutableDependencies", - // "x[0].isFinal"), "y[1]", "y") - // .expToString() - // + " as mutableDependenciesBis, " - // + new Any("otherMutableDependencies", "NOT - // x[0].isFinal").expToString() - // + " as isMutableDueToPublicField "), - // // new ReturnClause("enclosingType, field, method, typeDec, - // // nodeInP, p, setters") - // // new WhereClause("SIZE(NODES(p))=12"), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec, nodes" - //// - // + ", - // COLLECT([ID(nodeInP),[isMutableDueToPublicField,mutableDependenciesBis,methodsOverridenByThisType,setters, - // getters,getterTypes ]]) as map " - //// - // ), - // new SimpleWithClause("enclosingType, field, - // method,typeDec,nodes as prevNodes" - // - // + "," - // + new Extract("nodes", - // "x+HEAD(" + new Filter("map", "y[0]=ID(x)", - // "y").expToString() + ")[1]").expToString() - // + " as nodes" - // - // ), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec,prevNodes, " + new Extract("nodes", - // "[x[0],CASE WHEN x[1] IS NULL THEN FALSE ELSE x[1] END, CASE - // WHEN x[2] IS NULL THEN [] ELSE x[2] END, CASE WHEN x[3] IS - // NULL THEN [] ELSE x[3] END, CASE WHEN x[4] IS NULL THEN [] - // ELSE x[4] END,CASE WHEN x[5] IS NULL THEN [] ELSE x[5] END, - // CASE WHEN x[6] IS NULL THEN [] ELSE x[6] END]") - // .expToString() - // + " as nodes" - //// - // ) - // , new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, CASE WHEN - // nodes IS NULL THEN [] ELSE nodes END as nodes "), - // - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, nodes, - // RANGE(0,SIZE(nodes)-1,1) as indexes"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes, nodes, - // indexes, EXTRACT(index IN indexes | CASE WHEN SIZE(FILTER(i - // IN indexes WHERE i=lastAttrIndexes[index]", "i").expToString(), - // "s+nodes[x][3]", "s=[]").expToString() - // - // , "index").expToString() + " as overrides, indexes, - // lastAttrIndexes"), - // new SimpleWithClause("enclosingType, field, method, - // typeDec,prevNodes, " + new Extract("indexes", - // "[nodes[x][0], nodes[x][1] OR ANY(setter IN nodes[x][4] WHERE - // NOT setter IN overrides[x]) " - // - // + ", nodes[x][2]+ EXTRACT( getterIndex IN FILTER(gf IN - // RANGE(0,SIZE(nodes[x][5])-1,1) " - // + "WHERE NOT nodes[x][5][gf] IN overrides[x]) | - // nodes[x][6][getterIndex])] ") - // .expToString() - // + " as nodes, indexes"), - //// new SimpleWithClause("enclosingType, field, method, - // typeDec,p, " + new Extract("indexes", - // // "[nodes[x][0], nodes[x][1]," + new Case("x>0 AND NOT - // // nodes[x+1] IS NULL", - // // "CASE WHEN nodes[x][0]:ATTR_DEC THEN nodes[x+1][0] IN - // // nodes[x-1][2] ELSE TRUE END", - //// "TRUE").expToString() + "] ").expToString() - //// + " as nodes"), - // new SimpleWithClause( - // "enclosingType, field, method, typeDec,prevNodes,indexes, " + - // new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," + new Case("x>1 AND - // nodes[x-1][0]:ATTR_DEC", - // " ANY(dep IN nodes[x-2][2] WHERE dep =nodes[x][0])", - // "TRUE").expToString() - // + "] ").expToString() - // + " as nodes"), - // new SimpleWithClause("DISTINCT enclosingType, field, method, - // typeDec, " - // + new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," - // + "NOT ANY(i IN indexes WHERE i<=x AND NOT nodes[i][2]) - // ]").expToString() - // + " as nodes ORDER BY typeDec"), - // // new SimpleWithClause( - // // "enclosingType, field, method,typeDec,p, CASE WHEN - // // SIZE(nodes)=0 THEN []+typeDec ELSE nodes END as nodes "), - // // new WhereClause("SIZE(nodes)=0"), - // new SimpleWithClause( - // "DISTINCT enclosingType, field, method, typeDec," - // + new Reduce("nodes", - // "s AND CASE WHEN x[0]:ATTR_DEC THEN TRUE ELSE NOT x[2] OR - // (NOT x[0]:ARRAY_TYPE AND NOT x[1]) END ", - // "s=true") - // .expToString() - // + " AND NOT typeDec:ARRAY_TYPE as res" - // - // ), - // new SimpleWithClause( - // "enclosingType, field,method, typeDec,ANY (x IN COLLECT(res) - // WHERE NOT x) as isMutable"), - // new SimpleWithClause("enclosingType, field,COLLECT(method) as - // methods, typeDec,isMutable"), - // - // new WhereClause("isMutable"), - // // FILTRAR - // // , - // new SimpleWithClause("COLLECT([enclosingType, field, methods, - // typeDec]) as res"), - // new UnwindClause("res", "typeRes"), - // new SimpleWithClause( - // "typeRes[1] as field, typeRes[3] as typeDec, typeRes[0] as - // enclosingType,typeRes[2] as methods, res"), - // new MatchClause(true, - // new MatchImpl("(typeDec)<-[:IS_SUBTYPE_EXTENDS | - // :IS_SUBTYPE_IMPLEMENTS*0..]-(subType)")), - // new - // SimpleWithClause("typeDec,methods,enclosingType,field,res, - // COLLECT(subType) as subtypes"), - // new SimpleWithClause( - // "typeDec,EXTRACT(m IN methods | m.fullyQualifiedName) as - // methods,enclosingType,field,res, FILTER(y IN subtypes WHERE - // NOT y IN EXTRACT(x IN res | x[3])) as nonMutableSubTypes"), - // new ReturnClause( - // " 'Warning[OBJ-56] Field ' +field.name+' declared in line ' - // +field.lineNumber+' in class - // '+enclosingType.fullyQualifiedName+' is not public, but it is - // exposed in public methods such as '+ methods+'. The problem - // is that the type '+typeDec.fullyQualifiedName+' (a posible - // class of the field '+field.name+') can be mutated by a - // malicious client.'+CASE WHEN SIZE(nonMutableSubTypes)=0 THEN - // ' You should implement an appropiate inmutable subtype as a - // wrapper for your attribute, as you have not created any - // yet.'ELSE 'Remember to use an appropiate inmutable subtype - // (such as '+EXTRACT(x IN nonMutableSubTypes | - // x.fullyQualifiedName)+') as a wrapper for your attribute.'END - // ") - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, " - // + new Extract("nodesWithInfo", "x[0]").expToString() - // + ",p, SIZE(NODES(p)), SIZE(nodesWithInfo)") - - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, NODES(p) ") - }; - } - - // WTIH ATTR, DECLARING TYPE - // public static void main(String[] args) { - // System.out.println(new OBJ56_SIMPLIFIED().queryToString()); - // } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_TEST.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_TEST.java deleted file mode 100644 index bcd1685..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/pq/OBJ56_TEST.java +++ /dev/null @@ -1,222 +0,0 @@ -package database.querys.cypherWrapper.cmu.pq; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.Case; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.Extract; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.Reduce; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.InmutabilityServicesPQ; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56_TEST extends AbstractQuery { - - public OBJ56_TEST(boolean isProgQuery) { - super(isProgQuery); - - } - - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - new MatchClause( - getStatementServices().getMethodFromStatement( - new MatchImpl( - "(enclosingType{accessLevel:'public'})-[:DECLARES_FIELD]->(field)-[:USED_BY]->(id)<-[:RETURN_EXPR]-()"), - new CompleteNode("method", NodeTypes.METHOD_DEF)), - // DECLARED IN A PUBLIC TYPE - new MatchImpl( - "(field)-[:ITS_TYPE_IS]->()<-[:IS_SUBTYPE_EXTENDS|IS_SUBTYPE_IMPLEMENTS*0..]-(typeDec)")), - new WhereClause("NOT field.accessLevel='public' AND method.accessLevel='public'"), - new SimpleWithClause("DISTINCT typeDec,enclosingType, field, method"), - // BIEN - new MatchClause(true, InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(typeDec)), - - new SimpleWithClause( - "DISTINCT typeDec,enclosingType, field, method,p, CASE WHEN p IS NULL THEN [typeDec] else NODES(p) END as nodes"), - new UnwindClause("nodes", "nodeInP"), - new SimpleWithClause("enclosingType, field, method, typeDec, nodeInP,nodes"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), TypeRelations.IS_SUBTYPE_EXTENDS, - TypeRelations.IS_SUBTYPE_IMPLEMENTS), new AnonymousNode()), - Pair.createP("f", RelationTypes.DECLARES_FIELD), - - Pair.createP("mod", PDGRelationTypes.MODIFIED_BY, - PDGRelationTypes.STATE_MAY_BE_MODIFIED_BY, PDGRelationTypes.STATE_MODIFIED_BY)), - getExpressionServices().getMethodFromExp(new NodeVar("mod"), - new CompleteNode("setMethod", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"), Pair.create("isStatic", false))), - - new MatchImpl("(nodeInP)-[:DECLARES_METHOD]->(setMethod)")), - - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,nodes, CASE WHEN setMethod IS NULL THEN [] ELSE COLLECT(setMethod) END as setters"), - - new MatchClause(true, - new MatchImpl(new RelationshipImpl(new NodeVar("nodeInP"), new AnonymousNode(), - new EdgeImpl(RelationTypes.DECLARES_METHOD)).relToString() - + "-[:OVERRIDES]->(ovMethod)")), - // new WhereClause("publicMethod.accessLevel='public'"), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,nodes, setters, COLLECT(ovMethod) as methodsOverridenByThisType"), - - new MatchClause(true, - new MatchImpl( - "(nodeInP)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->()-[:DECLARES_METHOD]->(getMethod)"), - getStatementServices().getMethodFromStatement( - new Path(new NodeVar("nodeInP"), Pair.createP("f", RelationTypes.DECLARES_FIELD), - Pair.createP("", PDGRelationTypes.USED_BY), - Pair.createInv("", RelationTypes.RETURN_EXPR)), - new CompleteNode("getMethod", NodeTypes.METHOD_DEF, - Pair.create("accessLevel", "public"), Pair.create("isStatic", false)))), - new MatchClause(true, - - new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS))), - - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,nodes, setters,methodsOverridenByThisType, COLLECT(DISTINCT getMethod) as getters, COLLECT(DISTINCT fType) as getterTypes"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.createP(new CompleteNode("f", Pair.create("isStatic", false), - Pair.create("accessLevel", "public")), RelationTypes.DECLARES_FIELD), - Pair.create(new EdgeImpl(TypeRelations.ITS_TYPE_IS), new NodeVar("fType")))), - new SimpleWithClause( - "enclosingType, field, method, typeDec,nodeInP,nodes,methodsOverridenByThisType, setters, getters,getterTypes, COLLECT(DISTINCT [f,fType]) as otherMutableDependencies "), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP, nodes, setters,methodsOverridenByThisType, getters,getterTypes, " - + new Extract(new Filter("otherMutableDependencies", "x[0].isFinal"), "y[1]", "y") - .expToString() - + " as mutableDependenciesBis, " - + new Any("otherMutableDependencies", "NOT x[0].isFinal").expToString() - + " as isMutableDueToPublicField "), - // new ReturnClause("enclosingType, field, method, typeDec, - // nodeInP, p, setters") - // new WhereClause("SIZE(NODES(p))=12"), - new SimpleWithClause("DISTINCT enclosingType, field, method, typeDec, nodes" -// - + ", COLLECT([ID(nodeInP),[isMutableDueToPublicField,mutableDependenciesBis,methodsOverridenByThisType,setters, getters,getterTypes ]]) as map " -// - ), - new SimpleWithClause("enclosingType, field, method,typeDec,nodes as prevNodes" - - + "," - + new Extract("nodes", - "x+HEAD(" + new Filter("map", "y[0]=ID(x)", - "y").expToString() + ")[1]").expToString() - + " as nodes" - - ), - new SimpleWithClause("DISTINCT enclosingType, field, method, typeDec,prevNodes, " + new Extract("nodes", - "[x[0],CASE WHEN x[1] IS NULL THEN FALSE ELSE x[1] END, CASE WHEN x[2] IS NULL THEN [] ELSE x[2] END, CASE WHEN x[3] IS NULL THEN [] ELSE x[3] END, CASE WHEN x[4] IS NULL THEN [] ELSE x[4] END,CASE WHEN x[5] IS NULL THEN [] ELSE x[5] END, CASE WHEN x[6] IS NULL THEN [] ELSE x[6] END]") - .expToString() - + " as nodes" -// - ) - , new SimpleWithClause( - "enclosingType, field, method, typeDec,prevNodes, CASE WHEN nodes IS NULL THEN [] ELSE nodes END as nodes "), - - new SimpleWithClause( - "enclosingType, field, method, typeDec,prevNodes, nodes, RANGE(0,SIZE(nodes)-1,1) as indexes"), - new SimpleWithClause( - "enclosingType, field, method, typeDec,prevNodes, nodes, indexes, EXTRACT(index IN indexes | CASE WHEN SIZE(FILTER(i IN indexes WHERE i=lastAttrIndexes[index]", "i").expToString(), - "s+nodes[x][3]", "s=[]").expToString() - - , "index").expToString() + " as overrides, indexes, lastAttrIndexes"), - new SimpleWithClause("enclosingType, field, method, typeDec,prevNodes, " + new Extract("indexes", - "[nodes[x][0], nodes[x][1] OR ANY(setter IN nodes[x][4] WHERE NOT setter IN overrides[x]) " - - + ", nodes[x][2]+ EXTRACT( getterIndex IN FILTER(gf IN RANGE(0,SIZE(nodes[x][5])-1,1) " - + "WHERE NOT nodes[x][5][gf] IN overrides[x]) | nodes[x][6][getterIndex])] ") - .expToString() - + " as nodes, indexes"), -// new SimpleWithClause("enclosingType, field, method, typeDec,p, " + new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," + new Case("x>0 AND NOT - // nodes[x+1] IS NULL", - // "CASE WHEN nodes[x][0]:ATTR_DEC THEN nodes[x+1][0] IN - // nodes[x-1][2] ELSE TRUE END", -// "TRUE").expToString() + "] ").expToString() -// + " as nodes"), - new SimpleWithClause( - "enclosingType, field, method, typeDec,prevNodes,indexes, " + new Extract("indexes", - "[nodes[x][0], nodes[x][1]," + new Case("x>1 AND nodes[x-1][0]:ATTR_DEC", - " ANY(dep IN nodes[x-2][2] WHERE dep =nodes[x][0])", "TRUE").expToString() - + "] ").expToString() - + " as nodes"), - new SimpleWithClause("DISTINCT enclosingType, field, method, typeDec, " - + new Extract("indexes", - "[nodes[x][0], nodes[x][1]," - + "NOT ANY(i IN indexes WHERE i<=x AND NOT nodes[i][2]) ]").expToString() - + " as nodes ORDER BY typeDec"), - // new SimpleWithClause( - // "enclosingType, field, method,typeDec,p, CASE WHEN - // SIZE(nodes)=0 THEN []+typeDec ELSE nodes END as nodes "), - // new WhereClause("SIZE(nodes)=0"), - new SimpleWithClause( - "DISTINCT enclosingType, field, method, typeDec," - + new Reduce("nodes", - "s AND CASE WHEN x[0]:ATTR_DEC THEN TRUE ELSE NOT x[2] OR (NOT x[0]:ARRAY_TYPE AND NOT x[1]) END ", - "s=true") - .expToString() - + " AND NOT typeDec:ARRAY_TYPE as res" - - ), - new SimpleWithClause( - "enclosingType, field,method, typeDec,ANY (x IN COLLECT(res) WHERE NOT x) as isMutable"), - new SimpleWithClause("enclosingType, field,COLLECT(method) as methods, typeDec,isMutable"), - - new WhereClause("isMutable"), - // FILTRAR - // , - new SimpleWithClause("COLLECT([enclosingType, field, methods, typeDec]) as res"), - new UnwindClause("res", "typeRes"), - new SimpleWithClause( - "typeRes[1] as field, typeRes[3] as typeDec, typeRes[0] as enclosingType,typeRes[2] as methods, res"), - new MatchClause(true, - new MatchImpl("(typeDec)<-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]-(subType)")), - new SimpleWithClause("typeDec,methods,enclosingType,field,res, COLLECT(subType) as subtypes"), - new SimpleWithClause( - "typeDec,EXTRACT(m IN methods | m.fullyQualifiedName) as methods,enclosingType,field,res, FILTER(y IN subtypes WHERE NOT y IN EXTRACT(x IN res | x[3])) as nonMutableSubTypes"), - new ReturnClause( - " 'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ methods+'. The problem is that the type '+typeDec.fullyQualifiedName+' (a posible class of the field '+field.name+') can be mutated by a malicious client.'+CASE WHEN SIZE(nonMutableSubTypes)=0 THEN ' You should implement an appropiate inmutable subtype as a wrapper for your attribute, as you have not created any yet.'ELSE 'Remember to use an appropiate inmutable subtype (such as '+EXTRACT(x IN nonMutableSubTypes | x.fullyQualifiedName)+') as a wrapper for your attribute.'END ") - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, " - // + new Extract("nodesWithInfo", "x[0]").expToString() - // + ",p, SIZE(NODES(p)), SIZE(nodesWithInfo)") - - // new ReturnClause( - // "enclosingType.fullyQualifiedName, field.name, method.name, - // typeDec.fullyQualifiedName, NODES(p) ") - }; - } - - // WTIH ATTR, DECLARING TYPE - public static void main(String[] args) { - System.out.println(new OBJ56_TEST(true).queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/CFGTest.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/CFGTest.java deleted file mode 100644 index e2def7b..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/CFGTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.NodeVar; - -public class CFGTest extends AbstractQuery { - - public CFGTest() { - super(false); - } - - @Override - protected void initiate() { - - clauses = new Clause[] { (Clause) getCFGServices().getCFGSuccesorsOf(new NodeVar("newStat"), ""), - // new ClauseImpl("MATCH (prevStat) WHERE prevStat IN FILTER(x - // IN succesors WHERE x[0]=modStat)[0][1]"), -// new ReturnClause( -// "DISTINCT newStat, if, innerStatement, ifRel, otherifRel ") - /* - * , new - * MatchClause - * ( - * true, - * new - * MatchImpl - * ( - * "(invSel)<-[:METHODINVOCATION_METHOD_SELECT]-(inv)" - * ), - * getExpressionServices - * (). - * getStatementFromExp - * (new - * NodeVar - * ( - * "inv" - * ), - * new - * NodeVar - * ( - * "prevStat" - * )), - * getStatementServices - * (). - * getEnclosingClassFromStatement - * (new - * NodeVar - * ( - * "prevStat" - * ))), - * new - * MatchClause - * ( - * true, - * new - * MatchImpl - * ( - * "(invSel)-[:MEMBER_SELECT_EXPR]->(object)" - * )), - * new - * MatchClause - * ( - * true, - * new - * MatchImpl - * ( - * "(classDec)-[:DECLARES_METHOD]->(methodDec)-[:HAS_METHODDECL_THROWS]->(throw)" - * )), - * new - * WhereClause( - * "(NOT object IS NULL AND object.actualType=classDec.fullyQualifiedName) OR (object IS NULL AND enclClass=classDec)" - * ), - * new - * SimpleWithClause("identss, closeableDec, object, newStat, closeStat,modStat,succesors,throw,prevStat" - * ), - * new - * MatchClause - * ( - * true, - * getStatementServices - * (). - * getOuterBlockFromStatement - * (new - * NodeVar - * ( - * "prevStat" - * ), - * new - * NodeVar - * ( - * "try" - * )) - * - * , new - * MatchImpl( - * "(try)-[:TRY_FINALLY | :TRY_CATCH | :CATCH_BLOCK *]->(afterBlock{nodeType:'JCBlock'})" - * ) , - * getStatementServices - * (). - * getStatementsInStatement - * (new - * NodeVar - * ( - * "afterBlock" - * )) ), - * new - * SimpleWithClause( - * "try.nodeType='JCTry' AND (prevStat.nodeType='JCThrow' OR NOT throw IS NULL OR prevStat.nodeType='JCAssert')" - * ), - * new - * ReturnClause( - * "identss, closeableDec, object, prevStat, newStat, closeStat,modStat,succesors,throw, COLLECT(innerStatement)as statementsAfterEx " - * ), - * new - * WhereClause(" closeStat IN FILTER(x IN succesors WHERE x[0]=prevStat)[0][1]" - * ), - * new - * ReturnClause( - * "identss, closeableDec, object, newStat,COLLECT(prevStat) as prevStats, closeStat,modStat,succesors,throw, statementsAfterEx " - * ), - * - */ - }; - } - - public static void main(String[] args) { - System.out.println(new CFGTest().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53.java deleted file mode 100644 index e9952f7..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53.java +++ /dev/null @@ -1,149 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; - -public class DCL53 extends AbstractQuery { - /* - * " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEC) " + - * "OPTIONAL MATCH (attr)-[:USED_BY]->(exprUse)<-[" + exprToOutExprQuery + - * "*0..]-(outUseExpr)<-[" + exprToStatQueryWithReturn + - * "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) + - * "*]-(outerBlock)<-[:HAS_METHODDECL_BODY]-() WITH typeDec.fullyQualifiedName as className, attr,outerBlock, exprUseStat, exprUse" - * - * - * + " OPTIONAL MATCH (attr)-[:MODIFIED_BY]->(modif)<-[" + - * - * - * getAnyRel(assignToOutExprNoCond) + "*0..]-(outModExpr)<-[" + - * exprToStatQueryWithReturn + "]-(exprModStat)<-[" + - * getAnyRel(statToOuterBlock) + "*]-(outerBlock), - * - * (modif)-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE exprModStat.position < - * exprUseStat.position " + - * - * - * " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - * + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" + - * " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - * + - * " WITH p,className, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat, exprModStat " - * + " OPTIONAL MATCH q=(exprModStat)<-[" + getAnyRel(statToOuterBlock) + - * "*0..]-(minimumCommonBlock), (minimumCommonBlock)-[" + - * getAnyRel(statToOuterBlock) + "*0..]->(exprUseStat) " + - * " WITH className, attr, exprUse, ANY(x IN COLLECT((NOT ANY(rel IN RELS(q) WHERE type(rel)='FORLOOP_UPDATE' OR type(rel)='IF_ELSE' OR type(rel)='FORLOOP_UPDATE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - * + - * " AND ((exprUse:IDENTIFIER OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse:IDENTIFIER AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - * + - * " AND (lhs_expr:IDENTIFIER OR (NOT memberSelectExprModif IS NULL AND memberSelectExprModif:IDENTIFIER AND (memberSelectExprModif.name='this' OR memberSelectExprModif.name='super'))) ) OR " - * + - * " (p IS NOT NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER))) WHERE x) as useWithModif " - * + - * " WITH className, attr, ALL( x IN COLLECT(useWithModif) WHERE x) OR exprUse IS NULL as isSillyAttr WHERE isSillyAttr" - * + - * " RETURN 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+' in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).'" - */ - public DCL53(boolean isProgQuery) { - super(isProgQuery); - - } - - @Override - protected void initiate() { - clauses = new Clause[] { new ClauseImpl( - OBJ56.CREATE_ALL_SUBTYPE_RELS+" WITH DISTINCT 'l' as l "), - new MatchClause(false,"(var{nodeType:'JCVariableDecl'})"), - new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar(new NodeVar("var"), "")), -//,new UnwindClause("ids","id"), -//new ClauseImpl("CREATE (id)-[:HAS_DEC]->(var)"), -new SimpleWithClause("COLLECT([var, ids]) as identss") - -,new UnwindClause("identss","p"), - -new SimpleWithClause("p[0] as attr, p[1] as ids, identss"), - - - - - new MatchClause(new MatchImpl("(classMod)<-[:HAS_CLASS_MODIFIERS]-(typeDec)-[:DECLARES_FIELD]->(attr)-[:HAS_VARIABLEDECL_MODIFIERS]->(attrMod)")), - new WhereClause("NOT ( (attrMod.flags CONTAINS 'public' OR attrMod.flags CONTAINS 'protected' AND NOT classMod.flags CONTAINS 'final') AND classMod.flags CONTAINS 'public' ) AND " - + " NOT( attrMod.flags CONTAINS 'static' AND attr.actualType='long' AND attrMod.flags CONTAINS 'final' AND attr.name='serialVersionUID') " - ), -// new MatchClause(true, "(attr)<-[:HAS_DEC]-(id)"), -// new SimpleWithClause("typeDec,attr,COLLECT( id) as ids"), -// new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar(new NodeVar("attr"), "typeDec,")), -// -// new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar(new NodeVar("attr"), "typeDec,")), -// new WhereClause(" attr=varDec "), -// new SimpleWithClause("typeDec,attr,COLLECT( id) as ids"), - new MatchClause(true, new MatchImpl("(modif{nodeType:'JCAssign'})-[:ASSIGNMENT_LHS ]->(id)")), - new WhereClause(" id IN ids"), - new SimpleWithClause("identss,typeDec,attr,COLLECT( id) as assignIds, ids"), - -// new ReturnClause("typeDec.fullyQualifiedName,attr.name, EXTRACT( a IN assignIds |a.lineNumber), EXTRACT (a IN FILTER(id IN ids WHERE NOT id IN assignIds) |a.lineNumber)") - new SimpleWithClause("identss,typeDec,attr, assignIds,FILTER(id IN ids WHERE NOT id IN assignIds) as useIds"), -// , new ReturnClause("typeDec.fullyQualifiedName,attr.name, EXTRACT( a IN assignIds |a.lineNumber), EXTRACT( a IN useIds|a.lineNumber)") - - new SimpleWithClause("identss,typeDec,attr,CASE WHEN SIZE(assignIds)=0 THEN [null] ELSE assignIds END as assignIds," - + "CASE WHEN SIZE(useIds)=0 THEN [null] ELSE useIds END as useIds"), - new UnwindClause("useIds", "useId"), - new UnwindClause("assignIds", "assignId"), -// new ReturnClause("typeDec.fullyQualifiedName,attr.name,useId.lineNumber, assignId.lineNumber") -// - - new MatchClause(true,getStatementServices().getMethodFromStatement( - getExpressionServices().getStatementFromExp(new NodeVar("useId")), new NodeVar("method"))), - new WhereClause("method.nodeType='JCMethodDecl'"), - - new SimpleWithClause("identss,typeDec.fullyQualifiedName as className,attr,useId, assignId, method, stat as useStat"), - - new MatchClause(true, getStatementServices().getMethodFromStatement( - getExpressionServices().getStatementFromExp(new NodeVar("assignId")), new NodeVar("method"))), - new ClauseImpl(" OPTIONAL MATCH (useId)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)" - + " WITH identss,attr, assignId, useId, useStat,stat, method, memberSelectExprUse, className,FILTER(x IN identss WHERE memberSelectExprUse IN x[1])[0][0] as varDec"), - new MatchClause(true, new MatchImpl("(assignId)-[:MEMBER_SELECT_EXPR]->(memberSelectModif)")), - new SimpleWithClause( - "attr, useStat,stat, method, memberSelectExprUse, varDec,memberSelectModif,className,FILTER(x IN identss WHERE memberSelectModif IN x[1])[0][0] as modifIdvarDec,useId, assignId"), - new MatchClause(true, - getStatementServices().getOuterBlockFromStatement(new NodeVar("useStat"), - new NodeVar("commonBlock")), - new Path(getStatementServices().getOuterBlockFromStatement(new NodeVar("stat"), - new NodeVar("commonBlock")), "modifStatToCommonBlockPath")), - new SimpleWithClause("className,attr,useId," -// + " stat,RELS(modifStatToCommonBlockPath), (((useId.nodeType='JCIdent' OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse.nodeType='JCIdent' AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super'))) AND (assignId.nodeType='JCIdent' OR (NOT memberSelectModif IS NULL AND memberSelectModif.nodeType='JCIdent' AND (memberSelectModif.name='this' OR memberSelectModif.name='super'))) ) OR (NOT memberSelectExprUse IS NULL AND NOT memberSelectModif IS NULL AND varDec=modifIdvarDec)) " - + "ANY(x IN COLLECT(NOT stat IS NULL AND stat.position < useStat.position AND " - + "NOT ANY(rel IN RELS(modifStatToCommonBlockPath) WHERE type(rel)='FORLOOP_UPDATE' OR type(rel)='IF_ELSE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') AND " - + "(((useId.nodeType='JCIdent' OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse.nodeType='JCIdent' AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super'))) AND (assignId.nodeType='JCIdent' OR (NOT memberSelectModif IS NULL AND memberSelectModif.nodeType='JCIdent' AND (memberSelectModif.name='this' OR memberSelectModif.name='super'))) ) OR (NOT memberSelectExprUse IS NULL AND NOT memberSelectModif IS NULL AND varDec=modifIdvarDec))" - + ") WHERE x) as assBefore " - ), - new SimpleWithClause("className,attr,ALL( x IN COLLECT(assBefore) WHERE x) OR useId IS NULL as isSillyAttr " ), - new WhereClause("isSillyAttr"), -// new WhereClause("ALL(x IN areSillyUses WHERE x)") , - //notUseBefore -// new ReturnClause("className, attr.name as a") - // new SimpleWithClause("typeDec, attr, ALL(x IN COLLECT(stat) WHERE x IS NULL) as isSillyAttr"), -// - new SimpleWithClause( - "DISTINCT 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr.name+' in class '+className + ' by transforming it into a local variable (as everytime its value is used in a method, there is a previous unconditional assignment).' as warning "), - new SimpleWithClause(" DISTINCT COLLECT(warning) as warningList "), - new ClauseImpl("MATCH ()-[r{created:true}]->() DELETE r "), - new ReturnClause("DISTINCT warningList") -// , new ReturnClause(" warningList") - - }; - } - - public static void main(String[] args) { - System.out.println(new DCL53(false).queryToString()); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53Simple.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53Simple.java deleted file mode 100644 index 8edea1a..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53Simple.java +++ /dev/null @@ -1,79 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; - -public class DCL53Simple extends AbstractQuery { - /* - * " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEC) " + - * "OPTIONAL MATCH (attr)-[:USED_BY]->(exprUse)<-[" + exprToOutExprQuery + - * "*0..]-(outUseExpr)<-[" + exprToStatQueryWithReturn + - * "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) + - * "*]-(outerBlock)<-[:HAS_METHODDECL_BODY]-() WITH typeDec.fullyQualifiedName as className, attr,outerBlock, exprUseStat, exprUse" - * - * - * + " OPTIONAL MATCH (attr)-[:MODIFIED_BY]->(modif)<-[" + - * - * - * getAnyRel(assignToOutExprNoCond) + "*0..]-(outModExpr)<-[" + - * exprToStatQueryWithReturn + "]-(exprModStat)<-[" + - * getAnyRel(statToOuterBlock) + - * "*]-(outerBlock), (modif)-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE exprModStat.position < exprUseStat.position " - * + - * " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - * + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" + - * " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - * + - * " WITH p,className, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat, exprModStat " - * + " OPTIONAL MATCH q=(exprModStat)<-[" + getAnyRel(statToOuterBlock) + - * "*0..]-(minimumCommonBlock), (minimumCommonBlock)-[" + - * getAnyRel(statToOuterBlock) + "*0..]->(exprUseStat) " + - * " WITH className, attr, exprUse, ANY(x IN COLLECT((NOT ANY(rel IN RELS(q) WHERE type(rel)='FORLOOP_UPDATE' OR type(rel)='IF_ELSE' OR type(rel)='FORLOOP_UPDATE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - * + - * " AND ((exprUse:IDENTIFIER OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse:IDENTIFIER AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - * + - * " AND (lhs_expr:IDENTIFIER OR (NOT memberSelectExprModif IS NULL AND memberSelectExprModif:IDENTIFIER AND (memberSelectExprModif.name='this' OR memberSelectExprModif.name='super'))) ) OR " - * + - * " (p IS NOT NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER))) WHERE x) as useWithModif " - * + - * " WITH className, attr, ALL( x IN COLLECT(useWithModif) WHERE x) OR exprUse IS NULL as isSillyAttr WHERE isSillyAttr" - * + - * " RETURN 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+' in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).'" - */ - public DCL53Simple(boolean isProgQuery) { - super(isProgQuery); - } - - @Override - protected void initiate() { - clauses = new Clause[] { - // new MatchClause(new - // MatchImpl("(typeDec)-[:DECLARES_FIELD]->(attr) ")), - // new MatchClause(true, - // getPDGServices().getCompleteIdentification(new NodeVar("id"), - // "typeDec,attr,")), - // new MatchClause(true, new - // MatchImpl("(modif{nodeType:'JCAssign'})-[:ASSIGNMENT_LHS]->()-[*0..]->(id)")), - // // new WhereClause("attr=dec"), - // new SimpleWithClause( - // "typeDec,attr,COLLECT( DISTINCT [id,dec,modif]) as - // identificationsWithOpModif, identss"), - // - // new UnwindClause("identificationsWithOpModif", "x"), - // new - // SimpleWithClause("identificationsWithOpModif,x,typeDec,attr,identss"), - // new UnwindClause("identificationsWithOpModif", "y"), new - // SimpleWithClause("typeDec,attr,y,x,identss"), - // new WhereClause("attr=x[1] AND attr=y[1] AND x[2] IS NULL AND - // NOT y[2] IS NULL"), - // new ReturnClause("x[0],y") - new MatchClause( - getPDGServices().getCompleteIdentification(new NodeVar("id"), "")), - new ReturnClause("id, dec ORDER BY id.position") - }; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_MEDIO.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_MEDIO.java deleted file mode 100644 index 50ea97e..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_MEDIO.java +++ /dev/null @@ -1,149 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; - -public class DCL53_MEDIO extends AbstractQuery { - /* - * " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEC) " + - * "OPTIONAL MATCH (attr)-[:USED_BY]->(exprUse)<-[" + exprToOutExprQuery + - * "*0..]-(outUseExpr)<-[" + exprToStatQueryWithReturn + - * "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) + - * "*]-(outerBlock)<-[:HAS_METHODDECL_BODY]-() WITH typeDec.fullyQualifiedName as className, attr,outerBlock, exprUseStat, exprUse" - * - * - * + " OPTIONAL MATCH (attr)-[:MODIFIED_BY]->(modif)<-[" + - * - * - * getAnyRel(assignToOutExprNoCond) + "*0..]-(outModExpr)<-[" + - * exprToStatQueryWithReturn + "]-(exprModStat)<-[" + - * getAnyRel(statToOuterBlock) + "*]-(outerBlock), - * - * (modif)-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE exprModStat.position < - * exprUseStat.position " + - * - * - * " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - * + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" + - * " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - * + - * " WITH p,className, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat, exprModStat " - * + " OPTIONAL MATCH q=(exprModStat)<-[" + getAnyRel(statToOuterBlock) + - * "*0..]-(minimumCommonBlock), (minimumCommonBlock)-[" + - * getAnyRel(statToOuterBlock) + "*0..]->(exprUseStat) " + - * " WITH className, attr, exprUse, ANY(x IN COLLECT((NOT ANY(rel IN RELS(q) WHERE type(rel)='FORLOOP_UPDATE' OR type(rel)='IF_ELSE' OR type(rel)='FORLOOP_UPDATE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - * + - * " AND ((exprUse:IDENTIFIER OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse:IDENTIFIER AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - * + - * " AND (lhs_expr:IDENTIFIER OR (NOT memberSelectExprModif IS NULL AND memberSelectExprModif:IDENTIFIER AND (memberSelectExprModif.name='this' OR memberSelectExprModif.name='super'))) ) OR " - * + - * " (p IS NOT NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER))) WHERE x) as useWithModif " - * + - * " WITH className, attr, ALL( x IN COLLECT(useWithModif) WHERE x) OR exprUse IS NULL as isSillyAttr WHERE isSillyAttr" - * + - * " RETURN 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+' in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).'" - */ - public DCL53_MEDIO(boolean isProgQuery) { - super(isProgQuery); - - } - - @Override - protected void initiate() { - clauses = new Clause[] { - /* new MatchClause(false,"(var{nodeType:'JCVariableDecl'})"), - new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar(new NodeVar("var"), "")) -,new UnwindClause("ids","id"), -new ClauseImpl("CREATE (id)-[:HAS_DEC]->(var)"), -new SimpleWithClause("var, COLLECT(id) as ids"),*/ - new MatchClause(false,"(var{nodeType:'JCVariableDecl'})"), - new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar( "")), -//,new UnwindClause("ids","id"), -//new ClauseImpl("CREATE (id)-[:HAS_DEC]->(var)"), -new SimpleWithClause("COLLECT([var, ids]) as identss") - -,new UnwindClause("identss","p"), - -new SimpleWithClause("p[0] as attr, p[1] as ids, identss"), - - - - - new MatchClause(new MatchImpl("(classMod)<-[:HAS_CLASS_MODIFIERS]-(typeDec)-[:DECLARES_FIELD]->(attr)-[:HAS_VARIABLEDECL_MODIFIERS]->(attrMod)")), - new WhereClause("NOT ( (attrMod.flags CONTAINS 'public' OR attrMod.flags CONTAINS 'protected' AND NOT classMod.flags CONTAINS 'final') AND classMod.flags CONTAINS 'public' ) AND " - + " NOT( attrMod.flags CONTAINS 'static' AND attr.actualType='long' AND attrMod.flags CONTAINS 'final' AND attr.name='serialVersionUID') " - ), - new MatchClause(true, "(attr)<-[:HAS_DEC]-(id)"), - new SimpleWithClause("typeDec,attr,COLLECT( id) as ids"), -// new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar(new NodeVar("attr"), "typeDec,")), -// -// new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar(new NodeVar("attr"), "typeDec,")), -// new WhereClause(" attr=varDec "), -// new SimpleWithClause("typeDec,attr,COLLECT( id) as ids"), - new MatchClause(true, new MatchImpl("(modif{nodeType:'JCAssign'})-[:ASSIGNMENT_LHS ]->(id)")), - new WhereClause(" id IN ids"), - new SimpleWithClause("typeDec,attr,COLLECT( id) as assignIds, ids"), - -// new ReturnClause("typeDec.fullyQualifiedName,attr.name, EXTRACT( a IN assignIds |a.lineNumber), EXTRACT (a IN FILTER(id IN ids WHERE NOT id IN assignIds) |a.lineNumber)") - new SimpleWithClause("typeDec,attr, assignIds,FILTER(id IN ids WHERE NOT id IN assignIds) as useIds"), -// , new ReturnClause("typeDec.fullyQualifiedName,attr.name, EXTRACT( a IN assignIds |a.lineNumber), EXTRACT( a IN useIds|a.lineNumber)") - - new SimpleWithClause("typeDec,attr,CASE WHEN SIZE(assignIds)=0 THEN [null] ELSE assignIds END as assignIds," - + "CASE WHEN SIZE(useIds)=0 THEN [null] ELSE useIds END as useIds"), - new UnwindClause("useIds", "useId"), - new UnwindClause("assignIds", "assignId"), -// new ReturnClause("typeDec.fullyQualifiedName,attr.name,useId.lineNumber, assignId.lineNumber") -// - - new MatchClause(true,getStatementServices().getMethodFromStatement( - getExpressionServices().getStatementFromExp(new NodeVar("useId")), new NodeVar("method"))), - new WhereClause("method.nodeType='JCMethodDecl'"), - - new SimpleWithClause("typeDec.fullyQualifiedName as className,attr,useId, assignId, method, stat as useStat"), - - new MatchClause(true, getStatementServices().getMethodFromStatement( - getExpressionServices().getStatementFromExp(new NodeVar("assignId")), new NodeVar("method"))), - new ClauseImpl(" OPTIONAL MATCH (useId)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)-[:HAS_DEC]->(varDec)" - + " WITH attr, assignId, useId, useStat,stat, method, memberSelectExprUse, className, varDec"), - new MatchClause(true, new MatchImpl("(assignId)-[:MEMBER_SELECT_EXPR]->(memberSelectModif)-[:HAS_DEC]->(modifIdvarDec)")), - new SimpleWithClause( - "attr, useStat,stat, method, memberSelectExprUse, varDec,memberSelectModif,className,modifIdvarDec,useId, assignId"), - new MatchClause(true, - getStatementServices().getOuterBlockFromStatement(new NodeVar("useStat"), - new NodeVar("commonBlock")), - new Path(getStatementServices().getOuterBlockFromStatement(new NodeVar("stat"), - new NodeVar("commonBlock")), "modifStatToCommonBlockPath")), - new SimpleWithClause("className,attr,useId," -// + " stat,RELS(modifStatToCommonBlockPath), (((useId.nodeType='JCIdent' OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse.nodeType='JCIdent' AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super'))) AND (assignId.nodeType='JCIdent' OR (NOT memberSelectModif IS NULL AND memberSelectModif.nodeType='JCIdent' AND (memberSelectModif.name='this' OR memberSelectModif.name='super'))) ) OR (NOT memberSelectExprUse IS NULL AND NOT memberSelectModif IS NULL AND varDec=modifIdvarDec)) " - + "ANY(x IN COLLECT(NOT stat IS NULL AND stat.position < useStat.position AND " - + "NOT ANY(rel IN RELS(modifStatToCommonBlockPath) WHERE type(rel)='FORLOOP_UPDATE' OR type(rel)='IF_ELSE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') AND " - + "(((useId.nodeType='JCIdent' OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse.nodeType='JCIdent' AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super'))) AND (assignId.nodeType='JCIdent' OR (NOT memberSelectModif IS NULL AND memberSelectModif.nodeType='JCIdent' AND (memberSelectModif.name='this' OR memberSelectModif.name='super'))) ) OR (NOT memberSelectExprUse IS NULL AND NOT memberSelectModif IS NULL AND varDec=modifIdvarDec))" - + ") WHERE x) as assBefore " - ), - new SimpleWithClause("className,attr,ALL( x IN COLLECT(assBefore) WHERE x) OR useId IS NULL as isSillyAttr " ), - new WhereClause("isSillyAttr"), -// new WhereClause("ALL(x IN areSillyUses WHERE x)") , - //notUseBefore -// new ReturnClause("className, attr.name as a") - // new SimpleWithClause("typeDec, attr, ALL(x IN COLLECT(stat) WHERE x IS NULL) as isSillyAttr"), -// - new ReturnClause("DISTINCT 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr.name+' in class '+className + ' by transforming it into a local variable (as everytime its value is used in a method, there is a previous unconditional assignment).' as w ORDER BY w") - - - }; - } - - public static void main(String[] args) { - System.out.println(new DCL53_MEDIO(false).queryToString()); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_OLD.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_OLD.java deleted file mode 100644 index 42d8c75..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_OLD.java +++ /dev/null @@ -1,124 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; - -public class DCL53_OLD extends AbstractQuery { - /* - * " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEC) " + - * "OPTIONAL MATCH (attr)-[:USED_BY]->(exprUse)<-[" + exprToOutExprQuery + - * "*0..]-(outUseExpr)<-[" + exprToStatQueryWithReturn + - * "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) + - * "*]-(outerBlock)<-[:HAS_METHODDECL_BODY]-() WITH typeDec.fullyQualifiedName as className, attr,outerBlock, exprUseStat, exprUse" - * - * - * + " OPTIONAL MATCH (attr)-[:MODIFIED_BY]->(modif)<-[" + - * - * - * getAnyRel(assignToOutExprNoCond) + "*0..]-(outModExpr)<-[" + - * exprToStatQueryWithReturn + "]-(exprModStat)<-[" + - * getAnyRel(statToOuterBlock) + "*]-(outerBlock), - * - * (modif)-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE exprModStat.position < - * exprUseStat.position " + - * - * - * " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - * + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" + - * " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - * + - * " WITH p,className, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat, exprModStat " - * + " OPTIONAL MATCH q=(exprModStat)<-[" + getAnyRel(statToOuterBlock) + - * "*0..]-(minimumCommonBlock), (minimumCommonBlock)-[" + - * getAnyRel(statToOuterBlock) + "*0..]->(exprUseStat) " + - * " WITH className, attr, exprUse, ANY(x IN COLLECT((NOT ANY(rel IN RELS(q) WHERE type(rel)='FORLOOP_UPDATE' OR type(rel)='IF_ELSE' OR type(rel)='FORLOOP_UPDATE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - * + - * " AND ((exprUse:IDENTIFIER OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse:IDENTIFIER AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - * + - * " AND (lhs_expr:IDENTIFIER OR (NOT memberSelectExprModif IS NULL AND memberSelectExprModif:IDENTIFIER AND (memberSelectExprModif.name='this' OR memberSelectExprModif.name='super'))) ) OR " - * + - * " (p IS NOT NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER))) WHERE x) as useWithModif " - * + - * " WITH className, attr, ALL( x IN COLLECT(useWithModif) WHERE x) OR exprUse IS NULL as isSillyAttr WHERE isSillyAttr" - * + - * " RETURN 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+' in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).'" - */ - public DCL53_OLD(boolean isProgQuery) { - super(isProgQuery); - } - - @Override - protected void initiate() { - clauses = new Clause[] { new MatchClause(new MatchImpl("(typeDec)-[:DECLARES_FIELD]->(attr) ")), - new MatchClause(true, getPDGServices().getCompleteIdentification(new NodeVar("id"), "typeDec,attr,")), - new MatchClause(true, new MatchImpl("(modif{nodeType:'JCAssign'})-[:ASSIGNMENT_LHS]->()-[*0..]->(id)")), - // new WhereClause("attr=dec"), - new SimpleWithClause( - "typeDec,attr,COLLECT( DISTINCT [id,dec,modif]) as identificationsWithOpModif, identss"), - - new UnwindClause("identificationsWithOpModif", "x"), - new SimpleWithClause("identificationsWithOpModif,x,typeDec,attr,identss"), - new UnwindClause("identificationsWithOpModif", "y"), new SimpleWithClause("typeDec,attr,y,x,identss"), - new WhereClause("attr=x[1] AND attr=y[1] AND x[2] IS NULL AND NOT y[2] IS NULL"), - - new SimpleWithClause( - "typeDec.fullyQualifiedName as className,attr,x[0] as useExpr, y[0] as modifId, y[2] as modif,identss"), - new MatchClause(getStatementServices().getMethodFromStatement( - getExpressionServices().getStatementFromExp(new NodeVar("useExpr")), new NodeVar("method"))), - new WhereClause("method.nodeType='JCMethodDecl'"), - new SimpleWithClause("className,attr,useExpr,stat as useStat,method, modifId, modif,identss"), - new MatchClause(getStatementServices().getMethodFromStatement( - getExpressionServices().getStatementFromExp(new NodeVar("modif")), new NodeVar("method")), - new MatchImpl("(modif)-[:ASSIGNMENT_LHS]->(lhs_expr)")), - new WhereClause("stat.position < useStat.position"), - - new SimpleWithClause("attr,useExpr, modifId, modif, lhs_expr, useStat,stat, method,identss,className"), - new ClauseImpl(" OPTIONAL MATCH (useExpr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)" - + " WITH attr,useExpr, modifId, modif, lhs_expr, useStat,stat, method, memberSelectExprUse, identss,className," - + new Filter("identss", "x[0]=memberSelectExprUse").expToString() + "[0][1] as varDec"), - new MatchClause(true, new MatchImpl("(modifId)-[:MEMBER_SELECT_EXPR]->(memberSelectModif)")), - new SimpleWithClause( - "attr,useExpr, modifId, modif, lhs_expr, useStat,stat, method, memberSelectExprUse, varDec,memberSelectModif,className" - + ", " + new Filter("identss", "x[0]=memberSelectModif").expToString() - + "[0][1] as modifIdvarDec"), - // new WhereClause(new Filter("identss", - // "x[0]=memberSelectModif").expToString()+"[0][1]=varDec OR ()" - // ) - new MatchClause(true, - getStatementServices().getOuterBlockFromStatement(new NodeVar("useStat"), - new NodeVar("commonBlock")), - new Path(getStatementServices().getOuterBlockFromStatement(new NodeVar("stat"), - new NodeVar("commonBlock")), "modifStatToCommonBlockPath")), - new SimpleWithClause( - "className,attr, useExpr, ANY(x IN COLLECT((NOT ANY(rel IN RELS(modifStatToCommonBlockPath) WHERE type(rel)='FORLOOP_UPDATE' OR type(rel)='IF_ELSE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - + " AND ((useExpr.nodeType='JCIdent' OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse.nodeType='JCIdent' AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - + " AND (modifId.nodeType='JCIdent' OR (NOT memberSelectModif IS NULL AND memberSelectModif.nodeType='JCIdent' AND (memberSelectModif.name='this' OR memberSelectModif.name='super'))) ) OR " - + // tenemos la restriccion condicional y - // (posibilidad de attr o this.super.attr o - // posibilidad de z.attr z.attr) - "(NOT memberSelectExprUse IS NULL AND NOT memberSelectModif IS NULL AND varDec=modifIdvarDec))) WHERE x) as useWithModif " - - ), - new ClauseImpl( - "WITH className,attr, ALL( x IN COLLECT(useWithModif) WHERE x) OR useExpr IS NULL as isSillyAttr WHERE isSillyAttr "), - new ReturnClause( - "'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr.name+' in class '+className + ' by transforming it into a local variable (as everytime its value is used in a method, there is a previous unconditional assignment).'") - - }; - } - - public static void main(String[] args) { - System.out.println(new DCL53_OLD(false).queryToString()); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_V2.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_V2.java deleted file mode 100644 index bb960ec..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/DCL53_V2.java +++ /dev/null @@ -1,129 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; - -public class DCL53_V2 extends AbstractQuery { - /* - * " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEC) " + - * "OPTIONAL MATCH (attr)-[:USED_BY]->(exprUse)<-[" + exprToOutExprQuery + - * "*0..]-(outUseExpr)<-[" + exprToStatQueryWithReturn + - * "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) + - * "*]-(outerBlock)<-[:HAS_METHODDECL_BODY]-() WITH typeDec.fullyQualifiedName as className, attr,outerBlock, exprUseStat, exprUse" - * - * - * + " OPTIONAL MATCH (attr)-[:MODIFIED_BY]->(modif)<-[" + - * - * - * getAnyRel(assignToOutExprNoCond) + "*0..]-(outModExpr)<-[" + - * exprToStatQueryWithReturn + "]-(exprModStat)<-[" + - * getAnyRel(statToOuterBlock) + "*]-(outerBlock), - * - * (modif)-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE exprModStat.position < - * exprUseStat.position " + - * - * - * " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - * + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" + - * " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - * + - * " WITH p,className, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat, exprModStat " - * + " OPTIONAL MATCH q=(exprModStat)<-[" + getAnyRel(statToOuterBlock) + - * "*0..]-(minimumCommonBlock), (minimumCommonBlock)-[" + - * getAnyRel(statToOuterBlock) + "*0..]->(exprUseStat) " + - * " WITH className, attr, exprUse, ANY(x IN COLLECT((NOT ANY(rel IN RELS(q) WHERE type(rel)='FORLOOP_UPDATE' OR type(rel)='IF_ELSE' OR type(rel)='FORLOOP_UPDATE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - * + - * " AND ((exprUse:IDENTIFIER OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse:IDENTIFIER AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - * + - * " AND (lhs_expr:IDENTIFIER OR (NOT memberSelectExprModif IS NULL AND memberSelectExprModif:IDENTIFIER AND (memberSelectExprModif.name='this' OR memberSelectExprModif.name='super'))) ) OR " - * + - * " (p IS NOT NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER))) WHERE x) as useWithModif " - * + - * " WITH className, attr, ALL( x IN COLLECT(useWithModif) WHERE x) OR exprUse IS NULL as isSillyAttr WHERE isSillyAttr" - * + - * " RETURN 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+' in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).'" - */ - public DCL53_V2(boolean isProgQuery) { - super(isProgQuery); - - } - - @Override - protected void initiate() { - clauses = new Clause[] { - new MatchClause(false,"(var{nodeType:'JCVariableDecl'})"), - new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar("")), -//,new UnwindClause("ids","id"), -//new ClauseImpl("CREATE (id)-[:HAS_DEC]->(var)"), -new SimpleWithClause("COLLECT([var, ids]) as identss") - -,new UnwindClause("identss","p"), - -new SimpleWithClause("p[0] as var, p[1] as ids, identss"), - - new MatchClause(new MatchImpl("(classMod)<-[:HAS_CLASS_MODIFIERS]-(typeDec)-[:DECLARES_FIELD]->(attr)-[:HAS_VARIABLEDECL_MODIFIERS]->(attrMod)")), - new WhereClause("NOT ( (attrMod.flags CONTAINS 'public' OR attrMod.flags CONTAINS 'protected' AND NOT classMod.flags CONTAINS 'final') AND classMod.flags CONTAINS 'public' ) AND " - + " NOT( attrMod.flags CONTAINS 'static' AND attr.actualType='long' AND attrMod.flags CONTAINS 'final' AND attr.name='serialVersionUID') " - ), -// new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar(new NodeVar("attr"), "typeDec,")), -// -// new MatchClause(true, getPDGServices().getCompleteIdentificationFromVar(new NodeVar("attr"), "typeDec,")), -// new WhereClause(" attr=varDec "), -// new SimpleWithClause("typeDec,attr,COLLECT( id) as ids"), - new MatchClause(true, new MatchImpl("(modif{nodeType:'JCAssign'})-[:ASSIGNMENT_LHS ]->(id)")), - new WhereClause(" id IN ids"), - new SimpleWithClause("typeDec,attr,COLLECT( id) as assignIds, ids, identss"), - -// new ReturnClause("typeDec.fullyQualifiedName,attr.name, EXTRACT( a IN assignIds |a.lineNumber), EXTRACT (a IN FILTER(id IN ids WHERE NOT id IN assignIds) |a.lineNumber)") - new SimpleWithClause("identss,typeDec,attr, assignIds,FILTER(id IN ids WHERE NOT id IN assignIds) as useIds"), -// , new ReturnClause("typeDec.fullyQualifiedName,attr.name, EXTRACT( a IN assignIds |a.lineNumber), EXTRACT( a IN useIds|a.lineNumber)") - - new SimpleWithClause("identss,typeDec,attr,CASE WHEN SIZE(assignIds)=0 THEN [null] ELSE assignIds END as assignIds," - + "CASE WHEN SIZE(useIds)=0 THEN [null] ELSE useIds END as useIds"), - new UnwindClause("useIds", "useId"), - new UnwindClause("assignIds", "assignId"), -// new ReturnClause("typeDec.fullyQualifiedName,attr.name,useId.lineNumber, assignId.lineNumber") -// - - new MatchClause(true,getStatementServices().getMethodFromStatement( - getExpressionServices().getStatementFromExp(new NodeVar("useId")), new NodeVar("method"))), - new WhereClause("method.nodeType='JCMethodDecl'"), - - new SimpleWithClause("identss,typeDec.fullyQualifiedName as className,attr,useId, assignId, method, stat as useStat"), - - new MatchClause(true, getStatementServices().getMethodFromStatement( - getExpressionServices().getStatementFromExp(new NodeVar("assignId")), new NodeVar("method"))), - new ClauseImpl(" OPTIONAL MATCH (useId)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)" - + " WITH identss,attr, assignId, useStat,stat, method, memberSelectExprUse, className,FILTER(x IN identss WHERE memberSelectExprUse IN x[1])[0][0] as varDec"), - new MatchClause(true, new MatchImpl("(assignId)-[:MEMBER_SELECT_EXPR]->(memberSelectModif)")), - new SimpleWithClause( - "attr, useStat,stat, method, memberSelectExprUse, varDec,memberSelectModif,className,FILTER(x IN identss WHERE memberSelectExprUse IN x[1])[0][0] as modifIdvarDec"), - - new SimpleWithClause("className,attr,useStat, COLLECT(NOT stat IS NULL AND stat.position < useStat.position) as assBefore"), - new SimpleWithClause("className,attr,COLLECT( NOT useStat IS NULL AND NOT ANY(x IN assBefore WHERE x)) as properUse" ), -// new SimpleWithClause("typeDec,attr, useStat IS NULL OR NOT ANY(x IN assBefore WHERE x) as properUse" ), - - new WhereClause("ALL(x IN properUse WHERE NOT x)") , - //notUseBefore - new ReturnClause("className, attr.name as a, properUse ORDER BY a") - // new SimpleWithClause("typeDec, attr, ALL(x IN COLLECT(stat) WHERE x IS NULL) as isSillyAttr"), -// new WhereClause("isSillyAttr"), -// new ReturnClause("typeDec.fullyQualifiedName,attr.name as a ORDER BY a") - - - }; - } - - public static void main(String[] args) { - System.out.println(new DCL53_V2(false).queryToString()); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54.java deleted file mode 100644 index c24e118..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54.java +++ /dev/null @@ -1,423 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.MethodInvocationServicesWiggle; -import database.querys.services.PDGServicesWiggle; -import database.querys.services.TypeServicesWiggle; - -public class ERR54 extends AbstractQuery { - - /* - * " MATCH (closeableSubtype)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(closeableInt:INTERFACE_DECLARATION{fullyQualifiedName:'java.lang.AutoCloseable'})" - * + - * " WHERE closeableSubtype:CLASS_DECLARATION OR closeableSubtype:INTERFACE_DECLARATION " - * + " WITH DISTINCT closeableSubtype.fullyQualifiedName as className " - * - * + - * " MATCH (closeableDec{actualType:className})-[:MODIFIED_BY]->(assign) <-[" - * + assignToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery + - * "]-(assignStat) " + - * - * - * - * - * " OPTIONAL MATCH (closeableDec)<-[r:TRY_RESOURCES]-() WITH assignStat,r, closeableDec WHERE r IS NULL" - * - * + - * "MATCH (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'close'})-[:MEMBER_SELECT_EXPR]->(id)<-[:USED_BY]-(closeableDec)," - * + " (mInv)<-[" + exprToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery - * + "]-(closeStat)" + ", - * - * (assignStat)-[" + cfgSuccesor + "*1..]->(prev)" + - * "-[:IF_THERE_IS_UNCAUGHT_EXCEPTION | :MAY_THROW | :THROWS]->(afterEx)" + - * - * " WITH COLLECT(DISTINCT closeStat) AS closes, prev,closeableDec, afterEx" - * - * - * + " MATCH (prev)-[" + cfgSuccesor + - * "*]->(closeStat) WHERE closeStat IN closes" + - * - * " WITH closes,COLLECT(DISTINCT prev) AS prevs, afterEx, closeableDec" + - * - * " WITH closes, [prev IN prevs WHERE NOT prev IN closes] as prevs, afterEx , closeableDec" - * + " WHERE SIZE(prevs)>=1 " + " MATCH (afterEx)-[" + - * getAnyRel(toCFGSuccesorNoCondEx) + - * "*0..]->(reachableAfterEx) WITH closes,COLLECT(reachableAfterEx) AS reachable, prevs, closeableDec" - * + " WHERE ALL(r IN reachable WHERE NOT r IN closes)" - * - * + - * " RETURN 'Warning [CMU-ERR54] variable '+closeableDec.name+ '(defined in line'+closeableDec.lineNumber+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN prevs | prev.lineNumber)+') may throw an exception.'" - * - * - */ - private final String EXCEPTION_HIER = "" + - "[['java.io.IOException',['java.lang.Exception','java.lang.Throwable'],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.net.MalformedURLException','java.net.SocketException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.util.InvalidPropertiesFormatException','java.util.jar.JarException','java.util.zip.ZipException']],\r\n" + - "['java.lang.AssertionError',['java.lang.Throwable'],['java.lang.AssertionError']],\r\n" + - "['java.lang.NullPointerException',['java.lang.Exception','java.lang.RuntimeException','java.lang.Throwable'],['java.lang.NullPointerException']],\r\n" + - "['java.lang.Throwable',[''],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.lang.AssertionError','java.lang.ClassFormatError','java.lang.ClassNotFoundException','java.lang.CloneNotSupportedException','java.lang.Exception','java.lang.IllegalAccessError','java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.InstantiationException','java.lang.InterruptedException','java.lang.NoSuchFieldException','java.lang.NoSuchMethodException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.Throwable','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.lang.invoke.NoSuchMemberException','java.lang.invoke.T','java.lang.reflect.InvocationTargetException','java.net.MalformedURLException','java.net.SocketException','java.net.URISyntaxException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.security.AccessControlException','java.security.DigestException','java.security.InvalidKeyException','java.security.NoSuchAlgorithmException','java.security.NoSuchProviderException','java.security.PrivilegedActionException','java.security.SignatureException','java.security.cert.CertificateEncodingException','java.security.cert.CertificateException','java.sql.SQLException','java.text.ParseException','java.util.InvalidPropertiesFormatException','java.util.MissingResourceException','java.util.X','java.util.X','java.util.X','java.util.X','java.util.concurrent.ExecutionException','java.util.concurrent.TimeoutException','java.util.jar.JarException','java.util.zip.ZipException','sun.util.locale.LocaleSyntaxException']],\r\n" + - "['java.lang.Exception',['java.lang.Throwable'],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.lang.ClassNotFoundException','java.lang.CloneNotSupportedException','java.lang.Exception','java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.InstantiationException','java.lang.InterruptedException','java.lang.NoSuchFieldException','java.lang.NoSuchMethodException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.lang.invoke.NoSuchMemberException','java.lang.reflect.InvocationTargetException','java.net.MalformedURLException','java.net.SocketException','java.net.URISyntaxException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.security.AccessControlException','java.security.DigestException','java.security.InvalidKeyException','java.security.NoSuchAlgorithmException','java.security.NoSuchProviderException','java.security.PrivilegedActionException','java.security.SignatureException','java.security.cert.CertificateEncodingException','java.security.cert.CertificateException','java.sql.SQLException','java.text.ParseException','java.util.InvalidPropertiesFormatException','java.util.MissingResourceException','java.util.concurrent.ExecutionException','java.util.concurrent.TimeoutException','java.util.jar.JarException','java.util.zip.ZipException','sun.util.locale.LocaleSyntaxException']],\r\n" + - "['java.lang.RuntimeException',['java.lang.Exception','java.lang.Throwable'],['java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.security.AccessControlException','java.util.MissingResourceException']],\r\n" + - "['java.lang.IllegalStateException',['java.lang.Exception','java.lang.RuntimeException','java.lang.Throwable'],['java.lang.IllegalStateException']]]\r\n" + - ""; - private final String METHOD_THAT_THROWS = "[['java.lang.Thread','sleep','(long)',['java.lang.InterruptedException']]\r\n" - + ",['java.io.BufferedReader','readLine','()',['java.io.IOException']]\r\n" - + ",['java.lang.Double','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Integer','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['android.content.res.Resources','getStringArray','(int)',['android.content.res.Resources$NotFoundException']]\r\n" - + ",['android.database.sqlite.SQLiteDatabase','execSQL','(java.lang.String)',['android.database.SQLException']]\r\n" - + ",['android.media.MediaPlayer','start','()',['java.lang.IllegalStateException']]\r\n" - + ",['android.media.MediaPlayer','stop','()',['java.lang.IllegalStateException']]\r\n" - + ",['java.lang.Object','wait','()',['java.lang.InterruptedException']]\r\n" - + ",['java.lang.Integer','parseInt','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Integer','','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','delete','(java.lang.String,int)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','create','(java.lang.String,byte[],java.util.List,org.apache.zookeeper.CreateMode)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','getData','(java.lang.String,boolean,org.apache.zookeeper.data.Stat)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','getChildren','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','exists','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','','(java.lang.String,int,org.apache.zookeeper.Watcher)',['java.io.IOException']]\r\n" - + ",['org.w3c.dom.Node','getNodeValue','()',['org.w3c.dom.DOMException']]\r\n" - + ",['java.io.ObjectInputStream','readObject','()',['java.io.IOException','java.lang.ClassNotFoundException']]\r\n" - + ",['java.io.ObjectInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeObject','(java.lang.Object)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" - + ",['java.io.FileInputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.FileInputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.nio.channels.FileChannel','tryLock','()',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','write','(byte[])',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.lang.reflect.Field','get','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.lang.reflect.Method','invoke','(java.lang.Object,java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['java.lang.Long','parseLong','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.net.InetAddress','getLocalHost','()',['java.net.UnknownHostException']]\r\n" - + ",['java.net.InetAddress','getByName','(java.lang.String)',['java.net.UnknownHostException']]\r\n" - + ",['java.lang.reflect.AccessibleObject','setAccessible','(boolean)',['java.lang.SecurityException']]\r\n" - + ",['java.lang.reflect.Array','get','(java.lang.Object,int)',['java.lang.ArrayIndexOutOfBoundsException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.lang.reflect.Array','getLength','(java.lang.Object)',['java.lang.IllegalArgumentException']]\r\n" - + ",['java.net.DatagramSocket','receive','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" - + ",['java.net.DatagramSocket','send','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" - + ",['java.net.DatagramSocket','setReceiveBufferSize','(int)',['java.net.SocketException']]\r\n" - + ",['java.net.DatagramSocket','','()',['java.net.SocketException']]\r\n" - + ",['java.net.DatagramSocket','','(int)',['java.net.SocketException']]\r\n" - + ",['java.net.MulticastSocket','joinGroup','(java.net.InetAddress)',['java.io.IOException']]\r\n" - + ",['java.net.MulticastSocket','','()',['java.io.IOException']]\r\n" - + ",['java.net.MulticastSocket','','(int)',['java.io.IOException']]\r\n" - + ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object,java.lang.String,int)',['java.awt.HeadlessException']]\r\n" - + ",['javax.xml.parsers.DocumentBuilder','parse','(java.io.InputStream)',['java.io.IOException','org.xml.sax.SAXException']]\r\n" - + ",['javax.xml.parsers.DocumentBuilderFactory','newDocumentBuilder','()',['javax.xml.parsers.ParserConfigurationException']]\r\n" - + ",['java.lang.Class','getDeclaredFields','()',['java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','getMethods','()',['java.lang.SecurityException']]\r\n" - + ",['java.lang.Object','wait','(long)',['java.lang.InterruptedException']]\r\n" - + ",['java.io.Reader','close','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','close','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','write','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.lang.Class','newInstance','()',['java.lang.IllegalAccessException','java.lang.InstantiationException']]\r\n" - + ",['java.lang.Class','getDeclaredMethod','(java.lang.String,java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','getConstructor','(java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','forName','(java.lang.String)',['java.lang.ClassNotFoundException']]\r\n" - + ",['java.io.File','createNewFile','()',['java.io.IOException']]\r\n" - + ",['javax.swing.JApplet','','()',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFrame','','(java.lang.String)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFrame','','()',['java.awt.HeadlessException']]\r\n" - + ",['junit.framework.TestCase','setUp','()',['java.lang.Exception']]\r\n" - + ",['junit.framework.TestCase','tearDown','()',['java.lang.Exception']]\r\n" - + ",['java.io.BufferedReader','close','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','close','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','accept','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','','(int)',['java.io.IOException']]\r\n" - + ",['java.lang.Thread','join','()',['java.lang.InterruptedException']]\r\n" - + ",['java.awt.Robot','','()',['java.awt.AWTException']]\r\n" - + ",['javax.swing.JInternalFrame','setSelected','(boolean)',['java.beans.PropertyVetoException']]\r\n" - + ",['javax.swing.JInternalFrame','setClosed','(boolean)',['java.beans.PropertyVetoException']]\r\n" - + ",['javax.swing.JFileChooser','showOpenDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFileChooser','showSaveDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" - + ",['java.awt.Toolkit','getScreenSize','()',['java.awt.HeadlessException']]\r\n" - + ",['java.awt.KeyboardFocusManager','setCurrentKeyboardFocusManager','(java.awt.KeyboardFocusManager)',['java.lang.SecurityException']]\r\n" - + ",['java.awt.Frame','','()',['java.awt.HeadlessException']]\r\n" - + ",['java.lang.reflect.Field','getInt','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.io.BufferedWriter','close','()',['java.io.IOException']]\r\n" - + ",['java.io.BufferedWriter','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.FileReader','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.InputStreamReader','close','()',['java.io.IOException']]\r\n" - + ",['java.io.FileWriter','','(java.io.File)',['java.io.IOException']]\r\n" - + ",['java.io.FileWriter','','(java.io.File,boolean)',['java.io.IOException']]\r\n" - + ",['java.io.OutputStreamWriter','close','()',['java.io.IOException']]\r\n" - + ",['java.io.OutputStreamWriter','flush','()',['java.io.IOException']]\r\n" - + ",['java.lang.reflect.Constructor','newInstance','(java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.InstantiationException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['java.net.Socket','close','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','getOutputStream','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','getInputStream','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','','(java.net.InetAddress,int)',['java.io.IOException']]\r\n" - + ",['java.util.logging.FileHandler','','(java.lang.String)',['java.io.IOException','java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Handler','setFormatter','(java.util.logging.Formatter)',['java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Logger','setLevel','(java.util.logging.Level)',['java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Logger','addHandler','(java.util.logging.Handler)',['java.lang.SecurityException']]\r\n" - + ",['javax.imageio.ImageIO','write','(java.awt.image.RenderedImage,java.lang.String,java.io.File)',['java.io.IOException']]\r\n" - + ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.SwingUtilities','invokeAndWait','(java.lang.Runnable)',['java.lang.InterruptedException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['ognl.Ognl','getValue','(java.lang.Object,java.util.Map,java.lang.Object)',['ognl.OgnlException']]\r\n" - + ",['ognl.Ognl','parseExpression','(java.lang.String)',['ognl.OgnlException']]\r\n" - + ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentInstance','(java.lang.Object)',['org.picocontainer.PicoRegistrationException']]\r\n" - + ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentImplementation','(java.lang.Class)',['org.picocontainer.PicoRegistrationException']]\r\n" - + ",['java.lang.Class','getFields','()',['java.lang.SecurityException']]\r\n" - + ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','(java.io.Writer)',['java.lang.Exception']]\r\n" - + ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','()',['java.lang.Exception']]\r\n" - + ",['java.beans.Introspector','getBeanInfo','(java.lang.Class)',['java.beans.IntrospectionException']]\r\n" - + ",['java.io.InputStream','available','()',['java.io.IOException']]\r\n" - + ",['java.io.InputStream','reset','()',['java.io.IOException']]\r\n" - + ",['java.lang.String','getBytes','(java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['javax.xml.bind.JAXBContext','createUnmarshaller','()',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.Class[])',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','createMarshaller','()',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.String)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,org.w3c.dom.Node)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Marshaller','setProperty','(java.lang.String,java.lang.Object)',['javax.xml.bind.PropertyException']]\r\n" - + ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,java.io.Writer)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Unmarshaller','unmarshal','(java.io.InputStream)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.transform.Transformer','transform','(javax.xml.transform.Source,javax.xml.transform.Result)',['javax.xml.transform.TransformerException']]\r\n" - + ",['javax.xml.transform.Transformer','setOutputProperty','(java.lang.String,java.lang.String)',['java.lang.IllegalArgumentException']]\r\n" - + ",['javax.xml.transform.TransformerFactory','newInstance','()',['javax.xml.transform.TransformerFactoryConfigurationError']]\r\n" - + ",['javax.xml.transform.TransformerFactory','newTransformer','()',['javax.xml.transform.TransformerConfigurationException']]\r\n" - + ",['org.w3c.dom.Element','removeAttribute','(java.lang.String)',['org.w3c.dom.DOMException']]\r\n" - + ",['org.w3c.dom.Node','getTextContent','()',['org.w3c.dom.DOMException']]\r\n" - + ",['java.io.FilterInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.InputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.BufferedWriter','newLine','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readUTF','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readDouble','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readInt','()',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" - + ",['java.io.FilterOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.File','createTempFile','(java.lang.String,java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.FileReader','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.InputStreamReader','','(java.io.InputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.OutputStreamWriter','','(java.io.OutputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.ObjectInputStream','readUTF','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','readDouble','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','readInt','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" - + ",['java.lang.Double','parseDouble','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Float','parseFloat','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.security.MessageDigest','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['java.util.concurrent.Future','get','()',['java.lang.InterruptedException','java.util.concurrent.ExecutionException']]\r\n" - + ",['java.util.zip.GZIPInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.util.zip.GZIPOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" - + ",['org.apache.commons.logging.LogFactory','getLog','(java.lang.Class)',['org.apache.commons.logging.LogConfigurationException']]\r\n" - + ",['com.sun.akuma.Daemon','init','(java.lang.String)',['java.lang.Exception']]\r\n" - + ",['com.sun.akuma.Daemon','daemonize','()',['java.io.IOException']]\r\n" - + ",['java.lang.String','','(byte[],int,int,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.Reader','read','(char[],int,int)',['java.io.IOException']]\r\n" - + ",['java.net.URI','','(java.lang.String)',['java.net.URISyntaxException']]\r\n" - + ",['java.net.URL','openStream','()',['java.io.IOException']]\r\n" - + ",['java.io.FileInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.net.InetAddress','getByAddress','(byte[])',['java.net.UnknownHostException']]\r\n" - + ",['java.util.Properties','load','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.security.KeyFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['java.security.KeyFactory','generatePrivate','(java.security.spec.KeySpec)',['java.security.spec.InvalidKeySpecException']]\r\n" - + ",['java.security.KeyStore','getInstance','(java.lang.String)',['java.security.KeyStoreException']]\r\n" - + ",['java.security.KeyStore','load','(java.io.InputStream,char[])',['java.io.IOException','java.security.NoSuchAlgorithmException','java.security.cert.CertificateException']]\r\n" - + ",['java.security.cert.CertificateFactory','getInstance','(java.lang.String)',['java.security.cert.CertificateException']]\r\n" - + ",['java.security.cert.CertificateFactory','generateCertificate','(java.io.InputStream)',['java.security.cert.CertificateException']]\r\n" - + ",['javax.net.ssl.KeyManagerFactory','init','(java.security.KeyStore,char[])',['java.security.KeyStoreException','java.security.NoSuchAlgorithmException','java.security.UnrecoverableKeyException']]\r\n" - + ",['javax.net.ssl.KeyManagerFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['javax.net.ssl.SSLContext','init','(javax.net.ssl.KeyManager[],javax.net.ssl.TrustManager[],java.security.SecureRandom)',['java.security.KeyManagementException']]\r\n" - + ",['javax.net.ssl.SSLContext','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['javax.net.ssl.SSLSession','getPeerCertificateChain','()',['javax.net.ssl.SSLPeerUnverifiedException']]\r\n" - + ",['javax.security.cert.Certificate','getEncoded','()',['javax.security.cert.CertificateEncodingException']]\r\n" - + ",['net.oauth.OAuthAccessor','newRequestMessage','(java.lang.String,java.lang.String,java.util.Collection)',['java.io.IOException','java.net.URISyntaxException','net.oauth.OAuthException']]\r\n" - + ",['net.oauth.OAuthMessage','getAuthorizationHeader','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['net.oauth.signature.pem.PEMReader','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['net.oauth.signature.pem.PKCS1EncodedKeySpec','','(byte[])',['java.io.IOException']]\r\n" - + ",['org.apache.log4j.FileAppender','','(org.apache.log4j.Layout,java.lang.String)',['java.io.IOException']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelUpstreamHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelHandler','handleDownstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + "]\r\n"; - - public ERR54() { - super(false); - } - - private static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS | :HAS_CLASS_IMPLEMENTS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m), (mType) WHERE SPLIT(mType.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_OF]->(mType) ON CREATE SET r.created=TRUE " - + "WITH DISTINCT ['java.lang.AutoCloseable','java.io.BufferedReader','java.io.BufferedWriter' ] as autocloseableTypeNames, sucessors "; - - // public static void main(String[] args) { - // System.out.println(new ERR54().queryToString()); - // } - @Override - protected void initiate() { - - clauses = new Clause[] { (Clause) getCFGServices().getCFGSuccesorsOf(new NodeVar("newStat"), ""), - new SimpleWithClause("DISTINCT COLLECT([newStat, succesors]) as sucessors"), - new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - // new ClauseImpl("MATCH (n)-[r:HAS_VARIABLEDECL_INIT]->(m) - // CREATE (n)-[: - new MatchClause(true, TypeServicesWiggle.getSuperTypesOf(new NodeVar("closeableSubtype"))), - new WhereClause("superType.fullyQualifiedName IN autocloseableTypeNames"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames+COLLECT(closeableSubtype.fullyQualifiedName) as autocloseableTypeNames"), - - new MatchClause(true, - " (subtype)-[:IS_SUBTYPE_OF*0..]->(enclClass)-[:DECLARES_METHOD]->(m)-[:HAS_METHODDECL_THROWS]->()"), - new MatchClause(true, " (m)-[:HAS_METHODDECL_PARAMETERS]->(p)"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames, CASE WHEN subtype.fullyQualifiedName CONTAINS '<' THEN SPLIT(subtype.fullyQualifiedName,'<')[0] ELSE subtype.fullyQualifiedName END as enclClass, m,p ORDER BY ID(p)"), - - new SimpleWithClause("autocloseableTypeNames,sucessors, " - + "enclClass, m.name as methodName, REDUCE(s='(', p IN COLLECT(p) | s+p.actualType+',') as paramTypes"), - new SimpleWithClause("DISTINCT autocloseableTypeNames,sucessors, " - + "COLLECT([enclClass, methodName, CASE WHEN paramTypes CONTAINS ',' THEN SUBSTRING(paramTypes, 0,LENGTH(paramTypes)-1) ELSE paramTypes END +')'])+" - + METHOD_THAT_THROWS + " as mThrowsInfo, " - + EXCEPTION_HIER+ - " as exHier" - ), - new MatchClause(true, - "(non_declaredEx)<-[:HAS_CLASS_EXTENDS]-(superDeclaredEx),hier=(declaredEx)-[:IS_SUBTYPE_OF*0..]->(superDeclaredEx)" - + ", (declaredEx)<-[:IS_SUBTYPE_OF*0..]-(subTypeDeclared)" - + " WHERE non_declaredEx.actualType IN EXTRACT(row IN exHier | row[0])" + "" - + " WITH DISTINCT" - + " autocloseableTypeNames,sucessors, mThrowsInfo, " - + " exHier, " - + " [declaredEx.fullyQualifiedName" - + ",EXTRACT(x IN TAIL(NODES(hier)) | x.fullyQualifiedName)+[non_declaredEx.actualType]+ FILTER(hier IN exHier WHERE hier[0]=non_declaredEx.actualType)[0][1]" - + ",EXTRACT(x IN COLLECT(subTypeDeclared) | x.fullyQualifiedName) ] as declaredHier" - + " WITH DISTINCT autocloseableTypeNames,sucessors, mThrowsInfo, exHier+COLLECT(declaredHier) as exHier"), - new ClauseImpl( - "MATCH(inv)<-[:ARRAYACCESS_EXPR|ARRAYACCESS_INDEX|ASSIGNMENT_LHS|ASSIGNMENT_RHS|BINOP_LHS|BINOP_RHS|CAST_ENCLOSES|COMPOUND_ASSIGNMENT_LHS|COMPOUND_ASSIGNMENT_RHS|CONDITIONAL_CONDITION|CONDITIONAL_THEN|CONDITIONAL_ELSE|HAS_VARIABLEDECL_INIT|INSTANCEOF_EXPR|PARENTHESIZED_ENCLOSES|MEMBER_SELECT_EXPR|METHODINVOCATION_ARGUMENTS|METHODINVOCATION_METHOD_SELECT|NEW_CLASS_ARGUMENTS|NEWARRAY_INIT|NEWARRAY_DIMENSION|UNARY_ENCLOSES*0..]-()<-[:ASSERT_CONDITION|DOWHILE_CONDITION|EXPR_ENCLOSES|FOREACH_EXPR|FORLOOP_CONDITION|HAS_VARIABLEDECL_INIT|IF_CONDITION|RETURN_EXPR|SWITCH_EXPR|SYNCHRONIZED_EXPR|THROW_EXPR|WHILE_CONDITION]-(stat)<-[:CASE_STATEMENTS|CATCH_BLOCK|CATCH_PARAM|ENCLOSES|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|HAS_METHODDECL_PARAMETERS|IF_THEN|IF_ELSE|LABELED_STATEMENT|SWITCH_ENCLOSES_CASES|SYNCHRONIZED_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*]-()<-[:HAS_METHODDECL_BODY]-({nodeType:'JCMethodDecl'})<-[:DECLARES_METHOD]-(callerEncType)\r\n" - + " WHERE inv.nodeType IN ['JCMethodInvocation', 'JCNewClass'] " - + "OPTIONAL MATCH (invMember)<-[:METHODINVOCATION_METHOD_SELECT]-(inv)" - + "OPTIONAL MATCH (invMember)-[:MEMBER_SELECT_EXPR]->(memberSelection)" - + "OPTIONAL MATCH (inv)-[:NEW_CLASS_ARGUMENTS]->(arg)" - + " WITH exHier, autocloseableTypeNames,sucessors, mThrowsInfo,stat,inv,invMember,arg, CASE WHEN invMember IS NULL THEN inv.actualType ELSE CASE WHEN invMember.nodeType='JCIdent' THEN callerEncType.fullyQualifiedName ELSE memberSelection.actualType END END as callerEncTypeName ORDER BY ID(arg)" - + " WITH DISTINCT " + "exHier,autocloseableTypeNames,sucessors, mThrowsInfo," - + "stat,inv,invMember, callerEncTypeName, REDUCE(s='(', arg IN COLLECT(arg) | s+CASE WHEN s='(' THEN arg.actualType ELSE ','+arg.actualType END )+')' as newClassArgs "), - - new SimpleWithClause("DISTINCT " - + "exHier,autocloseableTypeNames,sucessors,mThrowsInfo," - + " stat, COLLECT([CASE WHEN callerEncTypeName CONTAINS '<' AND NOT callerEncTypeName STARTS WITH '<' THEN SPLIT(callerEncTypeName,'<')[0] ELSE callerEncTypeName END , CASE WHEN invMember IS NULL THEN '' ELSE invMember.name END,CASE WHEN invMember IS NULL THEN newClassArgs ELSE SPLIT(invMember.actualType,')')[0]+')' END]) as invInfoInStats"), -new SimpleWithClause( - " DISTINCT "+ - "exHier,autocloseableTypeNames,sucessors,mThrowsInfo,"+ - "stat," - + "REDUCE(s=[], x IN " - + "EXTRACT(invSignature IN invInfoInStats | " - + " FILTER(throwSignature IN mThrowsInfo WHERE throwSignature[0]=invSignature[0] AND throwSignature[1]=invSignature[1] AND throwSignature[2]=invSignature[2])[0][3] )" - + "| CASE WHEN x IS NULL THEN s ELSE s+x END ) " - + "as throws " - ) - -, - new SimpleWithClause( - "DISTINCT " - + "exHier, autocloseableTypeNames,sucessors," - + " FILTER(x IN COLLECT( [stat,throws]) WHERE SIZE(x[1])>0) as statsMayThrow"), - new MatchClause(true, - "(stat)-[:THROW_EXPR]->(throwExpr) WITH DISTINCT exHier,autocloseableTypeNames,sucessors, statsMayThrow+COLLECT([stat,throwExpr.actualType]) as statsMayThrow"), - new MatchClause(true, - "(stat{nodeType:'JCAssert'}) WITH DISTINCT " - + "exHier, autocloseableTypeNames,sucessors," - + " statsMayThrow+COLLECT([stat,'java.lang.AssertionError']) as statsMayThrow") - - ,new MatchClause(PDGServicesWiggle.WIGGLE.getIdsAndVarDeclarations(new NodeVar("id"), - "exHier, autocloseableTypeNames,sucessors,statsMayThrow ")), - new SimpleWithClause("exHier, autocloseableTypeNames,sucessors,statsMayThrow ,id, varDec, varDec.actualType IN autocloseableTypeNames as isVarClos"), - new WhereClause("isVarClos"), - new SimpleWithClause( - "DISTINCT exHier,autocloseableTypeNames,sucessors,statsMayThrow, varDec as dec, COLLECT(DISTINCT id) as ids"), - // new ReturnClause("DISTINCT dec, ids"), - new MatchClause(true, - " (dec)<-[r:TRY_RESOURCES]-() WITH DISTINCT exHier,sucessors,statsMayThrow, dec,ids,r WHERE r IS NULL"), - // new ReturnClause("DISTINCT dec") - - new MatchClause(true, - getAssignmentServices().getLeftPartAssignments(new NodeVar("assignment"), new NodeVar("id")), - getExpressionServices().getStatementFromExp(new NodeVar("assignment"))), - new WhereClause("id IN ids"), - new SimpleWithClause(" DISTINCT " + "exHier, sucessors,statsMayThrow,ids, " + "dec, COLLECT(stat) as mods "), - - new MatchClause(true, new MatchImpl("(dec)-[r:HAS_VARIABLEDECL_INIT]->()")), - new SimpleWithClause("DISTINCT " + "exHier, sucessors, statsMayThrow," - + " dec, ids, mods + CASE WHEN r IS NULL THEN [] ELSE [dec] END as mods"), - new UnwindClause("mods", "mod"), - new MatchClause(MethodInvocationServicesWiggle.getMethodInvocationOf("close"), - getExpressionServices().getStatementFromExp(new NodeVar("mInv"), new NodeVar("closeStat"))), - - new WhereClause("object IN ids"), - new SimpleWithClause("DISTINCT exHier,sucessors,statsMayThrow, dec, mod, COLLECT(closeStat) as closeStmts"), - new SimpleWithClause( - " exHier,sucessors,"+ - " dec, mod,closeStmts, FILTER( stat IN statsMayThrow WHERE NOT stat[0] IN closeStmts AND stat[0] IN FILTER(x IN sucessors WHERE x[0]=mod)[0][1]" - + " AND ANY(closeStat IN closeStmts WHERE closeStat IN FILTER(x IN sucessors WHERE x[0]=stat[0])[0][1]) ) as prevStats"), - new UnwindClause("prevStats", "prevStat"), - // new ReturnClause("DISTINCT FILTER(x IN sucessors WHERE - // x[0].nodeType='JCCatch' )") -new SimpleWithClause("exHier,sucessors,dec, mod,closeStmts, prevStat[0] as prevStat, prevStat[1] as throwTypes"), - new MatchClause(true, - "p=" + getStatementServices().getOuterBlockFromStatement(new NodeVar("prevStat"), - new NodeVar("try{nodeType:'JCTry'}")).matchToString()), - new WhereClause("NOT TYPE(REVERSE(RELATIONSHIPS(p))[0]) IN ['TRY_CATCH', 'TRY_FINALLY']"), - - new MatchClause(true, "(try)-[:TRY_CATCH ]->(catch)-[:CATCH_PARAM]->(catchVar)"), - - new SimpleWithClause( - "DISTINCT " - + "sucessors,throwTypes," - + " dec, mod, prevStat,closeStmts, try, catch, FILTER(catchHier IN exHier WHERE catchHier[0]=catchVar.actualType)[0] as catchHier "), - new UnwindClause("throwTypes", "throwType"), - new SimpleWithClause( - "DISTINCT " - + "sucessors," - + " dec, mod, prevStat,closeStmts, try, catch,throwType, throwType IN catchHier[1] as maybeCaught,throwType IN catchHier[2] as alwaysCaught ORDER BY catch.position "), - - -// new SimpleWithClause( -// "DISTINCT sucessors,dec, mod, prevStat,closeStmts, try, REDUCE(l=[],catch IN COLLECT(catch) | l+FILTER(x IN sucessors WHERE x[0]=catch)[0][1] ) as catchSucs"), - new MatchClause(true, - getStatementServices() - .getOuterBlockFromStatement(new NodeVar("finallyStat"), new NodeVar("finally")) - .matchToString() + "<-[:TRY_FINALLY]-(try)"), - - new SimpleWithClause( - "sucessors," - + " dec, mod, prevStat,closeStmts,throwType, FILTER( x IN COLLECT([catch,maybeCaught,alwaysCaught]) WHERE NOT x[0] IS NULL) as catchInfo, COLLECT(finallyStat) as finallySucs") - , - new SimpleWithClause("dec, mod, prevStat,closeStmts, throwType, " - + "REDUCE(l=[],catchSucs IN EXTRACT( x IN FILTER(index IN RANGE(0,SIZE(catchInfo)-1) WHERE (catchInfo[index][1] OR catchInfo[index][2]) AND index<=FILTER(i IN RANGE(0,SIZE(catchInfo)-1) WHERE catchInfo[i][2])[0]) " - + " | FILTER(sucInfo IN sucessors WHERE catchInfo[x][0]=sucInfo[0])[0][1] )" - + "| l+catchSucs) +finallySucs as stmsReacheableAfterEx"), - -// new SimpleWithClause( -// " DISTINCT dec, mod, prevStat,closeStmts, try, CASE WHEN SIZE(catchSucs)=0 THEN COLLECT(finallyStat) ELSE catchSucs END as stmsReacheableAfterEx"), - new SimpleWithClause( - "DISTINCT dec, mod, prevStat,NOT ANY( reacheableStmt IN REDUCE(l=[], reacheables IN COLLECT(stmsReacheableAfterEx) | l+reacheables ) WHERE reacheableStmt IN closeStmts) as notReachebleClose"), - new WhereClause(" notReachebleClose "), - new MatchClause(getStatementServices().getEnclosingClassFromStatement(new NodeVar("dec"))), - new SimpleWithClause( - "DISTINCT 'Warning [CMU-ERR54] variable '+dec.name+ '(defined in line'+dec.lineNumber+', class '+enclClass.fullyQualifiedName+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN COLLECT(DISTINCT prevStat) | prev.lineNumber)+') may throw an exception.' as warning"), - new SimpleWithClause("DISTINCT COLLECT(warning) as warnings"), - new MatchClause(false, "()-[r:IS_SUBTYPE_OF]->() DELETE r WITH DISTINCT warnings RETURN warnings") - // , new WhereClause(" allReacheables ") - }; - } - - public static void main(String[] args) { - System.out.println(new ERR54().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54FALTA_PREV_THROWS.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54FALTA_PREV_THROWS.java deleted file mode 100644 index 0c554f7..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54FALTA_PREV_THROWS.java +++ /dev/null @@ -1,391 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.PDGServicesWiggle; -import database.querys.services.TypeServicesWiggle; - -public class ERR54FALTA_PREV_THROWS extends AbstractQuery { - - /* - * " MATCH (closeableSubtype)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(closeableInt:INTERFACE_DECLARATION{fullyQualifiedName:'java.lang.AutoCloseable'})" - * + - * " WHERE closeableSubtype:CLASS_DECLARATION OR closeableSubtype:INTERFACE_DECLARATION " - * + " WITH DISTINCT closeableSubtype.fullyQualifiedName as className " - * - * + - * " MATCH (closeableDec{actualType:className})-[:MODIFIED_BY]->(assign) <-[" - * + assignToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery + - * "]-(assignStat) " + - * - * - * - * - * " OPTIONAL MATCH (closeableDec)<-[r:TRY_RESOURCES]-() WITH assignStat,r, closeableDec WHERE r IS NULL" - * - * + - * "MATCH (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'close'})-[:MEMBER_SELECT_EXPR]->(id)<-[:USED_BY]-(closeableDec)," - * + " (mInv)<-[" + exprToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery - * + "]-(closeStat)" + ", - * - * (assignStat)-[" + cfgSuccesor + "*1..]->(prev)" + - * "-[:IF_THERE_IS_UNCAUGHT_EXCEPTION | :MAY_THROW | :THROWS]->(afterEx)" + - * - * " WITH COLLECT(DISTINCT closeStat) AS closes, prev,closeableDec, afterEx" - * - * - * + " MATCH (prev)-[" + cfgSuccesor + - * "*]->(closeStat) WHERE closeStat IN closes" + - * - * " WITH closes,COLLECT(DISTINCT prev) AS prevs, afterEx, closeableDec" + - * - * " WITH closes, [prev IN prevs WHERE NOT prev IN closes] as prevs, afterEx , closeableDec" - * + " WHERE SIZE(prevs)>=1 " + " MATCH (afterEx)-[" + - * getAnyRel(toCFGSuccesorNoCondEx) + - * "*0..]->(reachableAfterEx) WITH closes,COLLECT(reachableAfterEx) AS reachable, prevs, closeableDec" - * + " WHERE ALL(r IN reachable WHERE NOT r IN closes)" - * - * + - * " RETURN 'Warning [CMU-ERR54] variable '+closeableDec.name+ '(defined in line'+closeableDec.lineNumber+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN prevs | prev.lineNumber)+') may throw an exception.'" - * - * - */ - private final String EXCEPTION_HIER = "" + - "[['java.io.IOException',['java.lang.Exception','java.lang.Throwable'],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.net.MalformedURLException','java.net.SocketException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.util.InvalidPropertiesFormatException','java.util.jar.JarException','java.util.zip.ZipException']],\r\n" + - "['java.lang.AssertionError',['java.lang.Throwable'],['java.lang.AssertionError']],\r\n" + - "['java.lang.NullPointerException',['java.lang.Exception','java.lang.RuntimeException','java.lang.Throwable'],['java.lang.NullPointerException']],\r\n" + - "['java.lang.Throwable',[''],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.lang.AssertionError','java.lang.ClassFormatError','java.lang.ClassNotFoundException','java.lang.CloneNotSupportedException','java.lang.Exception','java.lang.IllegalAccessError','java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.InstantiationException','java.lang.InterruptedException','java.lang.NoSuchFieldException','java.lang.NoSuchMethodException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.Throwable','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.lang.invoke.NoSuchMemberException','java.lang.invoke.T','java.lang.reflect.InvocationTargetException','java.net.MalformedURLException','java.net.SocketException','java.net.URISyntaxException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.security.AccessControlException','java.security.DigestException','java.security.InvalidKeyException','java.security.NoSuchAlgorithmException','java.security.NoSuchProviderException','java.security.PrivilegedActionException','java.security.SignatureException','java.security.cert.CertificateEncodingException','java.security.cert.CertificateException','java.sql.SQLException','java.text.ParseException','java.util.InvalidPropertiesFormatException','java.util.MissingResourceException','java.util.X','java.util.X','java.util.X','java.util.X','java.util.concurrent.ExecutionException','java.util.concurrent.TimeoutException','java.util.jar.JarException','java.util.zip.ZipException','sun.util.locale.LocaleSyntaxException']],\r\n" + - "['java.lang.Exception',['java.lang.Throwable'],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.lang.ClassNotFoundException','java.lang.CloneNotSupportedException','java.lang.Exception','java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.InstantiationException','java.lang.InterruptedException','java.lang.NoSuchFieldException','java.lang.NoSuchMethodException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.lang.invoke.NoSuchMemberException','java.lang.reflect.InvocationTargetException','java.net.MalformedURLException','java.net.SocketException','java.net.URISyntaxException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.security.AccessControlException','java.security.DigestException','java.security.InvalidKeyException','java.security.NoSuchAlgorithmException','java.security.NoSuchProviderException','java.security.PrivilegedActionException','java.security.SignatureException','java.security.cert.CertificateEncodingException','java.security.cert.CertificateException','java.sql.SQLException','java.text.ParseException','java.util.InvalidPropertiesFormatException','java.util.MissingResourceException','java.util.concurrent.ExecutionException','java.util.concurrent.TimeoutException','java.util.jar.JarException','java.util.zip.ZipException','sun.util.locale.LocaleSyntaxException']],\r\n" + - "['java.lang.RuntimeException',['java.lang.Exception','java.lang.Throwable'],['java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.security.AccessControlException','java.util.MissingResourceException']],\r\n" + - "['java.lang.IllegalStateException',['java.lang.Exception','java.lang.RuntimeException','java.lang.Throwable'],['java.lang.IllegalStateException']]]\r\n" + - ""; - private final String METHOD_THAT_THROWS = "[['java.lang.Thread','sleep','(long)',['java.lang.InterruptedException']]\r\n" - + ",['java.io.BufferedReader','readLine','()',['java.io.IOException']]\r\n" - + ",['java.lang.Double','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Integer','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['android.content.res.Resources','getStringArray','(int)',['android.content.res.Resources$NotFoundException']]\r\n" - + ",['android.database.sqlite.SQLiteDatabase','execSQL','(java.lang.String)',['android.database.SQLException']]\r\n" - + ",['android.media.MediaPlayer','start','()',['java.lang.IllegalStateException']]\r\n" - + ",['android.media.MediaPlayer','stop','()',['java.lang.IllegalStateException']]\r\n" - + ",['java.lang.Object','wait','()',['java.lang.InterruptedException']]\r\n" - + ",['java.lang.Integer','parseInt','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Integer','','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','delete','(java.lang.String,int)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','create','(java.lang.String,byte[],java.util.List,org.apache.zookeeper.CreateMode)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','getData','(java.lang.String,boolean,org.apache.zookeeper.data.Stat)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','getChildren','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','exists','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','','(java.lang.String,int,org.apache.zookeeper.Watcher)',['java.io.IOException']]\r\n" - + ",['org.w3c.dom.Node','getNodeValue','()',['org.w3c.dom.DOMException']]\r\n" - + ",['java.io.ObjectInputStream','readObject','()',['java.io.IOException','java.lang.ClassNotFoundException']]\r\n" - + ",['java.io.ObjectInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeObject','(java.lang.Object)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" - + ",['java.io.FileInputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.FileInputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.nio.channels.FileChannel','tryLock','()',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','write','(byte[])',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.lang.reflect.Field','get','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.lang.reflect.Method','invoke','(java.lang.Object,java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['java.lang.Long','parseLong','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.net.InetAddress','getLocalHost','()',['java.net.UnknownHostException']]\r\n" - + ",['java.net.InetAddress','getByName','(java.lang.String)',['java.net.UnknownHostException']]\r\n" - + ",['java.lang.reflect.AccessibleObject','setAccessible','(boolean)',['java.lang.SecurityException']]\r\n" - + ",['java.lang.reflect.Array','get','(java.lang.Object,int)',['java.lang.ArrayIndexOutOfBoundsException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.lang.reflect.Array','getLength','(java.lang.Object)',['java.lang.IllegalArgumentException']]\r\n" - + ",['java.net.DatagramSocket','receive','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" - + ",['java.net.DatagramSocket','send','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" - + ",['java.net.DatagramSocket','setReceiveBufferSize','(int)',['java.net.SocketException']]\r\n" - + ",['java.net.DatagramSocket','','()',['java.net.SocketException']]\r\n" - + ",['java.net.DatagramSocket','','(int)',['java.net.SocketException']]\r\n" - + ",['java.net.MulticastSocket','joinGroup','(java.net.InetAddress)',['java.io.IOException']]\r\n" - + ",['java.net.MulticastSocket','','()',['java.io.IOException']]\r\n" - + ",['java.net.MulticastSocket','','(int)',['java.io.IOException']]\r\n" - + ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object,java.lang.String,int)',['java.awt.HeadlessException']]\r\n" - + ",['javax.xml.parsers.DocumentBuilder','parse','(java.io.InputStream)',['java.io.IOException','org.xml.sax.SAXException']]\r\n" - + ",['javax.xml.parsers.DocumentBuilderFactory','newDocumentBuilder','()',['javax.xml.parsers.ParserConfigurationException']]\r\n" - + ",['java.lang.Class','getDeclaredFields','()',['java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','getMethods','()',['java.lang.SecurityException']]\r\n" - + ",['java.lang.Object','wait','(long)',['java.lang.InterruptedException']]\r\n" - + ",['java.io.Reader','close','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','close','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','write','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.lang.Class','newInstance','()',['java.lang.IllegalAccessException','java.lang.InstantiationException']]\r\n" - + ",['java.lang.Class','getDeclaredMethod','(java.lang.String,java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','getConstructor','(java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','forName','(java.lang.String)',['java.lang.ClassNotFoundException']]\r\n" - + ",['java.io.File','createNewFile','()',['java.io.IOException']]\r\n" - + ",['javax.swing.JApplet','','()',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFrame','','(java.lang.String)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFrame','','()',['java.awt.HeadlessException']]\r\n" - + ",['junit.framework.TestCase','setUp','()',['java.lang.Exception']]\r\n" - + ",['junit.framework.TestCase','tearDown','()',['java.lang.Exception']]\r\n" - + ",['java.io.BufferedReader','close','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','close','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','accept','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','','(int)',['java.io.IOException']]\r\n" - + ",['java.lang.Thread','join','()',['java.lang.InterruptedException']]\r\n" - + ",['java.awt.Robot','','()',['java.awt.AWTException']]\r\n" - + ",['javax.swing.JInternalFrame','setSelected','(boolean)',['java.beans.PropertyVetoException']]\r\n" - + ",['javax.swing.JInternalFrame','setClosed','(boolean)',['java.beans.PropertyVetoException']]\r\n" - + ",['javax.swing.JFileChooser','showOpenDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFileChooser','showSaveDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" - + ",['java.awt.Toolkit','getScreenSize','()',['java.awt.HeadlessException']]\r\n" - + ",['java.awt.KeyboardFocusManager','setCurrentKeyboardFocusManager','(java.awt.KeyboardFocusManager)',['java.lang.SecurityException']]\r\n" - + ",['java.awt.Frame','','()',['java.awt.HeadlessException']]\r\n" - + ",['java.lang.reflect.Field','getInt','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.io.BufferedWriter','close','()',['java.io.IOException']]\r\n" - + ",['java.io.BufferedWriter','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.FileReader','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.InputStreamReader','close','()',['java.io.IOException']]\r\n" - + ",['java.io.FileWriter','','(java.io.File)',['java.io.IOException']]\r\n" - + ",['java.io.FileWriter','','(java.io.File,boolean)',['java.io.IOException']]\r\n" - + ",['java.io.OutputStreamWriter','close','()',['java.io.IOException']]\r\n" - + ",['java.io.OutputStreamWriter','flush','()',['java.io.IOException']]\r\n" - + ",['java.lang.reflect.Constructor','newInstance','(java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.InstantiationException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['java.net.Socket','close','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','getOutputStream','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','getInputStream','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','','(java.net.InetAddress,int)',['java.io.IOException']]\r\n" - + ",['java.util.logging.FileHandler','','(java.lang.String)',['java.io.IOException','java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Handler','setFormatter','(java.util.logging.Formatter)',['java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Logger','setLevel','(java.util.logging.Level)',['java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Logger','addHandler','(java.util.logging.Handler)',['java.lang.SecurityException']]\r\n" - + ",['javax.imageio.ImageIO','write','(java.awt.image.RenderedImage,java.lang.String,java.io.File)',['java.io.IOException']]\r\n" - + ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.SwingUtilities','invokeAndWait','(java.lang.Runnable)',['java.lang.InterruptedException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['ognl.Ognl','getValue','(java.lang.Object,java.util.Map,java.lang.Object)',['ognl.OgnlException']]\r\n" - + ",['ognl.Ognl','parseExpression','(java.lang.String)',['ognl.OgnlException']]\r\n" - + ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentInstance','(java.lang.Object)',['org.picocontainer.PicoRegistrationException']]\r\n" - + ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentImplementation','(java.lang.Class)',['org.picocontainer.PicoRegistrationException']]\r\n" - + ",['java.lang.Class','getFields','()',['java.lang.SecurityException']]\r\n" - + ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','(java.io.Writer)',['java.lang.Exception']]\r\n" - + ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','()',['java.lang.Exception']]\r\n" - + ",['java.beans.Introspector','getBeanInfo','(java.lang.Class)',['java.beans.IntrospectionException']]\r\n" - + ",['java.io.InputStream','available','()',['java.io.IOException']]\r\n" - + ",['java.io.InputStream','reset','()',['java.io.IOException']]\r\n" - + ",['java.lang.String','getBytes','(java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['javax.xml.bind.JAXBContext','createUnmarshaller','()',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.Class[])',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','createMarshaller','()',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.String)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,org.w3c.dom.Node)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Marshaller','setProperty','(java.lang.String,java.lang.Object)',['javax.xml.bind.PropertyException']]\r\n" - + ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,java.io.Writer)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Unmarshaller','unmarshal','(java.io.InputStream)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.transform.Transformer','transform','(javax.xml.transform.Source,javax.xml.transform.Result)',['javax.xml.transform.TransformerException']]\r\n" - + ",['javax.xml.transform.Transformer','setOutputProperty','(java.lang.String,java.lang.String)',['java.lang.IllegalArgumentException']]\r\n" - + ",['javax.xml.transform.TransformerFactory','newInstance','()',['javax.xml.transform.TransformerFactoryConfigurationError']]\r\n" - + ",['javax.xml.transform.TransformerFactory','newTransformer','()',['javax.xml.transform.TransformerConfigurationException']]\r\n" - + ",['org.w3c.dom.Element','removeAttribute','(java.lang.String)',['org.w3c.dom.DOMException']]\r\n" - + ",['org.w3c.dom.Node','getTextContent','()',['org.w3c.dom.DOMException']]\r\n" - + ",['java.io.FilterInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.InputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.BufferedWriter','newLine','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readUTF','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readDouble','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readInt','()',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" - + ",['java.io.FilterOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.File','createTempFile','(java.lang.String,java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.FileReader','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.InputStreamReader','','(java.io.InputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.OutputStreamWriter','','(java.io.OutputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.ObjectInputStream','readUTF','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','readDouble','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','readInt','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" - + ",['java.lang.Double','parseDouble','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Float','parseFloat','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.security.MessageDigest','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['java.util.concurrent.Future','get','()',['java.lang.InterruptedException','java.util.concurrent.ExecutionException']]\r\n" - + ",['java.util.zip.GZIPInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.util.zip.GZIPOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" - + ",['org.apache.commons.logging.LogFactory','getLog','(java.lang.Class)',['org.apache.commons.logging.LogConfigurationException']]\r\n" - + ",['com.sun.akuma.Daemon','init','(java.lang.String)',['java.lang.Exception']]\r\n" - + ",['com.sun.akuma.Daemon','daemonize','()',['java.io.IOException']]\r\n" - + ",['java.lang.String','','(byte[],int,int,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.Reader','read','(char[],int,int)',['java.io.IOException']]\r\n" - + ",['java.net.URI','','(java.lang.String)',['java.net.URISyntaxException']]\r\n" - + ",['java.net.URL','openStream','()',['java.io.IOException']]\r\n" - + ",['java.io.FileInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.net.InetAddress','getByAddress','(byte[])',['java.net.UnknownHostException']]\r\n" - + ",['java.util.Properties','load','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.security.KeyFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['java.security.KeyFactory','generatePrivate','(java.security.spec.KeySpec)',['java.security.spec.InvalidKeySpecException']]\r\n" - + ",['java.security.KeyStore','getInstance','(java.lang.String)',['java.security.KeyStoreException']]\r\n" - + ",['java.security.KeyStore','load','(java.io.InputStream,char[])',['java.io.IOException','java.security.NoSuchAlgorithmException','java.security.cert.CertificateException']]\r\n" - + ",['java.security.cert.CertificateFactory','getInstance','(java.lang.String)',['java.security.cert.CertificateException']]\r\n" - + ",['java.security.cert.CertificateFactory','generateCertificate','(java.io.InputStream)',['java.security.cert.CertificateException']]\r\n" - + ",['javax.net.ssl.KeyManagerFactory','init','(java.security.KeyStore,char[])',['java.security.KeyStoreException','java.security.NoSuchAlgorithmException','java.security.UnrecoverableKeyException']]\r\n" - + ",['javax.net.ssl.KeyManagerFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['javax.net.ssl.SSLContext','init','(javax.net.ssl.KeyManager[],javax.net.ssl.TrustManager[],java.security.SecureRandom)',['java.security.KeyManagementException']]\r\n" - + ",['javax.net.ssl.SSLContext','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['javax.net.ssl.SSLSession','getPeerCertificateChain','()',['javax.net.ssl.SSLPeerUnverifiedException']]\r\n" - + ",['javax.security.cert.Certificate','getEncoded','()',['javax.security.cert.CertificateEncodingException']]\r\n" - + ",['net.oauth.OAuthAccessor','newRequestMessage','(java.lang.String,java.lang.String,java.util.Collection)',['java.io.IOException','java.net.URISyntaxException','net.oauth.OAuthException']]\r\n" - + ",['net.oauth.OAuthMessage','getAuthorizationHeader','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['net.oauth.signature.pem.PEMReader','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['net.oauth.signature.pem.PKCS1EncodedKeySpec','','(byte[])',['java.io.IOException']]\r\n" - + ",['org.apache.log4j.FileAppender','','(org.apache.log4j.Layout,java.lang.String)',['java.io.IOException']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelUpstreamHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelHandler','handleDownstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + "]\r\n"; - - public ERR54FALTA_PREV_THROWS() { - super(false); - } - - private static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS | :HAS_CLASS_IMPLEMENTS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m), (mType) WHERE SPLIT(mType.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_OF]->(mType) ON CREATE SET r.created=TRUE " - + "WITH DISTINCT ['java.lang.AutoCloseable','java.io.BufferedReader','java.io.BufferedWriter' ] as autocloseableTypeNames, sucessors "; - - // public static void main(String[] args) { - // System.out.println(new ERR54().queryToString()); - // } - @Override - protected void initiate() { - - clauses = new Clause[] { (Clause) getCFGServices().getCFGSuccesorsOf(new NodeVar("newStat"), ""), - new SimpleWithClause("DISTINCT COLLECT([newStat, succesors]) as sucessors"), - new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - // new ClauseImpl("MATCH (n)-[r:HAS_VARIABLEDECL_INIT]->(m) - // CREATE (n)-[: - new MatchClause(true, TypeServicesWiggle.getSuperTypesOf(new NodeVar("closeableSubtype"))), - new WhereClause("superType.fullyQualifiedName IN autocloseableTypeNames"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames+COLLECT(closeableSubtype.fullyQualifiedName) as autocloseableTypeNames"), - - new MatchClause(true, - " (subtype)-[:IS_SUBTYPE_OF*0..]->(enclClass)-[:DECLARES_METHOD]->(m)-[:HAS_METHODDECL_THROWS]->()"), - new MatchClause(true, " (m)-[:HAS_METHODDECL_PARAMETERS]->(p)"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames, CASE WHEN subtype.fullyQualifiedName CONTAINS '<' THEN SPLIT(subtype.fullyQualifiedName,'<')[0] ELSE subtype.fullyQualifiedName END as enclClass, m,p ORDER BY ID(p)"), - - new SimpleWithClause("autocloseableTypeNames,sucessors, " - + "enclClass, m.name as methodName, REDUCE(s='(', p IN COLLECT(p) | s+p.actualType+',') as paramTypes"), - new SimpleWithClause("DISTINCT autocloseableTypeNames,sucessors, " - + "COLLECT([enclClass, methodName, CASE WHEN paramTypes CONTAINS ',' THEN SUBSTRING(paramTypes, 0,LENGTH(paramTypes)-1) ELSE paramTypes END +')'])+" - + METHOD_THAT_THROWS + " as mThrowsInfo, " - + EXCEPTION_HIER+ - " as exHier" - ), - new MatchClause(true, - "(non_declaredEx)<-[:HAS_CLASS_EXTENDS]-(superDeclaredEx),hier=(declaredEx)-[:IS_SUBTYPE_OF*0..]->(superDeclaredEx)" - + ", (declaredEx)<-[:IS_SUBTYPE_OF*0..]-(subTypeDeclared)" - + " WHERE non_declaredEx.actualType IN EXTRACT(row IN exHier | row[0])" + "" - + " WITH DISTINCT" - + " autocloseableTypeNames,sucessors, mThrowsInfo, " - + " exHier, " - + " [declaredEx.fullyQualifiedName" - + ",EXTRACT(x IN TAIL(NODES(hier)) | x.fullyQualifiedName)+[non_declaredEx.actualType]+ FILTER(hier IN exHier WHERE hier[0]=non_declaredEx.actualType)[0][1]" - + ",EXTRACT(x IN COLLECT(subTypeDeclared) | x.fullyQualifiedName) ] as declaredHier" - + " WITH DISTINCT autocloseableTypeNames,sucessors, mThrowsInfo, exHier+COLLECT(declaredHier) as exHier"), - new ClauseImpl( - "MATCH(inv)<-[:ARRAYACCESS_EXPR|ARRAYACCESS_INDEX|ASSIGNMENT_LHS|ASSIGNMENT_RHS|BINOP_LHS|BINOP_RHS|CAST_ENCLOSES|COMPOUND_ASSIGNMENT_LHS|COMPOUND_ASSIGNMENT_RHS|CONDITIONAL_CONDITION|CONDITIONAL_THEN|CONDITIONAL_ELSE|HAS_VARIABLEDECL_INIT|INSTANCEOF_EXPR|PARENTHESIZED_ENCLOSES|MEMBER_SELECT_EXPR|METHODINVOCATION_ARGUMENTS|METHODINVOCATION_METHOD_SELECT|NEW_CLASS_ARGUMENTS|NEWARRAY_INIT|NEWARRAY_DIMENSION|UNARY_ENCLOSES*0..]-()<-[:ASSERT_CONDITION|DOWHILE_CONDITION|EXPR_ENCLOSES|FOREACH_EXPR|FORLOOP_CONDITION|HAS_VARIABLEDECL_INIT|IF_CONDITION|RETURN_EXPR|SWITCH_EXPR|SYNCHRONIZED_EXPR|THROW_EXPR|WHILE_CONDITION]-(stat)<-[:CASE_STATEMENTS|CATCH_BLOCK|CATCH_PARAM|ENCLOSES|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|HAS_METHODDECL_PARAMETERS|IF_THEN|IF_ELSE|LABELED_STATEMENT|SWITCH_ENCLOSES_CASES|SYNCHRONIZED_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*]-()<-[:HAS_METHODDECL_BODY]-({nodeType:'JCMethodDecl'})<-[:DECLARES_METHOD]-(callerEncType)\r\n" - + " WHERE inv.nodeType IN ['JCMethodInvocation', 'JCNewClass'] " - + "OPTIONAL MATCH (invMember)<-[:METHODINVOCATION_METHOD_SELECT]-(inv)" - + "OPTIONAL MATCH (invMember)-[:MEMBER_SELECT_EXPR]->(memberSelection)" - + "OPTIONAL MATCH (inv)-[:NEW_CLASS_ARGUMENTS]->(arg)" - + " WITH autocloseableTypeNames,sucessors, mThrowsInfo,stat,inv,invMember,arg, CASE WHEN invMember IS NULL THEN inv.actualType ELSE CASE WHEN invMember.nodeType='JCIdent' THEN callerEncType.fullyQualifiedName ELSE memberSelection.actualType END END as callerEncTypeName ORDER BY ID(arg)" - + " WITH DISTINCT " + "autocloseableTypeNames,sucessors, mThrowsInfo," - + "stat,inv,invMember, callerEncTypeName, REDUCE(s='(', arg IN COLLECT(arg) | s+CASE WHEN s='(' THEN arg.actualType ELSE ','+arg.actualType END )+')' as newClassArgs "), - - new SimpleWithClause("DISTINCT " + "autocloseableTypeNames,sucessors,mThrowsInfo," - + " stat, COLLECT([CASE WHEN callerEncTypeName CONTAINS '<' AND NOT callerEncTypeName STARTS WITH '<' THEN SPLIT(callerEncTypeName,'<')[0] ELSE callerEncTypeName END , CASE WHEN invMember IS NULL THEN '' ELSE invMember.name END,CASE WHEN invMember IS NULL THEN newClassArgs ELSE SPLIT(invMember.actualType,')')[0]+')' END]) as invInfoInStats"), -new SimpleWithClause( - " DISTINCT autocloseableTypeNames,sucessors,mThrowsInfo,"+ - "stat,REDUCE(s=[], x IN EXTRACT(invSignature IN invInfoInStats | " - + " FILTER(throwSignature IN mThrowsInfo WHERE throwSignature[0]=invSignature[0] AND throwSignature[1]=invSignature[1] AND throwSignature[2]=invSignature[2])[0][3] )" - + "| s+x) as throws " - ) - -, - new SimpleWithClause( - "DISTINCT " - + "autocloseableTypeNames,sucessors," - + " FILTER(x IN COLLECT( [stat,throws]) WHERE NOT x[1] IS NULL) as statsMayThrow"), - new MatchClause(true, - "(stat)-[:THROW_EXPR]->(throwExpr) WITH DISTINCT autocloseableTypeNames,sucessors, statsMayThrow+COLLECT([stat,throwExpr.actualType]) as statsMayThrow"), - new MatchClause(true, - "(stat{nodeType:'JCAssert'}) WITH DISTINCT " - + "autocloseableTypeNames,sucessors," - + " statsMayThrow+COLLECT([stat,'java.lang.AssertionError']) as statsMayThrow") - - ,new MatchClause(PDGServicesWiggle.WIGGLE.getIdsAndVarDeclarations(new NodeVar("id"), - "autocloseableTypeNames,sucessors,statsMayThrow ")), - new WhereClause("varDec.actualType IN autocloseableTypeNames"), - new SimpleWithClause( - "DISTINCT autocloseableTypeNames,sucessors,statsMayThrow, varDec as dec, COLLECT(DISTINCT id) as ids"), - new ReturnClause("DISTINCT dec, ids"), - /* new MatchClause(true, - " (dec)<-[r:TRY_RESOURCES]-() WITH DISTINCT sucessors,statsMayThrow, dec,ids,r WHERE r IS NULL"), - // new ReturnClause("DISTINCT dec") - - new MatchClause(true, - getAssignmentServices().getLeftPartAssignments(new NodeVar("assignment"), new NodeVar("id")), - getExpressionServices().getStatementFromExp(new NodeVar("assignment"))), - new WhereClause("id IN ids"), - new SimpleWithClause(" DISTINCT " + " sucessors,statsMayThrow,ids, " + "dec, COLLECT(stat) as mods "), - - new MatchClause(true, new MatchImpl("(dec)-[r:HAS_VARIABLEDECL_INIT]->()")), - new SimpleWithClause("DISTINCT " + " sucessors, statsMayThrow," - + " dec, ids, mods + CASE WHEN r IS NULL THEN [] ELSE [dec] END as mods"), - new UnwindClause("mods", "mod"), - new MatchClause(MethodInvocationServicesWiggle.getMethodInvocationOf("close"), - getExpressionServices().getStatementFromExp(new NodeVar("mInv"), new NodeVar("closeStat"))), - - new WhereClause("object IN ids"), - new SimpleWithClause("DISTINCT sucessors,statsMayThrow, dec, mod, COLLECT(closeStat) as closeStmts"), - new SimpleWithClause( - " sucessors, dec, mod,closeStmts, FILTER( stat IN statsMayThrow WHERE NOT stat IN closeStmts AND stat IN FILTER(x IN sucessors WHERE x[0]=mod)[0][1]" - + " AND ANY(closeStat IN closeStmts WHERE closeStat IN FILTER(x IN sucessors WHERE x[0]=stat)[0][1]) ) as prevStats"), - new UnwindClause("prevStats", "prevStat"), - // new ReturnClause("DISTINCT FILTER(x IN sucessors WHERE - // x[0].nodeType='JCCatch' )") - - new MatchClause(true, - "p=" + getStatementServices().getOuterBlockFromStatement(new NodeVar("prevStat"), - new NodeVar("try{nodeType:'JCTry'}")).matchToString()), - new WhereClause("NOT TYPE(REVERSE(RELATIONSHIPS(p))[0]) IN ['TRY_CATCH', 'TRY_FINALLY']"), - new MatchClause(true, "(try)-[:TRY_CATCH ]->(catch)"), - new SimpleWithClause( - "DISTINCT sucessors,dec, mod, prevStat,closeStmts, try, REDUCE(l=[],catch IN COLLECT(catch) | l+FILTER(x IN sucessors WHERE x[0]=catch)[0][1] ) as catchSucs"), - new MatchClause(true, - getStatementServices() - .getOuterBlockFromStatement(new NodeVar("finallyStat"), new NodeVar("finally")) - .matchToString() + "<-[:TRY_FINALLY]-(try)"), - new SimpleWithClause( - " DISTINCT dec, mod, prevStat,closeStmts, try, CASE WHEN SIZE(catchSucs)=0 THEN COLLECT(finallyStat) ELSE catchSucs END as stmsReacheableAfterEx"), - new SimpleWithClause( - "DISTINCT dec, mod, prevStat,NOT ANY( reacheableStmt IN REDUCE(l=[], reacheables IN COLLECT(stmsReacheableAfterEx) | l+reacheables ) WHERE reacheableStmt IN closeStmts) as notReachebleClose"), - new WhereClause(" notReachebleClose "), - new MatchClause(getStatementServices().getEnclosingClassFromStatement(new NodeVar("dec"))), - new SimpleWithClause( - "DISTINCT 'Warning [CMU-ERR54] variable '+dec.name+ '(defined in line'+dec.lineNumber+', class '+enclClass.fullyQualifiedName+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN COLLECT(DISTINCT prevStat) | prev.lineNumber)+') may throw an exception.' as warning"), - new SimpleWithClause("DISTINCT COLLECT(warning) as warnings"), - new MatchClause(false, "()-[r:IS_SUBTYPE_OF]->() DELETE r WITH DISTINCT warnings RETURN warnings") - // , new WhereClause(" allReacheables ") - */}; - } - - public static void main(String[] args) { - System.out.println(new ERR54FALTA_PREV_THROWS().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54_FALTA_REACHABLE_SOLO.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54_FALTA_REACHABLE_SOLO.java deleted file mode 100644 index ae476b3..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54_FALTA_REACHABLE_SOLO.java +++ /dev/null @@ -1,396 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.MethodInvocationServicesWiggle; -import database.querys.services.PDGServicesWiggle; -import database.querys.services.TypeServicesWiggle; - -public class ERR54_FALTA_REACHABLE_SOLO extends AbstractQuery { - - /* - * " MATCH (closeableSubtype)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(closeableInt:INTERFACE_DECLARATION{fullyQualifiedName:'java.lang.AutoCloseable'})" - * + - * " WHERE closeableSubtype:CLASS_DECLARATION OR closeableSubtype:INTERFACE_DECLARATION " - * + " WITH DISTINCT closeableSubtype.fullyQualifiedName as className " - * - * + - * " MATCH (closeableDec{actualType:className})-[:MODIFIED_BY]->(assign) <-[" - * + assignToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery + - * "]-(assignStat) " + - * - * - * - * - * " OPTIONAL MATCH (closeableDec)<-[r:TRY_RESOURCES]-() WITH assignStat,r, closeableDec WHERE r IS NULL" - * - * + - * "MATCH (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'close'})-[:MEMBER_SELECT_EXPR]->(id)<-[:USED_BY]-(closeableDec)," - * + " (mInv)<-[" + exprToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery - * + "]-(closeStat)" + ", - * - * (assignStat)-[" + cfgSuccesor + "*1..]->(prev)" + - * "-[:IF_THERE_IS_UNCAUGHT_EXCEPTION | :MAY_THROW | :THROWS]->(afterEx)" + - * - * " WITH COLLECT(DISTINCT closeStat) AS closes, prev,closeableDec, afterEx" - * - * - * + " MATCH (prev)-[" + cfgSuccesor + - * "*]->(closeStat) WHERE closeStat IN closes" + - * - * " WITH closes,COLLECT(DISTINCT prev) AS prevs, afterEx, closeableDec" + - * - * " WITH closes, [prev IN prevs WHERE NOT prev IN closes] as prevs, afterEx , closeableDec" - * + " WHERE SIZE(prevs)>=1 " + " MATCH (afterEx)-[" + - * getAnyRel(toCFGSuccesorNoCondEx) + - * "*0..]->(reachableAfterEx) WITH closes,COLLECT(reachableAfterEx) AS reachable, prevs, closeableDec" - * + " WHERE ALL(r IN reachable WHERE NOT r IN closes)" - * - * + - * " RETURN 'Warning [CMU-ERR54] variable '+closeableDec.name+ '(defined in line'+closeableDec.lineNumber+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN prevs | prev.lineNumber)+') may throw an exception.'" - * - * - */ - private final String EXCEPTION_HIER = "" + - "[['java.io.IOException',['java.lang.Exception','java.lang.Throwable'],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.net.MalformedURLException','java.net.SocketException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.util.InvalidPropertiesFormatException','java.util.jar.JarException','java.util.zip.ZipException']],\r\n" + - "['java.lang.AssertionError',['java.lang.Throwable'],['java.lang.AssertionError']],\r\n" + - "['java.lang.NullPointerException',['java.lang.Exception','java.lang.RuntimeException','java.lang.Throwable'],['java.lang.NullPointerException']],\r\n" + - "['java.lang.Throwable',[''],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.lang.AssertionError','java.lang.ClassFormatError','java.lang.ClassNotFoundException','java.lang.CloneNotSupportedException','java.lang.Exception','java.lang.IllegalAccessError','java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.InstantiationException','java.lang.InterruptedException','java.lang.NoSuchFieldException','java.lang.NoSuchMethodException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.Throwable','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.lang.invoke.NoSuchMemberException','java.lang.invoke.T','java.lang.reflect.InvocationTargetException','java.net.MalformedURLException','java.net.SocketException','java.net.URISyntaxException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.security.AccessControlException','java.security.DigestException','java.security.InvalidKeyException','java.security.NoSuchAlgorithmException','java.security.NoSuchProviderException','java.security.PrivilegedActionException','java.security.SignatureException','java.security.cert.CertificateEncodingException','java.security.cert.CertificateException','java.sql.SQLException','java.text.ParseException','java.util.InvalidPropertiesFormatException','java.util.MissingResourceException','java.util.X','java.util.X','java.util.X','java.util.X','java.util.concurrent.ExecutionException','java.util.concurrent.TimeoutException','java.util.jar.JarException','java.util.zip.ZipException','sun.util.locale.LocaleSyntaxException']],\r\n" + - "['java.lang.Exception',['java.lang.Throwable'],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.lang.ClassNotFoundException','java.lang.CloneNotSupportedException','java.lang.Exception','java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.InstantiationException','java.lang.InterruptedException','java.lang.NoSuchFieldException','java.lang.NoSuchMethodException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.lang.invoke.NoSuchMemberException','java.lang.reflect.InvocationTargetException','java.net.MalformedURLException','java.net.SocketException','java.net.URISyntaxException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.security.AccessControlException','java.security.DigestException','java.security.InvalidKeyException','java.security.NoSuchAlgorithmException','java.security.NoSuchProviderException','java.security.PrivilegedActionException','java.security.SignatureException','java.security.cert.CertificateEncodingException','java.security.cert.CertificateException','java.sql.SQLException','java.text.ParseException','java.util.InvalidPropertiesFormatException','java.util.MissingResourceException','java.util.concurrent.ExecutionException','java.util.concurrent.TimeoutException','java.util.jar.JarException','java.util.zip.ZipException','sun.util.locale.LocaleSyntaxException']],\r\n" + - "['java.lang.RuntimeException',['java.lang.Exception','java.lang.Throwable'],['java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.security.AccessControlException','java.util.MissingResourceException']],\r\n" + - "['java.lang.IllegalStateException',['java.lang.Exception','java.lang.RuntimeException','java.lang.Throwable'],['java.lang.IllegalStateException']]]\r\n" + - ""; - private final String METHOD_THAT_THROWS = "[['java.lang.Thread','sleep','(long)',['java.lang.InterruptedException']]\r\n" - + ",['java.io.BufferedReader','readLine','()',['java.io.IOException']]\r\n" - + ",['java.lang.Double','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Integer','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['android.content.res.Resources','getStringArray','(int)',['android.content.res.Resources$NotFoundException']]\r\n" - + ",['android.database.sqlite.SQLiteDatabase','execSQL','(java.lang.String)',['android.database.SQLException']]\r\n" - + ",['android.media.MediaPlayer','start','()',['java.lang.IllegalStateException']]\r\n" - + ",['android.media.MediaPlayer','stop','()',['java.lang.IllegalStateException']]\r\n" - + ",['java.lang.Object','wait','()',['java.lang.InterruptedException']]\r\n" - + ",['java.lang.Integer','parseInt','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Integer','','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','delete','(java.lang.String,int)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','create','(java.lang.String,byte[],java.util.List,org.apache.zookeeper.CreateMode)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','getData','(java.lang.String,boolean,org.apache.zookeeper.data.Stat)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','getChildren','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','exists','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','','(java.lang.String,int,org.apache.zookeeper.Watcher)',['java.io.IOException']]\r\n" - + ",['org.w3c.dom.Node','getNodeValue','()',['org.w3c.dom.DOMException']]\r\n" - + ",['java.io.ObjectInputStream','readObject','()',['java.io.IOException','java.lang.ClassNotFoundException']]\r\n" - + ",['java.io.ObjectInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeObject','(java.lang.Object)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" - + ",['java.io.FileInputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.FileInputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.nio.channels.FileChannel','tryLock','()',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','write','(byte[])',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.lang.reflect.Field','get','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.lang.reflect.Method','invoke','(java.lang.Object,java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['java.lang.Long','parseLong','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.net.InetAddress','getLocalHost','()',['java.net.UnknownHostException']]\r\n" - + ",['java.net.InetAddress','getByName','(java.lang.String)',['java.net.UnknownHostException']]\r\n" - + ",['java.lang.reflect.AccessibleObject','setAccessible','(boolean)',['java.lang.SecurityException']]\r\n" - + ",['java.lang.reflect.Array','get','(java.lang.Object,int)',['java.lang.ArrayIndexOutOfBoundsException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.lang.reflect.Array','getLength','(java.lang.Object)',['java.lang.IllegalArgumentException']]\r\n" - + ",['java.net.DatagramSocket','receive','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" - + ",['java.net.DatagramSocket','send','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" - + ",['java.net.DatagramSocket','setReceiveBufferSize','(int)',['java.net.SocketException']]\r\n" - + ",['java.net.DatagramSocket','','()',['java.net.SocketException']]\r\n" - + ",['java.net.DatagramSocket','','(int)',['java.net.SocketException']]\r\n" - + ",['java.net.MulticastSocket','joinGroup','(java.net.InetAddress)',['java.io.IOException']]\r\n" - + ",['java.net.MulticastSocket','','()',['java.io.IOException']]\r\n" - + ",['java.net.MulticastSocket','','(int)',['java.io.IOException']]\r\n" - + ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object,java.lang.String,int)',['java.awt.HeadlessException']]\r\n" - + ",['javax.xml.parsers.DocumentBuilder','parse','(java.io.InputStream)',['java.io.IOException','org.xml.sax.SAXException']]\r\n" - + ",['javax.xml.parsers.DocumentBuilderFactory','newDocumentBuilder','()',['javax.xml.parsers.ParserConfigurationException']]\r\n" - + ",['java.lang.Class','getDeclaredFields','()',['java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','getMethods','()',['java.lang.SecurityException']]\r\n" - + ",['java.lang.Object','wait','(long)',['java.lang.InterruptedException']]\r\n" - + ",['java.io.Reader','close','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','close','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','write','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.lang.Class','newInstance','()',['java.lang.IllegalAccessException','java.lang.InstantiationException']]\r\n" - + ",['java.lang.Class','getDeclaredMethod','(java.lang.String,java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','getConstructor','(java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','forName','(java.lang.String)',['java.lang.ClassNotFoundException']]\r\n" - + ",['java.io.File','createNewFile','()',['java.io.IOException']]\r\n" - + ",['javax.swing.JApplet','','()',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFrame','','(java.lang.String)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFrame','','()',['java.awt.HeadlessException']]\r\n" - + ",['junit.framework.TestCase','setUp','()',['java.lang.Exception']]\r\n" - + ",['junit.framework.TestCase','tearDown','()',['java.lang.Exception']]\r\n" - + ",['java.io.BufferedReader','close','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','close','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','accept','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','','(int)',['java.io.IOException']]\r\n" - + ",['java.lang.Thread','join','()',['java.lang.InterruptedException']]\r\n" - + ",['java.awt.Robot','','()',['java.awt.AWTException']]\r\n" - + ",['javax.swing.JInternalFrame','setSelected','(boolean)',['java.beans.PropertyVetoException']]\r\n" - + ",['javax.swing.JInternalFrame','setClosed','(boolean)',['java.beans.PropertyVetoException']]\r\n" - + ",['javax.swing.JFileChooser','showOpenDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFileChooser','showSaveDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" - + ",['java.awt.Toolkit','getScreenSize','()',['java.awt.HeadlessException']]\r\n" - + ",['java.awt.KeyboardFocusManager','setCurrentKeyboardFocusManager','(java.awt.KeyboardFocusManager)',['java.lang.SecurityException']]\r\n" - + ",['java.awt.Frame','','()',['java.awt.HeadlessException']]\r\n" - + ",['java.lang.reflect.Field','getInt','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.io.BufferedWriter','close','()',['java.io.IOException']]\r\n" - + ",['java.io.BufferedWriter','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.FileReader','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.InputStreamReader','close','()',['java.io.IOException']]\r\n" - + ",['java.io.FileWriter','','(java.io.File)',['java.io.IOException']]\r\n" - + ",['java.io.FileWriter','','(java.io.File,boolean)',['java.io.IOException']]\r\n" - + ",['java.io.OutputStreamWriter','close','()',['java.io.IOException']]\r\n" - + ",['java.io.OutputStreamWriter','flush','()',['java.io.IOException']]\r\n" - + ",['java.lang.reflect.Constructor','newInstance','(java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.InstantiationException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['java.net.Socket','close','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','getOutputStream','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','getInputStream','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','','(java.net.InetAddress,int)',['java.io.IOException']]\r\n" - + ",['java.util.logging.FileHandler','','(java.lang.String)',['java.io.IOException','java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Handler','setFormatter','(java.util.logging.Formatter)',['java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Logger','setLevel','(java.util.logging.Level)',['java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Logger','addHandler','(java.util.logging.Handler)',['java.lang.SecurityException']]\r\n" - + ",['javax.imageio.ImageIO','write','(java.awt.image.RenderedImage,java.lang.String,java.io.File)',['java.io.IOException']]\r\n" - + ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.SwingUtilities','invokeAndWait','(java.lang.Runnable)',['java.lang.InterruptedException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['ognl.Ognl','getValue','(java.lang.Object,java.util.Map,java.lang.Object)',['ognl.OgnlException']]\r\n" - + ",['ognl.Ognl','parseExpression','(java.lang.String)',['ognl.OgnlException']]\r\n" - + ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentInstance','(java.lang.Object)',['org.picocontainer.PicoRegistrationException']]\r\n" - + ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentImplementation','(java.lang.Class)',['org.picocontainer.PicoRegistrationException']]\r\n" - + ",['java.lang.Class','getFields','()',['java.lang.SecurityException']]\r\n" - + ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','(java.io.Writer)',['java.lang.Exception']]\r\n" - + ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','()',['java.lang.Exception']]\r\n" - + ",['java.beans.Introspector','getBeanInfo','(java.lang.Class)',['java.beans.IntrospectionException']]\r\n" - + ",['java.io.InputStream','available','()',['java.io.IOException']]\r\n" - + ",['java.io.InputStream','reset','()',['java.io.IOException']]\r\n" - + ",['java.lang.String','getBytes','(java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['javax.xml.bind.JAXBContext','createUnmarshaller','()',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.Class[])',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','createMarshaller','()',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.String)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,org.w3c.dom.Node)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Marshaller','setProperty','(java.lang.String,java.lang.Object)',['javax.xml.bind.PropertyException']]\r\n" - + ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,java.io.Writer)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Unmarshaller','unmarshal','(java.io.InputStream)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.transform.Transformer','transform','(javax.xml.transform.Source,javax.xml.transform.Result)',['javax.xml.transform.TransformerException']]\r\n" - + ",['javax.xml.transform.Transformer','setOutputProperty','(java.lang.String,java.lang.String)',['java.lang.IllegalArgumentException']]\r\n" - + ",['javax.xml.transform.TransformerFactory','newInstance','()',['javax.xml.transform.TransformerFactoryConfigurationError']]\r\n" - + ",['javax.xml.transform.TransformerFactory','newTransformer','()',['javax.xml.transform.TransformerConfigurationException']]\r\n" - + ",['org.w3c.dom.Element','removeAttribute','(java.lang.String)',['org.w3c.dom.DOMException']]\r\n" - + ",['org.w3c.dom.Node','getTextContent','()',['org.w3c.dom.DOMException']]\r\n" - + ",['java.io.FilterInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.InputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.BufferedWriter','newLine','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readUTF','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readDouble','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readInt','()',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" - + ",['java.io.FilterOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.File','createTempFile','(java.lang.String,java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.FileReader','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.InputStreamReader','','(java.io.InputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.OutputStreamWriter','','(java.io.OutputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.ObjectInputStream','readUTF','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','readDouble','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','readInt','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" - + ",['java.lang.Double','parseDouble','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Float','parseFloat','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.security.MessageDigest','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['java.util.concurrent.Future','get','()',['java.lang.InterruptedException','java.util.concurrent.ExecutionException']]\r\n" - + ",['java.util.zip.GZIPInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.util.zip.GZIPOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" - + ",['org.apache.commons.logging.LogFactory','getLog','(java.lang.Class)',['org.apache.commons.logging.LogConfigurationException']]\r\n" - + ",['com.sun.akuma.Daemon','init','(java.lang.String)',['java.lang.Exception']]\r\n" - + ",['com.sun.akuma.Daemon','daemonize','()',['java.io.IOException']]\r\n" - + ",['java.lang.String','','(byte[],int,int,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.Reader','read','(char[],int,int)',['java.io.IOException']]\r\n" - + ",['java.net.URI','','(java.lang.String)',['java.net.URISyntaxException']]\r\n" - + ",['java.net.URL','openStream','()',['java.io.IOException']]\r\n" - + ",['java.io.FileInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.net.InetAddress','getByAddress','(byte[])',['java.net.UnknownHostException']]\r\n" - + ",['java.util.Properties','load','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.security.KeyFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['java.security.KeyFactory','generatePrivate','(java.security.spec.KeySpec)',['java.security.spec.InvalidKeySpecException']]\r\n" - + ",['java.security.KeyStore','getInstance','(java.lang.String)',['java.security.KeyStoreException']]\r\n" - + ",['java.security.KeyStore','load','(java.io.InputStream,char[])',['java.io.IOException','java.security.NoSuchAlgorithmException','java.security.cert.CertificateException']]\r\n" - + ",['java.security.cert.CertificateFactory','getInstance','(java.lang.String)',['java.security.cert.CertificateException']]\r\n" - + ",['java.security.cert.CertificateFactory','generateCertificate','(java.io.InputStream)',['java.security.cert.CertificateException']]\r\n" - + ",['javax.net.ssl.KeyManagerFactory','init','(java.security.KeyStore,char[])',['java.security.KeyStoreException','java.security.NoSuchAlgorithmException','java.security.UnrecoverableKeyException']]\r\n" - + ",['javax.net.ssl.KeyManagerFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['javax.net.ssl.SSLContext','init','(javax.net.ssl.KeyManager[],javax.net.ssl.TrustManager[],java.security.SecureRandom)',['java.security.KeyManagementException']]\r\n" - + ",['javax.net.ssl.SSLContext','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['javax.net.ssl.SSLSession','getPeerCertificateChain','()',['javax.net.ssl.SSLPeerUnverifiedException']]\r\n" - + ",['javax.security.cert.Certificate','getEncoded','()',['javax.security.cert.CertificateEncodingException']]\r\n" - + ",['net.oauth.OAuthAccessor','newRequestMessage','(java.lang.String,java.lang.String,java.util.Collection)',['java.io.IOException','java.net.URISyntaxException','net.oauth.OAuthException']]\r\n" - + ",['net.oauth.OAuthMessage','getAuthorizationHeader','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['net.oauth.signature.pem.PEMReader','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['net.oauth.signature.pem.PKCS1EncodedKeySpec','','(byte[])',['java.io.IOException']]\r\n" - + ",['org.apache.log4j.FileAppender','','(org.apache.log4j.Layout,java.lang.String)',['java.io.IOException']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelUpstreamHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelHandler','handleDownstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + "]\r\n"; - - public ERR54_FALTA_REACHABLE_SOLO() { - super(false); - } - - private static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS | :HAS_CLASS_IMPLEMENTS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m), (mType) WHERE SPLIT(mType.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_OF]->(mType) ON CREATE SET r.created=TRUE " - + "WITH DISTINCT ['java.lang.AutoCloseable','java.io.BufferedReader','java.io.BufferedWriter' ] as autocloseableTypeNames, sucessors "; - - // public static void main(String[] args) { - // System.out.println(new ERR54().queryToString()); - // } - @Override - protected void initiate() { - - clauses = new Clause[] { (Clause) getCFGServices().getCFGSuccesorsOf(new NodeVar("newStat"), ""), - new SimpleWithClause("DISTINCT COLLECT([newStat, succesors]) as sucessors"), - new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - // new ClauseImpl("MATCH (n)-[r:HAS_VARIABLEDECL_INIT]->(m) - // CREATE (n)-[: - new MatchClause(true, TypeServicesWiggle.getSuperTypesOf(new NodeVar("closeableSubtype"))), - new WhereClause("superType.fullyQualifiedName IN autocloseableTypeNames"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames+COLLECT(closeableSubtype.fullyQualifiedName) as autocloseableTypeNames"), - - new MatchClause(true, - " (subtype)-[:IS_SUBTYPE_OF*0..]->(enclClass)-[:DECLARES_METHOD]->(m)-[:HAS_METHODDECL_THROWS]->()"), - new MatchClause(true, " (m)-[:HAS_METHODDECL_PARAMETERS]->(p)"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames, CASE WHEN subtype.fullyQualifiedName CONTAINS '<' THEN SPLIT(subtype.fullyQualifiedName,'<')[0] ELSE subtype.fullyQualifiedName END as enclClass, m,p ORDER BY ID(p)"), - - new SimpleWithClause("autocloseableTypeNames,sucessors, " - + "enclClass, m.name as methodName, REDUCE(s='(', p IN COLLECT(p) | s+p.actualType+',') as paramTypes"), - new SimpleWithClause("DISTINCT autocloseableTypeNames,sucessors, " - + "COLLECT([enclClass, methodName, CASE WHEN paramTypes CONTAINS ',' THEN SUBSTRING(paramTypes, 0,LENGTH(paramTypes)-1) ELSE paramTypes END +')'])+" - + METHOD_THAT_THROWS + " as mThrowsInfo, " - + EXCEPTION_HIER+ - " as exHier" - ), - new MatchClause(true, - "(non_declaredEx)<-[:HAS_CLASS_EXTENDS]-(superDeclaredEx),hier=(declaredEx)-[:IS_SUBTYPE_OF*0..]->(superDeclaredEx)" - + ", (declaredEx)<-[:IS_SUBTYPE_OF*0..]-(subTypeDeclared)" - + " WHERE non_declaredEx.actualType IN EXTRACT(row IN exHier | row[0])" + "" - + " WITH DISTINCT" - + " autocloseableTypeNames,sucessors, mThrowsInfo, " - + " exHier, " - + " [declaredEx.fullyQualifiedName" - + ",EXTRACT(x IN TAIL(NODES(hier)) | x.fullyQualifiedName)+[non_declaredEx.actualType]+ FILTER(hier IN exHier WHERE hier[0]=non_declaredEx.actualType)[0][1]" - + ",EXTRACT(x IN COLLECT(subTypeDeclared) | x.fullyQualifiedName) ] as declaredHier" - + " WITH DISTINCT autocloseableTypeNames,sucessors, mThrowsInfo, exHier+COLLECT(declaredHier) as exHier"), - new ClauseImpl( - "MATCH(inv)<-[:ARRAYACCESS_EXPR|ARRAYACCESS_INDEX|ASSIGNMENT_LHS|ASSIGNMENT_RHS|BINOP_LHS|BINOP_RHS|CAST_ENCLOSES|COMPOUND_ASSIGNMENT_LHS|COMPOUND_ASSIGNMENT_RHS|CONDITIONAL_CONDITION|CONDITIONAL_THEN|CONDITIONAL_ELSE|HAS_VARIABLEDECL_INIT|INSTANCEOF_EXPR|PARENTHESIZED_ENCLOSES|MEMBER_SELECT_EXPR|METHODINVOCATION_ARGUMENTS|METHODINVOCATION_METHOD_SELECT|NEW_CLASS_ARGUMENTS|NEWARRAY_INIT|NEWARRAY_DIMENSION|UNARY_ENCLOSES*0..]-()<-[:ASSERT_CONDITION|DOWHILE_CONDITION|EXPR_ENCLOSES|FOREACH_EXPR|FORLOOP_CONDITION|HAS_VARIABLEDECL_INIT|IF_CONDITION|RETURN_EXPR|SWITCH_EXPR|SYNCHRONIZED_EXPR|THROW_EXPR|WHILE_CONDITION]-(stat)<-[:CASE_STATEMENTS|CATCH_BLOCK|CATCH_PARAM|ENCLOSES|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|HAS_METHODDECL_PARAMETERS|IF_THEN|IF_ELSE|LABELED_STATEMENT|SWITCH_ENCLOSES_CASES|SYNCHRONIZED_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*]-()<-[:HAS_METHODDECL_BODY]-({nodeType:'JCMethodDecl'})<-[:DECLARES_METHOD]-(callerEncType)\r\n" - + " WHERE inv.nodeType IN ['JCMethodInvocation', 'JCNewClass'] " - + "OPTIONAL MATCH (invMember)<-[:METHODINVOCATION_METHOD_SELECT]-(inv)" - + "OPTIONAL MATCH (invMember)-[:MEMBER_SELECT_EXPR]->(memberSelection)" - + "OPTIONAL MATCH (inv)-[:NEW_CLASS_ARGUMENTS]->(arg)" - + " WITH autocloseableTypeNames,sucessors, mThrowsInfo,stat,inv,invMember,arg, CASE WHEN invMember IS NULL THEN inv.actualType ELSE CASE WHEN invMember.nodeType='JCIdent' THEN callerEncType.fullyQualifiedName ELSE memberSelection.actualType END END as callerEncTypeName ORDER BY ID(arg)" - + " WITH DISTINCT " + "autocloseableTypeNames,sucessors, mThrowsInfo," - + "stat,inv,invMember, callerEncTypeName, REDUCE(s='(', arg IN COLLECT(arg) | s+CASE WHEN s='(' THEN arg.actualType ELSE ','+arg.actualType END )+')' as newClassArgs "), - - new SimpleWithClause("DISTINCT " + "autocloseableTypeNames,sucessors,mThrowsInfo," - + " stat, COLLECT([CASE WHEN callerEncTypeName CONTAINS '<' AND NOT callerEncTypeName STARTS WITH '<' THEN SPLIT(callerEncTypeName,'<')[0] ELSE callerEncTypeName END , CASE WHEN invMember IS NULL THEN '' ELSE invMember.name END,CASE WHEN invMember IS NULL THEN newClassArgs ELSE SPLIT(invMember.actualType,')')[0]+')' END]) as invInfoInStats"), -new SimpleWithClause( - " DISTINCT autocloseableTypeNames,sucessors,mThrowsInfo,"+ - "stat,REDUCE(s=[], x IN EXTRACT(invSignature IN invInfoInStats | " - + " FILTER(throwSignature IN mThrowsInfo WHERE throwSignature[0]=invSignature[0] AND throwSignature[1]=invSignature[1] AND throwSignature[2]=invSignature[2])[0][3] )" - + "| s+x) as throws " - ) - -, - new SimpleWithClause( - "DISTINCT " - + "autocloseableTypeNames,sucessors," - + " FILTER(x IN COLLECT( [stat,throws]) WHERE NOT x[1] IS NULL) as statsMayThrow"), - new MatchClause(true, - "(stat)-[:THROW_EXPR]->(throwExpr) WITH DISTINCT autocloseableTypeNames,sucessors, statsMayThrow+COLLECT([stat,throwExpr.actualType]) as statsMayThrow"), - new MatchClause(true, - "(stat{nodeType:'JCAssert'}) WITH DISTINCT " - + "autocloseableTypeNames,sucessors," - + " statsMayThrow+COLLECT([stat,'java.lang.AssertionError']) as statsMayThrow") - - ,new MatchClause(PDGServicesWiggle.WIGGLE.getIdsAndVarDeclarations(new NodeVar("id"), - "autocloseableTypeNames,sucessors,statsMayThrow ")), - new SimpleWithClause("autocloseableTypeNames,sucessors,statsMayThrow ,id, varDec, varDec.actualType IN autocloseableTypeNames as isVarClos"), - new WhereClause("isVarClos"), - new SimpleWithClause( - "DISTINCT autocloseableTypeNames,sucessors,statsMayThrow, varDec as dec, COLLECT(DISTINCT id) as ids"), - // new ReturnClause("DISTINCT dec, ids"), - new MatchClause(true, - " (dec)<-[r:TRY_RESOURCES]-() WITH DISTINCT sucessors,statsMayThrow, dec,ids,r WHERE r IS NULL"), - // new ReturnClause("DISTINCT dec") - - new MatchClause(true, - getAssignmentServices().getLeftPartAssignments(new NodeVar("assignment"), new NodeVar("id")), - getExpressionServices().getStatementFromExp(new NodeVar("assignment"))), - new WhereClause("id IN ids"), - new SimpleWithClause(" DISTINCT " + " sucessors,statsMayThrow,ids, " + "dec, COLLECT(stat) as mods "), - - new MatchClause(true, new MatchImpl("(dec)-[r:HAS_VARIABLEDECL_INIT]->()")), - new SimpleWithClause("DISTINCT " + " sucessors, statsMayThrow," - + " dec, ids, mods + CASE WHEN r IS NULL THEN [] ELSE [dec] END as mods"), - new UnwindClause("mods", "mod"), - new MatchClause(MethodInvocationServicesWiggle.getMethodInvocationOf("close"), - getExpressionServices().getStatementFromExp(new NodeVar("mInv"), new NodeVar("closeStat"))), - - new WhereClause("object IN ids"), - new SimpleWithClause("DISTINCT sucessors,statsMayThrow, dec, mod, COLLECT(closeStat) as closeStmts"), - new ReturnClause( -// " sucessors,"+ - " dec, mod,closeStmts, FILTER( stat IN statsMayThrow WHERE NOT stat[0] IN closeStmts AND stat[0] IN FILTER(x IN sucessors WHERE x[0]=mod)[0][1]" - + " AND ANY(closeStat IN closeStmts WHERE closeStat IN FILTER(x IN sucessors WHERE x[0]=stat[0])[0][1]) ) as prevStats"), - /* new UnwindClause("prevStats", "prevStat"), - // new ReturnClause("DISTINCT FILTER(x IN sucessors WHERE - // x[0].nodeType='JCCatch' )") - - new MatchClause(true, - "p=" + getStatementServices().getOuterBlockFromStatement(new NodeVar("prevStat"), - new NodeVar("try{nodeType:'JCTry'}")).matchToString()), - new WhereClause("NOT TYPE(REVERSE(RELATIONSHIPS(p))[0]) IN ['TRY_CATCH', 'TRY_FINALLY']"), - new MatchClause(true, "(try)-[:TRY_CATCH ]->(catch)"), - new SimpleWithClause( - "DISTINCT sucessors,dec, mod, prevStat,closeStmts, try, REDUCE(l=[],catch IN COLLECT(catch) | l+FILTER(x IN sucessors WHERE x[0]=catch)[0][1] ) as catchSucs"), - new MatchClause(true, - getStatementServices() - .getOuterBlockFromStatement(new NodeVar("finallyStat"), new NodeVar("finally")) - .matchToString() + "<-[:TRY_FINALLY]-(try)"), - new SimpleWithClause( - " DISTINCT dec, mod, prevStat,closeStmts, try, CASE WHEN SIZE(catchSucs)=0 THEN COLLECT(finallyStat) ELSE catchSucs END as stmsReacheableAfterEx"), - new SimpleWithClause( - "DISTINCT dec, mod, prevStat,NOT ANY( reacheableStmt IN REDUCE(l=[], reacheables IN COLLECT(stmsReacheableAfterEx) | l+reacheables ) WHERE reacheableStmt IN closeStmts) as notReachebleClose"), - new WhereClause(" notReachebleClose "), - new MatchClause(getStatementServices().getEnclosingClassFromStatement(new NodeVar("dec"))), - new SimpleWithClause( - "DISTINCT 'Warning [CMU-ERR54] variable '+dec.name+ '(defined in line'+dec.lineNumber+', class '+enclClass.fullyQualifiedName+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN COLLECT(DISTINCT prevStat) | prev.lineNumber)+') may throw an exception.' as warning"), - new SimpleWithClause("DISTINCT COLLECT(warning) as warnings"), - new MatchClause(false, "()-[r:IS_SUBTYPE_OF]->() DELETE r WITH DISTINCT warnings RETURN warnings") - // , new WhereClause(" allReacheables ") - */}; - } - - public static void main(String[] args) { - System.out.println(new ERR54_FALTA_REACHABLE_SOLO().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54_OLD.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54_OLD.java deleted file mode 100644 index 635f3bc..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/ERR54_OLD.java +++ /dev/null @@ -1,359 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.MethodInvocationServicesWiggle; -import database.querys.services.PDGServicesWiggle; -import database.querys.services.TypeServicesWiggle; - -public class ERR54_OLD extends AbstractQuery { - - /* - * " MATCH (closeableSubtype)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(closeableInt:INTERFACE_DECLARATION{fullyQualifiedName:'java.lang.AutoCloseable'})" - * + - * " WHERE closeableSubtype:CLASS_DECLARATION OR closeableSubtype:INTERFACE_DECLARATION " - * + " WITH DISTINCT closeableSubtype.fullyQualifiedName as className " - * - * + - * " MATCH (closeableDec{actualType:className})-[:MODIFIED_BY]->(assign) <-[" - * + assignToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery + - * "]-(assignStat) " + - * - * - * - * - * " OPTIONAL MATCH (closeableDec)<-[r:TRY_RESOURCES]-() WITH assignStat,r, closeableDec WHERE r IS NULL" - * - * + - * "MATCH (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'close'})-[:MEMBER_SELECT_EXPR]->(id)<-[:USED_BY]-(closeableDec)," - * + " (mInv)<-[" + exprToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery - * + "]-(closeStat)" + ", - * - * (assignStat)-[" + cfgSuccesor + "*1..]->(prev)" + - * "-[:IF_THERE_IS_UNCAUGHT_EXCEPTION | :MAY_THROW | :THROWS]->(afterEx)" + - * - * " WITH COLLECT(DISTINCT closeStat) AS closes, prev,closeableDec, afterEx" - * - * - * + " MATCH (prev)-[" + cfgSuccesor + - * "*]->(closeStat) WHERE closeStat IN closes" + - * - * " WITH closes,COLLECT(DISTINCT prev) AS prevs, afterEx, closeableDec" + - * - * " WITH closes, [prev IN prevs WHERE NOT prev IN closes] as prevs, afterEx , closeableDec" - * + " WHERE SIZE(prevs)>=1 " + " MATCH (afterEx)-[" + - * getAnyRel(toCFGSuccesorNoCondEx) + - * "*0..]->(reachableAfterEx) WITH closes,COLLECT(reachableAfterEx) AS reachable, prevs, closeableDec" - * + " WHERE ALL(r IN reachable WHERE NOT r IN closes)" - * - * + - * " RETURN 'Warning [CMU-ERR54] variable '+closeableDec.name+ '(defined in line'+closeableDec.lineNumber+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN prevs | prev.lineNumber)+') may throw an exception.'" - * - * - */ - private final String METHOD_THAT_THROWS = "[['java.lang.Thread','sleep','(long)',['java.lang.InterruptedException']]\r\n" + - ",['java.io.BufferedReader','readLine','()',['java.io.IOException']]\r\n" + - ",['java.lang.Double','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" + - ",['java.lang.Integer','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" + - ",['android.content.res.Resources','getStringArray','(int)',['android.content.res.Resources$NotFoundException']]\r\n" + - ",['android.database.sqlite.SQLiteDatabase','execSQL','(java.lang.String)',['android.database.SQLException']]\r\n" + - ",['android.media.MediaPlayer','start','()',['java.lang.IllegalStateException']]\r\n" + - ",['android.media.MediaPlayer','stop','()',['java.lang.IllegalStateException']]\r\n" + - ",['java.lang.Object','wait','()',['java.lang.InterruptedException']]\r\n" + - ",['java.lang.Integer','parseInt','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" + - ",['java.lang.Integer','','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" + - ",['org.apache.zookeeper.ZooKeeper','delete','(java.lang.String,int)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" + - ",['org.apache.zookeeper.ZooKeeper','create','(java.lang.String,byte[],java.util.List,org.apache.zookeeper.CreateMode)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" + - ",['org.apache.zookeeper.ZooKeeper','getData','(java.lang.String,boolean,org.apache.zookeeper.data.Stat)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" + - ",['org.apache.zookeeper.ZooKeeper','getChildren','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" + - ",['org.apache.zookeeper.ZooKeeper','exists','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" + - ",['org.apache.zookeeper.ZooKeeper','','(java.lang.String,int,org.apache.zookeeper.Watcher)',['java.io.IOException']]\r\n" + - ",['org.w3c.dom.Node','getNodeValue','()',['org.w3c.dom.DOMException']]\r\n" + - ",['java.io.ObjectInputStream','readObject','()',['java.io.IOException','java.lang.ClassNotFoundException']]\r\n" + - ",['java.io.ObjectInputStream','close','()',['java.io.IOException']]\r\n" + - ",['java.io.ObjectInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" + - ",['java.io.ObjectOutputStream','writeObject','(java.lang.Object)',['java.io.IOException']]\r\n" + - ",['java.io.ObjectOutputStream','close','()',['java.io.IOException']]\r\n" + - ",['java.io.ObjectOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" + - ",['java.io.FileInputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" + - ",['java.io.FileInputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" + - ",['java.nio.channels.FileChannel','tryLock','()',['java.io.IOException']]\r\n" + - ",['java.io.FileOutputStream','write','(byte[])',['java.io.IOException']]\r\n" + - ",['java.io.FileOutputStream','close','()',['java.io.IOException']]\r\n" + - ",['java.io.FileOutputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" + - ",['java.lang.reflect.Field','get','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" + - ",['java.lang.reflect.Method','invoke','(java.lang.Object,java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.reflect.InvocationTargetException']]\r\n" + - ",['java.lang.Long','parseLong','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" + - ",['java.net.InetAddress','getLocalHost','()',['java.net.UnknownHostException']]\r\n" + - ",['java.net.InetAddress','getByName','(java.lang.String)',['java.net.UnknownHostException']]\r\n" + - ",['java.lang.reflect.AccessibleObject','setAccessible','(boolean)',['java.lang.SecurityException']]\r\n" + - ",['java.lang.reflect.Array','get','(java.lang.Object,int)',['java.lang.ArrayIndexOutOfBoundsException','java.lang.IllegalArgumentException']]\r\n" + - ",['java.lang.reflect.Array','getLength','(java.lang.Object)',['java.lang.IllegalArgumentException']]\r\n" + - ",['java.net.DatagramSocket','receive','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" + - ",['java.net.DatagramSocket','send','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" + - ",['java.net.DatagramSocket','setReceiveBufferSize','(int)',['java.net.SocketException']]\r\n" + - ",['java.net.DatagramSocket','','()',['java.net.SocketException']]\r\n" + - ",['java.net.DatagramSocket','','(int)',['java.net.SocketException']]\r\n" + - ",['java.net.MulticastSocket','joinGroup','(java.net.InetAddress)',['java.io.IOException']]\r\n" + - ",['java.net.MulticastSocket','','()',['java.io.IOException']]\r\n" + - ",['java.net.MulticastSocket','','(int)',['java.io.IOException']]\r\n" + - ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object,java.lang.String,int)',['java.awt.HeadlessException']]\r\n" + - ",['javax.xml.parsers.DocumentBuilder','parse','(java.io.InputStream)',['java.io.IOException','org.xml.sax.SAXException']]\r\n" + - ",['javax.xml.parsers.DocumentBuilderFactory','newDocumentBuilder','()',['javax.xml.parsers.ParserConfigurationException']]\r\n" + - ",['java.lang.Class','getDeclaredFields','()',['java.lang.SecurityException']]\r\n" + - ",['java.lang.Class','getMethods','()',['java.lang.SecurityException']]\r\n" + - ",['java.lang.Object','wait','(long)',['java.lang.InterruptedException']]\r\n" + - ",['java.io.Reader','close','()',['java.io.IOException']]\r\n" + - ",['java.io.Writer','close','()',['java.io.IOException']]\r\n" + - ",['java.io.Writer','flush','()',['java.io.IOException']]\r\n" + - ",['java.io.Writer','write','(java.lang.String)',['java.io.IOException']]\r\n" + - ",['java.lang.Class','newInstance','()',['java.lang.IllegalAccessException','java.lang.InstantiationException']]\r\n" + - ",['java.lang.Class','getDeclaredMethod','(java.lang.String,java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" + - ",['java.lang.Class','getConstructor','(java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" + - ",['java.lang.Class','forName','(java.lang.String)',['java.lang.ClassNotFoundException']]\r\n" + - ",['java.io.File','createNewFile','()',['java.io.IOException']]\r\n" + - ",['javax.swing.JApplet','','()',['java.awt.HeadlessException']]\r\n" + - ",['javax.swing.JFrame','','(java.lang.String)',['java.awt.HeadlessException']]\r\n" + - ",['javax.swing.JFrame','','()',['java.awt.HeadlessException']]\r\n" + - ",['junit.framework.TestCase','setUp','()',['java.lang.Exception']]\r\n" + - ",['junit.framework.TestCase','tearDown','()',['java.lang.Exception']]\r\n" + - ",['java.io.BufferedReader','close','()',['java.io.IOException']]\r\n" + - ",['java.net.ServerSocket','close','()',['java.io.IOException']]\r\n" + - ",['java.net.ServerSocket','accept','()',['java.io.IOException']]\r\n" + - ",['java.net.ServerSocket','','(int)',['java.io.IOException']]\r\n" + - ",['java.lang.Thread','join','()',['java.lang.InterruptedException']]\r\n" + - ",['java.awt.Robot','','()',['java.awt.AWTException']]\r\n" + - ",['javax.swing.JInternalFrame','setSelected','(boolean)',['java.beans.PropertyVetoException']]\r\n" + - ",['javax.swing.JInternalFrame','setClosed','(boolean)',['java.beans.PropertyVetoException']]\r\n" + - ",['javax.swing.JFileChooser','showOpenDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" + - ",['javax.swing.JFileChooser','showSaveDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" + - ",['java.awt.Toolkit','getScreenSize','()',['java.awt.HeadlessException']]\r\n" + - ",['java.awt.KeyboardFocusManager','setCurrentKeyboardFocusManager','(java.awt.KeyboardFocusManager)',['java.lang.SecurityException']]\r\n" + - ",['java.awt.Frame','','()',['java.awt.HeadlessException']]\r\n" + - ",['java.lang.reflect.Field','getInt','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" + - ",['java.io.BufferedWriter','close','()',['java.io.IOException']]\r\n" + - ",['java.io.BufferedWriter','flush','()',['java.io.IOException']]\r\n" + - ",['java.io.FileReader','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" + - ",['java.io.InputStreamReader','close','()',['java.io.IOException']]\r\n" + - ",['java.io.FileWriter','','(java.io.File)',['java.io.IOException']]\r\n" + - ",['java.io.FileWriter','','(java.io.File,boolean)',['java.io.IOException']]\r\n" + - ",['java.io.OutputStreamWriter','close','()',['java.io.IOException']]\r\n" + - ",['java.io.OutputStreamWriter','flush','()',['java.io.IOException']]\r\n" + - ",['java.lang.reflect.Constructor','newInstance','(java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.InstantiationException','java.lang.reflect.InvocationTargetException']]\r\n" + - ",['java.net.Socket','close','()',['java.io.IOException']]\r\n" + - ",['java.net.Socket','getOutputStream','()',['java.io.IOException']]\r\n" + - ",['java.net.Socket','getInputStream','()',['java.io.IOException']]\r\n" + - ",['java.net.Socket','','(java.net.InetAddress,int)',['java.io.IOException']]\r\n" + - ",['java.util.logging.FileHandler','','(java.lang.String)',['java.io.IOException','java.lang.SecurityException']]\r\n" + - ",['java.util.logging.Handler','setFormatter','(java.util.logging.Formatter)',['java.lang.SecurityException']]\r\n" + - ",['java.util.logging.Logger','setLevel','(java.util.logging.Level)',['java.lang.SecurityException']]\r\n" + - ",['java.util.logging.Logger','addHandler','(java.util.logging.Handler)',['java.lang.SecurityException']]\r\n" + - ",['javax.imageio.ImageIO','write','(java.awt.image.RenderedImage,java.lang.String,java.io.File)',['java.io.IOException']]\r\n" + - ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object)',['java.awt.HeadlessException']]\r\n" + - ",['javax.swing.SwingUtilities','invokeAndWait','(java.lang.Runnable)',['java.lang.InterruptedException','java.lang.reflect.InvocationTargetException']]\r\n" + - ",['ognl.Ognl','getValue','(java.lang.Object,java.util.Map,java.lang.Object)',['ognl.OgnlException']]\r\n" + - ",['ognl.Ognl','parseExpression','(java.lang.String)',['ognl.OgnlException']]\r\n" + - ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentInstance','(java.lang.Object)',['org.picocontainer.PicoRegistrationException']]\r\n" + - ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentImplementation','(java.lang.Class)',['org.picocontainer.PicoRegistrationException']]\r\n" + - ",['java.lang.Class','getFields','()',['java.lang.SecurityException']]\r\n" + - ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','(java.io.Writer)',['java.lang.Exception']]\r\n" + - ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','()',['java.lang.Exception']]\r\n" + - ",['java.beans.Introspector','getBeanInfo','(java.lang.Class)',['java.beans.IntrospectionException']]\r\n" + - ",['java.io.InputStream','available','()',['java.io.IOException']]\r\n" + - ",['java.io.InputStream','reset','()',['java.io.IOException']]\r\n" + - ",['java.lang.String','getBytes','(java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" + - ",['javax.xml.bind.JAXBContext','createUnmarshaller','()',['javax.xml.bind.JAXBException']]\r\n" + - ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.Class[])',['javax.xml.bind.JAXBException']]\r\n" + - ",['javax.xml.bind.JAXBContext','createMarshaller','()',['javax.xml.bind.JAXBException']]\r\n" + - ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.String)',['javax.xml.bind.JAXBException']]\r\n" + - ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,org.w3c.dom.Node)',['javax.xml.bind.JAXBException']]\r\n" + - ",['javax.xml.bind.Marshaller','setProperty','(java.lang.String,java.lang.Object)',['javax.xml.bind.PropertyException']]\r\n" + - ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,java.io.Writer)',['javax.xml.bind.JAXBException']]\r\n" + - ",['javax.xml.bind.Unmarshaller','unmarshal','(java.io.InputStream)',['javax.xml.bind.JAXBException']]\r\n" + - ",['javax.xml.transform.Transformer','transform','(javax.xml.transform.Source,javax.xml.transform.Result)',['javax.xml.transform.TransformerException']]\r\n" + - ",['javax.xml.transform.Transformer','setOutputProperty','(java.lang.String,java.lang.String)',['java.lang.IllegalArgumentException']]\r\n" + - ",['javax.xml.transform.TransformerFactory','newInstance','()',['javax.xml.transform.TransformerFactoryConfigurationError']]\r\n" + - ",['javax.xml.transform.TransformerFactory','newTransformer','()',['javax.xml.transform.TransformerConfigurationException']]\r\n" + - ",['org.w3c.dom.Element','removeAttribute','(java.lang.String)',['org.w3c.dom.DOMException']]\r\n" + - ",['org.w3c.dom.Node','getTextContent','()',['org.w3c.dom.DOMException']]\r\n" + - ",['java.io.FilterInputStream','close','()',['java.io.IOException']]\r\n" + - ",['java.io.InputStream','close','()',['java.io.IOException']]\r\n" + - ",['java.io.BufferedWriter','newLine','()',['java.io.IOException']]\r\n" + - ",['java.io.DataInputStream','readUTF','()',['java.io.IOException']]\r\n" + - ",['java.io.DataInputStream','readDouble','()',['java.io.IOException']]\r\n" + - ",['java.io.DataInputStream','readInt','()',['java.io.IOException']]\r\n" + - ",['java.io.DataOutputStream','flush','()',['java.io.IOException']]\r\n" + - ",['java.io.DataOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" + - ",['java.io.DataOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" + - ",['java.io.DataOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" + - ",['java.io.FilterOutputStream','close','()',['java.io.IOException']]\r\n" + - ",['java.io.File','createTempFile','(java.lang.String,java.lang.String)',['java.io.IOException']]\r\n" + - ",['java.io.FileOutputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" + - ",['java.io.FileReader','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" + - ",['java.io.InputStreamReader','','(java.io.InputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" + - ",['java.io.OutputStreamWriter','','(java.io.OutputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" + - ",['java.io.ObjectInputStream','readUTF','()',['java.io.IOException']]\r\n" + - ",['java.io.ObjectInputStream','readDouble','()',['java.io.IOException']]\r\n" + - ",['java.io.ObjectInputStream','readInt','()',['java.io.IOException']]\r\n" + - ",['java.io.ObjectOutputStream','flush','()',['java.io.IOException']]\r\n" + - ",['java.io.ObjectOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" + - ",['java.io.ObjectOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" + - ",['java.io.ObjectOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" + - ",['java.lang.Double','parseDouble','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" + - ",['java.lang.Float','parseFloat','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" + - ",['java.security.MessageDigest','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" + - ",['java.util.concurrent.Future','get','()',['java.lang.InterruptedException','java.util.concurrent.ExecutionException']]\r\n" + - ",['java.util.zip.GZIPInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" + - ",['java.util.zip.GZIPOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" + - ",['org.apache.commons.logging.LogFactory','getLog','(java.lang.Class)',['org.apache.commons.logging.LogConfigurationException']]\r\n" + - ",['com.sun.akuma.Daemon','init','(java.lang.String)',['java.lang.Exception']]\r\n" + - ",['com.sun.akuma.Daemon','daemonize','()',['java.io.IOException']]\r\n" + - ",['java.lang.String','','(byte[],int,int,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" + - ",['java.io.Reader','read','(char[],int,int)',['java.io.IOException']]\r\n" + - ",['java.net.URI','','(java.lang.String)',['java.net.URISyntaxException']]\r\n" + - ",['java.net.URL','openStream','()',['java.io.IOException']]\r\n" + - ",['java.io.FileInputStream','close','()',['java.io.IOException']]\r\n" + - ",['java.net.InetAddress','getByAddress','(byte[])',['java.net.UnknownHostException']]\r\n" + - ",['java.util.Properties','load','(java.io.InputStream)',['java.io.IOException']]\r\n" + - ",['java.security.KeyFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" + - ",['java.security.KeyFactory','generatePrivate','(java.security.spec.KeySpec)',['java.security.spec.InvalidKeySpecException']]\r\n" + - ",['java.security.KeyStore','getInstance','(java.lang.String)',['java.security.KeyStoreException']]\r\n" + - ",['java.security.KeyStore','load','(java.io.InputStream,char[])',['java.io.IOException','java.security.NoSuchAlgorithmException','java.security.cert.CertificateException']]\r\n" + - ",['java.security.cert.CertificateFactory','getInstance','(java.lang.String)',['java.security.cert.CertificateException']]\r\n" + - ",['java.security.cert.CertificateFactory','generateCertificate','(java.io.InputStream)',['java.security.cert.CertificateException']]\r\n" + - ",['javax.net.ssl.KeyManagerFactory','init','(java.security.KeyStore,char[])',['java.security.KeyStoreException','java.security.NoSuchAlgorithmException','java.security.UnrecoverableKeyException']]\r\n" + - ",['javax.net.ssl.KeyManagerFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" + - ",['javax.net.ssl.SSLContext','init','(javax.net.ssl.KeyManager[],javax.net.ssl.TrustManager[],java.security.SecureRandom)',['java.security.KeyManagementException']]\r\n" + - ",['javax.net.ssl.SSLContext','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" + - ",['javax.net.ssl.SSLSession','getPeerCertificateChain','()',['javax.net.ssl.SSLPeerUnverifiedException']]\r\n" + - ",['javax.security.cert.Certificate','getEncoded','()',['javax.security.cert.CertificateEncodingException']]\r\n" + - ",['net.oauth.OAuthAccessor','newRequestMessage','(java.lang.String,java.lang.String,java.util.Collection)',['java.io.IOException','java.net.URISyntaxException','net.oauth.OAuthException']]\r\n" + - ",['net.oauth.OAuthMessage','getAuthorizationHeader','(java.lang.String)',['java.io.IOException']]\r\n" + - ",['net.oauth.signature.pem.PEMReader','','(java.io.InputStream)',['java.io.IOException']]\r\n" + - ",['net.oauth.signature.pem.PKCS1EncodedKeySpec','','(byte[])',['java.io.IOException']]\r\n" + - ",['org.apache.log4j.FileAppender','','(org.apache.log4j.Layout,java.lang.String)',['java.io.IOException']]\r\n" + - ",['org.jboss.netty.channel.SimpleChannelUpstreamHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" + - ",['org.jboss.netty.channel.SimpleChannelHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" + - ",['org.jboss.netty.channel.SimpleChannelHandler','handleDownstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" + - "]\r\n" - ; - - public ERR54_OLD() { - super(false); - } - - private static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS | :HAS_CLASS_IMPLEMENTS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m), (mType) WHERE SPLIT(mType.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_OF]->(mType) ON CREATE SET r.created=TRUE " - + "WITH DISTINCT ['java.lang.AutoCloseable','java.io.BufferedReader','java.io.BufferedWriter' ] as autocloseableTypeNames, sucessors "; - - // public static void main(String[] args) { - // System.out.println(new ERR54().queryToString()); - // } - @Override - protected void initiate() { - - clauses = new Clause[] { (Clause) getCFGServices().getCFGSuccesorsOf(new NodeVar("newStat"), ""), - new SimpleWithClause("DISTINCT COLLECT([newStat, succesors]) as sucessors"), - new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - // new ClauseImpl("MATCH (n)-[r:HAS_VARIABLEDECL_INIT]->(m) - // CREATE (n)-[: - new MatchClause(true, TypeServicesWiggle.getSuperTypesOf(new NodeVar("closeableSubtype"))), - new WhereClause("superType.fullyQualifiedName IN autocloseableTypeNames"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames+COLLECT(closeableSubtype.fullyQualifiedName) as autocloseableTypeNames"), - - new MatchClause(true, - " (subtype)-[:IS_SUBTYPE_OF*0..]->(enclClass)-[:DECLARES_METHOD]->(m)-[:HAS_METHODDECL_THROWS]->()"), - new MatchClause(true, " (m)-[:HAS_METHODDECL_PARAMETERS]->(p)"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames, CASE WHEN subtype.fullyQualifiedName CONTAINS '<' THEN SPLIT(subtype.fullyQualifiedName,'<')[0] ELSE subtype.fullyQualifiedName END as enclClass, m,p ORDER BY ID(p)"), - - new SimpleWithClause("autocloseableTypeNames,sucessors, " - + "enclClass, m.name as methodName, REDUCE(s='(', p IN COLLECT(p) | s+p.actualType+',') as paramTypes"), - new SimpleWithClause("DISTINCT autocloseableTypeNames,sucessors, " - + "COLLECT([enclClass, methodName, CASE WHEN paramTypes CONTAINS ',' THEN SUBSTRING(paramTypes, 0,LENGTH(paramTypes)-1) ELSE paramTypes END +')'])+" - + METHOD_THAT_THROWS + " as mThrowsInfo"), - new ClauseImpl( - "MATCH(inv)<-[:ARRAYACCESS_EXPR|ARRAYACCESS_INDEX|ASSIGNMENT_LHS|ASSIGNMENT_RHS|BINOP_LHS|BINOP_RHS|CAST_ENCLOSES|COMPOUND_ASSIGNMENT_LHS|COMPOUND_ASSIGNMENT_RHS|CONDITIONAL_CONDITION|CONDITIONAL_THEN|CONDITIONAL_ELSE|HAS_VARIABLEDECL_INIT|INSTANCEOF_EXPR|PARENTHESIZED_ENCLOSES|MEMBER_SELECT_EXPR|METHODINVOCATION_ARGUMENTS|METHODINVOCATION_METHOD_SELECT|NEW_CLASS_ARGUMENTS|NEWARRAY_INIT|NEWARRAY_DIMENSION|UNARY_ENCLOSES*0..]-()<-[:ASSERT_CONDITION|DOWHILE_CONDITION|EXPR_ENCLOSES|FOREACH_EXPR|FORLOOP_CONDITION|HAS_VARIABLEDECL_INIT|IF_CONDITION|RETURN_EXPR|SWITCH_EXPR|SYNCHRONIZED_EXPR|THROW_EXPR|WHILE_CONDITION]-(stat)<-[:CASE_STATEMENTS|CATCH_BLOCK|CATCH_PARAM|ENCLOSES|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|HAS_METHODDECL_PARAMETERS|IF_THEN|IF_ELSE|LABELED_STATEMENT|SWITCH_ENCLOSES_CASES|SYNCHRONIZED_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*]-()<-[:HAS_METHODDECL_BODY]-({nodeType:'JCMethodDecl'})<-[:DECLARES_METHOD]-(callerEncType)\r\n" - + " WHERE inv.nodeType IN ['JCMethodInvocation', 'JCNewClass'] " - + "OPTIONAL MATCH (invMember)<-[:METHODINVOCATION_METHOD_SELECT]-(inv)" - + "OPTIONAL MATCH (invMember)-[:MEMBER_SELECT_EXPR]->(memberSelection)" - + "OPTIONAL MATCH (inv)-[:NEW_CLASS_ARGUMENTS]->(arg)" - + " WITH autocloseableTypeNames,sucessors, mThrowsInfo,stat,inv,invMember,arg, CASE WHEN invMember IS NULL THEN inv.actualType ELSE CASE WHEN invMember.nodeType='JCIdent' THEN callerEncType.fullyQualifiedName ELSE memberSelection.actualType END END as callerEncTypeName ORDER BY ID(arg)" - + " WITH DISTINCT " + "autocloseableTypeNames,sucessors, mThrowsInfo," - + "stat,inv,invMember, callerEncTypeName, REDUCE(s='(', arg IN COLLECT(arg) | s+CASE WHEN s='(' THEN arg.actualType ELSE ','+arg.actualType END )+')' as newClassArgs "), - - new SimpleWithClause("DISTINCT " + "autocloseableTypeNames,sucessors,mThrowsInfo," - + " stat, COLLECT([CASE WHEN callerEncTypeName CONTAINS '<' AND NOT callerEncTypeName STARTS WITH '<' THEN SPLIT(callerEncTypeName,'<')[0] ELSE callerEncTypeName END , CASE WHEN invMember IS NULL THEN '' ELSE invMember.name END,CASE WHEN invMember IS NULL THEN newClassArgs ELSE SPLIT(invMember.actualType,')')[0]+')' END]) as invInfoInStats"), - - new WhereClause("ANY(invSignature IN invInfoInStats " - + " WHERE ANY(throwSignature IN mThrowsInfo WHERE throwSignature[0]=invSignature[0] AND throwSignature[1]=invSignature[1] AND throwSignature[2]=invSignature[2]) )"), - new SimpleWithClause( - "DISTINCT autocloseableTypeNames,sucessors, COLLECT( DISTINCT stat) as statsMayThrow"), - new MatchClause(true, - "(stat) WHERE stat.nodeType IN ['JCThrow', 'JCAssert'] WITH DISTINCT autocloseableTypeNames,sucessors, statsMayThrow+COLLECT(stat) as statsMayThrow"), - - new MatchClause(PDGServicesWiggle.WIGGLE.getIdsAndVarDeclarations(new NodeVar("id"), - "autocloseableTypeNames,sucessors,statsMayThrow ")), - new WhereClause("varDec.actualType IN autocloseableTypeNames"), - new SimpleWithClause( - "DISTINCT autocloseableTypeNames,sucessors,statsMayThrow, varDec as dec, COLLECT(DISTINCT id) as ids"), - // new ReturnClause("DISTINCT dec, ids"), - new MatchClause(true, - " (dec)<-[r:TRY_RESOURCES]-() WITH DISTINCT sucessors,statsMayThrow, dec,ids,r WHERE r IS NULL"), - // new ReturnClause("DISTINCT dec") - - new MatchClause(true, - getAssignmentServices().getLeftPartAssignments(new NodeVar("assignment"), new NodeVar("id")), - getExpressionServices().getStatementFromExp(new NodeVar("assignment"))), - new WhereClause("id IN ids"), - new SimpleWithClause(" DISTINCT " + " sucessors,statsMayThrow,ids, " + "dec, COLLECT(stat) as mods "), - - new MatchClause(true, new MatchImpl("(dec)-[r:HAS_VARIABLEDECL_INIT]->()")), - new SimpleWithClause("DISTINCT " + " sucessors, statsMayThrow," - + " dec, ids, mods + CASE WHEN r IS NULL THEN [] ELSE [dec] END as mods"), - new UnwindClause("mods", "mod"), - new MatchClause(MethodInvocationServicesWiggle.getMethodInvocationOf("close"), - getExpressionServices().getStatementFromExp(new NodeVar("mInv"), new NodeVar("closeStat"))), - - new WhereClause("object IN ids"), - new SimpleWithClause("DISTINCT sucessors,statsMayThrow, dec, mod, COLLECT(closeStat) as closeStmts"), - new SimpleWithClause( - " sucessors, dec, mod,closeStmts, FILTER( stat IN statsMayThrow WHERE NOT stat IN closeStmts AND stat IN FILTER(x IN sucessors WHERE x[0]=mod)[0][1]" - + " AND ANY(closeStat IN closeStmts WHERE closeStat IN FILTER(x IN sucessors WHERE x[0]=stat)[0][1]) ) as prevStats"), - new UnwindClause("prevStats", "prevStat"), - // new ReturnClause("DISTINCT FILTER(x IN sucessors WHERE - // x[0].nodeType='JCCatch' )") - - new MatchClause(true, - "p=" + getStatementServices().getOuterBlockFromStatement(new NodeVar("prevStat"), - new NodeVar("try{nodeType:'JCTry'}")).matchToString()), - new WhereClause("NOT TYPE(REVERSE(RELATIONSHIPS(p))[0]) IN ['TRY_CATCH', 'TRY_FINALLY']"), - new MatchClause(true, "(try)-[:TRY_CATCH ]->(catch)"), - new SimpleWithClause( - "DISTINCT sucessors,dec, mod, prevStat,closeStmts, try, REDUCE(l=[],catch IN COLLECT(catch) | l+FILTER(x IN sucessors WHERE x[0]=catch)[0][1] ) as catchSucs"), - new MatchClause(true, - getStatementServices() - .getOuterBlockFromStatement(new NodeVar("finallyStat"), new NodeVar("finally")) - .matchToString() + "<-[:TRY_FINALLY]-(try)"), - new SimpleWithClause( - " DISTINCT dec, mod, prevStat,closeStmts, try, CASE WHEN SIZE(catchSucs)=0 THEN COLLECT(finallyStat) ELSE catchSucs END as stmsReacheableAfterEx"), - new SimpleWithClause( - "DISTINCT dec, mod, prevStat,NOT ANY( reacheableStmt IN REDUCE(l=[], reacheables IN COLLECT(stmsReacheableAfterEx) | l+reacheables ) WHERE reacheableStmt IN closeStmts) as notReachebleClose"), - new WhereClause(" notReachebleClose "), - new MatchClause(getStatementServices().getEnclosingClassFromStatement(new NodeVar("dec"))), - new SimpleWithClause( - "DISTINCT 'Warning [CMU-ERR54] variable '+dec.name+ '(defined in line'+dec.lineNumber+', class '+enclClass.fullyQualifiedName+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN COLLECT(DISTINCT prevStat) | prev.lineNumber)+') may throw an exception.' as warning") - , new SimpleWithClause("DISTINCT COLLECT(warning) as warnings"), new MatchClause(false, "()-[r:IS_SUBTYPE_OF]->() DELETE r WITH DISTINCT warnings RETURN warnings") - // , new WhereClause(" allReacheables ") - }; - } - - public static void main(String[] args) { - System.out.println(new ERR54_OLD().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/MET52.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/MET52.java deleted file mode 100644 index 1c69cbb..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/MET52.java +++ /dev/null @@ -1,72 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.ModifiersServiceWiggle; -import database.relations.RelationTypesWiggle; - -public class MET52 extends AbstractQuery { - - public MET52() { - super(false); - // TODO Auto-generated constructor stub - } - - /* - * - * private static final String - * MET52_DO_NOT_USE_CLONE_WITH_UNTRUSTED_PARAMETERS = - * " MATCH (typeDec{accessLevel:'public'})-[:DECLARES_METHOD]->(method{accessLevel:'public'})-[:HAS_METHODDECL_PARAMETERS]->(param)" - * + - * " -[:USED_BY]->(id), (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'clone'})-[:MEMBER_SELECT_EXPR]->(id), (mInv)-[:HAS_DEC]->(dec) WHERE dec.fullyQualifiedName CONTAINS '()' WITH param, mInv.lineNumber as line, method.fullyQualifiedName as methodName" - * + - * " MATCH (typeDec{fullyQualifiedName:param.actualType, accessLevel:'public', isFinal:false})" - * + - * " RETURN 'Warning [CMU-MET52] You must not use the clone method to copy unstrasted parameters (like parameter ' + param.name+ ', cloned in line '+ line + ' in method ' + methodName +').'" - * ; - * - * - */ - public static void main(String[] args){ - System.out.println(new MET52().queryToString()); - } - @Override - protected void initiate() { - clauses = new Clause[] { - new MatchClause(ModifiersServiceWiggle.getClassModifiers(new NodeVar("typeDec")), - new RelationshipImpl(new NodeVar("typeDec"), new NodeVar("method"), - new EdgeImpl(RelationTypesWiggle.DECLARES_METHOD)), - new RelationshipImpl(new NodeVar("param"), - ModifiersServiceWiggle.getMethodModifiers(new NodeVar("method")), - new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.HAS_METHODDECL_PARAMETERS))), - new WhereClause("methodModifiers.flags CONTAINS 'public' AND classModifiers.flags CONTAINS 'public'"), - new SimpleWithClause("param", "method"), - new MatchClause(getPDGServices().getIdsAndVarDeclarations(new NodeVar("useId"), new NodeVar("param"), - "method")), - new MatchClause(new MatchImpl( - "(mInv{nodeType:'JCMethodInvocation'})-[:METHODINVOCATION_METHOD_SELECT]->(mSelect{name:'clone'})-[:MEMBER_SELECT_EXPR]->(useId)")), - new MatchClause(true, - new RelationshipImpl(new NodeVar("mInv"), new NodeVar("arg"), - RelationTypesWiggle.METHODINVOCATION_ARGUMENTS)), - new WhereClause("arg IS NULL"), - new SimpleWithClause("param, mInv.lineNumber as line, method.name as methodName"), - new MatchClause(ModifiersServiceWiggle.getClassModifiers( - new NodeVar("typeDec"))), - new WhereClause( - "classModifiers.flags CONTAINS 'public' AND NOT classModifiers.flags CONTAINS 'final' AND SPLIT(typeDec.fullyQualifiedName, '<')[0]=SPLIT(param.actualType, '<')[0]"), - new ReturnClause( - "'Warning [CMU-MET52] You must not use the clone method to copy unstrasted parameters (like parameter ' + param.name+ ', cloned in line '+ line + ' in method ' + methodName +').'") - - }; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/MIDDLE_ERR54.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/MIDDLE_ERR54.java deleted file mode 100644 index 1ec2d74..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/MIDDLE_ERR54.java +++ /dev/null @@ -1,381 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.MethodInvocationServicesWiggle; -import database.querys.services.PDGServicesWiggle; -import database.querys.services.TypeServicesWiggle; - -public class MIDDLE_ERR54 extends AbstractQuery { - - /* - * " MATCH (closeableSubtype)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(closeableInt:INTERFACE_DECLARATION{fullyQualifiedName:'java.lang.AutoCloseable'})" - * + - * " WHERE closeableSubtype:CLASS_DECLARATION OR closeableSubtype:INTERFACE_DECLARATION " - * + " WITH DISTINCT closeableSubtype.fullyQualifiedName as className " - * - * + - * " MATCH (closeableDec{actualType:className})-[:MODIFIED_BY]->(assign) <-[" - * + assignToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery + - * "]-(assignStat) " + - * - * - * - * - * " OPTIONAL MATCH (closeableDec)<-[r:TRY_RESOURCES]-() WITH assignStat,r, closeableDec WHERE r IS NULL" - * - * + - * "MATCH (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'close'})-[:MEMBER_SELECT_EXPR]->(id)<-[:USED_BY]-(closeableDec)," - * + " (mInv)<-[" + exprToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery - * + "]-(closeStat)" + ", - * - * (assignStat)-[" + cfgSuccesor + "*1..]->(prev)" + - * "-[:IF_THERE_IS_UNCAUGHT_EXCEPTION | :MAY_THROW | :THROWS]->(afterEx)" + - * - * " WITH COLLECT(DISTINCT closeStat) AS closes, prev,closeableDec, afterEx" - * - * - * + " MATCH (prev)-[" + cfgSuccesor + - * "*]->(closeStat) WHERE closeStat IN closes" + - * - * " WITH closes,COLLECT(DISTINCT prev) AS prevs, afterEx, closeableDec" + - * - * " WITH closes, [prev IN prevs WHERE NOT prev IN closes] as prevs, afterEx , closeableDec" - * + " WHERE SIZE(prevs)>=1 " + " MATCH (afterEx)-[" + - * getAnyRel(toCFGSuccesorNoCondEx) + - * "*0..]->(reachableAfterEx) WITH closes,COLLECT(reachableAfterEx) AS reachable, prevs, closeableDec" - * + " WHERE ALL(r IN reachable WHERE NOT r IN closes)" - * - * + - * " RETURN 'Warning [CMU-ERR54] variable '+closeableDec.name+ '(defined in line'+closeableDec.lineNumber+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN prevs | prev.lineNumber)+') may throw an exception.'" - * - * - */ - private final String EXCEPTION_HIER = "" + - "[['java.io.IOException',['java.lang.Exception','java.lang.Throwable'],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.net.MalformedURLException','java.net.SocketException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.util.InvalidPropertiesFormatException','java.util.jar.JarException','java.util.zip.ZipException']],\r\n" + - "['java.lang.AssertionError',['java.lang.Throwable'],['java.lang.AssertionError']],\r\n" + - "['java.lang.NullPointerException',['java.lang.Exception','java.lang.RuntimeException','java.lang.Throwable'],['java.lang.NullPointerException']],\r\n" + - "['java.lang.Throwable',[''],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.lang.AssertionError','java.lang.ClassFormatError','java.lang.ClassNotFoundException','java.lang.CloneNotSupportedException','java.lang.Exception','java.lang.IllegalAccessError','java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.InstantiationException','java.lang.InterruptedException','java.lang.NoSuchFieldException','java.lang.NoSuchMethodException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.Throwable','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.lang.invoke.NoSuchMemberException','java.lang.invoke.T','java.lang.reflect.InvocationTargetException','java.net.MalformedURLException','java.net.SocketException','java.net.URISyntaxException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.security.AccessControlException','java.security.DigestException','java.security.InvalidKeyException','java.security.NoSuchAlgorithmException','java.security.NoSuchProviderException','java.security.PrivilegedActionException','java.security.SignatureException','java.security.cert.CertificateEncodingException','java.security.cert.CertificateException','java.sql.SQLException','java.text.ParseException','java.util.InvalidPropertiesFormatException','java.util.MissingResourceException','java.util.X','java.util.X','java.util.X','java.util.X','java.util.concurrent.ExecutionException','java.util.concurrent.TimeoutException','java.util.jar.JarException','java.util.zip.ZipException','sun.util.locale.LocaleSyntaxException']],\r\n" + - "['java.lang.Exception',['java.lang.Throwable'],['java.io.FileNotFoundException','java.io.IOException','java.io.InvalidClassException','java.io.InvalidObjectException','java.io.NotActiveException','java.io.ObjectStreamException','java.io.StreamCorruptedException','java.io.SyncFailedException','java.io.UnsupportedEncodingException','java.lang.ClassNotFoundException','java.lang.CloneNotSupportedException','java.lang.Exception','java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.InstantiationException','java.lang.InterruptedException','java.lang.NoSuchFieldException','java.lang.NoSuchMethodException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.lang.invoke.NoSuchMemberException','java.lang.reflect.InvocationTargetException','java.net.MalformedURLException','java.net.SocketException','java.net.URISyntaxException','java.net.UnknownHostException','java.net.UnknownServiceException','java.nio.channels.AsynchronousCloseException','java.nio.charset.CharacterCodingException','java.security.AccessControlException','java.security.DigestException','java.security.InvalidKeyException','java.security.NoSuchAlgorithmException','java.security.NoSuchProviderException','java.security.PrivilegedActionException','java.security.SignatureException','java.security.cert.CertificateEncodingException','java.security.cert.CertificateException','java.sql.SQLException','java.text.ParseException','java.util.InvalidPropertiesFormatException','java.util.MissingResourceException','java.util.concurrent.ExecutionException','java.util.concurrent.TimeoutException','java.util.jar.JarException','java.util.zip.ZipException','sun.util.locale.LocaleSyntaxException']],\r\n" + - "['java.lang.RuntimeException',['java.lang.Exception','java.lang.Throwable'],['java.lang.IllegalArgumentException','java.lang.IllegalStateException','java.lang.NullPointerException','java.lang.NumberFormatException','java.lang.RuntimeException','java.lang.SecurityException','java.lang.TypeNotPresentException','java.lang.UnsupportedOperationException','java.security.AccessControlException','java.util.MissingResourceException']],\r\n" + - "['java.lang.IllegalStateException',['java.lang.Exception','java.lang.RuntimeException','java.lang.Throwable'],['java.lang.IllegalStateException']]]\r\n" + - ""; - private final String METHOD_THAT_THROWS = "[['java.lang.Thread','sleep','(long)',['java.lang.InterruptedException']]\r\n" - + ",['java.io.BufferedReader','readLine','()',['java.io.IOException']]\r\n" - + ",['java.lang.Double','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Integer','valueOf','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['android.content.res.Resources','getStringArray','(int)',['android.content.res.Resources$NotFoundException']]\r\n" - + ",['android.database.sqlite.SQLiteDatabase','execSQL','(java.lang.String)',['android.database.SQLException']]\r\n" - + ",['android.media.MediaPlayer','start','()',['java.lang.IllegalStateException']]\r\n" - + ",['android.media.MediaPlayer','stop','()',['java.lang.IllegalStateException']]\r\n" - + ",['java.lang.Object','wait','()',['java.lang.InterruptedException']]\r\n" - + ",['java.lang.Integer','parseInt','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Integer','','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','delete','(java.lang.String,int)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','create','(java.lang.String,byte[],java.util.List,org.apache.zookeeper.CreateMode)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','getData','(java.lang.String,boolean,org.apache.zookeeper.data.Stat)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','getChildren','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','exists','(java.lang.String,boolean)',['java.lang.InterruptedException','org.apache.zookeeper.KeeperException']]\r\n" - + ",['org.apache.zookeeper.ZooKeeper','','(java.lang.String,int,org.apache.zookeeper.Watcher)',['java.io.IOException']]\r\n" - + ",['org.w3c.dom.Node','getNodeValue','()',['org.w3c.dom.DOMException']]\r\n" - + ",['java.io.ObjectInputStream','readObject','()',['java.io.IOException','java.lang.ClassNotFoundException']]\r\n" - + ",['java.io.ObjectInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeObject','(java.lang.Object)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" - + ",['java.io.FileInputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.FileInputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.nio.channels.FileChannel','tryLock','()',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','write','(byte[])',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.lang.reflect.Field','get','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.lang.reflect.Method','invoke','(java.lang.Object,java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['java.lang.Long','parseLong','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.net.InetAddress','getLocalHost','()',['java.net.UnknownHostException']]\r\n" - + ",['java.net.InetAddress','getByName','(java.lang.String)',['java.net.UnknownHostException']]\r\n" - + ",['java.lang.reflect.AccessibleObject','setAccessible','(boolean)',['java.lang.SecurityException']]\r\n" - + ",['java.lang.reflect.Array','get','(java.lang.Object,int)',['java.lang.ArrayIndexOutOfBoundsException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.lang.reflect.Array','getLength','(java.lang.Object)',['java.lang.IllegalArgumentException']]\r\n" - + ",['java.net.DatagramSocket','receive','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" - + ",['java.net.DatagramSocket','send','(java.net.DatagramPacket)',['java.io.IOException']]\r\n" - + ",['java.net.DatagramSocket','setReceiveBufferSize','(int)',['java.net.SocketException']]\r\n" - + ",['java.net.DatagramSocket','','()',['java.net.SocketException']]\r\n" - + ",['java.net.DatagramSocket','','(int)',['java.net.SocketException']]\r\n" - + ",['java.net.MulticastSocket','joinGroup','(java.net.InetAddress)',['java.io.IOException']]\r\n" - + ",['java.net.MulticastSocket','','()',['java.io.IOException']]\r\n" - + ",['java.net.MulticastSocket','','(int)',['java.io.IOException']]\r\n" - + ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object,java.lang.String,int)',['java.awt.HeadlessException']]\r\n" - + ",['javax.xml.parsers.DocumentBuilder','parse','(java.io.InputStream)',['java.io.IOException','org.xml.sax.SAXException']]\r\n" - + ",['javax.xml.parsers.DocumentBuilderFactory','newDocumentBuilder','()',['javax.xml.parsers.ParserConfigurationException']]\r\n" - + ",['java.lang.Class','getDeclaredFields','()',['java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','getMethods','()',['java.lang.SecurityException']]\r\n" - + ",['java.lang.Object','wait','(long)',['java.lang.InterruptedException']]\r\n" - + ",['java.io.Reader','close','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','close','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.Writer','write','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.lang.Class','newInstance','()',['java.lang.IllegalAccessException','java.lang.InstantiationException']]\r\n" - + ",['java.lang.Class','getDeclaredMethod','(java.lang.String,java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','getConstructor','(java.lang.Class[])',['java.lang.NoSuchMethodException','java.lang.SecurityException']]\r\n" - + ",['java.lang.Class','forName','(java.lang.String)',['java.lang.ClassNotFoundException']]\r\n" - + ",['java.io.File','createNewFile','()',['java.io.IOException']]\r\n" - + ",['javax.swing.JApplet','','()',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFrame','','(java.lang.String)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFrame','','()',['java.awt.HeadlessException']]\r\n" - + ",['junit.framework.TestCase','setUp','()',['java.lang.Exception']]\r\n" - + ",['junit.framework.TestCase','tearDown','()',['java.lang.Exception']]\r\n" - + ",['java.io.BufferedReader','close','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','close','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','accept','()',['java.io.IOException']]\r\n" - + ",['java.net.ServerSocket','','(int)',['java.io.IOException']]\r\n" - + ",['java.lang.Thread','join','()',['java.lang.InterruptedException']]\r\n" - + ",['java.awt.Robot','','()',['java.awt.AWTException']]\r\n" - + ",['javax.swing.JInternalFrame','setSelected','(boolean)',['java.beans.PropertyVetoException']]\r\n" - + ",['javax.swing.JInternalFrame','setClosed','(boolean)',['java.beans.PropertyVetoException']]\r\n" - + ",['javax.swing.JFileChooser','showOpenDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.JFileChooser','showSaveDialog','(java.awt.Component)',['java.awt.HeadlessException']]\r\n" - + ",['java.awt.Toolkit','getScreenSize','()',['java.awt.HeadlessException']]\r\n" - + ",['java.awt.KeyboardFocusManager','setCurrentKeyboardFocusManager','(java.awt.KeyboardFocusManager)',['java.lang.SecurityException']]\r\n" - + ",['java.awt.Frame','','()',['java.awt.HeadlessException']]\r\n" - + ",['java.lang.reflect.Field','getInt','(java.lang.Object)',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException']]\r\n" - + ",['java.io.BufferedWriter','close','()',['java.io.IOException']]\r\n" - + ",['java.io.BufferedWriter','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.FileReader','','(java.io.File)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.InputStreamReader','close','()',['java.io.IOException']]\r\n" - + ",['java.io.FileWriter','','(java.io.File)',['java.io.IOException']]\r\n" - + ",['java.io.FileWriter','','(java.io.File,boolean)',['java.io.IOException']]\r\n" - + ",['java.io.OutputStreamWriter','close','()',['java.io.IOException']]\r\n" - + ",['java.io.OutputStreamWriter','flush','()',['java.io.IOException']]\r\n" - + ",['java.lang.reflect.Constructor','newInstance','(java.lang.Object[])',['java.lang.IllegalAccessException','java.lang.IllegalArgumentException','java.lang.InstantiationException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['java.net.Socket','close','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','getOutputStream','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','getInputStream','()',['java.io.IOException']]\r\n" - + ",['java.net.Socket','','(java.net.InetAddress,int)',['java.io.IOException']]\r\n" - + ",['java.util.logging.FileHandler','','(java.lang.String)',['java.io.IOException','java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Handler','setFormatter','(java.util.logging.Formatter)',['java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Logger','setLevel','(java.util.logging.Level)',['java.lang.SecurityException']]\r\n" - + ",['java.util.logging.Logger','addHandler','(java.util.logging.Handler)',['java.lang.SecurityException']]\r\n" - + ",['javax.imageio.ImageIO','write','(java.awt.image.RenderedImage,java.lang.String,java.io.File)',['java.io.IOException']]\r\n" - + ",['javax.swing.JOptionPane','showConfirmDialog','(java.awt.Component,java.lang.Object)',['java.awt.HeadlessException']]\r\n" - + ",['javax.swing.SwingUtilities','invokeAndWait','(java.lang.Runnable)',['java.lang.InterruptedException','java.lang.reflect.InvocationTargetException']]\r\n" - + ",['ognl.Ognl','getValue','(java.lang.Object,java.util.Map,java.lang.Object)',['ognl.OgnlException']]\r\n" - + ",['ognl.Ognl','parseExpression','(java.lang.String)',['ognl.OgnlException']]\r\n" - + ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentInstance','(java.lang.Object)',['org.picocontainer.PicoRegistrationException']]\r\n" - + ",['org.picocontainer.defaults.DefaultPicoContainer','registerComponentImplementation','(java.lang.Class)',['org.picocontainer.PicoRegistrationException']]\r\n" - + ",['java.lang.Class','getFields','()',['java.lang.SecurityException']]\r\n" - + ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','(java.io.Writer)',['java.lang.Exception']]\r\n" - + ",['com.nfe.guardian.shared.model.response.NFEGuardianResponse','toXML','()',['java.lang.Exception']]\r\n" - + ",['java.beans.Introspector','getBeanInfo','(java.lang.Class)',['java.beans.IntrospectionException']]\r\n" - + ",['java.io.InputStream','available','()',['java.io.IOException']]\r\n" - + ",['java.io.InputStream','reset','()',['java.io.IOException']]\r\n" - + ",['java.lang.String','getBytes','(java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['javax.xml.bind.JAXBContext','createUnmarshaller','()',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.Class[])',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','createMarshaller','()',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.JAXBContext','newInstance','(java.lang.String)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,org.w3c.dom.Node)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Marshaller','setProperty','(java.lang.String,java.lang.Object)',['javax.xml.bind.PropertyException']]\r\n" - + ",['javax.xml.bind.Marshaller','marshal','(java.lang.Object,java.io.Writer)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.bind.Unmarshaller','unmarshal','(java.io.InputStream)',['javax.xml.bind.JAXBException']]\r\n" - + ",['javax.xml.transform.Transformer','transform','(javax.xml.transform.Source,javax.xml.transform.Result)',['javax.xml.transform.TransformerException']]\r\n" - + ",['javax.xml.transform.Transformer','setOutputProperty','(java.lang.String,java.lang.String)',['java.lang.IllegalArgumentException']]\r\n" - + ",['javax.xml.transform.TransformerFactory','newInstance','()',['javax.xml.transform.TransformerFactoryConfigurationError']]\r\n" - + ",['javax.xml.transform.TransformerFactory','newTransformer','()',['javax.xml.transform.TransformerConfigurationException']]\r\n" - + ",['org.w3c.dom.Element','removeAttribute','(java.lang.String)',['org.w3c.dom.DOMException']]\r\n" - + ",['org.w3c.dom.Node','getTextContent','()',['org.w3c.dom.DOMException']]\r\n" - + ",['java.io.FilterInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.InputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.BufferedWriter','newLine','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readUTF','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readDouble','()',['java.io.IOException']]\r\n" - + ",['java.io.DataInputStream','readInt','()',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" - + ",['java.io.DataOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" - + ",['java.io.FilterOutputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.io.File','createTempFile','(java.lang.String,java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.FileOutputStream','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.FileReader','','(java.lang.String)',['java.io.FileNotFoundException']]\r\n" - + ",['java.io.InputStreamReader','','(java.io.InputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.OutputStreamWriter','','(java.io.OutputStream,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.ObjectInputStream','readUTF','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','readDouble','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectInputStream','readInt','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','flush','()',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeUTF','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeDouble','(double)',['java.io.IOException']]\r\n" - + ",['java.io.ObjectOutputStream','writeInt','(int)',['java.io.IOException']]\r\n" - + ",['java.lang.Double','parseDouble','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.lang.Float','parseFloat','(java.lang.String)',['java.lang.NumberFormatException']]\r\n" - + ",['java.security.MessageDigest','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['java.util.concurrent.Future','get','()',['java.lang.InterruptedException','java.util.concurrent.ExecutionException']]\r\n" - + ",['java.util.zip.GZIPInputStream','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.util.zip.GZIPOutputStream','','(java.io.OutputStream)',['java.io.IOException']]\r\n" - + ",['org.apache.commons.logging.LogFactory','getLog','(java.lang.Class)',['org.apache.commons.logging.LogConfigurationException']]\r\n" - + ",['com.sun.akuma.Daemon','init','(java.lang.String)',['java.lang.Exception']]\r\n" - + ",['com.sun.akuma.Daemon','daemonize','()',['java.io.IOException']]\r\n" - + ",['java.lang.String','','(byte[],int,int,java.lang.String)',['java.io.UnsupportedEncodingException']]\r\n" - + ",['java.io.Reader','read','(char[],int,int)',['java.io.IOException']]\r\n" - + ",['java.net.URI','','(java.lang.String)',['java.net.URISyntaxException']]\r\n" - + ",['java.net.URL','openStream','()',['java.io.IOException']]\r\n" - + ",['java.io.FileInputStream','close','()',['java.io.IOException']]\r\n" - + ",['java.net.InetAddress','getByAddress','(byte[])',['java.net.UnknownHostException']]\r\n" - + ",['java.util.Properties','load','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['java.security.KeyFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['java.security.KeyFactory','generatePrivate','(java.security.spec.KeySpec)',['java.security.spec.InvalidKeySpecException']]\r\n" - + ",['java.security.KeyStore','getInstance','(java.lang.String)',['java.security.KeyStoreException']]\r\n" - + ",['java.security.KeyStore','load','(java.io.InputStream,char[])',['java.io.IOException','java.security.NoSuchAlgorithmException','java.security.cert.CertificateException']]\r\n" - + ",['java.security.cert.CertificateFactory','getInstance','(java.lang.String)',['java.security.cert.CertificateException']]\r\n" - + ",['java.security.cert.CertificateFactory','generateCertificate','(java.io.InputStream)',['java.security.cert.CertificateException']]\r\n" - + ",['javax.net.ssl.KeyManagerFactory','init','(java.security.KeyStore,char[])',['java.security.KeyStoreException','java.security.NoSuchAlgorithmException','java.security.UnrecoverableKeyException']]\r\n" - + ",['javax.net.ssl.KeyManagerFactory','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['javax.net.ssl.SSLContext','init','(javax.net.ssl.KeyManager[],javax.net.ssl.TrustManager[],java.security.SecureRandom)',['java.security.KeyManagementException']]\r\n" - + ",['javax.net.ssl.SSLContext','getInstance','(java.lang.String)',['java.security.NoSuchAlgorithmException']]\r\n" - + ",['javax.net.ssl.SSLSession','getPeerCertificateChain','()',['javax.net.ssl.SSLPeerUnverifiedException']]\r\n" - + ",['javax.security.cert.Certificate','getEncoded','()',['javax.security.cert.CertificateEncodingException']]\r\n" - + ",['net.oauth.OAuthAccessor','newRequestMessage','(java.lang.String,java.lang.String,java.util.Collection)',['java.io.IOException','java.net.URISyntaxException','net.oauth.OAuthException']]\r\n" - + ",['net.oauth.OAuthMessage','getAuthorizationHeader','(java.lang.String)',['java.io.IOException']]\r\n" - + ",['net.oauth.signature.pem.PEMReader','','(java.io.InputStream)',['java.io.IOException']]\r\n" - + ",['net.oauth.signature.pem.PKCS1EncodedKeySpec','','(byte[])',['java.io.IOException']]\r\n" - + ",['org.apache.log4j.FileAppender','','(org.apache.log4j.Layout,java.lang.String)',['java.io.IOException']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelUpstreamHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelHandler','handleUpstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + ",['org.jboss.netty.channel.SimpleChannelHandler','handleDownstream','(org.jboss.netty.channel.ChannelHandlerContext,org.jboss.netty.channel.ChannelEvent)',['java.lang.Exception']]\r\n" - + "]\r\n"; - - public MIDDLE_ERR54() { - super(false); - } - - private static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS | :HAS_CLASS_IMPLEMENTS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m), (mType) WHERE SPLIT(mType.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_OF]->(mType) ON CREATE SET r.created=TRUE " - + "WITH DISTINCT ['java.lang.AutoCloseable','java.io.BufferedReader','java.io.BufferedWriter' ] as autocloseableTypeNames, sucessors "; - - // public static void main(String[] args) { - // System.out.println(new ERR54().queryToString()); - // } - @Override - protected void initiate() { - - clauses = new Clause[] { (Clause) getCFGServices().getCFGSuccesorsOf(new NodeVar("newStat"), ""), - new SimpleWithClause("DISTINCT COLLECT([newStat, succesors]) as sucessors"), - new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - // new ClauseImpl("MATCH (n)-[r:HAS_VARIABLEDECL_INIT]->(m) - // CREATE (n)-[: - new MatchClause(true, TypeServicesWiggle.getSuperTypesOf(new NodeVar("closeableSubtype"))), - new WhereClause("superType.fullyQualifiedName IN autocloseableTypeNames"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames+COLLECT(closeableSubtype.fullyQualifiedName) as autocloseableTypeNames"), - - new MatchClause(true, - " (subtype)-[:IS_SUBTYPE_OF*0..]->(enclClass)-[:DECLARES_METHOD]->(m)-[:HAS_METHODDECL_THROWS]->()"), - new MatchClause(true, " (m)-[:HAS_METHODDECL_PARAMETERS]->(p)"), new SimpleWithClause( - "DISTINCT sucessors,autocloseableTypeNames, CASE WHEN subtype.fullyQualifiedName CONTAINS '<' THEN SPLIT(subtype.fullyQualifiedName,'<')[0] ELSE subtype.fullyQualifiedName END as enclClass, m,p ORDER BY ID(p)"), - - new SimpleWithClause("autocloseableTypeNames,sucessors, " - + "enclClass, m.name as methodName, REDUCE(s='(', p IN COLLECT(p) | s+p.actualType+',') as paramTypes"), - new SimpleWithClause("DISTINCT autocloseableTypeNames,sucessors, " - + "COLLECT([enclClass, methodName, CASE WHEN paramTypes CONTAINS ',' THEN SUBSTRING(paramTypes, 0,LENGTH(paramTypes)-1) ELSE paramTypes END +')'])+" - + METHOD_THAT_THROWS + " as mThrowsInfo, " - + EXCEPTION_HIER+ - " as exHier"), - new MatchClause(true, - "(non_declaredEx)<-[:HAS_CLASS_EXTENDS]-(superDeclaredEx),hier=(declaredEx)-[:IS_SUBTYPE_OF*0..]->(superDeclaredEx)" - + ", (declaredEx)<-[:IS_SUBTYPE_OF*0..]-(subTypeDeclared)" - + " WHERE non_declaredEx.actualType IN EXTRACT(row IN exHier | row[0])" + "" - + " WITH DISTINCT" - + " autocloseableTypeNames,sucessors, mThrowsInfo, " - + " exHier, " - + " [declaredEx.fullyQualifiedName" - + ",EXTRACT(x IN TAIL(NODES(hier)) | x.fullyQualifiedName)+[non_declaredEx.actualType]+ FILTER(hier IN exHier WHERE hier[0]=non_declaredEx.actualType)[0][1]" - + ",EXTRACT(x IN COLLECT(subTypeDeclared) | x.fullyQualifiedName) ] as declaredHier" - + " WITH DISTINCT autocloseableTypeNames,sucessors, mThrowsInfo, exHier+COLLECT(declaredHier) as exHier"), - new ClauseImpl( - "MATCH(inv)<-[:ARRAYACCESS_EXPR|ARRAYACCESS_INDEX|ASSIGNMENT_LHS|ASSIGNMENT_RHS|BINOP_LHS|BINOP_RHS|CAST_ENCLOSES|COMPOUND_ASSIGNMENT_LHS|COMPOUND_ASSIGNMENT_RHS|CONDITIONAL_CONDITION|CONDITIONAL_THEN|CONDITIONAL_ELSE|HAS_VARIABLEDECL_INIT|INSTANCEOF_EXPR|PARENTHESIZED_ENCLOSES|MEMBER_SELECT_EXPR|METHODINVOCATION_ARGUMENTS|METHODINVOCATION_METHOD_SELECT|NEW_CLASS_ARGUMENTS|NEWARRAY_INIT|NEWARRAY_DIMENSION|UNARY_ENCLOSES*0..]-()<-[:ASSERT_CONDITION|DOWHILE_CONDITION|EXPR_ENCLOSES|FOREACH_EXPR|FORLOOP_CONDITION|HAS_VARIABLEDECL_INIT|IF_CONDITION|RETURN_EXPR|SWITCH_EXPR|SYNCHRONIZED_EXPR|THROW_EXPR|WHILE_CONDITION]-(stat)<-[:CASE_STATEMENTS|CATCH_BLOCK|CATCH_PARAM|ENCLOSES|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|HAS_METHODDECL_PARAMETERS|IF_THEN|IF_ELSE|LABELED_STATEMENT|SWITCH_ENCLOSES_CASES|SYNCHRONIZED_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*]-()<-[:HAS_METHODDECL_BODY]-({nodeType:'JCMethodDecl'})<-[:DECLARES_METHOD]-(callerEncType)\r\n" - + " WHERE inv.nodeType IN ['JCMethodInvocation', 'JCNewClass'] " - + "OPTIONAL MATCH (invMember)<-[:METHODINVOCATION_METHOD_SELECT]-(inv)" - + "OPTIONAL MATCH (invMember)-[:MEMBER_SELECT_EXPR]->(memberSelection)" - + "OPTIONAL MATCH (inv)-[:NEW_CLASS_ARGUMENTS]->(arg)" - + " WITH autocloseableTypeNames,sucessors, mThrowsInfo,stat,inv,invMember,arg, CASE WHEN invMember IS NULL THEN inv.actualType ELSE CASE WHEN invMember.nodeType='JCIdent' THEN callerEncType.fullyQualifiedName ELSE memberSelection.actualType END END as callerEncTypeName ORDER BY ID(arg)" - + " WITH DISTINCT " + "autocloseableTypeNames,sucessors, mThrowsInfo," - + "stat,inv,invMember, callerEncTypeName, REDUCE(s='(', arg IN COLLECT(arg) | s+CASE WHEN s='(' THEN arg.actualType ELSE ','+arg.actualType END )+')' as newClassArgs "), - - new SimpleWithClause("DISTINCT " + "autocloseableTypeNames,sucessors,mThrowsInfo," - + " stat, COLLECT([CASE WHEN callerEncTypeName CONTAINS '<' AND NOT callerEncTypeName STARTS WITH '<' THEN SPLIT(callerEncTypeName,'<')[0] ELSE callerEncTypeName END , CASE WHEN invMember IS NULL THEN '' ELSE invMember.name END,CASE WHEN invMember IS NULL THEN newClassArgs ELSE SPLIT(invMember.actualType,')')[0]+')' END]) as invInfoInStats"), - - new WhereClause("ANY(invSignature IN invInfoInStats " - + " WHERE ANY(throwSignature IN mThrowsInfo WHERE throwSignature[0]=invSignature[0] AND throwSignature[1]=invSignature[1] AND throwSignature[2]=invSignature[2]) )"), - new SimpleWithClause( - "DISTINCT autocloseableTypeNames,sucessors, COLLECT( DISTINCT stat) as statsMayThrow"), - new MatchClause(true, - "(stat) WHERE stat.nodeType IN ['JCThrow', 'JCAssert'] WITH DISTINCT autocloseableTypeNames,sucessors, statsMayThrow+COLLECT(stat) as statsMayThrow"), - - new MatchClause(PDGServicesWiggle.WIGGLE.getIdsAndVarDeclarations(new NodeVar("id"), - "autocloseableTypeNames,sucessors,statsMayThrow ")), - new WhereClause("varDec.actualType IN autocloseableTypeNames"), - new SimpleWithClause( - "DISTINCT autocloseableTypeNames,sucessors,statsMayThrow, varDec as dec, COLLECT(DISTINCT id) as ids"), - // new ReturnClause("DISTINCT dec, ids"), - new MatchClause(true, - " (dec)<-[r:TRY_RESOURCES]-() WITH DISTINCT sucessors,statsMayThrow, dec,ids,r WHERE r IS NULL"), - // new ReturnClause("DISTINCT dec") - - new MatchClause(true, - getAssignmentServices().getLeftPartAssignments(new NodeVar("assignment"), new NodeVar("id")), - getExpressionServices().getStatementFromExp(new NodeVar("assignment"))), - new WhereClause("id IN ids"), - new SimpleWithClause(" DISTINCT " + " sucessors,statsMayThrow,ids, " + "dec, COLLECT(stat) as mods "), - - new MatchClause(true, new MatchImpl("(dec)-[r:HAS_VARIABLEDECL_INIT]->()")), - new SimpleWithClause("DISTINCT " + " sucessors, statsMayThrow," - + " dec, ids, mods + CASE WHEN r IS NULL THEN [] ELSE [dec] END as mods"), - new UnwindClause("mods", "mod"), - new MatchClause(MethodInvocationServicesWiggle.getMethodInvocationOf("close"), - getExpressionServices().getStatementFromExp(new NodeVar("mInv"), new NodeVar("closeStat"))), - - new WhereClause("object IN ids"), - new SimpleWithClause("DISTINCT sucessors,statsMayThrow, dec, mod, COLLECT(closeStat) as closeStmts"), - new SimpleWithClause( - " sucessors, dec, mod,closeStmts, FILTER( stat IN statsMayThrow WHERE NOT stat IN closeStmts AND stat IN FILTER(x IN sucessors WHERE x[0]=mod)[0][1]" - + " AND ANY(closeStat IN closeStmts WHERE closeStat IN FILTER(x IN sucessors WHERE x[0]=stat)[0][1]) ) as prevStats"), - new UnwindClause("prevStats", "prevStat"), - // new ReturnClause("DISTINCT FILTER(x IN sucessors WHERE - // x[0].nodeType='JCCatch' )") - - new MatchClause(true, - "p=" + getStatementServices().getOuterBlockFromStatement(new NodeVar("prevStat"), - new NodeVar("try{nodeType:'JCTry'}")).matchToString()), - new WhereClause("NOT TYPE(REVERSE(RELATIONSHIPS(p))[0]) IN ['TRY_CATCH', 'TRY_FINALLY']"), - new MatchClause(true, "(try)-[:TRY_CATCH ]->(catch)"), - new SimpleWithClause( - "DISTINCT sucessors,dec, mod, prevStat,closeStmts, try, REDUCE(l=[],catch IN COLLECT(catch) | l+FILTER(x IN sucessors WHERE x[0]=catch)[0][1] ) as catchSucs"), - new MatchClause(true, - getStatementServices() - .getOuterBlockFromStatement(new NodeVar("finallyStat"), new NodeVar("finally")) - .matchToString() + "<-[:TRY_FINALLY]-(try)"), - new SimpleWithClause( - " DISTINCT dec, mod, prevStat,closeStmts, try, CASE WHEN SIZE(catchSucs)=0 THEN COLLECT(finallyStat) ELSE catchSucs END as stmsReacheableAfterEx"), - new SimpleWithClause( - "DISTINCT dec, mod, prevStat,NOT ANY( reacheableStmt IN REDUCE(l=[], reacheables IN COLLECT(stmsReacheableAfterEx) | l+reacheables ) WHERE reacheableStmt IN closeStmts) as notReachebleClose"), - new WhereClause(" notReachebleClose "), - new MatchClause(getStatementServices().getEnclosingClassFromStatement(new NodeVar("dec"))), - new SimpleWithClause( - "DISTINCT 'Warning [CMU-ERR54] variable '+dec.name+ '(defined in line'+dec.lineNumber+', class '+enclClass.fullyQualifiedName+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN COLLECT(DISTINCT prevStat) | prev.lineNumber)+') may throw an exception.' as warning"), - new SimpleWithClause("DISTINCT COLLECT(warning) as warnings"), - new MatchClause(false, "()-[r:IS_SUBTYPE_OF]->() DELETE r WITH DISTINCT warnings RETURN warnings") - // , new WhereClause(" allReacheables ") - }; - } - - public static void main(String[] args) { - System.out.println(new MIDDLE_ERR54().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/NUM50.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/NUM50.java deleted file mode 100644 index 9e2f9e2..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/NUM50.java +++ /dev/null @@ -1,68 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.Extract; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; - -public class NUM50 extends AbstractQuery { - - /* - * private static final String - * NUM50CONVERT_INT_TO_FLOAT_FOR_FLOAT_OPERATIONS = - * "MATCH (varDec{actualType:'float'})-[:MODIFIED_BY]->(mod)-[:ASSIGNMENT_RHS | :INITIALIZATION_EXPR]->(rightSide)" - * + - * " OPTIONAL MATCH (binopR{actualType:'int'})<-[:BINOP_RHS]-(rightSide)-[:BINOP_LHS]->({actualType:'int'})" - * + - * " WITH varDec, COLLECT(rightSide.actualType='float') as rightSidesAreFloat, " - * + new Filter("COLLECT([rightSide,binopR])", - * "NOT x[1] IS NULL AND x[0].operator='DIVIDE'").expToString() + - * " as lines" + " WHERE " + " NOT " + new Any("rightSidesAreFloat", - * "x").expToString() + " AND SIZE(lines)>0 " - * - * // UN COLLECT DE FLOATS PAL ANY y un filter de lines que tiene que // ser - * mayor que 0 + - * " RETURN 'Warning [CMU-NUM50] A truncated integer division was detected in line(s) ' +" - * + new Extract("lines", "x[0].lineNumber").expToString() + - * " +', assigned to variables of type float. If you want to make a float division and assign the result to the variable ' + varDec.name+', you must include a operand as a float. Otherwise you can change the type of '+ varDec.name+' from float to int, as it is never used to store an actual float value.' " - * // + new Reduce("lines", "s+','+x", "''").expToString() ; - */ - - public NUM50() { - super(false); - // TODO Auto-generated constructor stub - } - - @Override - protected void initiate() { - clauses = new Clause[] { - // new SimpleWithClause("varDec"), - new MatchClause(true, - // LHS_ ASSIGN - getPDGServices().getCompleteIdentification(new NodeVar("id"), "")), - - new WhereClause("dec.actualType='float'"), - new MatchClause(true, - new MatchImpl("(rhs)<-[:ASSIGNMENT_RHS]-(modif{nodeType:'JCAssign'})-[:ASSIGNMENT_LHS]->(id)")), - - new MatchClause(true, new MatchImpl("(dec)-[:HAS_VARIABLEDECL_INIT]->(init)")), - new SimpleWithClause("init,rhs,dec"), - new MatchClause(new MatchImpl( - "(binopR{actualType:'int'})<-[:BINOP_RHS]-(division)<-[:BINOP_LHS | :BINOP_RHS | :UNARY_ENCLOSES |:CONDITIONAL_ELSE|:CONDITIONAL_THEN |:PARENTHESIZED_ENCLOSES*0..]-(rightSide), (division)-[:BINOP_LHS]->({actualType:'int'}) WHERE rightSide=rhs OR rightSide=init")), - new SimpleWithClause( - "FILTER(x IN CASE WHEN init IS NULL THEN COLLECT(rhs) ELSE COLLECT(rhs) +init END WHERE NOT x IS NULL) as rhs, dec as varDec"), - new WhereClause("NOT " + new Any("rhs", "x.actualType='float'").expToString()), - new ReturnClause("'Warning [CMU-NUM50] A truncated integer division was detected in line(s) ' +" - + new Extract("rhs", "x.lineNumber").expToString() - + " +', assigned to variable of type float. If you want to make a float division and assign the result to the variable ' + varDec.name+', you must include a operand as a float. Otherwise you can change the type of '+ varDec.name+' from float to int, as it is never used to store an actual float value.' " - - ) }; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50.java deleted file mode 100644 index b71e59f..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50.java +++ /dev/null @@ -1,202 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServicesWiggle; -import database.relations.RelationTypesWiggle; - -public class OBJ50 extends AbstractQuery { - - /* - * MATCH - * (declaringType{accessLevel:'public'})-[:DECLARES_FIELD]->(attr{typeKind:' - * DECLARED'})-[:ITS_TYPE_IS]->(typeDec) WHERE attr.isFinal AND - * attr.accessLevel='public' WITH attr, declaringType, typeDec - * - * MATCH - * p=(typeDec)-[:DECLARES_FIELD|ITS_TYPE_IS|IS_SUBTYPE_EXTENDS*]->(next{ - * typeKind:'DECLARED'}) WITH attr, declaringType, typeDec, NODES(p) as - * nodes - * - * CREATE (res{res:true}) FOREACH (i IN RANGE(1,SIZE(nodes),1) | SET res.res - * = res.res AND (CASE WHEN nodes[i]:ATTR_DEC THEN - * NOT(nodes[i-1].accessLevel='public' AND NOT nodes[i].isFinal AND NOT - * nodes[i].isStatic AND ( nodes[i].accessLevel='public' OR - * (nodes[i].accessLevel='protected' AND NOT nodes[i-1].isFinal) )) ELSE - * TRUE END)) WITH attr, declaringType, typeDec, nodes, res ------> TO DO - * - * - * - * OPTIONAL MATCH - * (field)-[mutationRel:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED|MODIFIED_BY] - * ->(ass) WHERE field IN nodes AND NOT ass:INITIALIZATION WITH attr, - * declaringType, res, typeDec, COUNT(mutationRel)>0 as hasAnyMutationRel - * - * WITH attr, declaringType, typeDec, ANY( x IN COLLECT( NOT res.res OR - * hasAnyMutationRel) WHERE x ) as isMutable WHERE isMutable RETURN 'Warning - * [CMU-OBJ50] Attribute '+ attr.name+' declared in - * '+declaringType.fullyQualifiedName+ ' is not actually final, only the - * reference. This is due to the type '+ typeDec.fullyQualifiedName+' is - * mutable ( the state of the attributes change in the program or may - * potentially be changed by a client).' - * - * - */ - private static final Expression ATTR_PROPERTIES = new ExprImpl( - "declaringTypeModfiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'final' AND attrModifiers.position>-1"); - private static final Clause[] PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServicesWiggle.typesAndDeclaredFieldsPlusModifiersAndTypes( - new RelationshipImpl(new NodeVar("declaringTypeModfiers"), new CompleteNode("declaringType"), - new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.HAS_CLASS_MODIFIERS)))); - - public OBJ50() { - super(false); - } - - @Override - protected void initiate() { - // TO_ DO ADD DELETE RELS - clauses = new Clause[] { -new ClauseImpl( - new WiggleCallGraph().queryToString()+" WITH DISTINCT '' as aux "+ - " MATCH (m{nodeType:'JCMethodDecl'})<-[:CALLS|:HAS_DEC*0..]-(anyCaller)<-[:DECLARES_METHOD]-(encClass)-[:HAS_CLASS_MODIFIERS]->(classMod),(anyCaller)-[:HAS_METHODDECL_MODIFIERS]->(methodMod) "), -new SimpleWithClause("m, NOT m.name='' AND ANY ( caller IN COLLECT(anyCaller) WHERE NOT caller.name='' AND ( methodMod.flags CONTAINS 'public' OR methodMod.flags CONTAINS 'protected' AND NOT classMod.flags CONTAINS 'final')) as notInit") -,new WhereClause("notInit") -,new SimpleWithClause("COLLECT(m) as notInitMethods"), - -// - new MatchClause(true, getPDGServices().getCompleteIdentification(new NodeVar("id"), "notInitMethods,")), - new MatchClause(false,"(id{nodeType:'JCIdent'}) "), - new MatchClause(true,"(id)<-[:METHODINVOCATION_METHOD_SELECT]-()-[:HAS_DEC]->()-[:HAS_METHODDECL_MODIFIERS]->(decMod)"), - new WhereClause("NOT decMod.flags CONTAINS 'static'"), - new SimpleWithClause("id, dec, ids,notInitMethods,identss, ANY(decM IN COLLECT(decMod) WHERE NOT decM IS NULL) as isInstanceCallId"), - new MatchClause(true,"(id)<-[:MEMBER_SELECT_EXPR]-(fieldAccess) "), - new WhereClause("fieldAccess.name IN ['this' , 'super']"), - new SimpleWithClause("id,isInstanceCallId, dec, ids,fieldAccess, notInitMethods,identss"), - new WhereClause("id.name IN ['this','super'] OR id IN ids OR isInstanceCallId OR NOT fieldAccess IS NULL"), - - new SimpleWithClause("DISTINCT id, CASE WHEN id IN ids THEN dec ElSE NULL END as dec, ids, notInitMethods, identss"), - - new MatchClause(true,"(fieldMod)<-[:HAS_VARIABLEDECL_MODIFIERS]-(dec)<-[:DECLARES_FIELD]-(encC)"), -new MatchClause(true,"(dec)<-[:HAS_METHODDECL_PARAMETERS]-(method)"), -new MatchClause(true,"(p)<-[:HAS_METHODDECL_PARAMETERS]-(method)"), - -new SimpleWithClause("notInitMethods,identss,id,fieldMod, p,dec,encC ORDER BY ID(p)"), - -new SimpleWithClause("notInitMethods,identss,id, dec,encC,fieldMod, COLLECT(p) as params"), -new SimpleWithClause("notInitMethods,identss,dec,encC,fieldMod,id, FILTER(i IN RANGE(0,SIZE(params)-1) WHERE dec=params[i])[0]+1 as pIndex") - -,new SimpleWithClause("notInitMethods,identss,dec,encC,id, CASE WHEN pIndex IS NULL THEN CASE WHEN dec IS NULL THEN 0 ELSE CASE WHEN encC IS NULL THEN -1 ELSE CASE WHEN fieldMod.flags CONTAINS 'static' THEN -1 ELSE 0 END END END ELSE pIndex END as pIndex" ) -, new WhereClause("pIndex>-1"), -new SimpleWithClause("DISTINCT notInitMethods,identss, COLLECT([id, pIndex]) as idDecType") - -//AQUI LO HAREMOS - , - new MatchClause(false, "(inv{nodeType:'JCMethodInvocation'})-[:METHODINVOCATION_METHOD_SELECT]->(methodSel)-[:ASSIGNMENT_RHS | :MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR *0..]->(id{nodeType:'JCIdent'})") - - , new SimpleWithClause("notInitMethods,identss,idDecType,inv,methodSel,[FILTER(idPType IN idDecType WHERE idPType[0]=id)[0][1],0] as thisFlow") - - , new MatchClause(true,"(inv)-[:METHODINVOCATION_ARGUMENTS]->()-[:ASSIGNMENT_RHS | :MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR *0..]->(id{nodeType:'JCIdent'})") - , new SimpleWithClause("DISTINCT notInitMethods,identss, idDecType,inv, methodSel, thisFlow, id ORDER BY ID(id)") - - , new SimpleWithClause("notInitMethods, identss, idDecType,inv, methodSel, thisFlow, COLLECT(id) as argIds") - , new SimpleWithClause("DISTINCT notInitMethods,identss, idDecType, COLLECT([inv, FILTER(x IN [thisFlow]+EXTRACT( i IN RANGE(0, SIZE(argIds)-1) | [FILTER(idPType IN idDecType WHERE idPType[0]=argIds[i])[0][1],i+1]) WHERE NOT x[0] IS NULL)]) as invIds"), - - new MatchClause(false, "(modification)-[:ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_LHS | :UNARY_ENCLOSES]->(lhs)-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(firstId{nodeType:'JCIdent'}), " - + getStatementServices().getMethodFromStatement(getExpressionServices().getStatementFromExp(new NodeVar("modification")), new MatchImpl("(method)-[:HAS_METHODDECL_MODIFIERS]->(methodMod)")).matchToString() - ), - //Si es id = tiene que ser atributo, el resto como antes - new SimpleWithClause("DISTINCT notInitMethods,identss,idDecType, invIds,method as mutator,lhs, firstId, FILTER(idP IN idDecType WHERE idP[0]=firstId)[0][1] as pType "), - - new WhereClause("lhs<>firstId OR pType=0"), - new SimpleWithClause("DISTINCT idDecType,notInitMethods,identss, invIds, mutator, COLLECT(DISTINCT pType) as pTypes "), - new MatchClause(false,"invTrace=(anyMethod{nodeType:'JCMethodDecl'})-[:CALLS | :HAS_DEC*0..]->(mutator)"), - new SimpleWithClause("DISTINCT idDecType,notInitMethods,identss, anyMethod,mutator, EXTRACT(inv IN FILTER(inv IN NODES(invTrace) WHERE inv.nodeType='JCMethodInvocation') | FILTER(invId IN invIds WHERE invId[0]=inv)[0][1]) as invTracePlusIdDec, pTypes"), - new WhereClause("ALL(inv IN invTracePlusIdDec WHERE NOT inv IS NULL)"), - new SimpleWithClause("idDecType, notInitMethods,identss, anyMethod, " - + "CASE WHEN SIZE(invTracePlusIdDec)=0 THEN pTypes ELSE EXTRACT( pair IN FILTER(finalDec IN " - + "EXTRACT( w IN REDUCE(s=[],argsInv IN invTracePlusIdDec | CASE WHEN SIZE(s)=0 THEN " - + " EXTRACT(a IN argsInv |[a[0],a]) ELSE " - + " EXTRACT(a IN argsInv | [ " - + " FILTER(x IN s WHERE x[1][1]=a[0])[0][0]" - + ", a])" - + " END) | [w[0],w[1][1]]) WHERE finalDec[1] IN pTypes) | pair[0]) END as mutableDecs"), - new SimpleWithClause("DISTINCT idDecType, notInitMethods,identss, anyMethod, REDUCE (s=[], x IN COLLECT(mutableDecs) | s+x) as mutableDecs") - , new SimpleWithClause("DISTINCT idDecType, notInitMethods,identss, COLLECT([anyMethod, mutableDecs]) as mutatorMethods "), - - -//new MatchClause(true,"(dec)<-[:DECLARES_FIELD]-(encC)"), new MatchClause(true,"(dec)<-[:HAS_METHODDECL_PARAMETERS]-(encM)") -// , new UnwindClause("identss", "p"), -// -// new SimpleWithClause("p[0] as dec, p[1] as ids, identss"), - new ClauseImpl( - "MATCH (varDecl{nodeType:'JCVariableDecl',typeKind:'DECLARED'})-[:HAS_VARIABLEDECL_MODIFIERS]->(varModifiers)" - ), - new WhereClause("varModifiers.flags CONTAINS 'final' "), - new MatchClause(true, - "(modification)-[:ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_LHS | :UNARY_ENCLOSES]->()-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*]->(id)-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(firstId{nodeType:'JCIdent'}), " - + getStatementServices().getMethodFromStatement(getExpressionServices().getStatementFromExp(new NodeVar("modification")), new NodeVar("method")).matchToString()+"<-[:DECLARES_METHOD]-(encClass)" - ), - new WhereClause( -// "NOT (NOT method IN notInitMethods AND ) AND "+ - "id IN EXTRACT(x IN FILTER(idDec IN identss WHERE idDec[1]=varDecl)| x[0]) AND ( modification.nodeType<>'JCUnary' OR modification.operator IN ['POSTFIX_INCREMENT', 'POSTFIX_DECREMENT', 'PREFIX_INCREMENT', 'PREFIX_DECREMENT']) "), - new SimpleWithClause("DISTINCT idDecType, mutatorMethods, notInitMethods,identss, varDecl,COLLECT([firstId, method, modification,encClass]) as stateMods"), - - new MatchClause(true, "(invDec)<-[:HAS_DEC]-(inv)-[:METHODINVOCATION_METHOD_SELECT]->()-[ :MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*1..]->(id)-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(firstId{nodeType:'JCIdent'})," - + "(inv)<-[:CALLS]-(method)<-[:DECLARES_METHOD]-(encClass) " - - ) -, new WhereClause("id IN EXTRACT(x IN FILTER(idDec IN identss WHERE idDec[1]=varDecl)| x[0]) " - + " AND 0 IN FILTER(methodAndMutDecs IN mutatorMethods WHERE invDec=methodAndMutDecs[0])[0][1]" - ) - , new SimpleWithClause("DISTINCT idDecType, mutatorMethods, notInitMethods,identss, varDecl,stateMods + COLLECT([firstId, method, inv,encClass]) as stateMods "), - - new MatchClause(true, "(invDec)<-[:HAS_DEC]-(inv)-[:METHODINVOCATION_ARGUMENTS]->(arg)-[ :MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(id)-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(firstId{nodeType:'JCIdent'})" - + ",(inv)<-[:CALLS]-(method)<-[:DECLARES_METHOD]-(encClass) " - - ) - , new WhereClause("id IN EXTRACT(x IN FILTER(idDec IN identss WHERE idDec[1]=varDecl)| x[0]) " -// + " AND 0 IN FILTER(methodAndMutDecs IN mutatorMethods WHERE invDec=methodAndMutDecs[0])[0][1]" - ), - new SimpleWithClause("idDecType, mutatorMethods,notInitMethods, varDecl,stateMods,method, invDec,inv,encClass, ID(arg) as order, firstId ORDER BY order"), - new SimpleWithClause("idDecType, mutatorMethods,notInitMethods, varDecl,stateMods,method, invDec, COLLECT([firstId, method, inv,encClass]) as argInfo ") - , - new SimpleWithClause("DISTINCT varDecl," - + "EXTRACT(sMod IN " - + "FILTER(refinedSMod IN " - + "EXTRACT(stateMod IN " - + "stateMods+ EXTRACT( argIndex IN FILTER(i IN RANGE(0,SIZE(argInfo)-1) WHERE (i+1) IN FILTER(methodAndMutDecs IN mutatorMethods WHERE invDec=methodAndMutDecs[0])[0][1]) | argInfo[argIndex])" - + "|[FILTER(idDecT IN idDecType WHERE idDecT[0]=stateMod[0])[0][1], stateMod[1],stateMod[2],stateMod[3]]) " - + "WHERE refinedSMod[1] IN notInitMethods OR (refinedSMod[0] IS NULL AND NOT refinedSMod[1] IS NULL) OR refinedSMod[0]<>0)" - + "| sMod[2].nodeType +'(line '+sMod[2].lineNumber+', class '+sMod[3].fullyQualifiedName+')') as stateMods" - ) - , new MatchClause(getStatementServices().getEnclosingClassFromDeclaration(new NodeVar("varDecl"))), - new SimpleWithClause( - "DISTINCT EXTRACT( varAndMods IN FILTER(x IN COLLECT([varDecl, stateMods, enclClass]) WHERE SIZE(x[1])>0)" - + "|'Warning [CMU-OBJ50] Declaration with name '+ varAndMods[0].name+ '( in line ' + varAndMods[0].lineNumber +', class ' +varAndMods[2].fullyQualifiedName+ ') is not actually final, only the reference. Concretely, '+ varAndMods[0].name +' may be mutated in '+varAndMods[1] )" - + " as res" - ) - - , new ClauseImpl("MATCH ()-[r]->() WHERE r.created DELETE r "), - new ReturnClause("DISTINCT res") - }; - - } - - public static void main(String[] args) { - System.out.println(new OBJ50().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50_ERROR_TEST.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50_ERROR_TEST.java deleted file mode 100644 index 103e6b0..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50_ERROR_TEST.java +++ /dev/null @@ -1,189 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServicesWiggle; -import database.relations.RelationTypesWiggle; - -public class OBJ50_ERROR_TEST extends AbstractQuery { - - /* - * MATCH - * (declaringType{accessLevel:'public'})-[:DECLARES_FIELD]->(attr{typeKind:' - * DECLARED'})-[:ITS_TYPE_IS]->(typeDec) WHERE attr.isFinal AND - * attr.accessLevel='public' WITH attr, declaringType, typeDec - * - * MATCH - * p=(typeDec)-[:DECLARES_FIELD|ITS_TYPE_IS|IS_SUBTYPE_EXTENDS*]->(next{ - * typeKind:'DECLARED'}) WITH attr, declaringType, typeDec, NODES(p) as - * nodes - * - * CREATE (res{res:true}) FOREACH (i IN RANGE(1,SIZE(nodes),1) | SET res.res - * = res.res AND (CASE WHEN nodes[i]:ATTR_DEC THEN - * NOT(nodes[i-1].accessLevel='public' AND NOT nodes[i].isFinal AND NOT - * nodes[i].isStatic AND ( nodes[i].accessLevel='public' OR - * (nodes[i].accessLevel='protected' AND NOT nodes[i-1].isFinal) )) ELSE - * TRUE END)) WITH attr, declaringType, typeDec, nodes, res ------> TO DO - * - * - * - * OPTIONAL MATCH - * (field)-[mutationRel:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED|MODIFIED_BY] - * ->(ass) WHERE field IN nodes AND NOT ass:INITIALIZATION WITH attr, - * declaringType, res, typeDec, COUNT(mutationRel)>0 as hasAnyMutationRel - * - * WITH attr, declaringType, typeDec, ANY( x IN COLLECT( NOT res.res OR - * hasAnyMutationRel) WHERE x ) as isMutable WHERE isMutable RETURN 'Warning - * [CMU-OBJ50] Attribute '+ attr.name+' declared in - * '+declaringType.fullyQualifiedName+ ' is not actually final, only the - * reference. This is due to the type '+ typeDec.fullyQualifiedName+' is - * mutable ( the state of the attributes change in the program or may - * potentially be changed by a client).' - * - * - */ - private static final Expression ATTR_PROPERTIES = new ExprImpl( - "declaringTypeModfiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'final' AND attrModifiers.position>-1"); - private static final Clause[] PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServicesWiggle.typesAndDeclaredFieldsPlusModifiersAndTypes( - new RelationshipImpl(new NodeVar("declaringTypeModfiers"), new CompleteNode("declaringType"), - new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.HAS_CLASS_MODIFIERS)))); - - public OBJ50_ERROR_TEST() { - super(false); - } - - @Override - protected void initiate() { - // TO_ DO ADD DELETE RELS - clauses = new Clause[] { -/*new ClauseImpl( - new WiggleCallGraph().queryToString()+" WITH DISTINCT '' as aux "+ - " MATCH (m{nodeType:'JCMethodDecl'})<-[:CALLS|:HAS_DEC*0..]-(anyCaller)<-[:DECLARES_METHOD]-(encClass)-[:HAS_CLASS_MODIFIERS]->(classMod),(anyCaller)-[:HAS_METHODDECL_MODIFIERS]->(methodMod) "), -new SimpleWithClause("m, NOT m.name='' AND ANY ( caller IN COLLECT(anyCaller) WHERE NOT caller.name='' AND ( methodMod.flags CONTAINS 'public' OR methodMod.flags CONTAINS 'protected' AND NOT classMod.flags CONTAINS 'final')) as notInit") -,new WhereClause("notInit") -,new SimpleWithClause("COLLECT(m) as notInitMethods"), - -// - new MatchClause(true, getPDGServices().getCompleteIdentification(new NodeVar("id"), "notInitMethods,")), - new MatchClause(false,"(id{nodeType:'JCIdent'}) "), - new MatchClause(true,"(id)<-[:METHODINVOCATION_METHOD_SELECT]-()-[:HAS_DEC]->()-[:HAS_METHODDECL_MODIFIERS]->(decMod)"), - new WhereClause("NOT decMod.flags CONTAINS 'static'"), - new SimpleWithClause("id, dec, ids,notInitMethods,identss, ANY(decM IN COLLECT(decMod) WHERE NOT decM IS NULL) as isInstanceCallId"), - new MatchClause(true,"(id)<-[:MEMBER_SELECT_EXPR]-(fieldAccess) "), - new WhereClause("fieldAccess.name IN ['this' , 'super']"), - new SimpleWithClause("id,isInstanceCallId, dec, ids,fieldAccess, notInitMethods,identss"), - new WhereClause("id.name IN ['this','super'] OR id IN ids OR isInstanceCallId OR NOT fieldAccess IS NULL"), - - new SimpleWithClause("DISTINCT id, CASE WHEN id IN ids THEN dec ElSE NULL END as dec, ids, notInitMethods, identss"), - - new MatchClause(true,"(fieldMod)<-[:HAS_VARIABLEDECL_MODIFIERS]-(dec)<-[:DECLARES_FIELD]-(encC)"), -new MatchClause(true,"(dec)<-[:HAS_METHODDECL_PARAMETERS]-(method)"), -new MatchClause(true,"(p)<-[:HAS_METHODDECL_PARAMETERS]-(method)"), - -new SimpleWithClause("notInitMethods,identss,id,fieldMod, p,dec,encC ORDER BY ID(p)"), - -new SimpleWithClause("notInitMethods,identss,id, dec,encC,fieldMod, COLLECT(p) as params"), -new SimpleWithClause("notInitMethods,identss,dec,encC,fieldMod,id, FILTER(i IN RANGE(0,SIZE(params)-1) WHERE dec=params[i])[0]+1 as pIndex") - -,new SimpleWithClause("notInitMethods,identss,dec,encC,id, CASE WHEN pIndex IS NULL THEN CASE WHEN dec IS NULL THEN 0 ELSE CASE WHEN encC IS NULL THEN -1 ELSE CASE WHEN fieldMod.flags CONTAINS 'static' THEN -1 ELSE 0 END END END ELSE pIndex END as pIndex" ) -, new WhereClause("pIndex>-1"), -new SimpleWithClause("DISTINCT notInitMethods,identss, COLLECT([id, pIndex]) as idDecType") - -//AQUI LO HAREMOS - , - new MatchClause(false, "(inv{nodeType:'JCMethodInvocation'})-[:METHODINVOCATION_METHOD_SELECT]->(methodSel)-[:ASSIGNMENT_RHS | :MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR *0..]->(id{nodeType:'JCIdent'})") - - , new SimpleWithClause("notInitMethods,identss,idDecType,inv,methodSel,[FILTER(idPType IN idDecType WHERE idPType[0]=id)[0][1],0] as thisFlow") - - , new MatchClause(true,"(inv)-[:METHODINVOCATION_ARGUMENTS]->()-[:ASSIGNMENT_RHS | :MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR *0..]->(id{nodeType:'JCIdent'})") - , new SimpleWithClause("DISTINCT notInitMethods,identss, idDecType,inv, methodSel, thisFlow, id ORDER BY ID(id)") - - , new SimpleWithClause("notInitMethods, identss, idDecType,inv, methodSel, thisFlow, COLLECT(id) as argIds") - , new SimpleWithClause("DISTINCT notInitMethods,identss, idDecType, COLLECT([inv, FILTER(x IN [thisFlow]+EXTRACT( i IN RANGE(0, SIZE(argIds)-1) | [FILTER(idPType IN idDecType WHERE idPType[0]=argIds[i])[0][1],i+1]) WHERE NOT x[0] IS NULL)]) as invIds"), - - new MatchClause(false, "(modification)-[:ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_LHS | :UNARY_ENCLOSES]->(lhs)-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(firstId{nodeType:'JCIdent'}), " - + getStatementServices().getMethodFromStatement(getExpressionServices().getStatementFromExp(new NodeVar("modification")), new MatchImpl("(method)-[:HAS_METHODDECL_MODIFIERS]->(methodMod)")).matchToString() - ), - //Si es id = tiene que ser atributo, el resto como antes - new SimpleWithClause("DISTINCT notInitMethods,identss, invIds,method as mutator,lhs, firstId, FILTER(idP IN idDecType WHERE idP[0]=firstId)[0][1] as pType "), - - new WhereClause("lhs<>firstId OR pType=0"), - new SimpleWithClause("DISTINCT notInitMethods,identss, invIds, mutator, COLLECT(DISTINCT pType) as pTypes "), - new MatchClause(false,"invTrace=(anyMethod{nodeType:'JCMethodDecl'})-[:CALLS | :HAS_DEC*0..]->(mutator)"), - new SimpleWithClause("DISTINCT notInitMethods,identss, anyMethod,mutator, EXTRACT(inv IN FILTER(inv IN NODES(invTrace) WHERE inv.nodeType='JCMethodInvocation') | FILTER(invId IN invIds WHERE invId[0]=inv)[0][1]) as invTracePlusIdDec, pTypes"), - new WhereClause("ALL(inv IN invTracePlusIdDec WHERE NOT inv IS NULL)"), - new SimpleWithClause("notInitMethods,identss, anyMethod, " - + "CASE WHEN SIZE(invTracePlusIdDec)=0 THEN pTypes ELSE EXTRACT( pair IN FILTER(finalDec IN " - + "EXTRACT( w IN REDUCE(s=[],argsInv IN invTracePlusIdDec | CASE WHEN SIZE(s)=0 THEN " - + " EXTRACT(a IN argsInv |[a[0],a]) ELSE " - + " EXTRACT(a IN argsInv | [ " - + " FILTER(x IN s WHERE x[1][1]=a[0])[0][0]" - + ", a])" - + " END) | [w[0],w[1][1]]) WHERE finalDec[1] IN pTypes) | pair[0]) END as mutableDecs"), - new SimpleWithClause("DISTINCT notInitMethods,identss, anyMethod, REDUCE (s=[], x IN COLLECT(mutableDecs) | s+x) as mutableDecs") - , new SimpleWithClause("DISTINCT notInitMethods,identss, COLLECT([anyMethod, mutableDecs]) as mutatorMethods "), - - -//new MatchClause(true,"(dec)<-[:DECLARES_FIELD]-(encC)"), new MatchClause(true,"(dec)<-[:HAS_METHODDECL_PARAMETERS]-(encM)") -// , new UnwindClause("identss", "p"), -// -// new SimpleWithClause("p[0] as dec, p[1] as ids, identss"), - new ClauseImpl( - "MATCH (varDecl{nodeType:'JCVariableDecl',typeKind:'DECLARED'})-[:HAS_VARIABLEDECL_MODIFIERS]->(varModifiers)" - ), - new WhereClause("varModifiers.flags CONTAINS 'final' "), - new SimpleWithClause("DISTINCT varDecl,[] as identss,[] as mutatorMethods,[] as notInitMethods"), - new MatchClause(true, - "(modification)-[:ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_LHS | :UNARY_ENCLOSES]->()-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*]->(id)-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(firstId{nodeType:'JCIdent'}), " - + getStatementServices().getMethodFromStatement(getExpressionServices().getStatementFromExp(new NodeVar("modification")), new NodeVar("method")).matchToString() - ), - new WhereClause( -// "NOT (NOT method IN notInitMethods AND ) AND "+ - "id IN EXTRACT(x IN FILTER(idDec IN identss WHERE idDec[1]=varDecl)| x[0]) AND ( modification.nodeType<>'JCUnary' OR modification.operator IN ['POSTFIX_INCREMENT', 'POSTFIX_DECREMENT', 'PREFIX_INCREMENT', 'PREFIX_DECREMENT']) "), - new SimpleWithClause("DISTINCT mutatorMethods, notInitMethods,identss, varDecl,COLLECT([firstId, method]) as stateMods"), - - new MatchClause(true, "(invDec)<-[:HAS_DEC]-(inv)-[:METHODINVOCATION_METHOD_SELECT]->()-[ :MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*1..]->(id)-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(firstId{nodeType:'JCIdent'})," - + "(inv)<-[:CALLS]-(method) " - - ) -, new WhereClause("id IN EXTRACT(x IN FILTER(idDec IN identss WHERE idDec[1]=varDecl)| x[0]) " - + " AND 0 IN FILTER(methodAndMutDecs IN mutatorMethods WHERE invDec=methodAndMutDecs[0])[0][1]" - ) - , new SimpleWithClause("DISTINCT mutatorMethods, notInitMethods,identss, varDecl,stateMods + COLLECT([firstId, method]) as stateMods "), - */ - new ClauseImpl( - "MATCH (varDecl{nodeType:'JCVariableDecl',typeKind:'DECLARED'})-[:HAS_VARIABLEDECL_MODIFIERS]->(varModifiers)" - ), - new SimpleWithClause("varDecl, [] as identss, [] as mutatorMethods, [] as stateMods"), - new MatchClause(true, "(invDec)<-[:HAS_DEC]-(inv)-[:METHODINVOCATION_ARGUMENTS]->(arg)-[ :MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(id)-[:MEMBER_SELECT_EXPR | :ARRAYACCESS_EXPR*0..]->(firstId{nodeType:'JCIdent'})" - + ",(inv)<-[:CALLS]-(method) " - - ) - , new WhereClause("id IN EXTRACT(x IN FILTER(idDec IN identss WHERE idDec[1]=varDecl)| x[0]) " -// + " AND 0 IN FILTER(methodAndMutDecs IN mutatorMethods WHERE invDec=methodAndMutDecs[0])[0][1]" - ), - new SimpleWithClause("mutatorMethods, varDecl,stateMods,method, invDec, arg, firstId ORDER BY ID(arg)"), - new SimpleWithClause("mutatorMethods, varDecl,stateMods,method, invDec, COLLECT([firstId, method]) as argInfo ") - , - new ReturnClause("DISTINCT varDecl,stateMods,method, invDec, EXTRACT( argIndex IN FILTER(i IN RANGE(0,SIZE(argInfo)-1) WHERE (i+1) IN FILTER(methodAndMutDecs IN mutatorMethods WHERE invDec=methodAndMutDecs[0])[0][1]) | argInfo[argIndex])") - }; - - } - - public static void main(String[] args) { - System.out.println(new OBJ50_ERROR_TEST().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50_OLD_NOT_TRANSLATED_TO_PQ_SIMPL.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50_OLD_NOT_TRANSLATED_TO_PQ_SIMPL.java deleted file mode 100644 index 9b717ed..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ50_OLD_NOT_TRANSLATED_TO_PQ_SIMPL.java +++ /dev/null @@ -1,128 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Binop; -import database.querys.cypherWrapper.Case; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.CreateClause; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.Extract; -import database.querys.cypherWrapper.ForEach; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.SetClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServicesWiggle; -import database.querys.services.InmutabilityServicesWiggle; -import database.relations.RelationTypesWiggle; -import utils.dataTransferClasses.Pair; - -public class OBJ50_OLD_NOT_TRANSLATED_TO_PQ_SIMPL extends AbstractQuery { - - /* - * MATCH - * (declaringType{accessLevel:'public'})-[:DECLARES_FIELD]->(attr{typeKind:' - * DECLARED'})-[:ITS_TYPE_IS]->(typeDec) WHERE attr.isFinal AND - * attr.accessLevel='public' WITH attr, declaringType, typeDec - * - * MATCH - * p=(typeDec)-[:DECLARES_FIELD|ITS_TYPE_IS|IS_SUBTYPE_EXTENDS*]->(next{ - * typeKind:'DECLARED'}) WITH attr, declaringType, typeDec, NODES(p) as - * nodes - * - * CREATE (res{res:true}) FOREACH (i IN RANGE(1,SIZE(nodes),1) | SET res.res - * = res.res AND (CASE WHEN nodes[i]:ATTR_DEC THEN - * NOT(nodes[i-1].accessLevel='public' AND NOT nodes[i].isFinal AND NOT - * nodes[i].isStatic AND ( nodes[i].accessLevel='public' OR - * (nodes[i].accessLevel='protected' AND NOT nodes[i-1].isFinal) )) ELSE - * TRUE END)) WITH attr, declaringType, typeDec, nodes, res ------> TO DO - * - * - * - * OPTIONAL MATCH - * (field)-[mutationRel:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED|MODIFIED_BY] - * ->(ass) WHERE field IN nodes AND NOT ass:INITIALIZATION WITH attr, - * declaringType, res, typeDec, COUNT(mutationRel)>0 as hasAnyMutationRel - * - * WITH attr, declaringType, typeDec, ANY( x IN COLLECT( NOT res.res OR - * hasAnyMutationRel) WHERE x ) as isMutable WHERE isMutable RETURN 'Warning - * [CMU-OBJ50] Attribute '+ attr.name+' declared in - * '+declaringType.fullyQualifiedName+ ' is not actually final, only the - * reference. This is due to the type '+ typeDec.fullyQualifiedName+' is - * mutable ( the state of the attributes change in the program or may - * potentially be changed by a client).' - * - * - */ - private static final Expression ATTR_PROPERTIES = new ExprImpl( - "declaringTypeModfiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'final' AND attrModifiers.position>-1"); - private static final Clause[] PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServicesWiggle.typesAndDeclaredFieldsPlusModifiersAndTypes( - new RelationshipImpl(new NodeVar("declaringTypeModfiers"), new CompleteNode("declaringType"), - new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.HAS_CLASS_MODIFIERS)))); - - public OBJ50_OLD_NOT_TRANSLATED_TO_PQ_SIMPL() { - super(false); - } - - private static final String CREATE_ITS_TYPE_IS_RELS = "MATCH (n),(m) WHERE EXISTS(n.actualType) AND n.actualType=m.fullyQualifiedName CREATE (n)-[:ITS_TYPE_IS{created:TRUE}]->(m) WITH 'L' as l "; - private static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS]->(m)-[:ITS_TYPE_IS]->(t) MERGE (n)-[r:IS_SUBTYPE_EXTENDS]->(t) ON CREATE SET r.created=TRUE WITH l "; - - @Override - protected void initiate() { - // TO_ DO ADD DELETE RELS - clauses = new Clause[] { new ClauseImpl(CREATE_ITS_TYPE_IS_RELS), new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS[0], PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS[1], - new SimpleWithClause("attr", "declaringType", "typeDec"), - new MatchClause( - InmutabilityServicesWiggle.getTypesSuperTypesAndFieldsTransitive(new NodeVar("typeDec"))), - new UnwindClause("NODES(p)", "nodeInP"), - new MatchClause(true, - new RelationshipImpl(new NodeVar("nodeInP"), - new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.DECLARES_FIELD) - .setName("declaredFieldRel"))), - new MatchClause(true, - new RelationshipImpl(new NodeVar("nodeInP"), new NodeVar("modifiers"), - new EdgeImpl(RelationTypesWiggle.HAS_VARIABLEDECL_MODIFIERS, - RelationTypesWiggle.HAS_CLASS_MODIFIERS))), - new SimpleWithClause( - "attr, declaringType, typeDec,p, COLLECT([nodeInP, NOT declaredFieldRel IS NULL, modifiers]) as nodes"), - - new CreateClause(new CompleteNode("res:RES", Pair.create("res", true))), - new ForEach("i", "RANGE(1,SIZE(nodes),1)", - new SetClause(new ExprImpl("res.res"), - new Binop("AND", new ExprImpl("res.res"), new Case("nodes[i][1]", - InmutabilityServicesWiggle.isInmutableField("nodes[i][2]", "nodes[i-1][2]"), - "TRUE")))), - - new SimpleWithClause("attr, declaringType, typeDec, " + new Extract("nodes", "x[0]").expToString() - + " as nodes, res"), - getPDGServices().getModificationsOnFields("nodes", "attr, declaringType, typeDec, res, nodes"), - new SimpleWithClause( - "attr, declaringType, typeDec, res, nodes, assignsMods+COLLECT(DISTINCT assignment) as assignsMods"), - new SimpleWithClause( - "attr, declaringType, typeDec, res, nodes, COUNT(assignsMods)>0 as hasAnyMutationRel"), - new SimpleWithClause( - "attr, declaringType, typeDec, ANY( x IN COLLECT( NOT res.res OR hasAnyMutationRel) WHERE x ) as isMutable, res"), - new ClauseImpl("DELETE res "), new SimpleWithClause("attr, declaringType, typeDec, isMutable"), - new WhereClause("isMutable"), - new SimpleWithClause( - " DISTINCT 'Warning [CMU-OBJ50] Attribute '+ attr.name+' declared in '+declaringType.fullyQualifiedName+ ' is not actually final, only the reference. This is due to the type '+ typeDec.fullyQualifiedName+' is mutable ( the state of the attributes change in the program or may potentially be changed by a client).' as warning "), - new ClauseImpl( - " WITH COLLECT(warning) as wList MATCH ()-[r{created:TRUE}]->() DELETE r WITH DISTINCT wList RETURN wList") - - }; - } - - public static void main(String[] args) { -System.out.println(new OBJ50_OLD_NOT_TRANSLATED_TO_PQ_SIMPL().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54.java deleted file mode 100644 index 3c74138..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54.java +++ /dev/null @@ -1,56 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.CreateClause; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.cypherWrapper.WithClause; -import database.querys.services.StatementServices; -import utils.dataTransferClasses.Pair; - -public class OBJ54 extends AbstractQuery { - - public OBJ54() { - super(false); - } - - @Override - protected void initiate() { - NodeVar assign = new NodeVar("assign"); - clauses = new Clause[] { - new MatchClause( - getPDGServices().getIdsAndVarDeclarations(Node.nodeForWiggle("id", NodeTypes.IDENTIFIER))), - new WithClause(new String[] { "varDec" }, - Pair.create("identifications", new ExprImpl("COLLECT( DISTINCT id)"))) - - // - , new MatchClause(StatementServices.WIGGLE.getEnclosingClassFromStatement("stat"), - - getAssignmentServices().getLeftPartAssignments( - getAssignmentServices().getRightPartAssignments( - Node.nodeForWiggle(NodeTypes.LITERAL, Pair.create("typeKind", "NULL"))), - Node.nodeForWiggle("id", NodeTypes.IDENTIFIER)), - getExpressionServices().getStatementFromExp(assign)), - new WhereClause("id IN identifications ").append(getCFGServices().getCFGSuccesorsOf(new NodeVar("stat"), - "assign, stat, enclClass, varDec, identifications")), - new UnwindClause("identifications", "id"), - new MatchClause(true, - getAssignmentServices().getLeftPartAssignments(new NodeVar("anyAssign"), new NodeVar("id"))), - new SimpleWithClause("assign, id, anyAssign, succesors, varDec, enclClass"), - new MatchClause(getExpressionServices().getStatementFromExp(new NodeVar("id"))), - - new WhereClause("anyAssign IS NULL "), new UnwindClause("succesors", "succesor"), - new CreateClause(new MatchImpl( - "(assign)-[:REL_ONE]->( succesor),(assign)-[:REL_TWO]->( stat), (assign)-[:REL_THREE]->(varDec),(assign)-[:REL_FOUR]->(enclClass)")) }; - } - - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54Long.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54Long.java deleted file mode 100644 index 3973e04..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54Long.java +++ /dev/null @@ -1,81 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.All; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.cypherWrapper.WithClause; -import database.querys.services.StatementServices; -import utils.dataTransferClasses.Pair; - -public class OBJ54Long extends AbstractQuery { - - public OBJ54Long() { - super(false); - } - - @Override - protected void initiate() { - NodeVar assign = new NodeVar("assign"); - clauses = new Clause[] { - new MatchClause( - getPDGServices().getIdsAndVarDeclarations(Node.nodeForWiggle("id", NodeTypes.IDENTIFIER))), - new WithClause(new String[] { "varDec" }, - Pair.create("identifications", new ExprImpl("COLLECT( DISTINCT id)"))) - - // - , new MatchClause( StatementServices.WIGGLE.getEnclosingClassFromDeclaration(new NodeVar("stat")), - - getAssignmentServices().getLeftPartAssignments( - getAssignmentServices().getRightPartAssignments( - Node.nodeForWiggle(NodeTypes.LITERAL, Pair.create("typeKind", "NULL"))), - Node.nodeForWiggle("id", NodeTypes.IDENTIFIER)), - getExpressionServices().getStatementFromExp(assign)), - new WhereClause("id IN identifications ") - .append(getCFGServices().getCFGSuccesorsOf(new NodeVar("stat"), - " enclClass, varDec, identifications, ")) - , -// new ReturnClause("DISTINCT varDec,stat, enclClass, identifications, succesors") -// new SimpleWithClause("stat as assignStat, enclClass, varDec, identifications, succesors") - - new UnwindClause("identifications", "id"), - new MatchClause(true, - getAssignmentServices().getLeftPartAssignments(new NodeVar("anyAssign"), new NodeVar("id"))), - new SimpleWithClause("stat as assignStat, id, anyAssign, succesors, varDec, enclClass"), - -// new WhereClause("anyAssign IS NULL "), - - new MatchClause(getExpressionServices().getStatementFromExp(new NodeVar("id"))) -// , new UnwindClause("succesors", "succesor"), - // new CreateClause(new MatchImpl( - // "(assign)-[:REL_ONE]->( succesor),(assign)-[:REL_TWO]->( - // stat), - // (assign)-[:REL_THREE]->(varDec),(assign)-[:REL_FOUR]->(enclClass)")), - ,new ClauseImpl( - // "MATCH (assign)-[:REL_ONE]->( - // succesor),(assign)-[:REL_TWO]->( stat), - // (assign)-[:REL_THREE]->(varDec),(assign)-[:REL_FOUR]->(enclClass) - // \n"+ - " WITH assignStat,varDec,enclClass, FILTER( x IN COLLECT(CASE WHEN anyAssign IS NULL THEN stat ELSE NULL END) WHERE NOT x IS NULL) as useStats, succesors" - + "\n WHERE " - + new All("useStats", "NOT x IN succesors").expToString() + " RETURN " - + "'Warning [CMU-OBJ54] You must not try to help garbage collector setting references to null when they are no longer used. To make your code clearer, just delete the assignment in line ' + assignStat.lineNumber + ' of the variable ' +varDec.name+ ' declared in line '+varDec.lineNumber+',class '+enclClass.fullyQualifiedName+'.'" - ) - - }; - - } - - public static void main(String[] args) { - System.out.println(new OBJ54Long().queryToString()); - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54Part_2.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54Part_2.java deleted file mode 100644 index d698afa..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ54Part_2.java +++ /dev/null @@ -1,16 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.All; -import database.querys.eval.Query; - -public class OBJ54Part_2 implements Query { - - @Override - public String queryToString() { - return "MATCH (assign)-[:REL_ONE]->( succesor),(assign)-[:REL_TWO]->( stat), (assign)-[:REL_THREE]->(varDec),(assign)-[:REL_FOUR]->(enclClass) \n" - + " WITH assign, COLLECT(stat) as useStats, COLLECT(succesor) as succesors\n WHERE " - + new All("useStats", "NOT x IN succesors").expToString() + " RETURN " - + "'Warning [CMU-OBJ54] You must not try to help garbage collector setting references to null when they are no longer used. To make your code clearer, just delete the assignment in line ' + assign.lineNumber + ' of the variable ' +varDec.name+ ' declared in class '+enclClass.fullyQualifiedName+'.'"; - } - -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ56.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ56.java deleted file mode 100644 index f53b5a2..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/OBJ56.java +++ /dev/null @@ -1,268 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.Case; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.Extract; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.Reduce; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.ReturnClause; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.InmutabilityServicesPQ; -import database.relations.RelationTypes; -import database.relations.RelationTypesWiggle; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class OBJ56 extends AbstractQuery { - - public OBJ56() { - super(false); - - } - - private static final String CREATE_ITS_TYPE_IS_RELS = - "MATCH (c)-[:DECLARES_FIELD]->(n),(m) WHERE EXISTS(n.actualType) AND n.actualType=m.fullyQualifiedName CREATE (n)-[:ITS_TYPE_IS{created:TRUE}]->(m) WITH DISTINCT 'l' as l "+ - "MATCH (c)-[:DECLARES_FIELD]->(n) WHERE EXISTS(n.typeKind) AND n.typeKind='ARRAY' MERGE (n)-[:ITS_TYPE_IS{created:TRUE}]->(arrayType:ARRAY_TYPE{fullyQualifiedName:n.actualType}) "; - public static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m),(t) WHERE SPLIT(t.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_EXTENDS]->(t) ON CREATE SET r.created=TRUE "; - - @Override - protected void initiate() { - Node typeDec = new NodeVar("typeDec"); - clauses = new Clause[] { - - new ClauseImpl(CREATE_ITS_TYPE_IS_RELS+" WITH DISTINCT 'l' as aux") - , new ClauseImpl(CREATE_ALL_SUBTYPE_RELS - +" WITH DISTINCT 'l' as aux" - ), - new MatchClause(getPDGServices().getCompleteIdentification(new NodeVar("id"), "")), - - new MatchClause( - getStatementServices().getMethodFromStatement( - new MatchImpl( - "(classMod)<-[:HAS_CLASS_MODIFIERS]-(enclosingType)-[:DECLARES_FIELD]->(dec),(id)<-[:RETURN_EXPR]-()"), - Node.nodeForWiggle("method", NodeTypes.METHOD_DEF)), - new MatchImpl( - "(enclosingMethodType)-[:DECLARES_METHOD]->(method)-[:HAS_METHODDECL_MODIFIERS]->(methodMod),(dec)-[:HAS_VARIABLEDECL_MODIFIERS]->(fieldMod) " - + ",(dec)-[:ITS_TYPE_IS]->()<-[:IS_SUBTYPE_EXTENDS|IS_SUBTYPE_IMPLEMENTS*0..]-(typeDec)" - )), - new WhereClause( - "id IN ids AND NOT fieldMod.flags CONTAINS 'public' AND methodMod.flags CONTAINS 'public' AND classMod.flags CONTAINS 'public' AND (typeDec:ARRAY_TYPE OR typeDec.nodeType<>'ClassType') "), - new SimpleWithClause("typeDec,enclosingType,dec as field,enclosingMethodType.fullyQualifiedName+':'+ method.name +'(line '+method.lineNumber+')' as method,identss"), - // BIEN - new MatchClause(true, InmutabilityServicesPQ.getTypesSuperTypesAndFieldsTransitive(typeDec)), - - new SimpleWithClause( - "DISTINCT typeDec,enclosingType, field,identss, method,p, CASE WHEN p IS NULL THEN [typeDec] else NODES(p) END as nodes"), - new UnwindClause("nodes", "nodeInP"), - new SimpleWithClause("enclosingType, field, method,identss, typeDec, nodeInP,nodes"), - // TESTING - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), TypeRelations.IS_SUBTYPE_EXTENDS, - TypeRelations.IS_SUBTYPE_IMPLEMENTS), new AnonymousNode()), - Pair.createP("f", RelationTypes.DECLARES_FIELD)), - - new RelationshipImpl(new NodeVar("mod"), new NodeVar("id"), - new EdgeImpl(Cardinalidad.ONE_TO_INF, RelationTypesWiggle.MEMBER_SELECT_EXPR, - RelationTypesWiggle.ARRAYACCESS_EXPR, RelationTypesWiggle.ASSIGNMENT_LHS)), - getExpressionServices().getMethodFromExp(new NodeVar("mod"), - Node.nodeForWiggle("setMethod", NodeTypes.METHOD_DEF)), - new MatchImpl( - "(nodeInP)-[:DECLARES_METHOD]->(setMethod)-[:HAS_METHODDECL_MODIFIERS]->(setMod)")), - - new WhereClause("setMod.flags CONTAINS 'public' AND NOT setMod.flags CONTAINS 'static' AND [id,f] IN identss AND setMethod.name<>''"), - - new SimpleWithClause( - "enclosingType, field, method, typeDec,identss, nodeInP,nodes, CASE WHEN setMethod IS NULL THEN [] ELSE COLLECT(DISTINCT setMethod) END as setters"), -// new ReturnClause( -// "enclosingType.fullyQualifiedName, field.name, method.name, typeDec.fullyQualifiedName, nodeInP,EXTRACT(n IN nodes |CASE WHEN EXISTS(n.fullyQualifiedName) THEN n.fullyQualifiedName ELSE n.name END), CASE WHEN setMethod IS NULL THEN [] ELSE COLLECT( DISTINCT setMethod) END as setters"), - - new MatchClause(true, - new MatchImpl( - "(anyMethod)<-[:DECLARES_METHOD]-(nodeInP)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]->()-[:DECLARES_METHOD]->(ovMethod{name:anyMethod.name})") - - ), -// new WhereClause("ovMethod.") , -// new ReturnClause("enclosingType, field, method, typeDec, nodeInP,nodes, setters, anyMethod, ovMethod") - - new MatchClause(true, - new MatchImpl( - "(anyMethod)-[:HAS_METHODDECL_PARAMETERS]->(p),(ovMethod)-[:HAS_METHODDECL_PARAMETERS]->(baseP)") - ), - - new SimpleWithClause( - "enclosingType, field, method,anyMethod, typeDec" - + ",identss" - + ",ovMethod, nodeInP,nodes, setters, COLLECT(p.actualType) as params, COLLECT(baseP.actualType) as baseParams "), - new SimpleWithClause( - "enclosingType, field, method,anyMethod, typeDec" - + ",identss" - + ",ovMethod, nodeInP,nodes, setters, EXTRACT(p IN params |[p, SIZE(FILTER(x IN params WHERE x=p))]) as params, " - + "EXTRACT(p IN baseParams |[p, SIZE(FILTER(x IN baseParams WHERE x=p))]) as baseParams"), - - - new SimpleWithClause(" enclosingType, field, method, typeDec" - + ",identss" - + ", nodeInP,nodes, setters" - + ",COLLECT( DISTINCT CASE WHEN " - + "SIZE(params)=SIZE(baseParams) AND ovMethod.name<>''" - + " AND ALL(pPair IN baseParams WHERE pPair IN params)" - + " THEN ovMethod ELSE NULL END) as methodsOverridenByThisType" - ), - -//new ReturnClause("distinct method") - - new MatchClause(true, - new MatchImpl( - "(nodeInP)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->()-[:DECLARES_METHOD]->(getMethod)-[:HAS_METHODDECL_MODIFIERS]->(methodMod)"), - - new Path(new NodeVar("nodeInP"), Pair.createP("f", RelationTypes.DECLARES_FIELD)), - getStatementServices().getMethodFromStatement( - new MatchImpl("(id)<-[:RETURN_EXP]-()"),new NodeVar("getMethod") - - )), - new WhereClause( - "[id,f] IN identss AND methodMod.flags CONTAINS 'public' AND NOT methodMod.flags CONTAINS 'static'"), -// new ReturnClause("enclosingType, field, method, typeDec, nodeInP,nodes, setters,methodsOverridenByThisType, COLLECT(DISTINCT getMethod) as getters") - new MatchClause(true, - - new RelationshipImpl(new NodeVar("f"), new NodeVar("fType"), - new EdgeImpl(TypeRelations.ITS_TYPE_IS))), - //WHERE -// Pair.create("accessLevel", "public"), Pair.create("isStatic", false) - - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP,nodes, setters,methodsOverridenByThisType, COLLECT(DISTINCT getMethod) as getters, COLLECT(DISTINCT fType) as getterTypes"), - new MatchClause(true, - new Path(new NodeVar("nodeInP"), - Pair.createP(new NodeVar("f"), RelationTypes.DECLARES_FIELD), - Pair.create(new EdgeImpl(TypeRelations.ITS_TYPE_IS), new NodeVar("fType"))) - , new MatchImpl("(f)-[:HAS_VARIABLEDECL_MODIFIERS]->(fMods)") - ), - new WhereClause("fMods.flags CONTAINS 'public' AND NOT fMods.flags CONTAINS 'static'"), -//WHERE , Pair.create("isStatic", false),Pair.create("accessLevel", "public") -new SimpleWithClause( - "enclosingType, field, method, typeDec,nodeInP,nodes,methodsOverridenByThisType, setters, getters,getterTypes, COLLECT(DISTINCT [f,fType,fMods.flags CONTAINS 'final']) as otherMutableDependencies "), - new SimpleWithClause( - "enclosingType, field, method, typeDec, nodeInP, nodes, setters,methodsOverridenByThisType, getters,getterTypes, " - + new Extract(new Filter("otherMutableDependencies", "x[2]"), "y[1]", "y") - .expToString() - + " as mutableDependenciesBis, " - + new Any("otherMutableDependencies", "NOT x[2]").expToString() - + " as isMutableDueToPublicField "), -// new ReturnClause("enclosingType, field, method, typeDec, -// nodeInP, p, setters") -// new WhereClause("SIZE(NODES(p))=12"), - new SimpleWithClause("DISTINCT enclosingType, field, method, typeDec, nodes" -// - + ", COLLECT([ID(nodeInP),[isMutableDueToPublicField,mutableDependenciesBis,methodsOverridenByThisType,setters, getters,getterTypes ]]) as map " -// -), - - new SimpleWithClause("enclosingType, field, method,typeDec,nodes as prevNodes" - - + "," - + new Extract("nodes", "x+HEAD(" + new Filter("map", "y[0]=ID(x)", "y").expToString() + ")[1]") - .expToString() - + " as nodes" - - ), new SimpleWithClause("DISTINCT enclosingType, field, method, typeDec,prevNodes, " + new Extract("nodes", "[x[0],CASE WHEN x[1] IS NULL THEN FALSE ELSE x[1] END, CASE WHEN x[2] IS NULL THEN [] ELSE x[2] END, CASE WHEN x[3] IS NULL THEN [] ELSE x[3] END, CASE WHEN x[4] IS NULL THEN [] ELSE x[4] END,CASE WHEN x[5] IS NULL THEN [] ELSE x[5] END, CASE WHEN x[6] IS NULL THEN [] ELSE x[6] END]").expToString() + " as nodes" - // - ), new SimpleWithClause("enclosingType, field, method, typeDec,prevNodes, CASE WHEN nodes IS NULL THEN [] ELSE nodes END as nodes "), - - new SimpleWithClause( - "enclosingType, field, method, typeDec,prevNodes, nodes, RANGE(0,SIZE(nodes)-1,1) as indexes"), - new SimpleWithClause( - "enclosingType, field, method, typeDec" - + ",prevNodes" - + ", nodes, indexes, EXTRACT(index IN indexes | CASE WHEN SIZE(FILTER(i IN indexes WHERE i=lastAttrIndexes[index]", "i").expToString(), - "s+nodes[x][3]", "s=[]").expToString() - - , "index").expToString() + " as overrides, indexes, lastAttrIndexes"), - new SimpleWithClause(" enclosingType, field, method, typeDec,prevNodes, " + new Extract("indexes", - "[nodes[x][0], nodes[x][1] OR ANY(setter IN nodes[x][4] WHERE NOT setter IN overrides[x]) " - - + ", nodes[x][2]+ EXTRACT( getterIndex IN FILTER(gf IN RANGE(0,SIZE(nodes[x][5])-1,1) " - + "WHERE NOT nodes[x][5][gf] IN overrides[x]) | nodes[x][6][getterIndex])] ") - .expToString() - + " as nodes, indexes "), - // new SimpleWithClause("enclosingType, field, method, - // typeDec,p, " + new Extract("indexes", - // "[nodes[x][0], nodes[x][1]," + new Case("x>0 AND NOT - // nodes[x+1] IS NULL", - // "CASE WHEN nodes[x][0]:ATTR_DEC THEN nodes[x+1][0] IN - // nodes[x-1][2] ELSE TRUE END", - // "TRUE").expToString() + "] ").expToString() - // + " as nodes"), - new SimpleWithClause( - "enclosingType, field, method, typeDec,prevNodes,indexes, " + new Extract("indexes", - "[nodes[x][0], nodes[x][1]," - + new Case("x>1 AND NOT nodes[x-1][0].nodeType='JCClassDecl'", - " ANY(dep IN nodes[x-2][2] WHERE dep =nodes[x][0])", "TRUE").expToString() - + "] ").expToString() - + " as nodes"), - new SimpleWithClause(" enclosingType, field, method, typeDec, " + new Extract("indexes", - "[nodes[x][0], nodes[x][1]," + "NOT ANY(i IN indexes WHERE i<=x AND NOT nodes[i][2]) ]") - .expToString() - + " as nodes "), - // new SimpleWithClause( - // "enclosingType, field, method,typeDec,p, CASE WHEN - // SIZE(nodes)=0 THEN []+typeDec ELSE nodes END as nodes "), - // new WhereClause("SIZE(nodes)=0"), - new SimpleWithClause("DISTINCT enclosingType, field, method, typeDec," + new Reduce("nodes", - // MISSING ADD ARRAY_TYPE AS ITS_TYPE_IS array AT THE - // VERY BEGINNING - "s AND CASE WHEN NOT x[0].nodeType='JCClassDecl' THEN TRUE ELSE NOT x[2] OR (NOT x[0]:ARRAY_TYPE AND NOT x[1]) END ", - "s=true").expToString() + " AND NOT typeDec:ARRAY_TYPE as res" - - ), new SimpleWithClause("enclosingType, field,method, typeDec,ANY (x IN COLLECT(res) WHERE NOT x) as isMutable"), - new SimpleWithClause("DISTINCT enclosingType, field,COLLECT(method) as methods, typeDec,isMutable"), - - new WhereClause("isMutable"), - // FILTRAR - // , - - new SimpleWithClause("COLLECT([enclosingType, field, methods, typeDec]) as res"), - new UnwindClause("res", "typeRes"), - new SimpleWithClause( - "typeRes[1] as field, typeRes[3] as typeDec, typeRes[0] as enclosingType,typeRes[2] as methods, res"), - new MatchClause(true, - new MatchImpl("(typeDec)<-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]-(subType)")), - new SimpleWithClause("typeDec,methods,enclosingType,field, EXTRACT(x IN res | x[3]) as mutableTypes, COLLECT(subType) as subtypes"), - new SimpleWithClause( - " typeDec, methods,enclosingType,field, FILTER(y IN subtypes WHERE NOT y IN mutableTypes) as nonMutableSubTypes") - ,new SimpleWithClause( " 'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ methods+'. The problem is that the type '+typeDec.fullyQualifiedName+' can be mutated by a malicious client.'+ CASE WHEN SIZE(nonMutableSubTypes)=0 THEN ' You should use an appropiate inmutable subtype as a wrapper for your attribute.'ELSE 'Remember to use an appropiate inmutable subtype (such as '+EXTRACT(x IN nonMutableSubTypes | x.fullyQualifiedName)+') as a wrapper for your attribute.'END as warning ") - - , new SimpleWithClause("DISTINCT COLLECT(warning) as warningList ") - , - new ClauseImpl( - "MATCH ()-[r]->() WHERE r.created DELETE r WITH DISTINCT warningList MATCH (array:ARRAY_TYPE) DELETE array ") - , new ReturnClause("DISTINCT warningList") -// , new ReturnClause(" warningList") - - }; - } - - public static void main(String[] args) { - System.out.println(new OBJ56().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleCallGraph.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleCallGraph.java deleted file mode 100644 index 5a0f0a1..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleCallGraph.java +++ /dev/null @@ -1,134 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServicesWiggle; -import database.relations.RelationTypesWiggle; - -public class WiggleCallGraph extends AbstractQuery { - - /* - * MATCH - * (declaringType{accessLevel:'public'})-[:DECLARES_FIELD]->(attr{typeKind:' - * DECLARED'})-[:ITS_TYPE_IS]->(typeDec) WHERE attr.isFinal AND - * attr.accessLevel='public' WITH attr, declaringType, typeDec - * - * MATCH - * p=(typeDec)-[:DECLARES_FIELD|ITS_TYPE_IS|IS_SUBTYPE_EXTENDS*]->(next{ - * typeKind:'DECLARED'}) WITH attr, declaringType, typeDec, NODES(p) as - * nodes - * - * CREATE (res{res:true}) FOREACH (i IN RANGE(1,SIZE(nodes),1) | SET res.res - * = res.res AND (CASE WHEN nodes[i]:ATTR_DEC THEN - * NOT(nodes[i-1].accessLevel='public' AND NOT nodes[i].isFinal AND NOT - * nodes[i].isStatic AND ( nodes[i].accessLevel='public' OR - * (nodes[i].accessLevel='protected' AND NOT nodes[i-1].isFinal) )) ELSE - * TRUE END)) WITH attr, declaringType, typeDec, nodes, res ------> TO DO - * - * - * - * OPTIONAL MATCH - * (field)-[mutationRel:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED|MODIFIED_BY] - * ->(ass) WHERE field IN nodes AND NOT ass:INITIALIZATION WITH attr, - * declaringType, res, typeDec, COUNT(mutationRel)>0 as hasAnyMutationRel - * - * WITH attr, declaringType, typeDec, ANY( x IN COLLECT( NOT res.res OR - * hasAnyMutationRel) WHERE x ) as isMutable WHERE isMutable RETURN 'Warning - * [CMU-OBJ50] Attribute '+ attr.name+' declared in - * '+declaringType.fullyQualifiedName+ ' is not actually final, only the - * reference. This is due to the type '+ typeDec.fullyQualifiedName+' is - * mutable ( the state of the attributes change in the program or may - * potentially be changed by a client).' - * - * - */ - private static final Expression ATTR_PROPERTIES = new ExprImpl( - "declaringTypeModfiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'final' AND attrModifiers.position>-1"); - private static final Clause[] PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServicesWiggle.typesAndDeclaredFieldsPlusModifiersAndTypes( - new RelationshipImpl(new NodeVar("declaringTypeModfiers"), new CompleteNode("declaringType"), - new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.HAS_CLASS_MODIFIERS)))); - - public WiggleCallGraph() { - super(false); - } - - public static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS |:HAS_CLASS_IMPLEMENTS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m),(t) WHERE SPLIT(t.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_OF]->(t) ON CREATE SET r.created=TRUE "; - - @Override - protected void initiate() { - // TO_ DO ADD DELETE RELS - clauses = new Clause[] { -// new ClauseImpl("MATCH (m{nodeType:'JCMethodDecl'})-[r:CALLS]->() DELETE r WITH DISTINCT '' as aux"), - new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - new SimpleWithClause("DISTINCT '' as aux "), - new MatchClause(new MatchImpl(getStatementServices().getMethodFromStatement(getExpressionServices() - .getStatementFromExp(new MatchImpl( "(invMember)<-[:METHODINVOCATION_METHOD_SELECT]-(inv{nodeType:'JCMethodInvocation'})")), new NodeVar("method{nodeType:'JCMethodDecl'}")).matchToString()+ - "<-[:DECLARES_METHOD]-(callerEncType)" - )), - new MatchClause(true, "(invMember)-[:MEMBER_SELECT_EXPR]->(memberSelection), (otherPossibleCallerEncType{nodeType:'JCClassDecl',fullyQualifiedName:memberSelection.actualType})"), - new SimpleWithClause("invMember, inv, method, CASE WHEN invMember.nodeType='JCIdent' THEN callerEncType ELSE otherPossibleCallerEncType END as callerEncType" ) - -,new WhereClause("NOT callerEncType IS NULL"), - new MatchClause(true, "(callerEncType)<-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]-(encSubType)-[:DECLARES_METHOD]->(invDeclaration)-[:HAS_METHODDECL_BODY]->()" - ),new WhereClause("CASE WHEN invMember.name ='this' THEN '' ELSE invMember.name END =invDeclaration.name "), - new MatchClause(true,"(invDeclaration)-[:HAS_METHODDECL_PARAMETERS]->(p) "), - new SimpleWithClause("inv, invMember, method, callerEncType,encSubType, invDeclaration, p ORDER BY ID(p)"), - - new SimpleWithClause("inv,invMember, FILTER(argType IN SPLIT(SPLIT(SUBSTRING(invMember.actualType,1),')')[0],',') WHERE argType<>'') as argTypes, method, callerEncType, invDeclaration, COLLECT(p.actualType) as pTypes"), - new SimpleWithClause("inv,invMember, method, callerEncType,argTypes, CASE WHEN SIZE(pTypes)=SIZE(argTypes) AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index]) THEN invDeclaration ELSE NULL END as invDeclaration "), - /* - new WhereClause("SIZE(pTypes)=SIZE(argTypes) AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index])" - - ),*/ - new SimpleWithClause("inv, invMember,argTypes, method, callerEncType, COLLECT(invDeclaration) as invDecs"), -// new SimpleWithClause("inv, invMember,argTypes, method, callerEncType, invDecs "), - - // SI el método buscado no está T, entonces buscamos el primer super que tenga el método, y siempre le sumamos la lista anterior de T'::m donde T'<:T - new MatchClause(true, "hierarchy=(callerEncType)-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(encSuperType)-[:DECLARES_METHOD]->(superInvDeclaration)-[:HAS_METHODDECL_BODY]->()" - ), -// new ReturnClause("DISTINCT method, callerEncType, inv, invDecs , hierarchy ORDER BY inv") - -new WhereClause("CASE WHEN invMember.name IN ['this','super'] THEN '' ELSE invMember.name END =superInvDeclaration.name AND (callerEncType<>encSuperType OR invMember.name<>'super')"), - new MatchClause(true,"(superInvDeclaration)-[:HAS_METHODDECL_PARAMETERS]->(p) "), - new SimpleWithClause("hierarchy,inv, invMember, argTypes, method, callerEncType,encSuperType,superInvDeclaration, invDecs, p ORDER BY ID(p)"), - // - new SimpleWithClause("hierarchy,inv,invMember,argTypes, method, callerEncType,encSuperType,superInvDeclaration, invDecs, COLLECT(p.actualType) as pTypes"), - new SimpleWithClause("inv,invMember, method, callerEncType, invDecs, CASE WHEN SIZE(pTypes)=SIZE(argTypes) " - + "AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index]) THEN superInvDeclaration ELSE NULL END as superInvDeclaration ORDER BY FILTER(i IN RANGE(0,CASE WHEN hierarchy IS NULL THEN 0 ELSE SIZE(NODES(hierarchy)) END) WHERE NODES(hierarchy)[i]=encSuperType)[0] " - - ), - new SimpleWithClause("method" -// + ", encSubType, method, callerEncType" - + ",inv,invDecs, COLLECT(superInvDeclaration)[0] as superDec"), - new SimpleWithClause("method" -// + ", encSubType, method, callerEncType" - + ",inv,invDecs+ CASE WHEN superDec IS NULL THEN [] ELSE [superDec] END as possibleDecs") - - - -, new UnwindClause("possibleDecs", "possibleCalle"), -//new ReturnClause("DISTINCT method, inv, possibleCalle ORDER BY inv") -new ClauseImpl("MERGE (method)-[r:CALLS]->(inv)-[r2:HAS_DEC]->(possibleCalle) ON CREATE SET r.created=TRUE, r2.created=TRUE ") - - }; - - } - - public static void main(String[] args) { - System.out.println(new WiggleCallGraph().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleExtendedCallGraph.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleExtendedCallGraph.java deleted file mode 100644 index dd59b8c..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleExtendedCallGraph.java +++ /dev/null @@ -1,134 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServicesWiggle; -import database.relations.RelationTypesWiggle; - -public class WiggleExtendedCallGraph extends AbstractQuery { - - /* - * MATCH - * (declaringType{accessLevel:'public'})-[:DECLARES_FIELD]->(attr{typeKind:' - * DECLARED'})-[:ITS_TYPE_IS]->(typeDec) WHERE attr.isFinal AND - * attr.accessLevel='public' WITH attr, declaringType, typeDec - * - * MATCH - * p=(typeDec)-[:DECLARES_FIELD|ITS_TYPE_IS|IS_SUBTYPE_EXTENDS*]->(next{ - * typeKind:'DECLARED'}) WITH attr, declaringType, typeDec, NODES(p) as - * nodes - * - * CREATE (res{res:true}) FOREACH (i IN RANGE(1,SIZE(nodes),1) | SET res.res - * = res.res AND (CASE WHEN nodes[i]:ATTR_DEC THEN - * NOT(nodes[i-1].accessLevel='public' AND NOT nodes[i].isFinal AND NOT - * nodes[i].isStatic AND ( nodes[i].accessLevel='public' OR - * (nodes[i].accessLevel='protected' AND NOT nodes[i-1].isFinal) )) ELSE - * TRUE END)) WITH attr, declaringType, typeDec, nodes, res ------> TO DO - * - * - * - * OPTIONAL MATCH - * (field)-[mutationRel:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED|MODIFIED_BY] - * ->(ass) WHERE field IN nodes AND NOT ass:INITIALIZATION WITH attr, - * declaringType, res, typeDec, COUNT(mutationRel)>0 as hasAnyMutationRel - * - * WITH attr, declaringType, typeDec, ANY( x IN COLLECT( NOT res.res OR - * hasAnyMutationRel) WHERE x ) as isMutable WHERE isMutable RETURN 'Warning - * [CMU-OBJ50] Attribute '+ attr.name+' declared in - * '+declaringType.fullyQualifiedName+ ' is not actually final, only the - * reference. This is due to the type '+ typeDec.fullyQualifiedName+' is - * mutable ( the state of the attributes change in the program or may - * potentially be changed by a client).' - * - * - */ - private static final Expression ATTR_PROPERTIES = new ExprImpl( - "declaringTypeModfiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'final' AND attrModifiers.position>-1"); - private static final Clause[] PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServicesWiggle.typesAndDeclaredFieldsPlusModifiersAndTypes( - new RelationshipImpl(new NodeVar("declaringTypeModfiers"), new CompleteNode("declaringType"), - new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.HAS_CLASS_MODIFIERS)))); - - public WiggleExtendedCallGraph() { - super(false); - } - - public static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS |:HAS_CLASS_IMPLEMENTS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m),(t) WHERE SPLIT(t.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_OF]->(t) ON CREATE SET r.created=TRUE "; - - @Override - protected void initiate() { - // TO_ DO ADD DELETE RELS - clauses = new Clause[] { -// new ClauseImpl("MATCH (m{nodeType:'JCMethodDecl'})-[r:CALLS]->() DELETE r WITH DISTINCT '' as aux"), - new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - new SimpleWithClause("DISTINCT '' as aux "), - new MatchClause(new MatchImpl(getStatementServices().getMethodFromStatement(getExpressionServices() - .getStatementFromExp(new MatchImpl( "(invMember)<-[:METHODINVOCATION_METHOD_SELECT]-(inv{nodeType:'JCMethodInvocation'})")), new NodeVar("method{nodeType:'JCMethodDecl'}")).matchToString()+ - "<-[:DECLARES_METHOD]-(callerEncType) MERGE (method)-[r:CALLS]->(inv) ON CREATE SET r.created=TRUE WITH inv, callerEncType" - )), - new MatchClause(true, "(invMember)-[:MEMBER_SELECT_EXPR]->(memberSelection), (otherPossibleCallerEncType{nodeType:'JCClassDecl',fullyQualifiedName:memberSelection.actualType})"), - new SimpleWithClause("invMember, inv, CASE WHEN invMember.nodeType='JCIdent' THEN callerEncType ELSE otherPossibleCallerEncType END as callerEncType" ) - -,new WhereClause("NOT callerEncType IS NULL"), - new MatchClause(true, "(callerEncType)<-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]-(encSubType)-[:DECLARES_METHOD]->(invDeclaration)-[:HAS_METHODDECL_BODY]->()" - ),new WhereClause("CASE WHEN invMember.name ='this' THEN '' ELSE invMember.name END =invDeclaration.name "), - new MatchClause(true,"(invDeclaration)-[:HAS_METHODDECL_PARAMETERS]->(p) "), - new SimpleWithClause("inv, invMember, callerEncType,encSubType, invDeclaration, p ORDER BY ID(p)"), - - new SimpleWithClause("inv,invMember, FILTER(argType IN SPLIT(SPLIT(SUBSTRING(invMember.actualType,1),')')[0],',') WHERE argType<>'') as argTypes, callerEncType, invDeclaration, COLLECT(p.actualType) as pTypes"), - new SimpleWithClause("inv,invMember, callerEncType,argTypes, CASE WHEN SIZE(pTypes)=SIZE(argTypes) AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index]) THEN invDeclaration ELSE NULL END as invDeclaration "), - /* - new WhereClause("SIZE(pTypes)=SIZE(argTypes) AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index])" - - ),*/ - new SimpleWithClause("inv, invMember,argTypes, callerEncType, COLLECT(invDeclaration) as invDecs"), -// new SimpleWithClause("inv, invMember,argTypes, method, callerEncType, invDecs "), - - // SI el método buscado no está T, entonces buscamos el primer super que tenga el método, y siempre le sumamos la lista anterior de T'::m donde T'<:T - new MatchClause(true, "hierarchy=(callerEncType)-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(encSuperType)-[:DECLARES_METHOD]->(superInvDeclaration)-[:HAS_METHODDECL_BODY]->()" - ), -// new ReturnClause("DISTINCT method, callerEncType, inv, invDecs , hierarchy ORDER BY inv") - -new WhereClause("CASE WHEN invMember.name IN ['this','super'] THEN '' ELSE invMember.name END =superInvDeclaration.name AND (callerEncType<>encSuperType OR invMember.name<>'super')"), - new MatchClause(true,"(superInvDeclaration)-[:HAS_METHODDECL_PARAMETERS]->(p) "), - new SimpleWithClause("hierarchy,inv, invMember, argTypes, callerEncType,encSuperType,superInvDeclaration, invDecs, p ORDER BY ID(p)"), - // - new SimpleWithClause("hierarchy,inv,invMember,argTypes, callerEncType,encSuperType,superInvDeclaration, invDecs, COLLECT(p.actualType) as pTypes"), - new SimpleWithClause("inv,invMember, callerEncType, invDecs, CASE WHEN SIZE(pTypes)=SIZE(argTypes) " - + "AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index]) THEN superInvDeclaration ELSE NULL END as superInvDeclaration ORDER BY FILTER(i IN RANGE(0,CASE WHEN hierarchy IS NULL THEN 0 ELSE SIZE(NODES(hierarchy)) END) WHERE NODES(hierarchy)[i]=encSuperType)[0] " - - ), - new SimpleWithClause( -// + ", encSubType, method, callerEncType" - "inv,invDecs, COLLECT(superInvDeclaration)[0] as superDec"), - new SimpleWithClause( -// + ", encSubType, method, callerEncType" - "inv,invDecs+ CASE WHEN superDec IS NULL THEN [] ELSE [superDec] END as possibleDecs") - - - -, new UnwindClause("possibleDecs", "possibleCalle"), -//new ReturnClause("DISTINCT method, inv, possibleCalle ORDER BY inv") -new ClauseImpl("MERGE (inv)-[r:HAS_DEC]->(possibleCalle) ON CREATE SET r.created=TRUE ") - - }; - - } - - public static void main(String[] args) { - System.out.println(new WiggleExtendedCallGraph().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleExtendedCallGraph2.java b/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleExtendedCallGraph2.java deleted file mode 100644 index 05e235f..0000000 --- a/ProgQuery/src/database/querys/cypherWrapper/cmu/wiggle/WiggleExtendedCallGraph2.java +++ /dev/null @@ -1,134 +0,0 @@ -package database.querys.cypherWrapper.cmu.wiggle; - -import database.querys.cypherWrapper.AbstractQuery; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.Expression; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.services.FieldServicesWiggle; -import database.relations.RelationTypesWiggle; - -public class WiggleExtendedCallGraph2 extends AbstractQuery { - - /* - * MATCH - * (declaringType{accessLevel:'public'})-[:DECLARES_FIELD]->(attr{typeKind:' - * DECLARED'})-[:ITS_TYPE_IS]->(typeDec) WHERE attr.isFinal AND - * attr.accessLevel='public' WITH attr, declaringType, typeDec - * - * MATCH - * p=(typeDec)-[:DECLARES_FIELD|ITS_TYPE_IS|IS_SUBTYPE_EXTENDS*]->(next{ - * typeKind:'DECLARED'}) WITH attr, declaringType, typeDec, NODES(p) as - * nodes - * - * CREATE (res{res:true}) FOREACH (i IN RANGE(1,SIZE(nodes),1) | SET res.res - * = res.res AND (CASE WHEN nodes[i]:ATTR_DEC THEN - * NOT(nodes[i-1].accessLevel='public' AND NOT nodes[i].isFinal AND NOT - * nodes[i].isStatic AND ( nodes[i].accessLevel='public' OR - * (nodes[i].accessLevel='protected' AND NOT nodes[i-1].isFinal) )) ELSE - * TRUE END)) WITH attr, declaringType, typeDec, nodes, res ------> TO DO - * - * - * - * OPTIONAL MATCH - * (field)-[mutationRel:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED|MODIFIED_BY] - * ->(ass) WHERE field IN nodes AND NOT ass:INITIALIZATION WITH attr, - * declaringType, res, typeDec, COUNT(mutationRel)>0 as hasAnyMutationRel - * - * WITH attr, declaringType, typeDec, ANY( x IN COLLECT( NOT res.res OR - * hasAnyMutationRel) WHERE x ) as isMutable WHERE isMutable RETURN 'Warning - * [CMU-OBJ50] Attribute '+ attr.name+' declared in - * '+declaringType.fullyQualifiedName+ ' is not actually final, only the - * reference. This is due to the type '+ typeDec.fullyQualifiedName+' is - * mutable ( the state of the attributes change in the program or may - * potentially be changed by a client).' - * - * - */ - private static final Expression ATTR_PROPERTIES = new ExprImpl( - "declaringTypeModfiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'public' AND attrModifiers.flags CONTAINS 'final' AND attrModifiers.position>-1"); - private static final Clause[] PUBLIC_TYPES_AND_PUBLIC_FINAL_FIELDS = new WhereClause(ATTR_PROPERTIES) - .addToClauses(FieldServicesWiggle.typesAndDeclaredFieldsPlusModifiersAndTypes( - new RelationshipImpl(new NodeVar("declaringTypeModfiers"), new CompleteNode("declaringType"), - new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.HAS_CLASS_MODIFIERS)))); - - public WiggleExtendedCallGraph2() { - super(false); - } - - public static final String CREATE_ALL_SUBTYPE_RELS = "MATCH (n)-[:HAS_CLASS_EXTENDS |:HAS_CLASS_IMPLEMENTS]->()-[:PARAMETERIZEDTYPE_TYPE*0..]->(m),(t) WHERE SPLIT(t.fullyQualifiedName,'<')[0]=SPLIT(m.actualType,'<')[0] MERGE (n)-[r:IS_SUBTYPE_OF]->(t) ON CREATE SET r.created=TRUE "; - - @Override - protected void initiate() { - // TO_ DO ADD DELETE RELS - clauses = new Clause[] { -// new ClauseImpl("MATCH (m{nodeType:'JCMethodDecl'})-[r:CALLS]->() DELETE r WITH DISTINCT '' as aux"), - new ClauseImpl(CREATE_ALL_SUBTYPE_RELS), - new SimpleWithClause("DISTINCT '' as aux "), - new MatchClause(new MatchImpl(getStatementServices().getMethodFromStatement(getExpressionServices() - .getStatementFromExp(new MatchImpl( "(invMember)<-[:METHODINVOCATION_METHOD_SELECT]-(inv{nodeType:'JCMethodInvocation'})")), new NodeVar("method{nodeType:'JCMethodDecl'}")).matchToString()+ - "<-[:DECLARES_METHOD]-(callerEncType) MERGE (inv)<-[r:CALLS]-(method) ON CREATE SET r.created=TRUE WITH method, inv, callerEncType" - )), - new MatchClause(true, "(invMember)-[:MEMBER_SELECT_EXPR]->(memberSelection), (otherPossibleCallerEncType{nodeType:'JCClassDecl',fullyQualifiedName:memberSelection.actualType})"), - new SimpleWithClause("invMember, inv, method, CASE WHEN invMember.nodeType='JCIdent' THEN callerEncType ELSE otherPossibleCallerEncType END as callerEncType" ) - -,new WhereClause("NOT callerEncType IS NULL"), - new MatchClause(true, "(callerEncType)<-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]-(encSubType)-[:DECLARES_METHOD]->(invDeclaration)-[:HAS_METHODDECL_BODY]->()" - ),new WhereClause("CASE WHEN invMember.name ='this' THEN '' ELSE invMember.name END =invDeclaration.name "), - new MatchClause(true,"(invDeclaration)-[:HAS_METHODDECL_PARAMETERS]->(p) "), - new SimpleWithClause("inv, invMember, method, callerEncType,encSubType, invDeclaration, p ORDER BY ID(p)"), - - new SimpleWithClause("inv,invMember, FILTER(argType IN SPLIT(SPLIT(SUBSTRING(invMember.actualType,1),')')[0],',') WHERE argType<>'') as argTypes, method, callerEncType, invDeclaration, COLLECT(p.actualType) as pTypes"), - new SimpleWithClause("inv,invMember, method, callerEncType,argTypes, CASE WHEN SIZE(pTypes)=SIZE(argTypes) AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index]) THEN invDeclaration ELSE NULL END as invDeclaration "), - /* - new WhereClause("SIZE(pTypes)=SIZE(argTypes) AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index])" - - ),*/ - new SimpleWithClause("inv, invMember,argTypes, method, callerEncType, COLLECT(invDeclaration) as invDecs"), -// new SimpleWithClause("inv, invMember,argTypes, method, callerEncType, invDecs "), - - // SI el método buscado no está T, entonces buscamos el primer super que tenga el método, y siempre le sumamos la lista anterior de T'::m donde T'<:T - new MatchClause(true, "hierarchy=(callerEncType)-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(encSuperType)-[:DECLARES_METHOD]->(superInvDeclaration)-[:HAS_METHODDECL_BODY]->()" - ), -// new ReturnClause("DISTINCT method, callerEncType, inv, invDecs , hierarchy ORDER BY inv") - -new WhereClause("CASE WHEN invMember.name IN ['this','super'] THEN '' ELSE invMember.name END =superInvDeclaration.name AND (callerEncType<>encSuperType OR invMember.name<>'super')"), - new MatchClause(true,"(superInvDeclaration)-[:HAS_METHODDECL_PARAMETERS]->(p) "), - new SimpleWithClause("hierarchy,inv, invMember, argTypes, method, callerEncType,encSuperType,superInvDeclaration, invDecs, p ORDER BY ID(p)"), - // - new SimpleWithClause("hierarchy,inv,invMember,argTypes, method, callerEncType,encSuperType,superInvDeclaration, invDecs, COLLECT(p.actualType) as pTypes"), - new SimpleWithClause("inv,invMember, method, callerEncType, invDecs, CASE WHEN SIZE(pTypes)=SIZE(argTypes) " - + "AND ALL(index IN RANGE(0,SIZE(pTypes)-1) WHERE argTypes[index]=pTypes[index]) THEN superInvDeclaration ELSE NULL END as superInvDeclaration ORDER BY FILTER(i IN RANGE(0,CASE WHEN hierarchy IS NULL THEN 0 ELSE SIZE(NODES(hierarchy)) END) WHERE NODES(hierarchy)[i]=encSuperType)[0] " - - ), - new SimpleWithClause("method" -// + ", encSubType, method, callerEncType" - + ",inv,invDecs, COLLECT(superInvDeclaration)[0] as superDec"), - new SimpleWithClause("method" -// + ", encSubType, method, callerEncType" - + ",inv,invDecs+ CASE WHEN superDec IS NULL THEN [] ELSE [superDec] END as possibleDecs") - - - -, new UnwindClause("possibleDecs", "possibleCalle"), -//new ReturnClause("DISTINCT method, inv, possibleCalle ORDER BY inv") -new ClauseImpl("MERGE (inv)-[r2:HAS_DEC]->(possibleCalle) ON CREATE SET r2.created=TRUE ") - - }; - - } - - public static void main(String[] args) { - System.out.println(new WiggleExtendedCallGraph2().queryToString()); - } -} diff --git a/ProgQuery/src/database/querys/eval/BlochQueries.java b/ProgQuery/src/database/querys/eval/BlochQueries.java deleted file mode 100644 index 4a5e9c3..0000000 --- a/ProgQuery/src/database/querys/eval/BlochQueries.java +++ /dev/null @@ -1,85 +0,0 @@ -package database.querys.eval; - -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintStream; - -import org.neo4j.graphdb.GraphDatabaseService; - -import database.embedded.EmbeddedDBManager; -import database.queries.sa.bloch.BLOCH_11_75; -import database.queries.sa.bloch.BLOCH_8_45; -import database.queries.sa.bloch.BLOCH_8_45_V2; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.Reduce; -import database.querys.cypherWrapper.cmu.pq.OBJ50; -import database.querys.cypherWrapper.cmu.pq.OBJ54; -import database.querys.cypherWrapper.cmu.pq.OBJ54_SA; -import database.querys.cypherWrapper.cmu.pq.OBJ56_SIMPLIFIED; -import database.querys.cypherWrapper.cmu.pq.OBJ56_SIMPLIFIED_SA; -import database.relations.CFGRelationTypes; -import database.relations.RelationTypes; -import database.relations.RelationTypesInterface; -import evaluation.Rule; - -public class BlochQueries { - - public static final Rule[] RULES = new Rule[] { new Rule(new BLOCH_11_75().queryToString()), new Rule(new BLOCH_8_45_V2().queryToString())}; - - public static void main(String[] args) throws IOException { - final boolean MEASURING_MEMORY = false; - int queryIndex = args.length == 0 ?1: Integer.parseInt(args[0]); - try { - GraphDatabaseService gs = EmbeddedDBManager.getNewEmbeddedDBService(); - - Rule rule = -// new Rule("MATCH (n) RETURN n") - RULES[queryIndex] - ; - - - if (args.length == 0) - System.out.println(rule.queries[0]); - long ini = System.nanoTime(); - String res = rule.execute(gs).resultAsString(); - long end = System.nanoTime(); - if (!MEASURING_MEMORY) { - System.err.println(res); - // String resString = res.resultAsString(); - System.out.print((end - ini) / 1000_000); - } else { -// System.out.println("Press any key..."); -// new Scanner(System.in).nextLine(); - } - if (args.length == 0) { - // System.out.println(res.hashCode()); - // System.out.println(res.resultAsString()); - int size = 0; - // System.out.println(size); - // while (res.hasNext()) { - // System.out.println(size); - // res.next(); - // size++; - // - // } - // System.out.println(size); - // BufferedWriter bw = new BufferedWriter(new - // FileWriter("outXX.txt")); - // bw.write(resString); - // bw.close(); - - } - // gs.execute(DELETE_ALL);} - } catch (Throwable t) { - t.printStackTrace(new PrintStream(new FileOutputStream("err" + queryIndex + ".txt"))); - BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt")); - bw.write(RULES[queryIndex].queries[0]); - bw.close(); - System.out.println("-1"); - } - } -} diff --git a/ProgQuery/src/database/querys/eval/CMUQueries.java b/ProgQuery/src/database/querys/eval/CMUQueries.java deleted file mode 100644 index bc71631..0000000 --- a/ProgQuery/src/database/querys/eval/CMUQueries.java +++ /dev/null @@ -1,841 +0,0 @@ -package database.querys.eval; - -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintStream; - -import org.neo4j.graphdb.GraphDatabaseService; - -import database.embedded.EmbeddedDBManager; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.Reduce; -import database.querys.cypherWrapper.cmu.pq.OBJ50; -import database.querys.cypherWrapper.cmu.pq.OBJ54; -import database.querys.cypherWrapper.cmu.pq.OBJ54_SA; -import database.querys.cypherWrapper.cmu.pq.OBJ56_SIMPLIFIED; -import database.querys.cypherWrapper.cmu.pq.OBJ56_SIMPLIFIED_SA; -import database.relations.CFGRelationTypes; -import database.relations.RelationTypes; -import database.relations.RelationTypesInterface; -import evaluation.Rule; - -public class CMUQueries { - private static final RelationTypes[] assignToOutExprNoCond = new RelationTypes[] { RelationTypes.ARRAYACCESS_EXPR, - RelationTypes.ARRAYACCESS_INDEX, RelationTypes.ASSIGNMENT_RHS, RelationTypes.BINOP_LHS, - RelationTypes.BINOP_RHS, RelationTypes.CAST_ENCLOSES, RelationTypes.COMPOUND_ASSIGNMENT_RHS, - RelationTypes.CONDITIONAL_EXPR_CONDITION, RelationTypes.INITIALIZATION_EXPR, RelationTypes.INSTANCE_OF_EXPR, - RelationTypes.MEMBER_REFERENCE_EXPRESSION, RelationTypes.MEMBER_SELECT_EXPR, - RelationTypes.METHODINVOCATION_ARGUMENTS, RelationTypes.METHODINVOCATION_METHOD_SELECT, - RelationTypes.NEW_CLASS_ARGUMENTS, RelationTypes.NEW_ARRAY_INIT, RelationTypes.NEW_ARRAY_DIMENSION, - RelationTypes.UNARY_ENCLOSES }; - private static final RelationTypes[] assignToOutExpr = new RelationTypes[] { RelationTypes.ARRAYACCESS_EXPR, - RelationTypes.ARRAYACCESS_INDEX, RelationTypes.ASSIGNMENT_RHS, RelationTypes.BINOP_LHS, - RelationTypes.BINOP_RHS, RelationTypes.BINOP_COND_RHS, RelationTypes.CAST_ENCLOSES, - RelationTypes.COMPOUND_ASSIGNMENT_RHS, RelationTypes.CONDITIONAL_EXPR_CONDITION, - RelationTypes.CONDITIONAL_EXPR_THEN, RelationTypes.CONDITIONAL_EXPR_ELSE, RelationTypes.INITIALIZATION_EXPR, - RelationTypes.INSTANCE_OF_EXPR, RelationTypes.MEMBER_REFERENCE_EXPRESSION, RelationTypes.MEMBER_SELECT_EXPR, - RelationTypes.METHODINVOCATION_ARGUMENTS, RelationTypes.METHODINVOCATION_METHOD_SELECT, - RelationTypes.NEW_CLASS_ARGUMENTS, RelationTypes.NEW_ARRAY_INIT, RelationTypes.NEW_ARRAY_DIMENSION, - RelationTypes.UNARY_ENCLOSES }; - private static final String assignToOutExprQuery = getAnyRel(assignToOutExpr); - private static final RelationTypes[] exprToOutExpr = new RelationTypes[] { RelationTypes.ARRAYACCESS_EXPR, - RelationTypes.ARRAYACCESS_INDEX, RelationTypes.ASSIGNMENT_LHS, RelationTypes.ASSIGNMENT_RHS, - RelationTypes.BINOP_LHS, RelationTypes.BINOP_RHS, RelationTypes.BINOP_COND_RHS, RelationTypes.CAST_ENCLOSES, - RelationTypes.COMPOUND_ASSIGNMENT_LHS, RelationTypes.COMPOUND_ASSIGNMENT_RHS, - RelationTypes.CONDITIONAL_EXPR_CONDITION, RelationTypes.CONDITIONAL_EXPR_THEN, - RelationTypes.CONDITIONAL_EXPR_ELSE, RelationTypes.INITIALIZATION_EXPR, RelationTypes.INSTANCE_OF_EXPR, - RelationTypes.MEMBER_REFERENCE_EXPRESSION, RelationTypes.MEMBER_SELECT_EXPR, - RelationTypes.METHODINVOCATION_ARGUMENTS, RelationTypes.METHODINVOCATION_METHOD_SELECT, - RelationTypes.NEW_CLASS_ARGUMENTS, RelationTypes.NEW_ARRAY_INIT, RelationTypes.NEW_ARRAY_DIMENSION, - RelationTypes.UNARY_ENCLOSES }; - - private static final String exprToOutExprQuery = getAnyRel(exprToOutExpr); - private static final RelationTypes[] statToEnclClass = new RelationTypes[] { RelationTypes.CASE_STATEMENTS, - RelationTypes.CATCH_ENCLOSES_BLOCK, RelationTypes.CATCH_PARAM, RelationTypes.DECLARES_FIELD, - RelationTypes.DECLARES_METHOD, RelationTypes.DECLARES_CONSTRUCTOR, RelationTypes.ENCLOSES, - RelationTypes.DO_WHILE_STATEMENT, RelationTypes.WHILE_STATEMENT, RelationTypes.HAS_ENUM_ELEMENT, - RelationTypes.FOREACH_STATEMENT, RelationTypes.FOREACH_VAR, RelationTypes.FORLOOP_INIT, - RelationTypes.FORLOOP_STATEMENT, RelationTypes.FORLOOP_UPDATE, RelationTypes.CALLABLE_HAS_BODY, - RelationTypes.CALLABLE_HAS_PARAMETER, RelationTypes.HAS_STATIC_INIT, RelationTypes.HAS_VARIABLEDECL_INIT, - RelationTypes.IF_THEN, RelationTypes.IF_ELSE, RelationTypes.LABELED_STMT_ENCLOSES, - RelationTypes.SWITCH_ENCLOSES_CASE, RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, RelationTypes.TRY_BLOCK, - RelationTypes.TRY_CATCH, RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES }; - private static final RelationTypes[] statToOuterBlock = new RelationTypes[] { RelationTypes.CASE_STATEMENTS, - RelationTypes.CATCH_ENCLOSES_BLOCK, RelationTypes.CATCH_PARAM, RelationTypes.ENCLOSES, - RelationTypes.DO_WHILE_STATEMENT, RelationTypes.WHILE_STATEMENT, RelationTypes.FOREACH_STATEMENT, - RelationTypes.FOREACH_VAR, RelationTypes.FORLOOP_INIT, RelationTypes.FORLOOP_STATEMENT, - RelationTypes.FORLOOP_UPDATE, RelationTypes.CALLABLE_HAS_PARAMETER, RelationTypes.HAS_STATIC_INIT, - RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.IF_THEN, RelationTypes.IF_ELSE, - RelationTypes.LABELED_STMT_ENCLOSES, RelationTypes.SWITCH_ENCLOSES_CASE, RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, - RelationTypes.TRY_BLOCK, RelationTypes.TRY_CATCH, RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES }; - - - private static final RelationTypes[] exprToStat = new RelationTypes[] { RelationTypes.ASSERT_CONDITION, - RelationTypes.DO_WHILE_CONDITION, RelationTypes.ENCLOSES_EXPR, RelationTypes.FOREACH_EXPR, - RelationTypes.FORLOOP_CONDITION, RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.IF_CONDITION, - RelationTypes.SWITCH_EXPR, RelationTypes.SYNCHRONIZED_EXPR, RelationTypes.THROW_EXPR, - RelationTypes.WHILE_CONDITION, RelationTypes.RETURN_EXPR }; - private static final String exprToStatQuery = getAnyRel(exprToStat); - // private static final String exprToStatQueryWithReturn = - // getAnyRel(exprToStat) + " | :RETURN_EXPR "; - - private static final CFGRelationTypes[] cfgUnconditionalSucc = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NO_EXCEPTION, CFGRelationTypes.CFG_THROWS }; - - private static final CFGRelationTypes[] toCFGSuccesor = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, - CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, CFGRelationTypes.CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION, - CFGRelationTypes.CFG_NO_EXCEPTION, CFGRelationTypes.CFG_CAUGHT_EXCEPTION, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, - CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE, CFGRelationTypes.CFG_MAY_THROW, - CFGRelationTypes.CFG_THROWS, CFGRelationTypes.CFG_ENTRIES }; - private static final CFGRelationTypes[] toCFGSuccesorNoEx = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, - CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, CFGRelationTypes.CFG_NO_EXCEPTION, - CFGRelationTypes.CFG_CAUGHT_EXCEPTION, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, - CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE }; - private static final CFGRelationTypes[] toCFGSuccesorNoCondEx = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, - CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, CFGRelationTypes.CFG_NO_EXCEPTION, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, - CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE, CFGRelationTypes.CFG_THROWS }; - private static final String cfgSuccesor = getAnyRel(toCFGSuccesor); - - public static String getAnyRel(RelationTypesInterface[] rels) { - String ret = ""; - for (RelationTypesInterface r : rels) - ret += ":" + r.toString() + " | "; - return ret.substring(0, ret.length() - 2); - } - - private static final String OBJ56_SENSITIVE_MUTABLE_CLASSES_WITH_UNMODIFICABLE_WRAPPERS = " MATCH (enclosingType{accessLevel:'public'})-[:DECLARES_FIELD]->(field)-[:USED_BY]->(id)<-[:RETURN_EXPR]-()<-[" - + getAnyRel(statToOuterBlock) - + "*]-(outerBlock)<-[:CALLABLE_HAS_BODY]-(method{accessLevel:'public'}), (field)-[:ITS_TYPE_IS]->(typeDec) WHERE field.accessLevel<>'public' AND (typeDec:CLASS_DECLARATION OR typeDec:ENUM_DECLARATION) " - + " WITH enclosingType.fullyQualifiedName AS enclosingTypeName, typeDec, field.name AS mutableFieldName " - + " OPTIONAL MATCH (field)-[r:MODIFIED_BY | :STATE_MODIFIED_BY]-(modif)<-[" + assignToOutExprQuery - + "*0..]-(outUseExpr)<-[" + exprToStatQuery + "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) - // This field Is Mutable From OutSide ?? Subconjunto de Is Mutable - + "*]-(outerBlock)<-[:CALLABLE_HAS_BODY]-(methodSet{accessLevel:'public'})<-[:DECLARES_METHOD]-(typeDec) " - + " WITH field, methodSet,typeDec, mutableFieldName, enclosingTypeName" - + " OPTIONAL MATCH (field{typeKind:'ARRAY'})-[:USED_BY]->(id)<-[:RETURN_EXPR]-()<-[" - + getAnyRel(statToOuterBlock) + "*]-(outerBlock)<-[:CALLABLE_HAS_BODY]-(methodGet{accessLevel:'public'})" - + "" - // GET - // TO - // MUTABLE - // FIELD - // --- - // OUTSIDE - // MUTABLE - // ANALYSIS there is public field, there is public setter, there - // is get to array or mutableType?? - + "" + "<-[:DECLARES_METHOD]-(typeDec) " - + " WITH COLLECT(methodSet) + COLLECT(methodGet) AS methods, field,typeDec, mutableFieldName, enclosingTypeName " - + " UNWIND methods AS m WITH COLLECT( DISTINCT m) as methods, mutableFieldName, enclosingTypeName, field, typeDec, (field.accessLevel='public' AND NOT field.isFinal AND NOT field.isStatic) AS anyPublicAttr" - + " WHERE SIZE(methods)>0 OR anyPublicAttr" - + " UNWIND methods AS m WITH typeDec, mutableFieldName, enclosingTypeName, COLLECT(DISTINCT m) AS methods, anyPublicAttr " - + " OPTIONAL MATCH p=(typeDec)<-[:IS_SUBTYPE_EXTENDS*]-(subType)" - + " OPTIONAL MATCH (subType)-[:DECLARES_METHOD]->(method)-[:OVERRIDES]->(ovMethod) WHERE ovMethod IN methods " - + " WITH typeDec, mutableFieldName, enclosingTypeName, subType, COUNT( DISTINCT ovMethod) as ovMethodCount, SIZE( methods) as methodCount, p, anyPublicAttr " - + " OPTIONAL MATCH (field)<-[:DECLARES_FIELD]-(typeInHierarchy) WHERE typeInHierarchy IN nodes(p) WITH COLLECT(field) AS fields, mutableFieldName, enclosingTypeName, typeDec, subType, ovMethodCount, methodCount, anyPublicAttr " - + " OPTIONAL MATCH (subType)-[:DECLARES_METHOD]->(method{accessLevel:'public'}) WITH COLLECT(method) as publicSubMethods, mutableFieldName, enclosingTypeName, fields, typeDec, subType, ovMethodCount, methodCount, anyPublicAttr " - + " OPTIONAL MATCH q=(field)-[r:MODIFIED_BY |:STATE_MODIFIED_BY]-(modif)<-[" + assignToOutExprQuery - + "*0..]-(outUseExpr)<-[" + exprToStatQuery + "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) - + "*]-(outerBlock)<-[:CALLABLE_HAS_BODY]-(method) WHERE field IN fields AND method IN publicSubMethods WITH typeDec, mutableFieldName, enclosingTypeName, subType, ovMethodCount, methodCount, COUNT(q) AS qs, anyPublicAttr, fields, publicSubMethods" - + " OPTIONAL MATCH s=(field)-[:USED_BY]->(id)<-[:RETURN_EXPR]-()<-[" + getAnyRel(statToOuterBlock) - + "*]-(outerBlock)<-[:CALLABLE_HAS_BODY]-(method) WHERE field.typeKind='ARRAY' AND field IN fields AND method IN publicSubMethods" - - + " WITH typeDec, mutableFieldName, enclosingTypeName,anyPublicAttr,subType, ovMethodCount, methodCount,qs, COUNT(s) AS ss, ANY(f IN fields WHERE f.accessLevel='public' AND NOT f.isStatic AND NOT f.isFinal) as updatedAnyPublicAttr" - + " WITH typeDec, mutableFieldName, enclosingTypeName,anyPublicAttr, COLLECT([subType, ovMethodCount, methodCount,qs, ss, updatedAnyPublicAttr]) as tuples" - + " WHERE anyPublicAttr OR ALL( tuple IN tuples WHERE tuple[1]0 OR tuple[4]>0 OR tuple[5]) " - + " RETURN 'Warning [CMU-OBJ56] You must provide sensitive mutable classes with unmodifiable wrappers. The class '+ enclosingTypeName + ' has a non-public atribute ' +mutableFieldName+' returned in a public method. The class of this attribute, ' +typeDec.fullyQualifiedName+', can be mutated by an unstrusted client and there are no unmodificable subclasses to be used as a wrapper.'" - - ; - - private static final String MET52_DO_NOT_USE_CLONE_WITH_UNTRUSTED_PARAMETERS = " MATCH (enclosingCU)-[:HAS_TYPE_DEF |:HAS_INNER_TYPE_DEF]->(typeDec{accessLevel:'public'})" - + "-[:DECLARES_METHOD]->(method{accessLevel:'public'})-[:CALLABLE_HAS_PARAMETER]->(param)" - + " -[:USED_BY]->(id)<-[:MEMBER_SELECT_EXPR]-(mSelect:MEMBER_SELECTION{memberName:'clone'})" - + "<-[:METHODINVOCATION_METHOD_SELECT]-(mInv:METHOD_INVOCATION), (param)-[:HAS_VARIABLEDECL_TYPE]->" - + "()-[:PARAMETERIZED_TYPE*0..1]->()-[:ITS_TYPE_IS]->(pType) " - + " WHERE mSelect.actualType CONTAINS '()' AND NOT pType.isFinal AND " - + "(NOT pType.isDeclared OR pType.accessLevel='public') RETURN " - + "'Warning [CMU-MET52] You must not use the clone method to copy unstrasted parameters (like parameter ' + param.name+ ', cloned in line '+ mInv.lineNumber+ ' in method ' + method.name +', file '+enclosingCU.fileName+').'"; - - // LO ÚNICO QUE ME MOSQUEA AHORA ES ESE OR DEL FINAL, PORQUE NO PERMITE - // COSAS COMO - /* - * if(){ - * - * a=b; Sysout(a); - * - * } - * - * EN LUGAR DE Sólo COSAS COMO - * - * if(){ a=b; } - * - * Sysout(a) - * - * Y LAS REGLAS DE EN MEDIO NO PERMITEN ESTO?? - * - * for() { a=b; Sysout(a) //PORQUE LA MODIF SE PUEDE ALCANZAR DESDE EL USO, - * PERO NUNCA SE EJECUTA ANTES EL USO QUE LA MODIFICACION } - * - * for() { Sysout(a) a=b; } - * - * Y LOS ATRIBUTOS NO PUEDEN SER PÚBLICOS DE CLASES PúBLICAS, PORQUE - * ENTONCES IGUAL SIRVE PARA ALGO... - */ - - // Que le preceda una modif - // Una modif con id o this.id o un member_sel sobre el mismo objeto (menos - // news) que el - // uso - // Movida de los bloques - // controlar expresiones padres o hermanas anteriores - // problema position - // not (isStatic() and isFinal() and getType().getName()="long" and - // getType() instanceof PrimitiveType and getName()="serialVersionUID") and - - private static final String DCL53_MINIMIZE_SCOPE_OF_VARIABLES = " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEC) " - + " WHERE NOT (attr.accessLevel='public' AND typeDec.accessLevel='public') AND " - + " NOT( attr.isStatic AND attr.actualType='long' AND attr.isFinal AND attr.name='serialVersionUID') " - // +" RETURN attr.name as a, typeDec.fullyQualifiedName ORDER BY a" - + " OPTIONAL MATCH (attr)-[:USED_BY]->(exprUse)<-[" + exprToOutExprQuery + "*0..]-(outUseExpr)<-[" - + exprToStatQuery + "]-(exprUseStat)" + "" + " OPTIONAL MATCH (exprUseStat)<-[" - + getAnyRel(statToOuterBlock) - + "*]-(outerBlock)<-[:CALLABLE_HAS_BODY]-() WITH typeDec.fullyQualifiedName as className, attr,outerBlock, exprUseStat, exprUse" - + " OPTIONAL MATCH (attr)-[:MODIFIED_BY]->(modif)<-[" + getAnyRel(assignToOutExprNoCond) - + "*0..]-(outModExpr)<-[" + exprToStatQuery + "]-(exprModStat)<-[" + getAnyRel(statToOuterBlock) - + "*]-(outerBlock), (modif)-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE exprModStat.position < exprUseStat.position " - + " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" - + " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - + " WITH outerBlock,p,className, attr.lineNumber as line, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat, exprModStat " - + " OPTIONAL MATCH q=(exprModStat)<-[" + getAnyRel(statToOuterBlock) - + "*0..]-(minimumCommonBlock), (minimumCommonBlock)-[" + getAnyRel(statToOuterBlock) - + "*0..]->(exprUseStat) " + " WITH className, attr, exprUse,line, " + " ANY(x IN " + "COLLECT(" + " " - + "( NOT outerBlock IS NULL AND" - + " NOT ANY(rel IN RELS(q) WHERE type(rel)='IF_ELSE' OR type(rel)='FORLOOP_UPDATE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - + " AND (" - + " (exprUse:IDENTIFIER OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse:IDENTIFIER AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - + " AND (lhs_expr:IDENTIFIER OR (NOT memberSelectExprModif IS NULL AND memberSelectExprModif:IDENTIFIER AND (memberSelectExprModif.name='this' OR memberSelectExprModif.name='super')))" - + " ) " + " OR " - + " (p IS NOT NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER)" - + ")" + ") " + " WHERE x) as useWithModif " - + " WITH line,className, attr , ALL( x IN COLLECT(useWithModif) WHERE x) OR exprUse IS NULL as isSillyAttr " - // + "WHERE isSillyAttr" - + " RETURN 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+'(declared in line '+line+') in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).' as war ORDER BY war"// Movida - // de - ; // los - - private static final String DCL53_MINIMIZE_SCOPE_OF_VARIABLES_V2 = " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEF) " - + " WHERE NOT ((attr.accessLevel='public' OR attr.accessLevel='protected' AND NOT typeDec.isFinal) AND typeDec.accessLevel='public') AND " - + " NOT( attr.isStatic AND attr.actualType='long' AND attr.isFinal AND attr.name='serialVersionUID') " - // +" RETURN attr.name as a, typeDec.fullyQualifiedName ORDER BY a" - + " OPTIONAL MATCH (attr)-[attrUseRel:USED_BY | :STATE_MODIFIED_BY]->(exprUse)<-[" + exprToOutExprQuery - + "*0..]-()<-[" + exprToStatQuery + "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) - + "*]-(outerBlock)<-[:CALLABLE_HAS_BODY]-(method) " - + " OPTIONAL MATCH (attr)-[attrModifRel:MODIFIED_BY]->(modif)<-[" + getAnyRel(assignToOutExprNoCond) - + "*0..]-()<-[" + exprToStatQuery + "]-(exprModStat)<-[" + getAnyRel(statToOuterBlock) - + "*]-(outerBlock), (modif)-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE exprModStat.position < exprUseStat.position AND ( NOT exprModStat IS NULL OR exprUse IS NULL) " - + " WITH attrModifRel,attrUseRel,typeDec.fullyQualifiedName as className, attr,outerBlock, exprUseStat, exprUse ,method, exprModStat, modif, lhs_expr " - + " MATCH q=(method)-[" + cfgSuccesor - + "*]->(exprUseStat) WITH attrModifRel,attrUseRel,exprModStat IN NODES(q) as modInPath,className, attr,outerBlock, exprUseStat, exprUse ,method, exprModStat, modif, lhs_expr " - - + " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" - + " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - - + " WITH attrModifRel,attrUseRel,ALL( modInPath IN COLLECT(modInPath) WHERE modInPath) as unconditionalAssign, method,p,className, attr.lineNumber as line, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat, exprModStat " - + " WITH attrModifRel,attrUseRel,className, attr,line, exprUse,unconditionalAssign, " - + " attrUseRel.isOwnAccess " + " AND attrModifRel.isOwnAccess " + " OR " - + " (NOT p IS NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER)" - + " as isTheSameVar " - - + " WITH line,className, attr ,exprUse, ANY( x IN COLLECT(unconditionalAssign AND isTheSameVar) WHERE x) as prevAssign " - + " WITH line,className, attr , ALL( x IN COLLECT(prevAssign) WHERE x) OR exprUse IS NULL as isSillyAttr" - // - + " WHERE isSillyAttr" + " RETURN " - // + "isSillyAttr, attr, className ORDER BY attr" - + "'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+'(declared in line '+line+') in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).' "// Movida - // de - ; - private static final String DCL53_MINIMIZE_SCOPE_OF_VARIABLES_V3 = "MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEF) " - + " WHERE NOT ((attr.accessLevel='public' OR attr.accessLevel='protected' AND NOT typeDec.isFinal) " - + " AND typeDec.accessLevel='public') AND NOT( attr.isStatic AND attr.actualType='long' AND attr.isFinal" - + " AND attr.name='serialVersionUID')\r\n" + "WITH DISTINCT typeDec, attr \r\n" - + "MATCH (attr)-[:USED_BY | :STATE_MODIFIED_BY]->(exprUse)\r\n" - + "WITH DISTINCT attr,COUNT(exprUse) as allUsesCount\r\n" - + "MATCH (lhs_expr) <-[:ASSIGNMENT_LHS]-(modif)<-[attrModifRel:MODIFIED_BY]-(attr)" - + "-[attrUseRel:USED_BY | :STATE_MODIFIED_BY]->(exprUse)\r\n" - + "WHERE modif.position(memberSelectExprUse)<-[:USED_BY]-(varDec)-[:STATE_MODIFIED_BY]->(modif)," - + " (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif)\r\n" - + "WITH DISTINCT attr, exprUse, modif, attrModifRel, memberSelectExprModif, memberSelectExprUse, allUsesCount\r\n" - + "WHERE\r\n" + " attrModifRel.isOwnAccess OR (NOT memberSelectExprUse\r\n" - + "IS NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL " - + "AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER)\r\n" - + "WITH DISTINCT attr, COLLECT(exprUse) as uses, modif, allUsesCount\r\n" - + "WHERE allUsesCount=SIZE(uses)\r\n" + "\r\n" - + "MATCH (modif)<-[:ARRAYACCESS_EXPR | :ARRAYACCESS_INDEX | :ASSIGNMENT_LHS | :ASSIGNMENT_RHS | :BINOP_LHS | :BINOP_RHS | :BINOP_COND_RHS | :CAST_ENCLOSES | :COMPOUND_ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_RHS | :CONDITIONAL_EXPR_CONDITION | :CONDITIONAL_EXPR_THEN | :CONDITIONAL_EXPR_ELSE | :INITIALIZATION_EXPR | :INSTANCE_OF_EXPR | :MEMBER_REFERENCE_EXPRESSION | :MEMBER_SELECT_EXPR | :METHODINVOCATION_ARGUMENTS | :METHODINVOCATION_METHOD_SELECT | :NEW_CLASS_ARGUMENTS | :NEW_ARRAY_INIT | :NEW_ARRAY_DIMENSION | :UNARY_ENCLOSES *0..]-()<-[:ASSERT_CONDITION | :DO_WHILE_CONDITION | :ENCLOSES_EXPR | :FOREACH_EXPR | :FORLOOP_CONDITION | :HAS_VARIABLEDECL_INIT | :IF_CONDITION | :SWITCH_EXPR | :SYNCHRONIZED_EXPR | :THROW_EXPR | :WHILE_CONDITION | :RETURN_EXPR ]-(modifStat), p1=(modifStat)<-[:DO_WHILE_STATEMENT| :WHILE_STATEMENT | :CASE_STATEMENTS | :CATCH_ENCLOSES_BLOCK | :CATCH_PARAM | :ENCLOSES | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :IF_THEN | :IF_ELSE | :LABELED_STMT_ENCLOSES | :SWITCH_ENCLOSES_CASES | :SYNCHRONIZED_ENCLOSES_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES *]-(outerBlock)<-[:CALLABLE_HAS_BODY]-()\r\n" - + "\r\n" + "\r\n" + "WITH DISTINCT attr, modif,outerBlock, modifStat, uses,p1, allUsesCount\r\n" - + "UNWIND uses as exprUse\r\n" - + "MATCH (exprUse)<-[:ARRAYACCESS_EXPR | :ARRAYACCESS_INDEX | :ASSIGNMENT_LHS | :ASSIGNMENT_RHS | :BINOP_LHS | :BINOP_RHS | :BINOP_COND_RHS | :CAST_ENCLOSES | :COMPOUND_ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_RHS | :CONDITIONAL_EXPR_CONDITION | :CONDITIONAL_EXPR_THEN | :CONDITIONAL_EXPR_ELSE | :INITIALIZATION_EXPR | :INSTANCE_OF_EXPR | :MEMBER_REFERENCE_EXPRESSION | :MEMBER_SELECT_EXPR | :METHODINVOCATION_ARGUMENTS | :METHODINVOCATION_METHOD_SELECT | :NEW_CLASS_ARGUMENTS | :NEW_ARRAY_INIT | :NEW_ARRAY_DIMENSION | :UNARY_ENCLOSES *0..]-()<-[:ASSERT_CONDITION | :DO_WHILE_CONDITION | :ENCLOSES_EXPR | :FOREACH_EXPR | :FORLOOP_CONDITION | :HAS_VARIABLEDECL_INIT | :IF_CONDITION | :SWITCH_EXPR | :SYNCHRONIZED_EXPR | :THROW_EXPR | :WHILE_CONDITION | :RETURN_EXPR ]-(exprUseStat), p2=(exprUseStat)<-[:DO_WHILE_STATEMENT | :WHILE_STATEMENT | :CASE_STATEMENTS | :CATCH_ENCLOSES_BLOCK | :CATCH_PARAM | :ENCLOSES | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :IF_THEN | :IF_ELSE | :LABELED_STMT_ENCLOSES | :SWITCH_ENCLOSES_CASES | :SYNCHRONIZED_ENCLOSES_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES *]-(outerBlock)\r\n" - + "\r\n" + "WITH DISTINCT attr,exprUseStat, p1,RELATIONSHIPS(p2) as exprUseBlockRels, allUsesCount\r\n" - + "WHERE ALL(r IN RELATIONSHIPS(p1) WHERE NOT TYPE(r) IN ['SWITCH_ENCLOSES_CASES','IF_ELSE','IF_THEN', 'FORLOOP_STATEMENT', 'FORLOOP_UPDATE', 'FOREACH_STATEMENT', 'TRY_CATCH', 'WHILE_STATEMENT' ] OR r IN exprUseBlockRels)\r\n" - + "WITH DISTINCT attr, COUNT(exprUseStat) as usesWithPrevModif, allUsesCount\r\n" - + "WHERE usesWithPrevModif=allUsesCount\r\n" + "MATCH (attr)<-[:DECLARES_FIELD]-(enclClass)\r\n" - + "RETURN DISTINCT 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr.name+'(declared in line '+attr.lineNumber+') in class '+enclClass.fullyQualifiedName + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).'"; - private static final String DCL53_MINIMIZE_SCOPE_OF_VARIABLES_V3_SA = - "MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEF) " - + " WHERE NOT ((attr.accessLevel='public' OR attr.accessLevel='protected' AND NOT typeDec.isFinal) " - + " AND typeDec.accessLevel='public') AND NOT( attr.isStatic AND attr.actualType='long' AND attr.isFinal" - + " AND attr.name='serialVersionUID')\r\n" + "WITH DISTINCT typeDec, attr \r\n" - + "MATCH (attr)-[:USED_BY | :STATE_MODIFIED_BY]->(exprUse)\r\n" - + "WITH DISTINCT typeDec,attr,COUNT(exprUse) as allUsesCount\r\n" - + "MATCH (lhs_expr) <-[:ASSIGNMENT_LHS]-(modif)<-[attrModifRel:MODIFIED_BY]-(attr)" - + "-[attrUseRel:USED_BY | :STATE_MODIFIED_BY]->(exprUse)\r\n" - + "WHERE modif.position(memberSelectExprUse)<-[:USED_BY]-(varDec)-[:STATE_MODIFIED_BY]->(modif)," - + " (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif)\r\n" - + "WITH DISTINCT typeDec,attr, exprUse, modif, attrModifRel, memberSelectExprModif, memberSelectExprUse, allUsesCount\r\n" - + "WHERE\r\n" + " attrModifRel.isOwnAccess OR (NOT memberSelectExprUse\r\n" - + "IS NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL " - + "AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER)\r\n" - + "WITH DISTINCT typeDec,attr, COLLECT(exprUse) as uses, modif, allUsesCount\r\n" - + "WHERE allUsesCount=SIZE(uses)\r\n" + "\r\n" - + "MATCH (modif)<-[:ARRAYACCESS_EXPR | :ARRAYACCESS_INDEX | :ASSIGNMENT_LHS | :ASSIGNMENT_RHS | :BINOP_LHS | :BINOP_RHS | :BINOP_COND_RHS | :CAST_ENCLOSES | :COMPOUND_ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_RHS | :CONDITIONAL_EXPR_CONDITION | :CONDITIONAL_EXPR_THEN | :CONDITIONAL_EXPR_ELSE | :INITIALIZATION_EXPR | :INSTANCE_OF_EXPR | :MEMBER_REFERENCE_EXPRESSION | :MEMBER_SELECT_EXPR | :METHODINVOCATION_ARGUMENTS | :METHODINVOCATION_METHOD_SELECT | :NEW_CLASS_ARGUMENTS | :NEW_ARRAY_INIT | :NEW_ARRAY_DIMENSION | :UNARY_ENCLOSES *0..]-()<-[:ASSERT_CONDITION | :DO_WHILE_CONDITION | :ENCLOSES_EXPR | :FOREACH_EXPR | :FORLOOP_CONDITION | :HAS_VARIABLEDECL_INIT | :IF_CONDITION | :SWITCH_EXPR | :SYNCHRONIZED_EXPR | :THROW_EXPR | :WHILE_CONDITION | :RETURN_EXPR ]-(modifStat), p1=(modifStat)<-[:DO_WHILE_STATEMENT| :WHILE_STATEMENT | :CASE_STATEMENTS | :CATCH_ENCLOSES_BLOCK | :CATCH_PARAM | :ENCLOSES | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :IF_THEN | :IF_ELSE | :LABELED_STMT_ENCLOSES | :SWITCH_ENCLOSES_CASES | :SYNCHRONIZED_ENCLOSES_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES *]-(outerBlock)<-[:CALLABLE_HAS_BODY]-()\r\n" - + "\r\n" + "\r\n" + "WITH DISTINCT typeDec, attr, modif,outerBlock, modifStat, uses,p1, allUsesCount\r\n" - + "UNWIND uses as exprUse\r\n" - + "MATCH (exprUse)<-[:ARRAYACCESS_EXPR | :ARRAYACCESS_INDEX | :ASSIGNMENT_LHS | :ASSIGNMENT_RHS | :BINOP_LHS | :BINOP_RHS | :BINOP_COND_RHS | :CAST_ENCLOSES | :COMPOUND_ASSIGNMENT_LHS | :COMPOUND_ASSIGNMENT_RHS | :CONDITIONAL_EXPR_CONDITION | :CONDITIONAL_EXPR_THEN | :CONDITIONAL_EXPR_ELSE | :INITIALIZATION_EXPR | :INSTANCE_OF_EXPR | :MEMBER_REFERENCE_EXPRESSION | :MEMBER_SELECT_EXPR | :METHODINVOCATION_ARGUMENTS | :METHODINVOCATION_METHOD_SELECT | :NEW_CLASS_ARGUMENTS | :NEW_ARRAY_INIT | :NEW_ARRAY_DIMENSION | :UNARY_ENCLOSES *0..]-()<-[:ASSERT_CONDITION | :DO_WHILE_CONDITION | :ENCLOSES_EXPR | :FOREACH_EXPR | :FORLOOP_CONDITION | :HAS_VARIABLEDECL_INIT | :IF_CONDITION | :SWITCH_EXPR | :SYNCHRONIZED_EXPR | :THROW_EXPR | :WHILE_CONDITION | :RETURN_EXPR ]-(exprUseStat), p2=(exprUseStat)<-[:DO_WHILE_STATEMENT | :WHILE_STATEMENT | :CASE_STATEMENTS | :CATCH_ENCLOSES_BLOCK | :CATCH_PARAM | :ENCLOSES | :FOREACH_STATEMENT | :FOREACH_VAR | :FORLOOP_INIT | :FORLOOP_STATEMENT | :FORLOOP_UPDATE | :IF_THEN | :IF_ELSE | :LABELED_STMT_ENCLOSES | :SWITCH_ENCLOSES_CASES | :SYNCHRONIZED_ENCLOSES_BLOCK | :TRY_BLOCK | :TRY_CATCH | :TRY_FINALLY | :TRY_RESOURCES *]-(outerBlock)\r\n" - + "\r\n" + "WITH DISTINCT typeDec,attr,exprUseStat, p1,RELATIONSHIPS(p2) as exprUseBlockRels, allUsesCount\r\n" - + "WHERE ALL(r IN RELATIONSHIPS(p1) WHERE NOT TYPE(r) IN ['SWITCH_ENCLOSES_CASES','IF_ELSE','IF_THEN', 'FORLOOP_STATEMENT', 'FORLOOP_UPDATE', 'FOREACH_STATEMENT', 'TRY_CATCH', 'WHILE_STATEMENT' ] OR r IN exprUseBlockRels)\r\n" - + "WITH DISTINCT typeDec,attr, COUNT(exprUseStat) as usesWithPrevModif, allUsesCount\r\n" - + "WHERE usesWithPrevModif=allUsesCount\r\n MATCH (cu)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->(typeDec) " - + "RETURN DISTINCT '[CMU-DCL53-II;'+cu.fileName+';field_definition;'+attr.actualType+'-'+attr.name+';'+attr.lineNumber+'; You must minimize the scope of the variables. You can minimize the scope of attribute '+attr.name+'(declared in line '+attr.lineNumber+') in class '+typeDec.fullyQualifiedName + ' by transforming it into a local variable (as every time its value is used in a method, there is a previous unconditional assignment).]'"; - - ; - //[BLOCH-6.36;C:\Users\admp1\Escritorio\StaticCodeAnalysis\Programs\ExampleClasses\src\main\java\examples\test\rule_3_10\B1.java; - //method_definition;examples.test.rule_3_10.B1:toString()java.lang.String;10;You must use the Override annotation in method toString (line 10) since it is actually overriding the method java.lang.Object:toString()java.lang.String] - -// bloques - /* - * private static final String DCL53_MINIMIZE_SCOPE_OF_VARIABLES = - * " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEC) " + - * "OPTIONAL MATCH (attr)-[:USED_BY]->(exprUse)<-[" + exprToOutExprQuery + - * "*0..]-(outUseExpr)<-[" + exprToStatQueryWithReturn + - * "]-(exprUseStat)<-[" + getAnyRel(statToOuterBlock) + - * "*]-(outerBlock)<-[:CALLABLE_HAS_BODY]-() WITH typeDec.fullyQualifiedName as className, attr,outerBlock, exprUseStat, exprUse" - * + " OPTIONAL MATCH (attr)-[:MODIFIED_BY]->(modif)<-[" + - * getAnyRel(assignToOutExprNoCond) + "*0..]-(outModExpr)<-[" + - * exprToStatQueryWithReturn + "]-(exprModStat)<-[" + - * getAnyRel(statToOuterBlock) + - * "*]-(outerBlock), (modif)-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE exprModStat.position < exprUseStat.position " - * + - * " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - * + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" + - * " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - * + - * " WITH p,className, attr.lineNumber as line, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat, exprModStat " - * + " OPTIONAL MATCH q=(exprModStat)<-[" + getAnyRel(statToOuterBlock) + - * "*0..]-(minimumCommonBlock), (minimumCommonBlock)-[" + - * getAnyRel(statToOuterBlock) + "*0..]->(exprUseStat) " + - * " WITH className, attr, exprUse,line, " + " ANY(x IN " + "COLLECT(" + - * " " + - * "( NOT ANY(rel IN RELS(q) WHERE type(rel)='IF_ELSE' OR type(rel)='FORLOOP_UPDATE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FORLOOP_INIT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - * + " AND (" + - * " (exprUse:IDENTIFIER OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse:IDENTIFIER AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - * + - * " AND (lhs_expr:IDENTIFIER OR (NOT memberSelectExprModif IS NULL AND memberSelectExprModif:IDENTIFIER AND (memberSelectExprModif.name='this' OR memberSelectExprModif.name='super')))" - * + " ) " + " OR " // + " (NOT memberSelectExprUse IS NULL AND NOT // - * memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER // AND - * memberSelectExprModif:IDENTIFIER)" // + " OR " + - * " (p IS NOT NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER)" - * + ")" + ") " + " WHERE x) as useWithModif " + - * " WITH line,className, attr , ALL( x IN COLLECT(useWithModif) WHERE x) OR exprUse IS NULL as isSillyAttr WHERE isSillyAttr" - * + - * " RETURN 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+'(declared in line '+line+') in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).'" - * - */ - private static final String DCL53_MINIMIZE_SCOPE_OF_VARIABLES_BEST = " MATCH (vardec:VAR_DEC)-[:USED_BY | :MODIFIED_BY]->(useOrModif)<-[" - + exprToOutExprQuery + "*0..]-(outExpr)<-[" + exprToStatQuery + "]-(exprStat), p=(vardec)-[" + cfgSuccesor - + "*]->(exprStat) WITH vardec, exprStat, p ORDER BY LENGTH(p) WITH vardec,COLLECT( DISTINCT exprStat) as stats WITH vardec, stats" - + " MATCH p=(block)-[" + getAnyRel(statToOuterBlock) + "*0..]->(stat) WHERE stat IN stats " - + " WITH vardec, block, COLLECT(DISTINCT stat) as statsInBlock, stats, MAX(LENGTH(p)) as size " - + " ORDER BY size WHERE SIZE(stats)=SIZE( statsInBlock) WITH vardec, HEAD(COLLECT( DISTINCT block)) as outerBlock, HEAD(stats) as headStat" - + " MATCH (vardec)-[" + cfgSuccesor + "*]->(middle)-[" + cfgSuccesor + "*]->(headStat)" - + " OPTIONAL MATCH p=(middle)-[" + getAnyRel(statToOuterBlock) + "*]->(outerBlock) " - + " OPTIONAL MATCH q=(middle)<-[" + getAnyRel(statToOuterBlock) + "]-(outerBlock) " - + " OPTIONAL MATCH r=(headStat)-[" + cfgSuccesor + "*]->(middle)" - + " WITH vardec, middle, headStat, outerBlock, p ,q, COUNT(r) as rCount WHERE rCount=0 AND NOT(p IS NULL AND q IS NULL) RETURN DISTINCT vardec, middle, LABELS(middle), headStat,LABELS(headStat), outerBlock,LABELS(outerBlock), p ,q ORDER BY vardec"; - private static final String DCL53_MINIMIZE_SCOPE_OF_VARIABLES_SAVE = " MATCH (vardec:VAR_DEC)-[:USED_BY | :MODIFIED_BY]->(useOrModif)<-[" - + exprToOutExprQuery + "*0..]-(outExpr)<-[" + exprToStatQuery + "]-(exprStat), p=(vardec)-[" + cfgSuccesor - + "*]->(exprStat) WITH vardec, exprStat, p ORDER BY LENGTH(p) WITH vardec,COLLECT( DISTINCT exprStat) as stats WITH vardec, stats" - + " MATCH p=(block)-[" + getAnyRel(statToOuterBlock) + "*0..]->(stat) WHERE stat IN stats " - + " WITH vardec, block, COLLECT(DISTINCT stat) as statsInBlock, stats, MAX(LENGTH(p)) as size " - + " ORDER BY size WHERE SIZE(stats)=SIZE( statsInBlock) RETURN vardec, HEAD(COLLECT( DISTINCT block)) as outerBlock,LABELS(HEAD(COLLECT( DISTINCT block))), HEAD(stats) as headStat, stats ORDER BY vardec"; - - private static final String NUM50CONVERT_INT_TO_FLOAT_FOR_FLOAT_OPERATIONS = "MATCH (varDec{actualType:'float'})-[:MODIFIED_BY | :HAS_VARIABLEDECL_INIT]->(mod)" - + "-[:ASSIGNMENT_RHS | :INITIALIZATION_EXPR]->(rightSide)" - + " OPTIONAL MATCH (binopR{actualType:'int'})<-[:BINOP_RHS]-(division)" - + "<-[:BINOP_LHS | :BINOP_RHS | :UNARY_ENCLOSES |:CONDITIONAL_EXPR_ELSE|:CONDITIONAL_EXPR_THEN |:PARENTHESIZED_ENCLOSES*0..]-(rightSide)" - + ",(division)-[:BINOP_LHS]->({actualType:'int'})" - + " WITH varDec, COLLECT(rightSide.actualType='float') as rightSidesAreFloat, " - + new Filter("COLLECT([rightSide,binopR])", "NOT x[1] IS NULL AND x[0].operator='DIVIDE'").expToString() - + " as lines" + " WHERE " + " NOT " + new Any("rightSidesAreFloat", "x").expToString() - + " AND SIZE(lines)>0 " - + " RETURN 'Warning [CMU-NUM50] A truncated integer division was detected in line(s) ' +" - + new Reduce("lines", - "CASE WHEN seed CONTAINS (x[0].lineNumber+'') THEN seed ELSE seed+x[0].lineNumber+',' END", - "seed=''").expToString() - + " +', assigned to variables of type float. If you want to make a float division and assign the result to the variable ' + varDec.name+', you must include a operand as a float. Otherwise you can change the type of '+ varDec.name+' from float to int, as it is never used to store an actual float value.' " - // + new Reduce("lines", "s+','+x", "''").expToString() - ; - - - private static final String NUM50CONVERT_INT_TO_FLOAT_FOR_FLOAT_OPERATIONS_SA = -"MATCH (varDec)-[:MODIFIED_BY | :HAS_VARIABLEDECL_INIT]->(mod)-[:ASSIGNMENT_RHS | :INITIALIZATION_EXPR]->(rightSide) WHERE varDec.actualType IN ['float', 'double'] OPTIONAL MATCH (binopR{actualType:'int'})<-[:BINOP_RHS]-(division)<-[:BINOP_LHS | :BINOP_RHS | :UNARY_ENCLOSES |:CONDITIONAL_EXPR_ELSE|:CONDITIONAL_EXPR_THEN *0..]-(rightSide),(division)-[:BINOP_LHS]->({actualType:'int'}) WITH varDec, COLLECT(rightSide.actualType IN ['float','double']) as rightSidesAreFloat, FILTER(x IN COLLECT([rightSide,binopR]) WHERE NOT x[1] IS NULL AND x[0].operator='DIVIDE' ) as lines WHERE NOT ANY( x IN rightSidesAreFloat WHERE x ) AND SIZE(lines)>0 WITH varDec, REDUCE(seed='',x IN lines | CASE WHEN seed CONTAINS (x[0].lineNumber+'') THEN seed ELSE seed+x[0].lineNumber+',' END ) as expLine\r\n" + -"\r\n" + -"MATCH (varDec)<-[:CASE_STATEMENTS|CATCH_ENCLOSES_BLOCK|CATCH_PARAM|ENCLOSES|DO_WHILE_STATEMENT|WHILE_STATEMENT|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|CALLABLE_HAS_PARAMETER|IF_THEN|IF_ELSE|LABELED_STMT_ENCLOSES|SWITCH_ENCLOSES_CASE|SYNCHRONIZED_ENCLOSES_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*0..]-()<-[:CALLABLE_HAS_BODY*0..1]-()<-[:DECLARES_METHOD| :DECLARES_CONSTUCTOR | :HAS_STATIC_INIT | :DECLARES_FIELD]-(typeDef)<-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]-(cu)\r\n" + -"\r\n" + -"RETURN '[CMU-NUM50;'+cu.fileName+';EXPRESSION/VAR_DEF;VARDEF '+varDec.actualType+' '+varDec.name+';'+varDec.lineNumber+'; A truncated integer division was detected in line(s) ' +expLine +', assigned to variables of type float or double. If you want to make a float/double division and assign the result to the variable ' + varDec.name+', you must include an operand as float/double. Otherwise you can change the type of '+ varDec.name+' from float/double to int, as it is never used to store an actual float/double value.]'" -; - private static final String OBJ51_MINIMIZE_ACCESSIBILITY_OF_CLASSES_AND_MEMBERS_PART_ONE = "MATCH (typeDec)-[:DECLARES_FIELD | :DECLARES_METHOD | :DECLARES_CONSTRUCTOR]->(member{accessLevel:'public'}) " - + " WHERE (typeDec:ENUM_DECLARATION OR typeDec:CLASS_DECLARATION) AND typeDec.accessLevel<>'public' " - + " OPTIONAL MATCH (member)-[ovRel:OVERRIDES]->({accessLevel:'public'}) " - + " WITH typeDec, member, COLLECT(ovRel) AS ovRels WHERE SIZE(ovRels)=0 " - + " RETURN 'Warning [CMU-OBJ54] You should minimize accessibility of members. You can reduce the access level of the attribute ' + member.name + ' declared in the class '+ typeDec.fullyQualifiedName + ', as this class is not public and the member does not override any public method.' AS warning"; - private static final String OBJ51_MINIMIZE_ACCESSIBILITY_OF_CLASSES_AND_MEMBERS_PART_TWO = "MATCH (typeDec{accessLevel:'package'}) WHERE typeDec:ENUM_DECLARATION OR typeDec:CLASS_DECLARATION OR typeDec:INTERFACE_DECLARATION " - + " OPTIONAL MATCH (typeDec)<-[:USES_TYPE_DEF]-(typeDecUser) WHERE typeDecUser<>typeDec" - + " WITH typeDec, COLLECT(DISTINCT typeDecUser) AS typeDecUsers" - + " OPTIONAL MATCH (typeDec)-[:DECLARES_FIELD | :DECLARES_METHOD ]->(member)-[:HAS_DEF | :MODIFIED_BY | :USED_BY]-(expr)" - + "<-[" + exprToOutExprQuery + "*0..]-(outExpr)<-[" + exprToStatQuery + "]-(exprStat)" - + " OPTIONAL MATCH (exprStat)<-[" + getAnyRel(statToEnclClass) + "*]-(classDec)" + " WHERE " - + " (classDec:ENUM_DECLARATION OR classDec:CLASS_DECLARATION OR classDec:INTERFACE_DECLARATION) AND classDec<>typeDec AND NOT classDec IN typeDecUsers " - + " WITH typeDec, COLLECT(DISTINCT classDec)+typeDecUsers AS classesUsingMembers " - + " WHERE SIZE(classesUsingMembers)=1 " - + " RETURN 'Warning [CMU-OBJ54] You should minimize accessibility of classes. The class ' + typeDec.fullyQualifiedName +' is marked as package-private but is only used by the class'+ HEAD(classesUsingMembers).fullyQualifiedName + ', you should reduce its accessibility level by making it a private static nested class.' AS warning"; - private static final String OBJ51_MINIMIZE_ACCESSIBILITY_OF_CLASSES_AND_MEMBERS = OBJ51_MINIMIZE_ACCESSIBILITY_OF_CLASSES_AND_MEMBERS_PART_ONE - + " UNION " + OBJ51_MINIMIZE_ACCESSIBILITY_OF_CLASSES_AND_MEMBERS_PART_TWO; - private static final String OBJ54_DONT_TRY_HELP_GC_SETTING_REFS_TO_NULL = "MATCH (:LITERAL{typeKind:'NULL'})<-[:ASSIGNMENT_RHS]-(ass:ASSIGNMENT)<-[:MODIFIED_BY | STATE_MODIFIED_BY]-(localVar:VAR_DEC{typeKind:'DECLARED'})-[:USED_BY]->(use)<-[" - + exprToOutExprQuery + "*]-(outExpr)<-[" + exprToStatQuery + "]-(useStat)," + " (ass)<-[" - + assignToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery + "]-(assignStat) " - + " WITH COLLECT(useStat) AS useStats, localVar, assignStat " + " OPTIONAL MATCH (assignStat)-[" - + cfgSuccesor + "*0..]->(useStat) " + " WHERE useStat IN useStats" - + " WITH localVar, COLLECT(DISTINCT useStat) AS reachableUseStats, assignStat " - + " WHERE SIZE(reachableUseStats)=0" - + " RETURN 'Warning [CMU-OBJ54] You must not try to help garbage collector setting references to null when they are no longer used. To make your code clearer, just delete the assignment in line ' + assignStat.lineNumber + ' of the varaible ' +localVar.name+ ' declared in line ' +localVar.lineNumber+'.'"; - - private static final String DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_END = " MATCH (package1)-[:DEPENDS_ON_PACKAGE]->(package2)," - + "p=shortestPath((package2)-[:DEPENDS_ON_PACKAGE*]->(package1))" - - + " WITH REDUCE(warning='',package IN package1+NODES(p)| warning + '->' +package.name) as packageDepList" - // + " ,RANGE(0,SIZE(NODES(p))-2) as firstIndexes" - // + " WHERE ALL(i1 IN firstIndexes WHERE NOT ANY(i2 IN firstIndexes - // WHERE ID(packages[i1])=ID(packages[i2]) AND i1<>i2))" - // + " WITH DISTINCT " - + " RETURN " - + " 'Warning [CMU-DCL60] There is a cycle between packages caused by the dependencies between ' +" - + " SUBSTRING(packageDepList,2,LENGTH(packageDepList))+ '. You should undo them.'" - // + " REDUCE(warning='Warning [CMU-DCL60] There is a cycle between packages - // caused by the dependencies between ',package IN packages | warning + - // (CASE WHEN SIZE(warning)>89 THEN '->' ELSE '' END) +package.name)+ '. You - // should undo them.'" - ; - private static final String DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_SA=" MATCH (package1)-[:DEPENDS_ON_PACKAGE]->(package2)," - + "p=shortestPath((package2)-[:DEPENDS_ON_PACKAGE*]->(package1))" - - + " WITH HEAD(COLLECT(package1)) as package1,REDUCE(warning='',package IN package1+NODES(p)| warning + '->' +package.name) as packageDepList, SIZE(NODES(p)) as total" - // + " ,RANGE(0,SIZE(NODES(p))-2) as firstIndexes" - // + " WHERE ALL(i1 IN firstIndexes WHERE NOT ANY(i2 IN firstIndexes - // WHERE ID(packages[i1])=ID(packages[i2]) AND i1<>i2))" - // + " WITH DISTINCT " - + " MATCH (package1)-[:PACKAGE_HAS_COMPILATION_UNIT]->(cu) WITH DISTINCT HEAD(COLLECT(cu.fileName)) as fName,total, package1, packageDepList" - + " RETURN " - + -" '[CMU-DCL60;'+fName + ' and '+total+' packages more ...;PACKAGE;'+package1.name+' and '+total+' packages more ...;0;There is a cycle between packages caused by the dependencies between '+ SUBSTRING(packageDepList,2,LENGTH(packageDepList))+ '. You should undo them.'"; - - private static final String DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_END_HARD = " MATCH p=(package1)-[:DEPENDS_ON_PACKAGE*]->(package2) WHERE package1<>package2" - + " MATCH (package2)-[:DEPENDS_ON_PACKAGE]->(package1)" - - // + " WITH REDUCE(warning='',package IN package1+NODES(p)| warning - // + '->' +package.name) as packageDepList" - // + " ,RANGE(0,SIZE(NODES(p))-2) as firstIndexes" - // + " WHERE ALL(i1 IN firstIndexes WHERE NOT ANY(i2 IN firstIndexes - // WHERE ID(packages[i1])=ID(packages[i2]) AND i1<>i2))" - // + " WITH DISTINCT " - + " RETURN p, package1"; - // + " 'Warning [CMU-DCL60] There is a cycle between packages caused by the - // dependencies between ' +" - // + " SUBSTRING(packageDepList,2,LENGTH(packageDepList))+ '. You should - // undo them.'"; - - private static final String DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES = "MATCH p=(typeDec1)-[:USES_TYPE_DEF]->(typeDec2)-[:USES_TYPE_DEF]->(typeDec3)," - + "(cu1:COMPILATION_UNIT)-[:HAS_INNER_TYPE_DEF | :HAS_TYPE_DEF]->(typeDec1)," - + "(cu2:COMPILATION_UNIT)-[:HAS_INNER_TYPE_DEF | :HAS_TYPE_DEF]->(typeDec2)," - + "(cu3:COMPILATION_UNIT)-[:HAS_INNER_TYPE_DEF | :HAS_TYPE_DEF]->(typeDec3)" - + " WHERE cu1.packageName<>cu2.packageName AND cu3.packageName=cu1.packageName " - + " RETURN DISTINCT cu1,cu2"; - // + " RETURN 'Warning [CMU-DCL60] There is a cycle between packages caused - // by the dependencies between ' +EXTRACT(x IN nodes(p) | - // x.fullyQualifiedName)+'.'"; - private static final String DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_REFINED_PART1_B = "MATCH (cu:COMPILATION_UNIT) WITH DISTINCT cu.packageName as package CREATE (p:PACKAGE{name:package})" - // + " WITH p as package1, p as package2 " - ; - private static final String DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_REFINED_PART2_B = "MATCH (typeDec1)-[:USES_TYPE_DEF]->(typeDec2)," - + "(cu1:COMPILATION_UNIT)-[:HAS_INNER_TYPE_DEF | :HAS_TYPE_DEF]->(typeDec1)," - + "(cu2:COMPILATION_UNIT)-[:HAS_INNER_TYPE_DEF | :HAS_TYPE_DEF]->(typeDec2) WHERE cu1.packageName <>cu2.packageName WITH DISTINCT cu1.packageName as c1,cu2.packageName as c2 MATCH (package1:PACKAGE{name:c1}),(package2:PACKAGE{name:c2}) CREATE (package1)-[r:DEPENDS_ON_PACKAGE]->(package2) "; - - private static final String DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_REFINED_PART3_B = "WITH package1 MATCH p=(package1)-[:DEPENDS_ON_PACKAGE*]->(package1) WITH " - + " REDUCE(warning='Warning [CMU-DCL60] There is a cycle between packages caused by the dependencies between ',package IN nodes(p) | warning + (CASE WHEN SIZE(warning)>89 THEN '->' ELSE '' END) +package.name)+ '. You should undo them.'" - + "as warning WITH COLLECT(warning) as wList MATCH (p:PACKAGE) DETACH DELETE p WITH DISTINCT wList RETURN wList"; - private static final String ERR54_USE_TRY_RESOURCES_TO_SAFELY_CLOSE = " MATCH (closeableSubtype)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->" - + "(closeableInt:INTERFACE_DEF{fullyQualifiedName:'java.lang.AutoCloseable'})" - + " WHERE closeableSubtype:CLASS_DEF OR closeableSubtype:INTERFACE_DEF " - + " WITH DISTINCT closeableSubtype.fullyQualifiedName as className " - - + " MATCH (closeableDec:LOCAL_VAR_DEF{actualType:className})-[:MODIFIED_BY | HAS_VARIABLEDECL_INIT]->(assignOrInit)" - + "MATCH (assignOrInit)<-[" + assignToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery - + "]-(assignStat) " - + " OPTIONAL MATCH (closeableDec)<-[r:TRY_RESOURCES]-() WITH assignStat,r, closeableDec WHERE r IS NULL" - // + " RETURN assignStat,r, closeableDec" - - + " OPTIONAL MATCH (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'close'})-[:MEMBER_SELECT_EXPR]->(id)<-[:USED_BY]-(closeableDec)," - + " (mInv)<-[" + exprToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery + "]-(closeStat)" - + ",(assignStat)-[" + cfgSuccesor + "*]->(prev)" - + "-[exceptionRel:CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION | :CFG_MAY_THROW | :CFG_THROWS]->(afterEx)" - + " WITH COLLECT(DISTINCT closeStat) AS closes, prev,closeableDec, afterEx,exceptionRel " - + "WHERE NOT prev IN closes " + " MATCH (prev)-[" + cfgSuccesor - + "*]->(closeStat) WHERE closeStat IN closes" - - + " OPTIONAL MATCH p=(afterEx)-[" + getAnyRel(toCFGSuccesor) // ESTE - // DEBERíA - // SER - // COND - // O - // NO - // COND - + "*0..]->(reachableAfterEx) WHERE reachableAfterEx IN closes " - + " WITH prev as prevs, closeableDec,p,exceptionRel, " + " CASE WHEN p IS NULL THEN NULL ELSE " - + " EXTRACT (index IN RANGE(0,SIZE(NODES(p))) | index=0 OR TYPE(RELATIONSHIPS(p)[index-1]) IN ['CFG_THROWS' ,'CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION' ,'CFG_MAY_THROW' ])" - + " END as previousThrow" + " WITH prevs, closeableDec,p,exceptionRel, " - + "CASE WHEN p IS NULL THEN NULL ELSE EXTRACT (index IN RANGE(0,SIZE(NODES(p))) | CASE WHEN NODES(p)[index]:CATCH_BLOCK OR previousThrow[index] AND NODES(p)[index]:LOCAL_VAR_DEF" - + " THEN 'catch' ELSE CASE WHEN previousThrow[index] THEN CASE WHEN index=0 THEN exceptionRel.exceptionType " - + " ELSE RELATIONSHIPS(p)[index-1].exceptionType END ELSE CASE WHEN NODES(p)[index]:TRY_BLOCK THEN 'newtry' ELSE NULL END END END )END" - + " as exFlow" - + " WITH p,closeableDec,prevs,CASE WHEN p IS NULL THEN NULL ELSE EXTRACT( relIndex IN RANGE(0,SIZE(RELATIONSHIPS(p))) | exFlow[LAST(FILTER( exIndex IN RANGE(0,SIZE(exFlow)) WHERE exIndex<=relIndex AND NOT exFlow[exIndex] IS NULL))]) END as exFlow " - + " WITH closeableDec,prevs," - + " NOT ANY(x IN COLLECT(CASE WHEN p IS NULL THEN FALSE ELSE ALL(relIndex IN RANGE(0,SIZE(RELATIONSHIPS(p))) WHERE CASE WHEN TYPE(RELATIONSHIPS(p)[relIndex])='CFG_NO_EXCEPTION' THEN exFlow[relIndex] IN ['catch' , 'newtry'] ELSE CASE WHEN TYPE(RELATIONSHIPS(p)[relIndex])='CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION' THEN exFlow[relIndex]=RELATIONSHIPS(p)[relIndex].exceptionType ELSE TRUE END END )END)WHERE x) as truePathToClose" - + " WITH closeableDec,COLLECT(prevs) as prevs, COLLECT(truePathToClose) as truePathToClose" - + " WHERE ANY ( x IN truePathToClose WHERE x) " + " MATCH (closeableDec)<-[" + getAnyRel(statToEnclClass) - + "*]-(enclClass) WHERE enclClass:TYPE_DEFINITION " - + " RETURN DISTINCT 'Warning [CMU-ERR54] variable '+closeableDec.name+ '(defined in line'+closeableDec.lineNumber+', class '+enclClass.fullyQualifiedName+') might not be properly closed, as statement(s) (in lines '+ REDUCE(seed='',prev IN prevs | seed+prev.lineNumber+',')+') may throw an exception.'" - - ; - private static final String ERR54_USE_TRY_RESOURCES_TO_SAFELY_CLOSE_SA = " MATCH (closeableSubtype)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->" - + "(closeableInt:INTERFACE_DEF{fullyQualifiedName:'java.lang.AutoCloseable'})" - + " WHERE closeableSubtype:CLASS_DEF OR closeableSubtype:INTERFACE_DEF " - + " WITH DISTINCT closeableSubtype.fullyQualifiedName as className " - - + " MATCH (closeableDec:LOCAL_VAR_DEF{actualType:className})-[:MODIFIED_BY | HAS_VARIABLEDECL_INIT]->(assignOrInit)" - + "MATCH (assignOrInit)<-[" + assignToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery - + "]-(assignStat) " - + " OPTIONAL MATCH (closeableDec)<-[r:TRY_RESOURCES]-() WITH assignStat,r, closeableDec WHERE r IS NULL" - // + " RETURN assignStat,r, closeableDec" - - + " OPTIONAL MATCH (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'close'})-[:MEMBER_SELECT_EXPR]->(id)<-[:USED_BY]-(closeableDec)," - + " (mInv)<-[" + exprToOutExprQuery + "*0..]-(expr)<-[" + exprToStatQuery + "]-(closeStat)" - + ",(assignStat)-[" + cfgSuccesor + "*]->(prev)" - + "-[exceptionRel:CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION | :CFG_MAY_THROW | :CFG_THROWS]->(afterEx)" - + " WITH COLLECT(DISTINCT closeStat) AS closes, prev,closeableDec, afterEx,exceptionRel " - + "WHERE NOT prev IN closes " + " MATCH (prev)-[" + cfgSuccesor - + "*]->(closeStat) WHERE closeStat IN closes" - - + " OPTIONAL MATCH p=(afterEx)-[" + getAnyRel(toCFGSuccesor) // ESTE - // DEBERíA - // SER - // COND - // O - // NO - // COND - + "*0..]->(reachableAfterEx) WHERE reachableAfterEx IN closes " - + " WITH prev as prevs, closeableDec,p,exceptionRel, " + " CASE WHEN p IS NULL THEN NULL ELSE " - + " EXTRACT (index IN RANGE(0,SIZE(NODES(p))) | index=0 OR TYPE(RELATIONSHIPS(p)[index-1]) IN ['CFG_THROWS' ,'CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION' ,'CFG_MAY_THROW' ])" - + " END as previousThrow" + " WITH prevs, closeableDec,p,exceptionRel, " - + "CASE WHEN p IS NULL THEN NULL ELSE EXTRACT (index IN RANGE(0,SIZE(NODES(p))) | CASE WHEN NODES(p)[index]:CATCH_BLOCK OR previousThrow[index] AND NODES(p)[index]:LOCAL_VAR_DEF" - + " THEN 'catch' ELSE CASE WHEN previousThrow[index] THEN CASE WHEN index=0 THEN exceptionRel.exceptionType " - + " ELSE RELATIONSHIPS(p)[index-1].exceptionType END ELSE CASE WHEN NODES(p)[index]:TRY_BLOCK THEN 'newtry' ELSE NULL END END END )END" - + " as exFlow" - + " WITH p,closeableDec,prevs,CASE WHEN p IS NULL THEN NULL ELSE EXTRACT( relIndex IN RANGE(0,SIZE(RELATIONSHIPS(p))) | exFlow[LAST(FILTER( exIndex IN RANGE(0,SIZE(exFlow)) WHERE exIndex<=relIndex AND NOT exFlow[exIndex] IS NULL))]) END as exFlow " - + " WITH closeableDec,prevs," - + " NOT ANY(x IN COLLECT(CASE WHEN p IS NULL THEN FALSE ELSE ALL(relIndex IN RANGE(0,SIZE(RELATIONSHIPS(p))) WHERE CASE WHEN TYPE(RELATIONSHIPS(p)[relIndex])='CFG_NO_EXCEPTION' THEN exFlow[relIndex] IN ['catch' , 'newtry'] ELSE CASE WHEN TYPE(RELATIONSHIPS(p)[relIndex])='CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION' THEN exFlow[relIndex]=RELATIONSHIPS(p)[relIndex].exceptionType ELSE TRUE END END )END)WHERE x) as truePathToClose" - + " WITH closeableDec,COLLECT(prevs) as prevs, COLLECT(truePathToClose) as truePathToClose" - + " WHERE ANY ( x IN truePathToClose WHERE x) " + " MATCH (closeableDec)<-[" + getAnyRel(statToEnclClass) - + "*]-(enclClass)<-[:HAS_TYPE_DEF|:HAS_INNER_DEF]-(cu) WHERE enclClass:TYPE_DEFINITION " - + " RETURN DISTINCT '[CMU-ERR54;'+cu.fileName+';local_var_def;LOCAL VAR '+closeableDec.actualType+' '+closeableDec.name+';'+closeableDec.lineNumber+';Variable '+closeableDec.name+ '(defined in line'+closeableDec.lineNumber+', class '+enclClass.fullyQualifiedName+') might not be properly closed, as statement(s) (in lines '+ REDUCE(seed='',prev IN prevs | seed+prev.lineNumber+',')+') may throw an exception.'" - - ; - private static final String ALT2_MET55_RETURN_EMPTY_COLLECTIONS_INSTEAD_NULL = " MATCH (returnClass)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]->(collection{fullyQualifiedName:'java.util.Collection'})" - + " WITH DISTINCT returnClass.fullyQualifiedName as className " - + " MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->()-[:DECLARES_METHOD]->(md)-[:CALLABLE_RETURN_TYPE]->(rt) " - + ", (md)<-[*]-(ret:RETURN_STATEMENT)" + "" + " RETURN md, rt, labels(rt)"; - private static final String MET55_RETURN_EMPTY_COLLECTIONS_INSTEAD_NULL = - - " MATCH (md)-[:CALLABLE_RETURN_TYPE]->(rt)-[:ITS_TYPE_IS |:PARAMETERIZED_TYPE*0..]->()-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(collection)\r\n" - + "WHERE collection.fullyQualifiedName='java.util.Collection' OR collection:ARRAY_TYPE WITH DISTINCT md \r\n" - + "MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->()-[:DECLARES_METHOD]->(md)<-[:CFG_END_OF]-(normalEnd)\r\n" - + " <-[:CFG_NEXT_STATEMENT]-(:RETURN_STATEMENT)-[:RETURN_EXPR]->()\r\n" - + " -[:CONDITIONAL_EXPR_THEN |:CONDITIONAL_EXPR_ELSE*0..]->(nullRet{typetag:'NULL_LITERAL'})\r\n" - + "WITH enclosingCU, nullRet WHERE nullRet IS NOT NULL\r\n" - + "RETURN 'Warning [CMU-MET55], you must not return null when you can return an empty collection or array.Line' +nullRet.lineNumber+' in '+enclosingCU.fileName+'.'"; - - private static final String MET55_RETURN_EMPTY_COLLECTIONS_INSTEAD_NULL_SA = - "MATCH (md)-[:CALLABLE_RETURN_TYPE]->(rt)-[:ITS_TYPE_IS |:PARAMETERIZEDTYPE_TYPE*0..]->()-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(collection)\r\n" + - "WHERE collection.fullyQualifiedName='java.util.Collection' OR collection:ARRAY_TYPE WITH DISTINCT md \r\n" + - "MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->()-[:DECLARES_METHOD]->(md)<-[:CFG_END_OF]-(normalEnd)\r\n" + - " <-[:CFG_NEXT_STATEMENT]-(:RETURN_STATEMENT)-[:RETURN_EXPR]->()\r\n" + - " -[:CONDITIONAL_EXPR_THEN |:CONDITIONAL_EXPR_ELSE*0..]->(nullRet{typetag:'NULL_LITERAL'})\r\n" + - "WITH DISTINCT enclosingCU, nullRet, md WHERE nullRet IS NOT NULL\r\n" + - "RETURN '[CMU-MET55;'+enclosingCU.fileName+';return_statement;RETURN OF '+md.fullyQualifiedName+';'+nullRet.lineNumber+'; You must not return null when you can return an empty collection or array.Line' +nullRet.lineNumber+' in '+enclosingCU.fileName+'.]'" -; // Dos formas -[*]-> RETURN o CFG_END<-[]- RETURNlllu - private static final String ALT_MET55_RETURN_EMPTY_COLLECTIONS_INSTEAD_NULL = " MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->()-[:DECLARES_METHOD]->(md)-[:CALLABLE_RETURN_TYPE]->(rt) " - + " WITH md, rt " - + " MATCH (returnClass{fullyQualifiedName:rt.actualType})-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]->(collection{fullyQualifiedName:'java.util.Collection'})" - - + " RETURN DISTINCT md"; - // ,actualType:'java.io.File' - private static final String SEC56_DONT_SERIALIZE_SYSTEM_RESOURCES = "MATCH (class)-[:DECLARES_FIELD]->(f{isTransient:false})-[:ITS_TYPE_IS]->(aux)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(fTypeOrSupertype) " - + ", (class)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]-> (superInt:INTERFACE_DEF{fullyQualifiedName:'java.io.Serializable'}) " - + " WHERE fTypeOrSupertype.fullyQualifiedName IN ['java.io.File' ,'org.omg.CosNaming.NamingContext' ,'org.omg.CORBA.DomainManager' ,'org.omg.PortableInterceptor.ObjectReferenceFactory']" - + " RETURN DISTINCT " - // + " enclosingCU, class, f, fTypeOrSupertype, superInt,aux,p" - + "'Warning [CMU-SEC56], you must not serialize direct handles to system resources like field ' + f.name + '(an instance of '+fTypeOrSupertype.fullyQualifiedName+'). Line '+ f.lineNumber + ' in '+ class.fullyQualifiedName+'.'"; - - private static final String SEC56_DONT_SERIALIZE_SYSTEM_RESOURCES_SA = - "MATCH (cu)-[:HAS_TYPE_DEF |:HAS_INNER_TYPE_DEF]->(class)-[:DECLARES_FIELD]->(f{isTransient:false})-[:ITS_TYPE_IS]->(aux)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(fTypeOrSupertype) \r\n" + - ", (class)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*]-> (superInt:INTERFACE_DEF{fullyQualifiedName:'java.io.Serializable'}) \r\n" + - " WHERE fTypeOrSupertype.fullyQualifiedName IN ['java.io.File' ,'org.omg.CosNaming.NamingContext' ,'org.omg.CORBA.DomainManager' \r\n" + - " ,'org.omg.PortableInterceptor.ObjectReferenceFactory'] \r\n" + - "RETURN DISTINCT '[CMU-SEC56;'+cu.fileName+';attribute_declaration;FIELD '+f.actualType+' '+f.name+'\";'+ f.lineNumber+'; You must not serialize direct handles to system resources like field ' + f.name + '(an instance of '+fTypeOrSupertype.fullyQualifiedName+'). Line '+ f.lineNumber + ' in '+ class.fullyQualifiedName+'.]'"; - private static final String DECL56_ORDINAL_ENUM = "MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->()-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]->(enclosingM)-[:CALLS]->" - + "(inv)-[:HAS_DEF]->(md) " + " WHERE md.fullyQualifiedName ='java.lang.Enum:ordinal()int' " - + "RETURN 'Warning [CMU-DEC56], you should not attach significance to the ordinal of an enum. Line '+inv.lineNumber + ' in '+ enclosingCU.fileName +'.' "; - private static final String DECL56_ORDINAL_ENUM_SA = -" MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->()-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]->(enclosingM)-[:CALLS]->(inv)-[:HAS_DEF]->(md) WHERE md.fullyQualifiedName ='java.lang.Enum:ordinal()int' RETURN '[CMU-DEC56;'+enclosingCU.fileName +';method_invocation/EXPRESSION;java.lang.Enum:ordinal();'+inv.lineNumber+';You should not attach significance to the ordinal of an enum. Line '+inv.lineNumber + ' in '+ enclosingCU.fileName +'.'"; - private static final String MET50_AVOID_CONFUSING_OVERLOADING = "MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->(class)" - + "-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]->(md)-[:CALLABLE_HAS_PARAMETER]->(p:PARAMETER_DEF)" + " " - + "WITH enclosingCU, md, class, COLLECT(p.actualType) as params " - + " MATCH (class)-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]->(md2)-[:CALLABLE_HAS_PARAMETER]->(p2)" - + " WHERE md.name = md2.name AND md <> md2 " - + " WITH enclosingCU, md, md2, params, COLLECT(p2.actualType) as params2 " - + "WHERE ALL(p IN params WHERE p IN params2) AND all(p IN params2 WHERE " - + "p IN params) AND ((SIZE(params)>=4 AND SIZE(params2)>=4) OR " + " SIZE(params)=SIZE(params2)) " - + " RETURN 'Warning [CMU-MET50], you must avoid confusing overloadings like '+ md.fullyQualifiedName + ' in line ' + md.lineNumber + ' ( very similar to declaration in line ' + md2.lineNumber +') in '+ enclosingCU.fileName +'.' "; - - private static final String MET53_ENSURE_CALL_SUPER_IN_CLONE = "MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->(typeDec)-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]->(md) WHERE " - + " md.fullyQualifiedName CONTAINS ':clone()'" - - + " OPTIONAL MATCH (md)-[:CALLS | :HAS_DEF*]->(superDec)" + " WHERE " - + " superDec.fullyQualifiedName CONTAINS ':clone()' AND " - + " NOT superDec.fullyQualifiedName CONTAINS (typeDec.fullyQualifiedName+':')" - + " WITH enclosingCU, md, COUNT(superDec) as superCallsCount " + " WHERE superCallsCount=0 " - + " RETURN 'Warning [CMU-MET53], you must call super.clone in every overriden clone method. Line '+ md.lineNumber + ' in ' + enclosingCU.fileName + '.'"; - - private static final String MET53_ENSURE_CALL_SUPER_IN_CLONE_SA ="MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->(typeDec)-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]->(md)-[:CALLABLE_RETURN_TYPE]->(typeRet) \r\n" + - "WHERE NOT typeRet:PRIMITIVE_TYPE AND md.fullyQualifiedName CONTAINS ':clone()'\r\n" + - "OPTIONAL MATCH (md)-[:CALLS]->()-[:HAS_DEF]->(superDec)-[:CALLABLE_RETURN_TYPE]->(superRet)\r\n" + - "WHERE superDec.fullyQualifiedName CONTAINS ':clone()' AND NOT superDec.fullyQualifiedName CONTAINS (typeDec.fullyQualifiedName+':') AND NOT superRet:PRIMITIVE_TYPE\r\n" + - "WITH enclosingCU, md, COUNT(superDec) as superCallsCount WHERE superCallsCount=0\r\n" + - "RETURN '[CMU-MET53;'+enclosingCU.fileName+';method_definition;'+md.fullyQualifiedName+';'+md.lineNumber+'; You must call super.clone in every overriden clone method. ]'" -; - // OJO, AQUI COMO SABES QUE NO ES Object o; o.clone()... donde - // Object:clone<-ov-method_clone SE necesita comprobación super.clone - private static final String ALTERN_MET53_ENSURE_CALL_SUPER_IN_CLONE = "MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->()-[:DECLARES_METHOD | :DECLARES_CONSTRUCTOR]->(md) " - + " WHERE md.fullyQualifiedName CONTAINS ':clone()' AND NOT md.fullyQualifiedName ENDS WITH ')void' " - - + " OPTIONAL MATCH (md)-[:CALLS]->(inv)-[:HAS_DEF]->(superDec)<-[:OVERRIDES]-(md), (inv)-[:METHODINVOCATION_METHOD_SELECT]->()-[:MEMBER_SELECT_EXPR]->({name:'super'})" - - + " WITH enclosingCU, md, COUNT(superDec) as superCallsCount" + " WHERE superCallsCount=0 " - + " RETURN 'Warning [CMU-MET53], you must call super.clone in every overriden clone method. Line '+ md.lineNumber + ' in ' + enclosingCU.fileName + '.'"; - private static final String OBJ50_DONT_CONFUSE_INMUTABLE_REFS_WITH_OBJECTS = "MATCH (declaringType{accessLevel:'public'})-[:DECLARES_FIELD]->(attr:ATTR_DEC{typeKind:'DECLARED'}) WHERE attr.isFinal AND attr.accessLevel='public'" - // First we find all the declared public final attributes - + " WITH attr, declaringType" - + " MATCH (typeDec)-[:DECLARES_FIELD]->(field) WHERE (typeDec:CLASS_DECLARATION OR typeDec:ENUM_DECLARATION) AND typeDec.fullyQualifiedName=attr.actualType" - // Here, we find the type of each of these attributes, and for each - // type we get all the declared attributes - + " OPTIONAL MATCH (field)-[r:STATE_MODIFIED_BY | :STATE_MAY_BE_MODIFIED_BY | :MODIFIED_BY]->(ass)" - // Here we look for modifications or state changes in this collected - // attributes - + " WITH attr,declaringType,field, typeDec, COUNT(DISTINCT r) as relsC" - - + " WHERE (field.accessLevel='public' AND NOT field.isFinal) OR relsC>0 " - // Finally, if any of these attributes has a relationship that - // implies a modification or a state change, - // or, if any of these attributes is public and not final, we emit a - // warning to the programmer - + " RETURN 'Warning [CMU-OBJ50] Attribute '+ attr.name+' declared in '+declaringType.fullyQualifiedName+ ' is not actually final, only the reference. This is due to the type '+ typeDec.fullyQualifiedName+' is mutable ( the state of the attributes '+COLLECT(field.name)+' change in the program or may potentially be changed by a client).'"; - - // "MATCH p=(typeDec)-[:DECLARES_FIELD | :ITS_TYPE_IS*]->(fieldOrType) WHERE - // typeDec:CLASS_DECLARATION OR typeDec:ENUM_DECLARATION RETURN - // typeDec.fullyQualifiedName,COLLECT(EXTRACT(n IN NODES(p) | CASE WHEN - // n:ATTR_DEC THEN n.name+'('+n.actualType+')' ELSE n.fullyQualifiedName - // END))" - public static void Pmain(String[] args) throws IOException { - int queryIndex = args.length == 0 ? 10 : Integer.parseInt(args[0]); - // GraphDatabaseService gs = DatabaseFachade.getDB(); - // String query = QUERIES[queryIndex]; - String query = // "MATCH (n:METHOD_DEC)-[r]-(m) WHERE n.name='confusing' - // RETURN n, LABELS(n), m,r, LABELS(m)" - new OBJ50(true).queryToString(); - // System.out.println(query); - long ini = System.nanoTime(); - String[] queries = new String[] { "MATCH (n) RETURN DISTINCT n", "MATCH ()-[r]->() RETURN DISTINCT r", - "MATCH (n) WHERE n:CLASS_DECLARATION OR n:INTERFACE_DECLARATION OR n:ENUM_DECLARATION RETURN DISTINCT n", - "MATCH (n) WHERE (n:CLASS_DECLARATION OR n:INTERFACE_DECLARATION OR n:ENUM_DECLARATION) AND n.isDeclared RETURN DISTINCT n", - "MATCH (n) WHERE n:METHOD_DEC OR n:CONSTRUCTOR_DEC RETURN DISTINCT n", - "MATCH (n) WHERE (n:METHOD_DEC OR n:CONSTRUCTOR_DEC) AND n.isDeclared RETURN DISTINCT n", - "MATCH ()-[r:IS_SUBTYPE_EXTENDS | IS_SUBTYPE_IMPLEMENTS ]->() RETURN DISTINCT r", - "MATCH ()-[r:USES_TYPE_DEF]->() RETURN DISTINCT r", - "MATCH ()-[r:" + CFGRelationTypes.getCFGRelations() + "]->() RETURN DISTINCT r", - "MATCH ()-[r: MODIFIED_BY | STATE_MODIFIED_BY | USED_BY | STATE_MAY_BE_MODIFIED_BY ]->() RETURN DISTINCT r", - "MATCH ()-[r:CALLS | HAS_DEF | OVERRIDES | REFER_TO | MAY_REFER_TO]->() RETURN DISTINCT r", - "MATCH ()-[r:HAS_INNER_TYPE_DEF]->() RETURN DISTINCT r", - "MATCH ()-[r:ITS_TYPE_IS]->() RETURN DISTINCT r", - "MATCH (n) WHERE n:INITIALIZATION OR n:CFG_METHOD_END OR n:CFG_METHOD_ENTRY OR n:CFG_EXCEPTIONAL_END OR n:CFG_LAST_STATEMENT_IN_FINALLY RETURN DISTINCT n", - "MATCH (n:COMPILATION_UNIT) RETURN n", "MATCH (n) RETURN DISTINCT SUM(SIZE(keys(n))) as res", - "MATCH ()-[r]->() RETURN DISTINCT SUM(SIZE(keys(r))) as res" - - }; - // Result res = gs.execute(queries[queryIndex]); - // System.out.println("4444"); - long end = System.nanoTime(); - // BufferedWriter bw = new BufferedWriter(new FileWriter(new - // File("outputPlan.txt"))); - // bw.write(res.resultAsString()); - // bw.write(res.getExecutionPlanDescription().toString()); - // bw.close(); - // - // if (queryIndex < queries.length - 2) - // // System.out.print(res.resultAsString()); - // System.out.print(res.stream().count()); - // else - // System.out.println((Long) res.next().get("res")); - - // gs.execute(MainQuery.DELETE_ALL); - // gs.shutdown(); - - } - - private static final String OBJ50_Q7_PAPER_VERSION = "MATCH (declaration:VARIABLE_DEF{isFinal:true})-[r:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED_BY]->(mutatorExpr)\r\n" - + "\r\n" - + "MATCH (mutatorExpr)<-[:ARRAYACCESS_EXPR|ARRAYACCESS_INDEX|ASSIGNMENT_LHS|ASSIGNMENT_RHS|BINOP_LHS|BINOP_RHS|CAST_ENCLOSES|COMPOUND_ASSIGNMENT_LHS|COMPOUND_ASSIGNMENT_RHS|CONDITIONAL_EXPR_CONDITION|CONDITIONAL_EXPR_THEN|CONDITIONAL_EXPR_ELSE|INITIALIZATION_EXPR|INSTANCE_OF_EXPR|MEMBER_REFERENCE_EXPRESSION|MEMBER_SELECT_EXPR|METHODINVOCATION_ARGUMENTS|METHODINVOCATION_METHOD_SELECT|NEW_CLASS_ARGUMENTS|NEW_ARRAY_INIT|NEW_ARRAY_DIMENSION|UNARY_ENCLOSES*0..]-()<-[:ASSERT_CONDITION|DO_WHILE_CONDITION|ENCLOSES_EXPR|FOREACH_EXPR|FORLOOP_CONDITION|HAS_VARIABLEDECL_INIT|IF_CONDITION|RETURN_EXPR|SWITCH_EXPR|SYNCHRONIZED_EXPR|THROW_EXPR|WHILE_CONDITION]-(stat)<-[:CASE_STATEMENTS|CATCH_ENCLOSES_BLOCK|CATCH_PARAM|ENCLOSES|DO_WHILE_STATEMENT|WHILE_STATEMENT|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|CALLABLE_HAS_PARAMETER|IF_THEN|IF_ELSE|LABELED_STMT_ENCLOSES|SWITCH_ENCLOSES_CASE|SYNCHRONIZED_ENCLOSES_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*]-()<-[:CALLABLE_HAS_BODY]-(method)<-[:DECLARES_FIELD|DECLARES_METHOD|DECLARES_CONSTRUCTOR|HAS_STATIC_INIT]-(exprEnclClass)\r\n" - + " WHERE NOT declaration:ATTR_DEF OR r.isOwnAccess=FALSE OR NOT method.isInitializer \r\n" - + "WITH declaration, mutatorExpr,exprEnclClass \r\n" - + "MATCH (declaration)<-[:CALLABLE_HAS_BODY|CALLABLE_HAS_PARAMETER|CASE_STATEMENTS|CATCH_ENCLOSES_BLOCK|CATCH_PARAM|ENCLOSES|DO_WHILE_STATEMENT|WHILE_STATEMENT|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|HAS_VARIABLEDECL_INIT|IF_THEN|IF_ELSE|LABELED_STMT_ENCLOSES|SWITCH_ENCLOSES_CASE|SYNCHRONIZED_ENCLOSES_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*0..]-()<-[:DECLARES_FIELD|DECLARES_METHOD|DECLARES_CONSTRUCTOR|HAS_STATIC_INIT]-(enclClass)\r\n" - + "WITH declaration, enclClass,COLLECT(LAST(LABELS(mutatorExpr))+', line '+mutatorExpr.lineNumber+ ', column '+mutatorExpr.column+ ', class '+ exprEnclClass.fullyQualifiedName) as mutatorsMessage\r\n" - + "RETURN 'Warning [CMU-OBJ50] Declaration with name '+ declaration.name+ '( in line ' + declaration.lineNumber +', class ' +enclClass.fullyQualifiedName + ') is not actually final, only the reference. Concretely, '+ declaration.name +' may be mutated in '+ REDUCE(seed=mutatorsMessage[0], x IN mutatorsMessage[1..] | seed+','+x) \r\n" - - ; - - private static final String OBJ50_Q7ADRI_PAPER_VERSION = "MATCH (declaration:VARIABLE_DEF{isFinal:true})-[r:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED_BY]->(mutatorExpr)\r\n" - + "\r\n" - + "MATCH (mutatorExpr)<-[:ARRAYACCESS_EXPR|ARRAYACCESS_INDEX|ASSIGNMENT_LHS|ASSIGNMENT_RHS|BINOP_LHS|BINOP_RHS|CAST_ENCLOSES|COMPOUND_ASSIGNMENT_LHS|COMPOUND_ASSIGNMENT_RHS|CONDITIONAL_EXPR_CONDITION|CONDITIONAL_EXPR_THEN|CONDITIONAL_EXPR_ELSE|INITIALIZATION_EXPR|INSTANCE_OF_EXPR|MEMBER_REFERENCE_EXPRESSION|MEMBER_SELECT_EXPR|METHODINVOCATION_ARGUMENTS|METHODINVOCATION_METHOD_SELECT|NEW_CLASS_ARGUMENTS|NEW_ARRAY_INIT|NEW_ARRAY_DIMENSION|UNARY_ENCLOSES*0..]-()<-[:ASSERT_CONDITION|DO_WHILE_CONDITION|ENCLOSES_EXPR|FOREACH_EXPR|FORLOOP_CONDITION|HAS_VARIABLEDECL_INIT|IF_CONDITION|RETURN_EXPR|SWITCH_EXPR|SYNCHRONIZED_EXPR|THROW_EXPR|WHILE_CONDITION]-(stat)<-[:CASE_STATEMENTS|CATCH_ENCLOSES_BLOCK|CATCH_PARAM|ENCLOSES|DO_WHILE_STATEMENT|WHILE_STATEMENT|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|CALLABLE_HAS_PARAMETER|IF_THEN|IF_ELSE|LABELED_STMT_ENCLOSES|SWITCH_ENCLOSES_CASE|SYNCHRONIZED_ENCLOSES_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*]-()<-[:CALLABLE_HAS_BODY]-(method)<-[:DECLARES_FIELD|DECLARES_METHOD|DECLARES_CONSTRUCTOR|HAS_STATIC_INIT]-(exprEnclClass)\r\n" - + " WHERE NOT declaration:ATTR_DEF OR r.isOwnAccess=FALSE OR NOT method.isInitializer \r\n" - + "WITH declaration, mutatorExpr,exprEnclClass \r\n" - + "MATCH (declaration)<-[:CALLABLE_HAS_BODY|CALLABLE_HAS_PARAMETER|CASE_STATEMENTS|CATCH_ENCLOSES_BLOCK|CATCH_PARAM|ENCLOSES|DO_WHILE_STATEMENT|WHILE_STATEMENT|FOREACH_STATEMENT|FOREACH_VAR|FORLOOP_INIT|FORLOOP_STATEMENT|FORLOOP_UPDATE|HAS_VARIABLEDECL_INIT|IF_THEN|IF_ELSE|LABELED_STMT_ENCLOSES|SWITCH_ENCLOSES_CASE|SYNCHRONIZED_ENCLOSES_BLOCK|TRY_BLOCK|TRY_CATCH|TRY_FINALLY|TRY_RESOURCES*0..]-()<-[:DECLARES_FIELD|DECLARES_METHOD|DECLARES_CONSTRUCTOR|HAS_STATIC_INIT]-(enclClass)<-[:HAS_TYPE_DEF | HAS_INNER_TYPE_DEF]-(cu)\r\n" - + "WITH cu,declaration, enclClass,COLLECT(LAST(LABELS(mutatorExpr))+', line '+mutatorExpr.lineNumber+ ', column '+mutatorExpr.column+ ', class '+ exprEnclClass.fullyQualifiedName) as mutatorsMessage\r\n" - + "RETURN '[CMU-OBJ50;'+cu.fileName+';var_declaration;'+declaration.actualType+'-'+declaration.name+';'+declaration.lineNumber+'; Declaration with name '+ declaration.name+ '( in line ' + declaration.lineNumber +', class ' +enclClass.fullyQualifiedName + ') is not actually final, only the reference. Concretely, '+ declaration.name +' may be mutated in '+ REDUCE(seed=mutatorsMessage[0], x IN mutatorsMessage[1..] | seed+','+x)+']' \r\n" -//[BLOCH-6.36;C:\Users\admp1\Escritorio\StaticCodeAnalysis\Programs\ExampleClasses\src\main\java\examples\test\rule_3_10\B1.java; - //method_definition;examples.test.rule_3_10.B1:toString()java.lang.String;10;You must use the Override annotation in method toString (line 10) since it is actually overriding the method java.lang.Object:toString()java.lang.String] - - ; - public static final Rule[] RULES = new Rule[] { new Rule(MET53_ENSURE_CALL_SUPER_IN_CLONE_SA), - new Rule(MET55_RETURN_EMPTY_COLLECTIONS_INSTEAD_NULL_SA), new Rule(SEC56_DONT_SERIALIZE_SYSTEM_RESOURCES_SA), - new Rule(DECL56_ORDINAL_ENUM_SA), new Rule(MET50_AVOID_CONFUSING_OVERLOADING), - /* - * new Rule( - * DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_REFINED_PART1_B - * - * + - * DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_REFINED_PART2_B - * + - * DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_REFINED_PART3_B) - * , - */ - new Rule(DCL60_AVOID_CYCLIC_DEPENDENCIES_BETWEEN_PACKAGES_SA), new Rule( - - new OBJ54_SA(true).queryToString()), - // new Rule(new OBJ50_SIMPLIFIED().queryToString()) - new Rule(OBJ50_Q7ADRI_PAPER_VERSION), new Rule(ERR54_USE_TRY_RESOURCES_TO_SAFELY_CLOSE_SA), - new Rule(MET52_DO_NOT_USE_CLONE_WITH_UNTRUSTED_PARAMETERS), - //MINIMIZE V2 - new Rule(DCL53_MINIMIZE_SCOPE_OF_VARIABLES_V3_SA), - // new - // Rule(OBJ51_MINIMIZE_ACCESSIBILITY_OF_CLASSES_AND_MEMBERS_PART_ONE - // + " UNION ALL " - // + OBJ51_MINIMIZE_ACCESSIBILITY_OF_CLASSES_AND_MEMBERS_PART_TWO) - new Rule(new OBJ56_SIMPLIFIED_SA().queryToString()), - new Rule(NUM50CONVERT_INT_TO_FLOAT_FOR_FLOAT_OPERATIONS_SA) }; - private static final String DEPS_OPENNLP = "[['opennlp.PrepAttachDataUtil','opennlp.model.AbstractModel'],['opennlp.PrepAttachDataUtil','opennlp.model.EventStream'],['opennlp.PrepAttachDataUtil','opennlp.model.Event'],['opennlp.PrepAttachDataUtil','opennlp.model.ListEventStream'],['opennlp.PrepAttachDataUtil','opennlp.perceptron.PerceptronPrepAttachTest'],['opennlp.model.AbstractModel','opennlp.model.MaxentModel'],['opennlp.model.AbstractModel','opennlp.model.Prior'],['opennlp.model.AbstractModel','opennlp.model.EvalParameters'],['opennlp.model.AbstractModel','opennlp.model.Context'],['opennlp.model.AbstractModel','opennlp.model.AbstractModel.ModelType'],['opennlp.model.AbstractModel','opennlp.model.IndexHashTable'],['opennlp.model.EventStream','opennlp.model.Event'],['opennlp.maxent.BasicContextGenerator','opennlp.maxent.ContextGenerator'],['opennlp.maxent.BasicEventStream','opennlp.maxent.BasicContextGenerator'],['opennlp.maxent.BasicEventStream','opennlp.maxent.ContextGenerator'],['opennlp.maxent.BasicEventStream','opennlp.model.AbstractEventStream'],['opennlp.maxent.BasicEventStream','opennlp.model.Event'],['opennlp.maxent.BasicEventStream','opennlp.maxent.DataStream'],['opennlp.model.AbstractEventStream','opennlp.model.EventStream'],['opennlp.maxent.DomainToModelMap','opennlp.maxent.ModelDomain'],['opennlp.maxent.DomainToModelMap','opennlp.model.MaxentModel'],['opennlp.maxent.Evalable','opennlp.model.MaxentModel'],['opennlp.maxent.Evalable','opennlp.model.EventCollector'],['opennlp.model.EventCollector','opennlp.model.Event'],['opennlp.maxent.GIS','opennlp.model.EventStream'],['opennlp.maxent.GIS','opennlp.model.DataIndexer'],['opennlp.maxent.GIS','opennlp.model.Prior'],['opennlp.maxent.GIS','opennlp.maxent.GISModel'],['opennlp.maxent.GIS','opennlp.maxent.GISTrainer'],['opennlp.maxent.GIS','opennlp.model.UniformPrior'],['opennlp.maxent.GISModel','opennlp.model.AbstractModel'],['opennlp.maxent.GISModel','opennlp.model.Prior'],['opennlp.maxent.GISModel','opennlp.model.EvalParameters'],['opennlp.maxent.GISModel','opennlp.model.Context'],['opennlp.maxent.GISModel','opennlp.maxent.io.SuffixSensitiveGISModelReader'],['opennlp.maxent.GISModel','opennlp.model.AbstractModel.ModelType'],['opennlp.maxent.GISModel','opennlp.model.UniformPrior'],['opennlp.model.EvalParameters','opennlp.model.Context'],['opennlp.maxent.GISTrainer.ModelExpactationComputeTask','opennlp.maxent.GISModel'],['opennlp.maxent.GISTrainer.ModelExpactationComputeTask','opennlp.maxent.GISTrainer'],['opennlp.maxent.GISTrainer','opennlp.model.EventStream'],['opennlp.maxent.GISTrainer','opennlp.model.DataIndexer'],['opennlp.maxent.GISTrainer','opennlp.model.Prior'],['opennlp.maxent.GISTrainer','opennlp.maxent.GISModel'],['opennlp.maxent.GISTrainer','opennlp.model.EvalParameters'],['opennlp.maxent.GISTrainer','opennlp.maxent.GISTrainer.ModelExpactationComputeTask'],['opennlp.maxent.GISTrainer','opennlp.model.MutableContext'],['opennlp.maxent.GISTrainer','opennlp.model.OnePassDataIndexer'],['opennlp.maxent.GISTrainer','opennlp.model.UniformPrior'],['opennlp.maxent.MaxentPrepAttachTest','opennlp.PrepAttachDataUtil'],['opennlp.maxent.MaxentPrepAttachTest','opennlp.model.AbstractModel'],['opennlp.maxent.MaxentPrepAttachTest','opennlp.maxent.GISTrainer'],['opennlp.maxent.MaxentPrepAttachTest','opennlp.model.TrainUtil'],['opennlp.maxent.MaxentPrepAttachTest','opennlp.model.TwoPassDataIndexer'],['opennlp.maxent.MaxentPrepAttachTest','opennlp.model.UniformPrior'],['opennlp.maxent.ModelApplier','opennlp.model.EventStream'],['opennlp.maxent.ModelApplier','opennlp.maxent.BasicContextGenerator'],['opennlp.maxent.ModelApplier','opennlp.maxent.ContextGenerator'],['opennlp.maxent.ModelApplier','opennlp.maxent.BasicEventStream'],['opennlp.maxent.ModelApplier','opennlp.model.Event'],['opennlp.maxent.ModelApplier','opennlp.model.MaxentModel'],['opennlp.maxent.ModelApplier','opennlp.maxent.DoubleStringPair'],['opennlp.maxent.ModelApplier','opennlp.maxent.PlainTextByLineDataStream'],['opennlp.maxent.ModelApplier','opennlp.model.GenericModelReader'],['opennlp.maxent.ModelApplier','opennlp.model.RealValueFileEventStream'],['opennlp.maxent.ModelReplacementManager','opennlp.model.MaxentModel'],['opennlp.maxent.ModelReplacementManager','opennlp.maxent.ModelSetter'],['opennlp.maxent.ModelSetter','opennlp.model.MaxentModel'],['opennlp.maxent.ModelTrainer','opennlp.model.AbstractModel'],['opennlp.maxent.ModelTrainer','opennlp.model.EventStream'],['opennlp.maxent.ModelTrainer','opennlp.maxent.BasicEventStream'],['opennlp.maxent.ModelTrainer','opennlp.maxent.GIS'],['opennlp.maxent.ModelTrainer','opennlp.maxent.PlainTextByLineDataStream'],['opennlp.maxent.ModelTrainer','opennlp.maxent.RealBasicEventStream'],['opennlp.maxent.ModelTrainer','opennlp.model.AbstractModelWriter'],['opennlp.maxent.ModelTrainer','opennlp.maxent.io.SuffixSensitiveGISModelWriter'],['opennlp.maxent.ModelTrainer','opennlp.model.OnePassDataIndexer'],['opennlp.maxent.ModelTrainer','opennlp.model.OnePassRealValueDataIndexer'],['opennlp.maxent.ModelTrainer','opennlp.perceptron.PerceptronTrainer'],['opennlp.maxent.ModelTrainer','opennlp.perceptron.SuffixSensitivePerceptronModelWriter'],['opennlp.maxent.PlainTextByLineDataStream','opennlp.maxent.DataStream'],['opennlp.maxent.RealBasicEventStream','opennlp.model.EventStream'],['opennlp.maxent.RealBasicEventStream','opennlp.maxent.BasicContextGenerator'],['opennlp.maxent.RealBasicEventStream','opennlp.maxent.ContextGenerator'],['opennlp.maxent.RealBasicEventStream','opennlp.model.AbstractEventStream'],['opennlp.maxent.RealBasicEventStream','opennlp.model.Event'],['opennlp.maxent.RealBasicEventStream','opennlp.maxent.DataStream'],['opennlp.maxent.RealBasicEventStream','opennlp.maxent.PlainTextByLineDataStream'],['opennlp.maxent.RealBasicEventStream','opennlp.model.RealValueFileEventStream'],['opennlp.maxent.RealValueModelTest','opennlp.maxent.GIS'],['opennlp.maxent.RealValueModelTest','opennlp.maxent.GISModel'],['opennlp.maxent.RealValueModelTest','opennlp.model.FileEventStream'],['opennlp.maxent.RealValueModelTest','opennlp.model.OnePassRealValueDataIndexer'],['opennlp.maxent.RealValueModelTest','opennlp.model.RealValueFileEventStream'],['opennlp.maxent.ScaleDoesntMatterTest','opennlp.model.EventStream'],['opennlp.maxent.ScaleDoesntMatterTest','opennlp.model.MaxentModel'],['opennlp.maxent.ScaleDoesntMatterTest','opennlp.maxent.GIS'],['opennlp.maxent.ScaleDoesntMatterTest','opennlp.maxent.PlainTextByLineDataStream'],['opennlp.maxent.ScaleDoesntMatterTest','opennlp.maxent.RealBasicEventStream'],['opennlp.maxent.ScaleDoesntMatterTest','opennlp.model.OnePassRealValueDataIndexer'],['opennlp.maxent.ScaleDoesntMatterTest','opennlp.model.RealValueFileEventStream'],['opennlp.maxent.TrainEval','opennlp.model.EventStream'],['opennlp.maxent.TrainEval','opennlp.model.Event'],['opennlp.maxent.TrainEval','opennlp.model.MaxentModel'],['opennlp.maxent.TrainEval','opennlp.maxent.Evalable'],['opennlp.maxent.TrainEval','opennlp.maxent.GIS'],['opennlp.maxent.io.BinaryGISModelReader','opennlp.maxent.io.GISModelReader'],['opennlp.maxent.io.BinaryGISModelReader','opennlp.model.BinaryFileDataReader'],['opennlp.maxent.io.GISModelReader','opennlp.model.AbstractModel'],['opennlp.maxent.io.GISModelReader','opennlp.maxent.GISModel'],['opennlp.maxent.io.GISModelReader','opennlp.model.Context'],['opennlp.maxent.io.GISModelReader','opennlp.model.AbstractModelReader'],['opennlp.maxent.io.GISModelReader','opennlp.model.DataReader'],['opennlp.maxent.io.BinaryGISModelWriter','opennlp.model.MaxentModel'],['opennlp.maxent.io.BinaryGISModelWriter','opennlp.maxent.io.GISModelWriter'],['opennlp.maxent.io.GISModelWriter','opennlp.model.MaxentModel'],['opennlp.maxent.io.GISModelWriter','opennlp.model.Context'],['opennlp.maxent.io.GISModelWriter','opennlp.model.AbstractModelWriter'],['opennlp.maxent.io.GISModelWriter','opennlp.model.ComparablePredicate'],['opennlp.maxent.io.GISModelWriter','opennlp.model.IndexHashTable'],['opennlp.model.AbstractModelReader','opennlp.model.AbstractModel'],['opennlp.model.AbstractModelReader','opennlp.model.Context'],['opennlp.model.AbstractModelReader','opennlp.model.DataReader'],['opennlp.model.AbstractModelReader','opennlp.model.BinaryFileDataReader'],['opennlp.model.AbstractModelReader','opennlp.model.PlainTextFileDataReader'],['opennlp.maxent.io.ObjectGISModelReader','opennlp.maxent.io.GISModelReader'],['opennlp.maxent.io.ObjectGISModelReader','opennlp.model.ObjectDataReader'],['opennlp.maxent.io.ObjectGISModelWriter','opennlp.model.AbstractModel'],['opennlp.maxent.io.ObjectGISModelWriter','opennlp.maxent.io.GISModelWriter'],['opennlp.maxent.io.OldFormatGISModelReader','opennlp.model.Context'],['opennlp.maxent.io.OldFormatGISModelReader','opennlp.model.AbstractModelReader'],['opennlp.maxent.io.OldFormatGISModelReader','opennlp.maxent.io.PlainTextGISModelReader'],['opennlp.maxent.io.OldFormatGISModelReader','opennlp.maxent.io.SuffixSensitiveGISModelWriter'],['opennlp.maxent.io.PlainTextGISModelReader','opennlp.maxent.io.GISModelReader'],['opennlp.maxent.io.PlainTextGISModelReader','opennlp.model.PlainTextFileDataReader'],['opennlp.maxent.io.PlainTextGISModelWriter','opennlp.model.AbstractModel'],['opennlp.maxent.io.PlainTextGISModelWriter','opennlp.maxent.io.GISModelWriter'],['opennlp.maxent.io.PooledGISModelReader','opennlp.maxent.io.SuffixSensitiveGISModelReader'],['opennlp.maxent.io.SuffixSensitiveGISModelReader','opennlp.model.AbstractModel'],['opennlp.maxent.io.SuffixSensitiveGISModelReader','opennlp.maxent.io.GISModelReader'],['opennlp.maxent.io.SuffixSensitiveGISModelReader','opennlp.maxent.io.SuffixSensitiveGISModelWriter'],['opennlp.maxent.io.RealValueFileEventStreamTest','opennlp.model.OnePassRealValueDataIndexer'],['opennlp.maxent.io.RealValueFileEventStreamTest','opennlp.model.RealValueFileEventStream'],['opennlp.maxent.io.SuffixSensitiveGISModelWriter','opennlp.model.AbstractModel'],['opennlp.maxent.io.SuffixSensitiveGISModelWriter','opennlp.maxent.io.BinaryGISModelWriter'],['opennlp.maxent.io.SuffixSensitiveGISModelWriter','opennlp.maxent.io.GISModelWriter'],['opennlp.maxent.io.SuffixSensitiveGISModelWriter','opennlp.maxent.io.PlainTextGISModelWriter'],['opennlp.maxent.io.TwoPassRealValueDataIndexerTest','opennlp.model.EventStream'],['opennlp.maxent.io.TwoPassRealValueDataIndexerTest','opennlp.model.MaxentModel'],['opennlp.maxent.io.TwoPassRealValueDataIndexerTest','opennlp.maxent.GIS'],['opennlp.maxent.io.TwoPassRealValueDataIndexerTest','opennlp.maxent.PlainTextByLineDataStream'],['opennlp.maxent.io.TwoPassRealValueDataIndexerTest','opennlp.maxent.RealBasicEventStream'],['opennlp.maxent.io.TwoPassRealValueDataIndexerTest','opennlp.model.OnePassRealValueDataIndexer'],['opennlp.maxent.io.TwoPassRealValueDataIndexerTest','opennlp.model.RealValueFileEventStream'],['opennlp.maxent.io.TwoPassRealValueDataIndexerTest','opennlp.model.TwoPassRealValueDataIndexer'],['opennlp.model.AbstractDataIndexer','opennlp.model.DataIndexer'],['opennlp.model.AbstractDataIndexer','opennlp.model.ComparableEvent'],['opennlp.model.AbstractModel.ModelType','opennlp.model.AbstractModel'],['opennlp.model.BinaryFileDataReader','opennlp.model.DataReader'],['opennlp.model.DynamicEvalParameters','opennlp.model.Context'],['opennlp.model.EventCollectorAsStream','opennlp.model.AbstractEventStream'],['opennlp.model.EventCollectorAsStream','opennlp.model.Event'],['opennlp.model.EventCollectorAsStream','opennlp.model.EventCollector'],['opennlp.model.FileEventStream','opennlp.model.AbstractModel'],['opennlp.model.FileEventStream','opennlp.model.EventStream'],['opennlp.model.FileEventStream','opennlp.model.AbstractEventStream'],['opennlp.model.FileEventStream','opennlp.model.Event'],['opennlp.model.FileEventStream','opennlp.maxent.GIS'],['opennlp.model.FileEventStream','opennlp.maxent.io.SuffixSensitiveGISModelWriter'],['opennlp.model.GenericModelReader','opennlp.model.AbstractModel'],['opennlp.model.GenericModelReader','opennlp.maxent.io.GISModelReader'],['opennlp.model.GenericModelReader','opennlp.model.AbstractModelReader'],['opennlp.model.GenericModelReader','opennlp.model.DataReader'],['opennlp.model.GenericModelReader','opennlp.model.GenericModelWriter'],['opennlp.model.GenericModelReader','opennlp.perceptron.PerceptronModelReader'],['opennlp.model.GenericModelWriter','opennlp.model.AbstractModel'],['opennlp.model.GenericModelWriter','opennlp.maxent.io.BinaryGISModelWriter'],['opennlp.model.GenericModelWriter','opennlp.model.AbstractModelWriter'],['opennlp.model.GenericModelWriter','opennlp.maxent.io.PlainTextGISModelWriter'],['opennlp.model.GenericModelWriter','opennlp.model.AbstractModel.ModelType'],['opennlp.model.GenericModelWriter','opennlp.perceptron.BinaryPerceptronModelWriter'],['opennlp.model.GenericModelWriter','opennlp.perceptron.PlainTextPerceptronModelWriter'],['opennlp.model.HashSumEventStream','opennlp.model.EventStream'],['opennlp.model.HashSumEventStream','opennlp.model.Event'],['opennlp.model.IndexHashTableTest','opennlp.model.IndexHashTable'],['opennlp.model.ListEventStream','opennlp.model.EventStream'],['opennlp.model.ListEventStream','opennlp.model.Event'],['opennlp.model.MutableContext','opennlp.model.Context'],['opennlp.model.ObjectDataReader','opennlp.model.DataReader'],['opennlp.model.OnePassDataIndexer','opennlp.model.EventStream'],['opennlp.model.OnePassDataIndexer','opennlp.model.Event'],['opennlp.model.OnePassDataIndexer','opennlp.model.AbstractDataIndexer'],['opennlp.model.OnePassDataIndexer','opennlp.model.ComparableEvent'],['opennlp.model.OnePassRealValueDataIndexer','opennlp.model.EventStream'],['opennlp.model.OnePassRealValueDataIndexer','opennlp.model.Event'],['opennlp.model.OnePassRealValueDataIndexer','opennlp.model.AbstractDataIndexer'],['opennlp.model.OnePassRealValueDataIndexer','opennlp.model.ComparableEvent'],['opennlp.model.OnePassRealValueDataIndexer','opennlp.model.OnePassDataIndexer'],['opennlp.model.PlainTextFileDataReader','opennlp.model.DataReader'],['opennlp.model.RealValueFileEventStream','opennlp.model.AbstractModel'],['opennlp.model.RealValueFileEventStream','opennlp.model.EventStream'],['opennlp.model.RealValueFileEventStream','opennlp.model.Event'],['opennlp.model.RealValueFileEventStream','opennlp.maxent.GIS'],['opennlp.model.RealValueFileEventStream','opennlp.maxent.io.SuffixSensitiveGISModelWriter'],['opennlp.model.RealValueFileEventStream','opennlp.model.FileEventStream'],['opennlp.model.RealValueFileEventStream','opennlp.model.OnePassRealValueDataIndexer'],['opennlp.model.RealValueFileEventStream2','opennlp.model.AbstractModel'],['opennlp.model.RealValueFileEventStream2','opennlp.model.EventStream'],['opennlp.model.RealValueFileEventStream2','opennlp.model.AbstractEventStream'],['opennlp.model.RealValueFileEventStream2','opennlp.model.Event'],['opennlp.model.RealValueFileEventStream2','opennlp.maxent.GIS'],['opennlp.model.RealValueFileEventStream2','opennlp.maxent.io.SuffixSensitiveGISModelWriter'],['opennlp.model.RealValueFileEventStream2','opennlp.model.FileEventStream'],['opennlp.model.Sequence','opennlp.model.Event'],['opennlp.model.SequenceStream','opennlp.model.AbstractModel'],['opennlp.model.SequenceStream','opennlp.model.Event'],['opennlp.model.SequenceStream','opennlp.model.Sequence'],['opennlp.model.SequenceStreamEventStream','opennlp.model.EventStream'],['opennlp.model.SequenceStreamEventStream','opennlp.model.Event'],['opennlp.model.SequenceStreamEventStream','opennlp.model.Sequence'],['opennlp.model.SequenceStreamEventStream','opennlp.model.SequenceStream'],['opennlp.model.TrainUtil','opennlp.model.AbstractModel'],['opennlp.model.TrainUtil','opennlp.model.EventStream'],['opennlp.model.TrainUtil','opennlp.maxent.GIS'],['opennlp.model.TrainUtil','opennlp.model.DataIndexer'],['opennlp.model.TrainUtil','opennlp.model.HashSumEventStream'],['opennlp.model.TrainUtil','opennlp.model.OnePassDataIndexer'],['opennlp.model.TrainUtil','opennlp.model.SequenceStream'],['opennlp.model.TrainUtil','opennlp.model.TwoPassDataIndexer'],['opennlp.model.TrainUtil','opennlp.perceptron.PerceptronTrainer'],['opennlp.model.TrainUtil','opennlp.perceptron.SimplePerceptronSequenceTrainer'],['opennlp.model.TwoPassDataIndexer','opennlp.model.EventStream'],['opennlp.model.TwoPassDataIndexer','opennlp.model.Event'],['opennlp.model.TwoPassDataIndexer','opennlp.model.AbstractDataIndexer'],['opennlp.model.TwoPassDataIndexer','opennlp.model.ComparableEvent'],['opennlp.model.TwoPassDataIndexer','opennlp.model.FileEventStream'],['opennlp.model.TwoPassRealValueDataIndexer','opennlp.model.EventStream'],['opennlp.model.TwoPassRealValueDataIndexer','opennlp.model.Event'],['opennlp.model.TwoPassRealValueDataIndexer','opennlp.model.AbstractDataIndexer'],['opennlp.model.TwoPassRealValueDataIndexer','opennlp.model.ComparableEvent'],['opennlp.model.TwoPassRealValueDataIndexer','opennlp.model.RealValueFileEventStream2'],['opennlp.model.TwoPassRealValueDataIndexer','opennlp.model.TwoPassDataIndexer'],['opennlp.model.UniformPrior','opennlp.model.Prior'],['opennlp.perceptron.BinaryPerceptronModelReader','opennlp.model.BinaryFileDataReader'],['opennlp.perceptron.BinaryPerceptronModelReader','opennlp.perceptron.PerceptronModelReader'],['opennlp.perceptron.PerceptronModelReader','opennlp.model.AbstractModel'],['opennlp.perceptron.PerceptronModelReader','opennlp.model.Context'],['opennlp.perceptron.PerceptronModelReader','opennlp.model.AbstractModelReader'],['opennlp.perceptron.PerceptronModelReader','opennlp.model.DataReader'],['opennlp.perceptron.PerceptronModelReader','opennlp.perceptron.PerceptronModel'],['opennlp.perceptron.BinaryPerceptronModelWriter','opennlp.model.MaxentModel'],['opennlp.perceptron.BinaryPerceptronModelWriter','opennlp.perceptron.PerceptronModelWriter'],['opennlp.perceptron.PerceptronModelWriter','opennlp.model.MaxentModel'],['opennlp.perceptron.PerceptronModelWriter','opennlp.model.Context'],['opennlp.perceptron.PerceptronModelWriter','opennlp.model.AbstractModelWriter'],['opennlp.perceptron.PerceptronModelWriter','opennlp.model.ComparablePredicate'],['opennlp.perceptron.PerceptronModelWriter','opennlp.model.IndexHashTable'],['opennlp.perceptron.PerceptronModel','opennlp.model.AbstractModel'],['opennlp.perceptron.PerceptronModel','opennlp.model.EvalParameters'],['opennlp.perceptron.PerceptronModel','opennlp.model.Context'],['opennlp.perceptron.PerceptronModel','opennlp.model.AbstractModel.ModelType'],['opennlp.perceptron.PerceptronModel','opennlp.model.IndexHashTable'],['opennlp.perceptron.PerceptronModel','opennlp.perceptron.PerceptronModelReader'],['opennlp.perceptron.PerceptronPrepAttachTest','opennlp.PrepAttachDataUtil'],['opennlp.perceptron.PerceptronPrepAttachTest','opennlp.model.AbstractModel'],['opennlp.perceptron.PerceptronPrepAttachTest','opennlp.model.TrainUtil'],['opennlp.perceptron.PerceptronPrepAttachTest','opennlp.model.TwoPassDataIndexer'],['opennlp.perceptron.PerceptronPrepAttachTest','opennlp.perceptron.PerceptronTrainer'],['opennlp.perceptron.PerceptronTrainer','opennlp.model.AbstractModel'],['opennlp.perceptron.PerceptronTrainer','opennlp.model.DataIndexer'],['opennlp.perceptron.PerceptronTrainer','opennlp.model.EvalParameters'],['opennlp.perceptron.PerceptronTrainer','opennlp.model.MutableContext'],['opennlp.perceptron.PerceptronTrainer','opennlp.perceptron.PerceptronModel'],['opennlp.perceptron.PlainTextPerceptronModelReader','opennlp.model.PlainTextFileDataReader'],['opennlp.perceptron.PlainTextPerceptronModelReader','opennlp.perceptron.PerceptronModelReader'],['opennlp.perceptron.PlainTextPerceptronModelWriter','opennlp.model.MaxentModel'],['opennlp.perceptron.PlainTextPerceptronModelWriter','opennlp.perceptron.PerceptronModelWriter'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.AbstractModel'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.Event'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.DataIndexer'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.IndexHashTable'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.MutableContext'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.OnePassDataIndexer'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.Sequence'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.SequenceStream'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.model.SequenceStreamEventStream'],['opennlp.perceptron.SimplePerceptronSequenceTrainer','opennlp.perceptron.PerceptronModel'],['opennlp.perceptron.SuffixSensitivePerceptronModelWriter','opennlp.model.AbstractModel'],['opennlp.perceptron.SuffixSensitivePerceptronModelWriter','opennlp.model.AbstractModelWriter'],['opennlp.perceptron.SuffixSensitivePerceptronModelWriter','opennlp.perceptron.BinaryPerceptronModelWriter'],['opennlp.perceptron.SuffixSensitivePerceptronModelWriter','opennlp.perceptron.PerceptronModelWriter'],['opennlp.perceptron.SuffixSensitivePerceptronModelWriter','opennlp.perceptron.PlainTextPerceptronModelWriter']]\r\n"; - - public static void main(String[] args) throws IOException { - final boolean MEASURING_MEMORY = false; - int queryIndex = args.length == 0 ?2: Integer.parseInt(args[0]); - try { - GraphDatabaseService gs = EmbeddedDBManager.getNewEmbeddedDBService(); - - Rule rule = - RULES[queryIndex]; - - - if (args.length == 0) - System.out.println(rule.queries[0]); - long ini = System.nanoTime(); - String res = rule.execute(gs).resultAsString(); - long end = System.nanoTime(); - if (!MEASURING_MEMORY) { - System.err.println(res); - // String resString = res.resultAsString(); - System.out.print((end - ini) / 1000_000); - } else { -// System.out.println("Press any key..."); -// new Scanner(System.in).nextLine(); - } - if (args.length == 0) { - // System.out.println(res.hashCode()); - // System.out.println(res.resultAsString()); - int size = 0; - // System.out.println(size); - // while (res.hasNext()) { - // System.out.println(size); - // res.next(); - // size++; - // - // } - // System.out.println(size); - // BufferedWriter bw = new BufferedWriter(new - // FileWriter("outXX.txt")); - // bw.write(resString); - // bw.close(); - - } - // gs.execute(DELETE_ALL);} - } catch (Throwable t) { - t.printStackTrace(new PrintStream(new FileOutputStream("err" + queryIndex + ".txt"))); - BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt")); - bw.write(RULES[queryIndex].queries[0]); - bw.close(); - System.out.println("-1"); - } - } -} diff --git a/ProgQuery/src/database/querys/eval/DeleteAllServer.java b/ProgQuery/src/database/querys/eval/DeleteAllServer.java deleted file mode 100644 index ee56604..0000000 --- a/ProgQuery/src/database/querys/eval/DeleteAllServer.java +++ /dev/null @@ -1,13 +0,0 @@ -package database.querys.eval; - -import database.querys.ServerQueryManager; - -public class DeleteAllServer { - - public static void main(String[] args) throws Exception { - final String DELETE_ALL = "MATCH (N) DETACH DELETE N"; - ServerQueryManager.SERVER_MANAGER = new ServerQueryManager("Oscar", "pass", "address"); - ServerQueryManager.SERVER_MANAGER.executeQuery(DELETE_ALL); - ServerQueryManager.SERVER_MANAGER.close(); - } -} diff --git a/ProgQuery/src/database/querys/eval/EmbeddedCountQuery.java b/ProgQuery/src/database/querys/eval/EmbeddedCountQuery.java deleted file mode 100644 index bde6218..0000000 --- a/ProgQuery/src/database/querys/eval/EmbeddedCountQuery.java +++ /dev/null @@ -1,22 +0,0 @@ -package database.querys.eval; - -import java.io.IOException; - -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Result; - -import database.embedded.EmbeddedDBManager; - -public class EmbeddedCountQuery { - - public static void main(String[] args) throws IOException { - - GraphDatabaseService gs = EmbeddedDBManager.getNewEmbeddedDBService(); - - Result res = gs.execute(args[0]); - System.out.println(res.next().values().iterator().next()); - // gs.execute(DELETE_ALL); - - } - -} \ No newline at end of file diff --git a/ProgQuery/src/database/querys/eval/FromDatabaseToGEXF.java b/ProgQuery/src/database/querys/eval/FromDatabaseToGEXF.java deleted file mode 100644 index 8d5c290..0000000 --- a/ProgQuery/src/database/querys/eval/FromDatabaseToGEXF.java +++ /dev/null @@ -1,123 +0,0 @@ -package database.querys.eval; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.Result; -import org.neo4j.graphdb.Transaction; - -import database.embedded.EmbeddedDBManager; -import utils.dataTransferClasses.Pair; - -public class FromDatabaseToGEXF { - static Map> nodeAttrs = new HashMap>(); - static Map> relAttrs = new HashMap>(); - - public static void main(String[] args) throws IOException { - GraphDatabaseService gs = EmbeddedDBManager.getNewEmbeddedDBService(); - String nodes = nodesAsGEXF(gs), rels = relsAsGEXF(gs); - String res = "" - + " RodriguezPrieto ProgQuery graph " - + "" + attributesAsGEXF() + nodes + rels - + ""; - BufferedWriter bw = new BufferedWriter(new FileWriter(new File("ProgQuery.gexf"))); - bw.write(res); - bw.close(); - - } - - private static String attributesAsGEXF() { - /* - * - * - * true - */ - String res = ""; - for (Entry> entry : nodeAttrs.entrySet()) - res += ""; - res += "\n"// " - ; - return res; - } - - private static String nodesAsGEXF(GraphDatabaseService gs) { - Transaction t = gs.beginTx(); - Result result = gs.execute("MATCH (n) RETURN n"); - t.success(); - String res = "\n"; - while (result.hasNext()) - res += nodeToGEFXXML((Node) result.next().get("n")) + "\n"; - return res + "\n"; - } - - private static String relsAsGEXF(GraphDatabaseService gs) { - Transaction t = gs.beginTx(); - Result result = gs.execute("MATCH ()-[r]->() RETURN r"); - t.success(); - String res = ""; - while (result.hasNext()) - res += relToGEFXXML((Relationship) result.next().get("r")) + "\n"; - return res + "\n"; - } - - private static String relToGEFXXML(Relationship rel) { - String relRep = "\n"; - relRep += propertiesToGEFXXML(rel.getAllProperties().entrySet(), relAttrs); - relRep += ""; - return relRep; - } - - private static String propertiesToGEFXXML(Set> props, - Map> idPropMap) { - String propsRep = ""; - if (props.size() > 0) { - propsRep += "\n"; - for (Entry prop : props) { - if (!idPropMap.containsKey(prop.getKey())) - idPropMap.put(prop.getKey(), Pair.create(idPropMap.size(), fromObjetToTypeString(prop.getValue()))); - propsRep += "", "**") + "\"/>\n"; - } - propsRep += ""; - } - return propsRep; - } - - private static String fromObjetToTypeString(Object value) { - if (value instanceof String) - return "string"; - else if (value instanceof Integer || value instanceof Long) - return "integer"; - else if (value instanceof Boolean) - return "boolean"; - throw new IllegalArgumentException("The value " + value + " has not an expected type " + value.getClass()); - } - - private static String nodeToGEFXXML(Node n) { - String nodeRep = "\n"; - nodeRep += propertiesToGEFXXML(n.getAllProperties().entrySet(), nodeAttrs); - nodeRep += ""; - return nodeRep; - } -} -/* - * - * - */ \ No newline at end of file diff --git a/ProgQuery/src/database/querys/eval/Join.java b/ProgQuery/src/database/querys/eval/Join.java deleted file mode 100644 index 4d2df0a..0000000 --- a/ProgQuery/src/database/querys/eval/Join.java +++ /dev/null @@ -1,21 +0,0 @@ -package database.querys.eval; - -import java.util.List; - -import org.neo4j.procedure.Description; -import org.neo4j.procedure.Name; -import org.neo4j.procedure.UserFunction; - -public class Join { - - @UserFunction - @Description("example.join(['s1','s2',...], delimiter) - join the given strings with the given delimiter.") - public String join( - @Name("strings") List strings, - @Name(value = "delimiter", defaultValue = ",") String delimiter) { - if (strings == null || delimiter == null) { - return null; - } - return String.join(delimiter, strings); - } -} diff --git a/ProgQuery/src/database/querys/eval/MainQuery.java b/ProgQuery/src/database/querys/eval/MainQuery.java deleted file mode 100644 index a7ed51a..0000000 --- a/ProgQuery/src/database/querys/eval/MainQuery.java +++ /dev/null @@ -1,61 +0,0 @@ -package database.querys.eval; - -import java.io.IOException; - -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Result; - -import database.embedded.EmbeddedDBManager; -import database.relations.CFGRelationTypes; - -public class MainQuery { - public static final String CFG_NODES_FOR_TESTING = "MATCH (stat) WHERE (stat:VAR_DEF OR stat:TRY_BLOCK OR stat:EXPRESSION_STATEMENT OR stat:IF_STATEMENT OR stat:THROW_STATEMENT OR stat:CATCH_BLOCK OR stat:FINALLY_BLOCK OR stat: LABELED_STATEMENT OR stat:FOR_LOOP OR stat:ASSERT_STATEMENT OR stat:CONTINUE_STATEMENT OR stat:BREAK_STATEMENT OR stat:WHILE_LOOP OR stat:FOR_EACH_LOOP OR stat:DO_WHILE_LOOP OR stat:EMPTY_STATEMENT) AND (stat.lineNumber>=12 AND stat.lineNumber<=118) RETURN stat, labels(stat) ORDER BY stat.lineNumber, stat.position"; - - /* - * TODO ESTO SON CONSULTAS DE PRUEBA, NINGUNA REPRESENTA NINGUNA REGLA DE - * PROGRAMACIóN - */ - public static final String ALL_NODES = "MATCH (n)-[r]->(m) RETURN n,r,m"; - public static final String DELETE_ALL = "MATCH (n) DETACH DELETE n"; - - private static final String TYPE_HIERARCHY = "MATCH (n)-[r:IS_SUBTYPE_IMPLEMENTS | IS_SUBTYPE_EXTENDS]->(m) RETURN n,r,m"; - - private static final String ALL_CALLS = "MATCH (n)-[r:CALLS]->(mi)-[r2:HAS_DEF]->(md) RETURN n,r,mi,md"; - private static final String CFG_RELS = " MATCH (m)-[r:" + CFGRelationTypes.getCFGRelations() - + " ]->(n) RETURN m, labels(m),r,n, labels(n)"; - - private static final String ALL_METHOD_DECS_RELS = "MATCH (m:METHOD_DEC)-[r]-(n) WHERE m.isDeclared RETURN m,r,n, labels(n)"; - private static final String OVERRIDES = "MATCH (m)-[:OVERRIDES]->(n) RETURN m.fullyQualifiedName,n.fullyQualifiedName"; - private static final String REFER_RELS = "MATCH (inv)-[r:REFERS_TO | MAY_REFER_TO]->(m) RETURN inv,r,m.fullyQualifiedName"; - - public static final String MAY_THROW_REL = "MATCH (stat)-[r:CFG_MAY_THROW]->(statDos) RETURN stat, labels(stat), r, statDos,labels(statDos)"; - public static final String STATE_MODS = "MATCH (n)-[r :STATE_MAY_BE_MODIFIED_BY | :STATE_MODIFIED_BY]->(m) RETURN n, labels(n),r, m"; - public static final String MAY_AND_REFER = "MATCH (n)-[r :REFERS_TO | :MAY_REFER_TO]->(m) RETURN n, labels(n),r, m"; - public static final String CDG = "MATCH (n)-[r :USES_TYPE_DEF ]->(m) RETURN n.fullyQualifiedName, m.fullyQualifiedName ORDER BY n.fullyQualifiedName"; - /** - * Aquí te paso consultas que modelan algunas reglas sencillas - **/ - // Un metodo que retorne una colección o un array, debe retornal colección - // o array vación en lugar de null - private static final String MET55_RETURN_EMPTY_COLLECTIONS_INSTEAD_NULL = - - " MATCH (md)-[:CALLABLE_HAS_BODY]->(rt)-[:ITS_TYPE_IS |:PARAMETERIZED_TYPE*0..]->()-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(collection) WHERE collection.fullyQualifiedName='java.util.Collection' OR collection:ARRAY_TYPE WITH DISTINCT md MATCH (enclosingCU)-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]->()-[:DECLARES_METHOD]->(md)<-[:CFG_END_OF]-(normalEnd)<-[:CFG_NEXT_STATEMENT]-(:RETURN_STATEMENT)-[:RETURN_EXPR]->() -[:CONDITIONAL_EXPR_THEN |:CONDITIONAL_EXPR_ELSE*0..]->(nullRet{typetag:'NULL_LITERAL'}) WITH enclosingCU, nullRet WHERE nullRet IS NOT NULL RETURN 'Warning [CMU-MET55], you must not return null when you can return an empty collection or array.Line' +nullRet.lineNumber+' in '+enclosingCU.fileName+'.'" -; - // Se llama a clone en un método publico de clase publica, y sobre un - // parámetro cuya clase es pública y no está marcada como final - // Hay riesgo de que te llegue un parámetro de un cliente maligno que haya - // extendido la clase del parámetro de modo que al clonarlo tenga un - // comportamiento inesperado/malicioso - private static final String MET52_DO_NOT_USE_CLONE_WITH_UNTRUSTED_PARAMETERS = " MATCH (enclosingCU)-[:HAS_TYPE_DEF |:HAS_INNER_TYPE_DEF]->(typeDec{accessLevel:'public'})-[:DECLARES_METHOD]->(method{accessLevel:'public'})-[:CALLABLE_HAS_PARAMETER]->(param) -[:USED_BY]->(id)<-[:MEMBER_SELECT_EXPR]-(mSelect:MEMBER_SELECTION{memberName:'clone'})<-[:METHODINVOCATION_METHOD_SELECT]-(mInv:METHOD_INVOCATION), (param)-[:HAS_VARIABLEDECL_TYPE]->()-[:PARAMETERIZED_TYPE*0..1]->()-[:ITS_TYPE_IS]->(pType) WHERE mSelect.actualType CONTAINS '()' AND NOT pType.isFinal AND (NOT pType.isDeclared OR pType.accessLevel='public') RETURN 'Warning [CMU-MET52] You must not use the clone method to copy unstrasted parameters (like parameter ' + param.name+ ', cloned in line '+ mInv.lineNumber+ ' in method ' + method.name +', file '+enclosingCU.fileName+').'"; - - public static void main(String[] args) throws IOException { - - GraphDatabaseService gs = EmbeddedDBManager.getNewEmbeddedDBService(); - - Result res = gs.execute(args[0]); - System.out.println(res.resultAsString()); - // gs.execute(DELETE_ALL); - - } - -} \ No newline at end of file diff --git a/ProgQuery/src/database/querys/eval/QueriesWithProcedures.java b/ProgQuery/src/database/querys/eval/QueriesWithProcedures.java deleted file mode 100644 index 23de5ef..0000000 --- a/ProgQuery/src/database/querys/eval/QueriesWithProcedures.java +++ /dev/null @@ -1,328 +0,0 @@ -package database.querys.eval; - -import static java.util.Arrays.asList; - -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintStream; -import java.util.List; -import java.util.Map; - -import org.neo4j.graphdb.DependencyResolver; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.helpers.collection.MapUtil; -import org.neo4j.kernel.api.exceptions.KernelException; -import org.neo4j.kernel.impl.proc.Procedures; -import org.neo4j.kernel.internal.GraphDatabaseAPI; -import org.neo4j.kernel.lifecycle.LifecycleException; -import org.neo4j.test.TestGraphDatabaseFactory; - -import database.embedded.EmbeddedDBManager; -import database.procedures.AnySucc; -import database.procedures.EnclosingStmt; -import database.procedures.FunctionUtils; -import database.relations.CFGRelationTypes; -import database.relations.RelationTypes; -import database.relations.RelationTypesInterface; -import evaluation.Rule; - -public class QueriesWithProcedures { - private static final RelationTypes[] assignToOutExprNoCond = new RelationTypes[] { RelationTypes.ARRAYACCESS_EXPR, - RelationTypes.ARRAYACCESS_INDEX, RelationTypes.ASSIGNMENT_RHS, RelationTypes.BINOP_LHS, - RelationTypes.BINOP_RHS, RelationTypes.CAST_ENCLOSES, RelationTypes.COMPOUND_ASSIGNMENT_RHS, - RelationTypes.CONDITIONAL_EXPR_CONDITION, RelationTypes.INITIALIZATION_EXPR, RelationTypes.INSTANCE_OF_EXPR, - RelationTypes.MEMBER_REFERENCE_EXPRESSION, RelationTypes.MEMBER_SELECT_EXPR, - RelationTypes.METHODINVOCATION_ARGUMENTS, RelationTypes.METHODINVOCATION_METHOD_SELECT, - RelationTypes.NEW_CLASS_ARGUMENTS, RelationTypes.NEW_ARRAY_INIT, RelationTypes.NEW_ARRAY_DIMENSION, - RelationTypes.UNARY_ENCLOSES }; - private static final RelationTypes[] assignToOutExpr = new RelationTypes[] { RelationTypes.ARRAYACCESS_EXPR, - RelationTypes.ARRAYACCESS_INDEX, RelationTypes.ASSIGNMENT_RHS, RelationTypes.BINOP_LHS, - RelationTypes.BINOP_RHS, RelationTypes.BINOP_COND_RHS, RelationTypes.CAST_ENCLOSES, - RelationTypes.COMPOUND_ASSIGNMENT_RHS, RelationTypes.CONDITIONAL_EXPR_CONDITION, - RelationTypes.CONDITIONAL_EXPR_THEN, RelationTypes.CONDITIONAL_EXPR_ELSE, RelationTypes.INITIALIZATION_EXPR, - RelationTypes.INSTANCE_OF_EXPR, RelationTypes.MEMBER_REFERENCE_EXPRESSION, RelationTypes.MEMBER_SELECT_EXPR, - RelationTypes.METHODINVOCATION_ARGUMENTS, RelationTypes.METHODINVOCATION_METHOD_SELECT, - RelationTypes.NEW_CLASS_ARGUMENTS, RelationTypes.NEW_ARRAY_INIT, RelationTypes.NEW_ARRAY_DIMENSION, - RelationTypes.UNARY_ENCLOSES }; - private static final String assignToOutExprQuery = getAnyRel(assignToOutExpr); - private static final RelationTypes[] exprToOutExpr = new RelationTypes[] { RelationTypes.ARRAYACCESS_EXPR, - RelationTypes.ARRAYACCESS_INDEX, RelationTypes.ASSIGNMENT_LHS, RelationTypes.ASSIGNMENT_RHS, - RelationTypes.BINOP_LHS, RelationTypes.BINOP_RHS, RelationTypes.BINOP_COND_RHS, RelationTypes.CAST_ENCLOSES, - RelationTypes.COMPOUND_ASSIGNMENT_LHS, RelationTypes.COMPOUND_ASSIGNMENT_RHS, - RelationTypes.CONDITIONAL_EXPR_CONDITION, RelationTypes.CONDITIONAL_EXPR_THEN, - RelationTypes.CONDITIONAL_EXPR_ELSE, RelationTypes.INITIALIZATION_EXPR, RelationTypes.INSTANCE_OF_EXPR, - RelationTypes.MEMBER_REFERENCE_EXPRESSION, RelationTypes.MEMBER_SELECT_EXPR, - RelationTypes.METHODINVOCATION_ARGUMENTS, RelationTypes.METHODINVOCATION_METHOD_SELECT, - RelationTypes.NEW_CLASS_ARGUMENTS, RelationTypes.NEW_ARRAY_INIT, RelationTypes.NEW_ARRAY_DIMENSION, - RelationTypes.UNARY_ENCLOSES }; - - private static final String exprToOutExprQuery = getAnyRel(exprToOutExpr); - private static final RelationTypes[] statToEnclClass = new RelationTypes[] { RelationTypes.CASE_STATEMENTS, - RelationTypes.CATCH_PARAM, RelationTypes.DECLARES_FIELD, - RelationTypes.DECLARES_METHOD, RelationTypes.DECLARES_CONSTRUCTOR, RelationTypes.ENCLOSES, - RelationTypes.HAS_ENUM_ELEMENT, RelationTypes.FOREACH_STATEMENT, RelationTypes.FOREACH_VAR, - RelationTypes.FORLOOP_INIT, RelationTypes.FORLOOP_STATEMENT, RelationTypes.FORLOOP_UPDATE, - RelationTypes.CALLABLE_HAS_BODY, RelationTypes.CALLABLE_HAS_PARAMETER, RelationTypes.HAS_STATIC_INIT, - RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.IF_THEN, RelationTypes.IF_ELSE, - RelationTypes.LABELED_STMT_ENCLOSES, RelationTypes.SWITCH_ENCLOSES_CASE, RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, - RelationTypes.TRY_BLOCK, RelationTypes.TRY_CATCH, RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES }; - private static final RelationTypes[] statToOuterBlock = new RelationTypes[] { RelationTypes.CASE_STATEMENTS, - RelationTypes.CATCH_PARAM, RelationTypes.ENCLOSES, - RelationTypes.FOREACH_STATEMENT, RelationTypes.FOREACH_VAR, RelationTypes.FORLOOP_INIT, - RelationTypes.FORLOOP_STATEMENT, RelationTypes.FORLOOP_UPDATE, RelationTypes.CALLABLE_HAS_PARAMETER, - RelationTypes.HAS_STATIC_INIT, RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.IF_THEN, - RelationTypes.IF_ELSE, RelationTypes.LABELED_STMT_ENCLOSES, RelationTypes.SWITCH_ENCLOSES_CASE, - RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, RelationTypes.TRY_BLOCK, RelationTypes.TRY_CATCH, - RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES }; - private static final RelationTypes[] exprToStat = new RelationTypes[] { RelationTypes.ASSERT_CONDITION, - RelationTypes.DO_WHILE_CONDITION, RelationTypes.ENCLOSES_EXPR, RelationTypes.FOREACH_EXPR, - RelationTypes.FORLOOP_CONDITION, RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.IF_CONDITION, - RelationTypes.SWITCH_EXPR, RelationTypes.SYNCHRONIZED_EXPR, RelationTypes.THROW_EXPR, - RelationTypes.WHILE_CONDITION, RelationTypes.RETURN_EXPR }; - private static final String exprToStatQuery = getAnyRel(exprToStat); - private static final String exprToStatQueryWithReturn = getAnyRel(exprToStat) + " | :RETURN_EXPR "; - - private static final CFGRelationTypes[] cfgUnconditionalSucc = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NO_EXCEPTION, CFGRelationTypes.CFG_THROWS }; - - private static final CFGRelationTypes[] toCFGSuccesor = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, - CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, CFGRelationTypes.CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION, - CFGRelationTypes.CFG_NO_EXCEPTION, CFGRelationTypes.CFG_CAUGHT_EXCEPTION, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, - CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE, CFGRelationTypes.CFG_MAY_THROW, - CFGRelationTypes.CFG_THROWS }; - private static final CFGRelationTypes[] toCFGSuccesorNoEx = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, - CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, CFGRelationTypes.CFG_NO_EXCEPTION, - CFGRelationTypes.CFG_CAUGHT_EXCEPTION, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, - CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE }; - private static final CFGRelationTypes[] toCFGSuccesorNoCondEx = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, - CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, CFGRelationTypes.CFG_NO_EXCEPTION, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, - CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE, CFGRelationTypes.CFG_THROWS }; - private static final String cfgSuccesor = getAnyRel(toCFGSuccesor); - - public static String getAnyRel(RelationTypesInterface[] rels) { - String ret = ""; - for (RelationTypesInterface r : rels) - ret += ":" + r.toString() + " | "; - return ret.substring(0, ret.length() - 2); - } - - public QueriesWithProcedures() { - // TODO Auto-generated constructor stub - } - - // public void registerProcedures(List> toRegister) { - // EmbeddedDriver embeddedDriver = (EmbeddedDriver) Components.driver(); - // GraphDatabaseService databaseService = - // embeddedDriver.getGraphDatabaseService(); - // Procedures procedures = ((GraphDatabaseAPI) - // databaseService).getDependencyResolver().resolveDependency(Procedures.class); - // toRegister.forEach((proc) -> { - // try { - // procedures.registerProcedure(proc); - // } catch (KernelException e) { - // throw new RuntimeException("Error registering " + proc, e); - // } - // }); - // - // } - private static GraphDatabaseService createInMemoryDatabase() throws Throwable { - try { - Map config = MapUtil.stringMap("dbms.transaction.timeout", "2s", "mapped_memory_total_size", - "5M", "dbms.pagecache.memory", "5M", "keep_logical_logs", "false", "cache_type", "none", - "query_cache_size", "15"); - GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig(config) - .newGraphDatabase(); - Procedures procedures = ((GraphDatabaseAPI) db).getDependencyResolver().resolveDependency(Procedures.class); - List> apocProcedures = asList(FunctionUtils.class); - apocProcedures.forEach((proc) -> { - try { - procedures.registerFunction(proc); - } catch (KernelException e) { - throw new RuntimeException("Error registering " + proc, e); - } - }); - return db; - } catch (Throwable re) { - Throwable t = re.getCause(); - if (re instanceof LifecycleException || t instanceof LifecycleException || t instanceof Error - || re instanceof Error) { - re.printStackTrace(); - throw new IllegalStateException("Lifecycle Exception during creation of database " + re.getMessage()); - } - if (t instanceof RuntimeException) - throw (RuntimeException) t; - if (t instanceof Error) - throw (Error) t; - throw t; - } - } - private static final String[] REDUCED = { - "MATCH (varDec)-[:MODIFIED_BY]->(ass:ASSIGNMENT)-[:ASSIGNMENT_RHS]->(:LITERAL{typeKind:'NULL'})\r\n" - + " WHERE varDec:VAR_DEC OR varDec:PARAMETER_DEC\r\n" - + "OPTIONAL MATCH (varDec)-[:USED_BY|STATE_MODIFIED_BY]->(use)" - + "WITH varDec,examples.getEnclosingStmt(ass) as assStat, COLLECT(examples.getEnclosingStmt(use)) as useStats\r\n" - - + " WHERE SIZE(FILTER( succ IN examples.getAnySucc(assStat) WHERE succ IN useStats))=0\r\n" - + "RETURN " - + "'Warning [CMU-OBJ54] You must not try to help garbage collector setting references to null when they are no longer used. To make your code clearer, just delete the assignment in line ' + assStat.lineNumber + ' of the variable ' +varDec.name+ ' declared in class '+examples.getEnclosingClass(varDec).fullyQualifiedName+'.'\r\n" - + "\r\n" + "", - "MATCH (declaration{isFinal:true})-[r:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED_BY]->(mutatorExpr)\r\n" - + " WHERE NOT declaration:THIS_REF AND NOT mutatorExpr:INITIALIZATION AND (r.isInit IS NULL OR NOT r.isInit) \r\n" - + "WITH declaration,examples.getEnclosingClass(declaration) as enclClass,COLLECT(HEAD(LABELS(mutatorExpr))+', line '+mutatorExpr.lineNumber+ ', class '+ examples.getEnclosingClass(examples.getEnclosingStmt(mutatorExpr)).fullyQualifiedName) as mutatorsMessage\r\n" - + "RETURN 'Warning [CMU-OBJ50] Declaration with name '+ declaration.name+ ' in line ' + declaration.lineNumber +', class ' +enclClass.fullyQualifiedName + 'is not actually final, only the reference. Concretely, '+ declaration.name +' may be mutated in '+mutatorsMessage\r\n" - + "\r\n", - - " MATCH (closeableSubtype)-[:IS_SUBTYPE_EXTENDS | :IS_SUBTYPE_IMPLEMENTS*0..]->(closeableInt:INTERFACE_DECLARATION{fullyQualifiedName:'java.lang.AutoCloseable'})" - + " WHERE closeableSubtype:CLASS_DECLARATION OR closeableSubtype:INTERFACE_DECLARATION " - + " WITH DISTINCT closeableSubtype.fullyQualifiedName as className " - - + " MATCH (closeableDec{actualType:className})-[:MODIFIED_BY]->(assign)" - - + " WHERE closeableDec:VAR_DEC " - + " OPTIONAL MATCH (closeableDec)<-[r:TRY_RESOURCES]-() WITH examples.getEnclosingStmt(assign) as assignStat,r, closeableDec WHERE r IS NULL" - - + " UNWIND examples.getAnySuccNotItself(assignStat) as prev " - + " OPTIONAL MATCH (mInv:METHOD_INVOCATION)-[:METHODINVOCATION_METHOD_SELECT]->(mSelect:MEMBER_SELECTION{memberName:'close'})-[:MEMBER_SELECT_EXPR]->(id)<-[:USED_BY]-(closeableDec)" - - + ",(prev)-[exceptionRel:CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION | :CFG_MAY_THROW | :CFG_THROWS]->(afterEx) " - + " WITH COLLECT(DISTINCT examples.getEnclosingStmt(mInv)) AS closes, prev,closeableDec, afterEx,exceptionRel " - + "WHERE NOT prev IN closes AND ANY(prevSucc IN examples.getAnySuccNotItself(prev) WHERE prevSucc IN closes) " - - - + " OPTIONAL MATCH p=(afterEx)-[" + getAnyRel(toCFGSuccesor) // ESTE - // DEBERíA - // SER - // COND - // O - // NO - // COND - + "*0..]->(reachableAfterEx) WHERE reachableAfterEx IN closes " - + " WITH prev as prevs, closeableDec,p,exceptionRel, " + " CASE WHEN p IS NULL THEN NULL ELSE " - + " EXTRACT (index IN RANGE(0,SIZE(NODES(p))) | index=0 OR TYPE(RELATIONSHIPS(p)[index-1]) IN ['CFG_THROWS' ,'CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION' ,'CFG_MAY_THROW' ])" - + " END as previousThrow" + " WITH prevs, closeableDec,p,exceptionRel, " - + "CASE WHEN p IS NULL THEN NULL ELSE EXTRACT (index IN RANGE(0,SIZE(NODES(p))) | CASE WHEN NODES(p)[index]:CATCH_BLOCK OR previousThrow[index] AND NODES(p)[index]:VAR_DEC THEN 'catch' ELSE CASE WHEN previousThrow[index] THEN CASE WHEN index=0 THEN exceptionRel.exceptionType ELSE RELATIONSHIPS(p)[index-1].exceptionType END ELSE CASE WHEN NODES(p)[index]:TRY_BLOCK THEN 'newtry' ELSE NULL END END END )END" - + " as exFlow" - + " WITH p,closeableDec,prevs,CASE WHEN p IS NULL THEN NULL ELSE EXTRACT( relIndex IN RANGE(0,SIZE(RELATIONSHIPS(p))) | exFlow[LAST(FILTER( exIndex IN RANGE(0,SIZE(exFlow)) WHERE exIndex<=relIndex AND NOT exFlow[exIndex] IS NULL))]) END as exFlow " - + " WITH closeableDec,prevs," - + " NOT ANY(x IN COLLECT(CASE WHEN p IS NULL THEN FALSE ELSE ALL(relIndex IN RANGE(0,SIZE(RELATIONSHIPS(p))) WHERE CASE WHEN TYPE(RELATIONSHIPS(p)[relIndex])='CFG_NO_EXCEPTION' THEN exFlow[relIndex] IN ['catch' , 'newtry'] ELSE CASE WHEN TYPE(RELATIONSHIPS(p)[relIndex])='CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION' THEN exFlow[relIndex]=RELATIONSHIPS(p)[relIndex].exceptionType ELSE TRUE END END )END)WHERE x) as truePathToClose" - + " WITH closeableDec,COLLECT(prevs) as prevs, COLLECT(truePathToClose) as truePathToClose" - + " WHERE ANY ( x IN truePathToClose WHERE x) " - - + " RETURN 'Warning [CMU-ERR54] variable '+closeableDec.name+ '(defined in line'+closeableDec.lineNumber+', class '+examples.getEnclosingClass(closeableDec).fullyQualifiedName+') might not be properly closed, as statement(s) (in lines '+ EXTRACT(prev IN prevs | prev.lineNumber)+') may throw an exception.'", - - " MATCH (typeDec)-[:DECLARES_FIELD]->(attr:ATTR_DEC) " - + " WHERE NOT (attr.accessLevel='public' OR attr.accessLevel='protected' AND NOT typeDec.isFinal) AND " - + " NOT( attr.isStatic AND attr.actualType='long' AND attr.isFinal AND attr.name='serialVersionUID') " - - + " OPTIONAL MATCH (attr)-[:USED_BY]->(exprUse)" - - + "WITH typeDec.fullyQualifiedName as className, attr,examples.getEnclosingStmt(exprUse) as exprUseStat , exprUse" - + " OPTIONAL MATCH (attr)-[:MODIFIED_BY]->(modif)" - - + "-[:ASSIGNMENT_LHS]->(lhs_expr) WHERE examples.getEnclosingMethod(examples.getEnclosingStmt(modif))=examples.getEnclosingMethod(exprUseStat) AND examples.getEnclosingStmt(modif).position < exprUseStat.position " - + " OPTIONAL MATCH (exprUse)-[:MEMBER_SELECT_EXPR]->(memberSelectExprUse)<-[:USED_BY]-(varDec) " - + " OPTIONAL MATCH p=(varDec)-[:STATE_MODIFIED_BY]->(modif)" - + " OPTIONAL MATCH (lhs_expr)-[:MEMBER_SELECT_EXPR]->(memberSelectExprModif) " - + " WITH p,className, attr.lineNumber as line, attr.name as attr,exprUse, modif,lhs_expr, memberSelectExprUse, memberSelectExprModif, exprUseStat,examples.getEnclosingStmt(modif) as exprModStat " - + " OPTIONAL MATCH q=(exprModStat)<-[" + getAnyRel(statToOuterBlock) - + "*0..]-(minimumCommonBlock), (minimumCommonBlock)-[" + getAnyRel(statToOuterBlock) - + "*0..]->(exprUseStat) " + " WITH className, attr, exprUse,line, " + " ANY(x IN " + "COLLECT(" - + " " + "( " - + " NOT ANY(rel IN RELS(q) WHERE type(rel)='IF_ELSE' OR type(rel)='FORLOOP_UPDATE' OR type(rel)='FORLOOP_STATEMENT' OR type(rel)='FOREACH_STATEMENT' OR type(rel)='TRY_CATCH' OR type(rel)='SWITCH_ENCLOSES_CASES' OR type(rel)='IF_THEN') " - + " AND (" - + " (exprUse:IDENTIFIER OR (NOT memberSelectExprUse IS NULL AND memberSelectExprUse:IDENTIFIER AND (memberSelectExprUse.name='this' OR memberSelectExprUse.name='super')))" - + " AND (lhs_expr:IDENTIFIER OR (NOT memberSelectExprModif IS NULL AND memberSelectExprModif:IDENTIFIER AND (memberSelectExprModif.name='this' OR memberSelectExprModif.name='super')))" - + " ) " + " OR " - + " (p IS NOT NULL AND NOT memberSelectExprUse IS NULL AND NOT memberSelectExprModif IS NULL AND memberSelectExprUse:IDENTIFIER AND memberSelectExprModif:IDENTIFIER)" - + ")" + ") " + " WHERE x) as useWithModif " - + " WITH line,className, attr , ALL( x IN COLLECT(useWithModif) WHERE x) OR exprUse IS NULL as isSillyAttr WHERE isSillyAttr" - + " RETURN 'Warning [CMU-DCL53] You must minimize the scope of the varaibles. You can minimize the scope of the attribute '+attr+'(declared in line '+line+') in class '+className + ' by transforming it into a local varaible (as everytime its value is used in a method, there is a previous unconditional assignment).' ORDER BY attr", - - "MATCH (enclosingType)-[:DECLARES_FIELD]->(field:ATTR_DEC)-[:USED_BY]->(retExpr)<-[:RETURN_EXPR]-(retStat)" - + " WITH enclosingType,field,examples.getEnclosingMethod(retStat) as method WHERE method:METHOD_DEC AND method.accessLevel='public' MATCH (method)" - + "<-[:DECLARES_METHOD]-(classExposingF{accessLevel:'public', isAbstract:false})\r\n" - + " WHERE NOT field.accessLevel='public' AND (NOT field.accessLevel='protected' OR classExposingF.isFinal)\r\n" - + "MATCH (field)-[:ITS_TYPE_IS]->(fieldType)<-[:IS_SUBTYPE_EXTENDS|IS_SUBTYPE_IMPLEMENTS*0..]-(fieldTypeOrSubtype),\r\n" - + "accessibleMembers=(fieldTypeOrSubtype)-[:DECLARES_FIELD|ITS_TYPE_IS|INHERITS_FIELD*0..]->(accessibleMember)\r\n" - + "WITH field,fieldType=fieldTypeOrSubtype as isFieldType,enclosingType, method,accessibleMember,fieldTypeOrSubtype, NODES(accessibleMembers) as accessibleMembers\r\n" - + "WITH field,isFieldType,enclosingType, accessibleMembers,accessibleMember,fieldTypeOrSubtype, COLLECT(DISTINCT method.fullyQualifiedName+'( line '+method.lineNumber+')') as publicGetters, EXTRACT(index IN RANGE(0,SIZE( accessibleMembers)-1,1) | [CASE WHEN index=0 THEN field ELSE accessibleMembers[index-1] END, accessibleMembers[index]]) as accessibleMembersAndPrevs\r\n" - + "WITH field,isFieldType,enclosingType, accessibleMembers,accessibleMember,fieldTypeOrSubtype, publicGetters, accessibleMembersAndPrevs,LAST(accessibleMembersAndPrevs)[0] as accessibleMemberPrev\r\n" - + "UNWIND accessibleMembersAndPrevs as accMemberAndPrev\r\n" - + "OPTIONAL MATCH (accesibleField)-[:USED_BY]->(fieldExpr)<-[:RETURN_EXPR]-(returnStat)," - + "(method{accessLevel:'public'})<-[:DECLARES_METHOD|INHERITS_METHOD]-(accessibleType) WHERE examples.getEnclosingMethod(returnStat)=method " - + "\r\n" - + " AND ID(accesibleField)=ID(accMemberAndPrev[1]) AND ID(accessibleType)=ID(accMemberAndPrev[0])\r\n" - + "WITH field,isFieldType,enclosingType, method,publicGetters,accMemberAndPrev as accMemberOrType, accessibleMembers, accessibleMember,accessibleMemberPrev,fieldTypeOrSubtype, COLLECT(method) as gettersForCurrentMember\r\n" - + "WITH field,isFieldType,enclosingType,fieldTypeOrSubtype,publicGetters,accessibleMember,accessibleMemberPrev, accessibleMembers, COLLECT( CASE WHEN accMemberOrType[1]:ATTR_DEC THEN NOT accMemberOrType[1].isStatic AND (accMemberOrType[1].accessLevel='public' OR SIZE(gettersForCurrentMember)>0) ELSE CASE WHEN accMemberOrType[1]:ARRAY_TYPE THEN TRUE ELSE EXISTS(accMemberOrType[1].accessLevel) AND accMemberOrType[1].accessLevel='public' END END) as isAccesible \r\n" - + "WITH DISTINCT field,isFieldType,fieldTypeOrSubtype, enclosingType, publicGetters, accessibleMember,accessibleMemberPrev, ALL( isAccHere IN isAccesible WHERE isAccHere) as isExternallyAcc\r\n" - + "OPTIONAL MATCH (accessibleMember)-[:DECLARES_METHOD|INHERITS_METHOD]->(mutator:METHOD_DEC{accessLevel:'public'})<-[:STATE_MAY_BE_MODIFIED_BY|STATE_MODIFIED_BY]-(:THIS_REF)\r\n" - + "WITH field,isFieldType,fieldTypeOrSubtype,enclosingType, publicGetters,COLLECT(DISTINCT 'MUTATOR METHOD '+mutator.fullyQualifiedName+'( line '+mutator.lineNumber +')') as allMut, EXTRACT(accField IN FILTER(accMember IN COLLECT(DISTINCT accessibleMember) WHERE accMember:ATTR_DEC AND NOT accMember.isStatic AND NOT accMember.isFinal AND accMember.accessLevel='public') | 'PUBLIC NON-FINAL FIELD '+accField.name+'( line'+accField.lineNumber+')') as externallyMutableFields,FILTER(x IN COLLECT( DISTINCT [accessibleMember:ARRAY_TYPE AND isExternallyAcc,'ACCESIBLE ARRAY FIELD ' + accessibleMemberPrev.name+' (line ' +accessibleMemberPrev.lineNumber+')']) WHERE x[0]) as arrayFieldsExposed\r\n" - + "WITH field,isFieldType,enclosingType,publicGetters,fieldTypeOrSubtype.fullyQualifiedName as fieldTypeOrSubtype,allMut,externallyMutableFields, arrayFieldsExposed, SIZE(allMut)>0 OR SIZE(externallyMutableFields)>0 OR SIZE(arrayFieldsExposed)>0 as isExtMutable\r\n" - + " WHERE CASE WHEN isFieldType THEN isExtMutable ELSE NOT isExtMutable END \r\n" - + "WITH field,enclosingType,publicGetters,EXTRACT(subtypeNameInfo IN FILTER(subtypeNameInfo IN COLLECT([isFieldType,fieldTypeOrSubtype]) WHERE NOT subtypeNameInfo[0])| subtypeNameInfo[1]) as immutableSubtypes,FILTER(subTypePair IN COLLECT([isFieldType, allMut+externallyMutableFields+arrayFieldsExposed]) WHERE subTypePair[0])[0][1] as mutabilityInfo\r\n" - + " WHERE NOT mutabilityInfo IS NULL\r\n" - + "RETURN 'Warning[OBJ-56] Field ' +field.name+' declared in line ' +field.lineNumber+' in class '+enclosingType.fullyQualifiedName+' is not public, but it is exposed in public methods such as '+ publicGetters+'. The problem is that there is at least one member ( like '+mutabilityInfo+')that can be accessed by a client to change the state of the field '+field.name + CASE WHEN SIZE(immutableSubtypes)=0 THEN '. You should implement an appropiate inmutable subtype as a wrapper for your attribute, as you have not created any yet.'ELSE '. Remember to use an appropiate inmutable subtype (such as '+immutableSubtypes+') as a wrapper for your attribute.'END\r\n" - + "\r\n" + "" }; - - private static final String QUERY_EXAMPLE = "MATCH (variable:VARIABLE_DEF{isFinal:true})-[mutation:STATE_MODIFIED_BY|STATE_MAY_BE_MODIFIED_BY]->(mutatorExpr)\r\n" - + "WITH variable, mutation, mutatorExpr, database.procedures.getEnclMethodFromExpr(mutatorExpr) as mutatorMethod\r\n" - + "MATCH (mutatorMethod)<-[:DECLARES_METHOD|DECLARES_CONSTRUCTOR| HAS_STATIC_INIT]-(mutatorEnclClass)<-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]-(mutatorCU)\r\n" - + "WHERE NOT(variable:ATTR_DEF AND mutation.isOwnAccess AND mutatorMethod.isInitializer) \r\n" - + " WITH variable, database.procedures.getEnclosingClass(variable) as variableEnclClass, REDUCE(seed='', mutationWarn IN COLLECT( ' Line ' + mutatorExpr.lineNumber + ', column ' + mutatorExpr.column + ', file \\''+ mutatorCU.fileName + '\\'') | seed+'\\n'+ mutationWarn ) as mutatorsMessage\r\n" - + "MATCH (variableEnclClass)<-[:HAS_TYPE_DEF | :HAS_INNER_TYPE_DEF]-(variableCU:COMPILATION_UNIT)\r\n" - + "RETURN 'Warning [CMU-OBJ50] The state of variable \\''+ variable.name + '\\' (in line ' + variable.lineNumber +', file \\'' + variableCU.fileName + '\\') is mutated, but declared final. The state of, \\''+ variable.name +'\\' is mutated in :' + mutatorsMessage\r\n" - - ; - - public static void main(String[] args) throws IOException { - int queryIndex = args.length == 0 ? 7 : Integer.parseInt(args[0]); - try { - - GraphDatabaseService gs = EmbeddedDBManager.getNewEmbeddedDBService(); - // EmbeddedDriver embeddedDriver = (EmbeddedDriver) - // Components.driver(); - // GraphDatabaseService databaseService = - // embeddedDriver.getGraphDatabaseService(); - for (Class c : new Class[] { EnclosingStmt.class, AnySucc.class }) - ((GraphDatabaseAPI) gs).getDependencyResolver() - .resolveDependency(Procedures.class, DependencyResolver.SelectionStrategy.FIRST) - .registerFunction(c); - // ((GraphDatabaseAPI) - // gs).getDependencyResolver().resolveDependency(Join.class,null).register(Join.class); - - System.out.println(gs.getClass()); - // Rule rule = new Rule(" RETURN examples.join(['y','o'],',')"); - Rule rule = new Rule(QUERY_EXAMPLE - - ); - if (args.length == 0) - System.out.println(rule.queries[0]); - long ini = System.nanoTime(); - String res = rule.execute(gs).resultAsString(); - long end = System.nanoTime(); - System.err.println(res); - System.out.print((end - ini) / 1000_000); - if (args.length == 0) { - int size = 0; - - } - } catch (Throwable t) { - t.printStackTrace(new PrintStream(new FileOutputStream("err" + queryIndex + ".txt"))); - BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt")); - // bw.write(RULES[queryIndex].queries[0]); - bw.close(); - System.out.println("-1"); - } - } -} diff --git a/ProgQuery/src/database/querys/eval/Query.java b/ProgQuery/src/database/querys/eval/Query.java deleted file mode 100644 index 77b5865..0000000 --- a/ProgQuery/src/database/querys/eval/Query.java +++ /dev/null @@ -1,8 +0,0 @@ -package database.querys.eval; - -public interface Query { - - String queryToString(); - - -} diff --git a/ProgQuery/src/database/querys/eval/RuleDetectionQueries.java b/ProgQuery/src/database/querys/eval/RuleDetectionQueries.java deleted file mode 100644 index aa83e84..0000000 --- a/ProgQuery/src/database/querys/eval/RuleDetectionQueries.java +++ /dev/null @@ -1,79 +0,0 @@ -package database.querys.eval; - -import java.io.IOException; - -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Result; - -import database.embedded.EmbeddedDBManager; - -public class RuleDetectionQueries { - public static final String ALL_NODES = "MATCH (n)-[r]->(m) RETURN n, labels(n),r,m, labels(m)"; - public static final String COVARIANT_ASSIGNMENTS = "match (n)-[:ASSIGNMENT_LHS]->(lhsNode), " - + "(n)-[:RHS]->(rhsNode)" + ", (u:COMPILATION_UNIT)-[]->(c:CLASS_DECLARATION)-[]->(temp)-[:ENCLOSES]->(n) " - + "WHERE( lhsNode.typeKind='ARRAY'" + " AND rhsNode.typeKind='ARRAY'" - + " AND lhsNode.actualType <> rhsNode.actualType)" - + " return distinct u.projectName, u.fileName, c.name, rhsNode.lineNumber, lhsNode.actualType, rhsNode.actualType LIMIT 10;"; - public static final String COUNT_OVERLOADED = "MATCH (p:COMPILATION_UNIT)-[]->(c:CLASS_DECLARATION)-[:DECLARES]->(n: METHOD_DEC)" - + "WHERE NOT(n.name = '') AND c.name <> \"\" " - + "WITH n.name +\"[sep]\"+ c.name + \"[sep]\"+ p.fileName as method, count(method) as overloadedCount " - + "WHERE overloadedCount > 1 RETURN SUM(overloadedCount) as total;"; - - public static final String WILDCARDS = "MATCH (p:COMPILATION_UNIT)-[:HAS_TYPE_DEF]->(c:CLASS_DECLARATION)-[*]->(n) " - + " RETURN DISTINCT labels(n), p.fileName, n.lineNumber,n, c.fullyQualifiedName ;"; - - public static final String COUNT_DISTINCT_ONLY_METHODS = "MATCH (c)-[:DECLARES_METHOD]->(n:METHOD_DEC) " - + "WHERE c:CLASS_DECLARATION OR c:INTERFACE_DECLARATION RETURN n.fullyQualifiedName"; - - public static final String GET_DISTINCT_METHODS_SIMPLE = "MATCH (n:METHOD_DEC) " - + " RETURN DISTINCT n.fullyQualifiedName"; - - public static final String COUNT_DISTINCT_ONLY_METHODS_UNION_BIS = "MATCH (c:CLASS_DECLARATION)-[:DECLARES_METHOD]->(n) UNION MATCH (c:INTERFACE_DECLARATION)-[:DECLARES_METHOD]->(n) RETURN n.fullyQualifiedName"; - - public static final String COUNT_DISTINCT_TYPE_DECS = "MATCH (c)" - + "WHERE c:CLASS_DECLARATION OR c:INTERFACE_DECLARATION OR c:ENUM_DECLARATION RETURN COUNT(c)"; - - public static final String DELETE_ALL = "MATCH (n) DETACH DELETE n"; - - // Lvl0 Wiggle can do it as quickly as our system - public static final String ALL_NODES_COUNT = "MATCH (n) RETURN COUNT(n)"; - public static final String COMPILATION_UNITS_COUNT = "MATCH (cu:COMPILATION_UNIT) RETURN COUNT(cu)"; - - // lvl 1 Wiggle can do it with a more complex query and not 100% correctly - // like uor system - public static final String GET_DISTINCT_DECLARED_METHODS_SIMPLE = "MATCH ()-[:DECLARES_METHOD]->(n) " - + " RETURN DISTINCT n.fullyQualifiedName"; - - public static final String GET_INTERFACE_COUNT = "MATCH (n:INTERFACE_DECLARATION) " + " RETURN n"; - - // COVARIANCE ARRAYS - - public static final String COVARIANT_ARRAY_ASSIGNMENTS = "MATCH (c)-[:DECLARES_METHOD ]->(m)-[*]->(a), (l)<-[:ASSIGNMENT_LHS]-(a:ASSIGNMENT)-[:ASSIGNMENT_RHS]->(r) " - + "WHERE l.typeKind='ARRAY' AND l.actualType<>r.actualType " + "return distinct a,l,r,m,c"; - - public static final String OVERLOADED_FETCH = "MATCH ()-[:DECLARES_METHOD]->(n) WITH count(n.completeName) as overloadedCount, n.completeName as name WHERE overloadedCount>1 RETURN name,overloadedCount ;"; - - public static final String FOR_PARAMS_FAVOR_INTERFACES_OVER_CLASSES = "MATCH (c)-[:DECLARES_METHOD]->(m)" - + "-[:CALLABLE_HAS_PARAMETER]->(param)-[:USED_BY]->(id)<-[:MEMBER_SELECT_EXPR]-(ms)<-[:METHODINVOCATION_METHOD_SELECT]-(mi)-[:HAS_DEF]->(mid)<-[:DECLARES_METHOD]-(interface)," - + "(paramClass)-[:IS_SUBTYPE_IMPLEMENTS]->(interface) " - - + "WHERE paramClass.fullyQualifiedName=param.actualType AND c.accessLevel='public' AND m.accessLevel='public' RETURN c,m,param, mid,interface"; - - public static final String[] QUERIES = new String[] { COMPILATION_UNITS_COUNT, GET_DISTINCT_METHODS_SIMPLE, - GET_INTERFACE_COUNT, COVARIANT_ARRAY_ASSIGNMENTS, OVERLOADED_FETCH, FOR_PARAMS_FAVOR_INTERFACES_OVER_CLASSES }; - - // Controlar si se puede sobreescribir el equals metiendo primitivas al - // parametro - public static void main(String[] args) throws IOException { - int queryIndex = args.length == 0 ? 4 : Integer.parseInt(args[0]); - GraphDatabaseService gs = EmbeddedDBManager.getNewEmbeddedDBService(); - String query = QUERIES[queryIndex]; - System.err.println(queryIndex + "\n" + query); - long ini = System.nanoTime(); - Result res = gs.execute(query); - long end = System.nanoTime(); - res.toString().length(); - System.out.print((end - ini) / 1000_000); - // gs.execute(DELETE_ALL); - } -} diff --git a/ProgQuery/src/database/querys/eval/ServerAnyQueries.java b/ProgQuery/src/database/querys/eval/ServerAnyQueries.java deleted file mode 100644 index 74e5bda..0000000 --- a/ProgQuery/src/database/querys/eval/ServerAnyQueries.java +++ /dev/null @@ -1,55 +0,0 @@ -package database.querys.eval; - -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.PrintStream; -import java.util.List; - -import org.neo4j.driver.v1.Record; - -import database.querys.ServerQueryManager; -import evaluation.Rule; - -public class ServerAnyQueries { - - public static void main(String[] args) throws Exception { - - try { - Rule rule = new Rule(args[0]); - // if (args.length == 0) - // System.out.println(rule.queries[0]); - // long ini = System.nanoTime(); - List l = ServerQueryManager.SERVER_MANAGER.executeQuery(rule.queries[0]); - System.out.println("Number of results: " + l.size()); - l.get(0).keys().forEach(recordColumn -> System.out.print(recordColumn + "\t")); - System.out.println(); - l.forEach(r -> { - r.values().forEach(v -> { - - System.out.print("NODE[" + v.asNode().id() + "]:"); - v.asNode().labels().forEach(label -> System.out.println(label + ",")); - v.asNode().keys().forEach( - nodeProp -> System.out.print("\t" + nodeProp + ":" + v.asNode().get(nodeProp))); - }); - System.out.println(); - }); - // long end = System.nanoTime(); - // l.stream().map(r -> - // r.get(0).asString()).collect(Collectors.toList()).forEach(System.err::println); - // System.out.println((end - ini) / 1000_000); - if (args.length == 0) { - - } - } catch (Throwable t) { - t.printStackTrace(); - t.printStackTrace(new PrintStream(new FileOutputStream("err_" + args[0] + ".txt"))); - BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt")); - bw.write(args[0]); - bw.close(); - System.out.println("-1"); - } finally { - ServerQueryManager.SERVER_MANAGER.close(); - } - } -} diff --git a/ProgQuery/src/database/querys/eval/ServerCountQueries.java b/ProgQuery/src/database/querys/eval/ServerCountQueries.java deleted file mode 100644 index c7dce2c..0000000 --- a/ProgQuery/src/database/querys/eval/ServerCountQueries.java +++ /dev/null @@ -1,43 +0,0 @@ -package database.querys.eval; - -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.PrintStream; -import java.util.List; - -import org.neo4j.driver.v1.Record; - -import database.querys.ServerQueryManager; -import evaluation.Rule; - -public class ServerCountQueries { - - public static void main(String[] args) throws Exception { - - try { - Rule rule = new Rule(args[0]); - // if (args.length == 0) - // System.out.println(rule.queries[0]); - // long ini = System.nanoTime(); - List l = ServerQueryManager.SERVER_MANAGER.executeQuery(rule.queries[0]); - System.out.println(l.get(0).get(0).asInt() + ""); - // long end = System.nanoTime(); - // l.stream().map(r -> - // r.get(0).asString()).collect(Collectors.toList()).forEach(System.err::println); - // System.out.println((end - ini) / 1000_000); - if (args.length == 0) { - - } - } catch (Throwable t) { - t.printStackTrace(); - t.printStackTrace(new PrintStream(new FileOutputStream("err_" + args[0] + ".txt"))); - BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt")); - bw.write(args[0]); - bw.close(); - System.out.println("-1"); - } finally { - ServerQueryManager.SERVER_MANAGER.close(); - } - } -} diff --git a/ProgQuery/src/database/querys/eval/ServerQueries.java b/ProgQuery/src/database/querys/eval/ServerQueries.java deleted file mode 100644 index 8a0074d..0000000 --- a/ProgQuery/src/database/querys/eval/ServerQueries.java +++ /dev/null @@ -1,50 +0,0 @@ -package database.querys.eval; - -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.PrintStream; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import org.neo4j.driver.v1.Record; - -import database.querys.ServerQueryManager; -import evaluation.Rule; - -public class ServerQueries { - - public static void main(String[] args) throws Exception { - int queryIndex = args.length == 0 ?8 : Integer.parseInt(args[0]); - try { - Rule rule = new Rule(CMUQueries.RULES[queryIndex].queries[0]); - Set listQueryIndexes = new HashSet<>(); - listQueryIndexes.add(11); - listQueryIndexes.add(7); - // if (args.length == 0) - // System.out.println(rule.queries[0]); - ServerQueryManager.SERVER_MANAGER = new ServerQueryManager("Oscar", "pass", "address"); - - long ini = System.nanoTime(); - List l = ServerQueryManager.SERVER_MANAGER.executeQuery(rule.queries[0]); - long end = System.nanoTime(); -// l.stream().map(r-> r.); - l.stream().map(r -> listQueryIndexes.contains(queryIndex) ? r.get(0).asList() : r.get(0).asString()).collect(Collectors.toList()).forEach(System.err::println); - System.out.print((end - ini) / 1000_000); - if (args.length == 0) { - - } - } catch (Throwable t) { - t.printStackTrace(new PrintStream(new FileOutputStream("err" + queryIndex + ".txt"))); - BufferedWriter bw = new BufferedWriter(new FileWriter("out.txt")); - bw.write(CMUQueries.RULES[queryIndex].queries[0]); - bw.close(); - System.out.println("-1"); - } finally { - ServerQueryManager.SERVER_MANAGER.close(); - System.exit(0); - } - } -} diff --git a/ProgQuery/src/database/querys/services/AssignmentServices.java b/ProgQuery/src/database/querys/services/AssignmentServices.java deleted file mode 100644 index 41961f7..0000000 --- a/ProgQuery/src/database/querys/services/AssignmentServices.java +++ /dev/null @@ -1,22 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.Node; - -public interface AssignmentServices { - - public static final AssignmentServices PROG_QUERY = new AssignmentServicesProgQueryImpl(); - public static final AssignmentServices WIGGLE = new AssignmentServicesWiggle(); - - public MatchElement getRightPartAssignments(Node assign, Node rhs); - - public MatchElement getRightPartAssignments(Node rhs); - - public MatchElement getLeftPartAssignments(MatchElement assign); - - public MatchElement getLeftPartAssignments(MatchElement assign, MatchElement id); - - public MatchElement getMemberSelectionsLeftSide(MatchElement assign); - - public MatchElement getLeftMostId(MatchElement assign); -} diff --git a/ProgQuery/src/database/querys/services/AssignmentServicesProgQueryImpl.java b/ProgQuery/src/database/querys/services/AssignmentServicesProgQueryImpl.java deleted file mode 100644 index 19b8f26..0000000 --- a/ProgQuery/src/database/querys/services/AssignmentServicesProgQueryImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package database.querys.services; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.relations.PDGRelationTypes; -import database.relations.RelationTypes; -import utils.dataTransferClasses.Pair; - -public class AssignmentServicesProgQueryImpl implements AssignmentServices { - - public Path getRightPartAssignmentsAndVarDeclarations(Node varDec, Node rhsExpr) { - return new Path(varDec, - Pair.create(new EdgeImpl(PDGRelationTypes.MODIFIED_BY), new CompleteNode("ass", NodeTypes.ASSIGNMENT)), - Pair.create(new EdgeImpl(RelationTypes.ASSIGNMENT_RHS), - new CompleteNode(NodeTypes.LITERAL, Pair.create("typeKind", "NULL")))); - } - - public Path getRightPartAssignmentsAndVarDeclarations(Node varDec) { - return getRightPartAssignmentsAndVarDeclarations(varDec, new NodeVar("rhsExp")); - } - - @Override - public Path getRightPartAssignments(Node assign, Node rhs) { - return new Path(rhs, Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypes.ASSIGNMENT_RHS), assign)); - } - - @Override - public Path getRightPartAssignments(Node rhs) { - return getRightPartAssignments(new CompleteNode("assign", NodeTypes.ASSIGNMENT), rhs); - } - - @Override - public MatchElement getLeftPartAssignments(MatchElement assign) { - return getLeftPartAssignments(assign, new NodeVar("id")); - } - - @Override - public MatchElement getLeftPartAssignments(MatchElement assign, MatchElement id) { - return new Path(assign, Pair.create(new EdgeImpl(RelationTypes.ASSIGNMENT_LHS), id)); - - } - - @Override - public MatchElement getMemberSelectionsLeftSide(MatchElement assign) { - throw new IllegalStateException(); - } - - @Override - public MatchElement getLeftMostId(MatchElement assign) { - throw new IllegalStateException(); - } -} diff --git a/ProgQuery/src/database/querys/services/AssignmentServicesWiggle.java b/ProgQuery/src/database/querys/services/AssignmentServicesWiggle.java deleted file mode 100644 index 4c70c70..0000000 --- a/ProgQuery/src/database/querys/services/AssignmentServicesWiggle.java +++ /dev/null @@ -1,33 +0,0 @@ -package database.querys.services; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.Path; -import database.relations.RelationTypesWiggle; -import utils.dataTransferClasses.Pair; - -public class AssignmentServicesWiggle extends AssignmentServicesProgQueryImpl { - @Override - public Path getRightPartAssignments(Node rhs) { - return getRightPartAssignments(Node.nodeForWiggle("assign", NodeTypes.ASSIGNMENT), rhs); - } - - @Override - public MatchElement getMemberSelectionsLeftSide(MatchElement assign) { - return getLeftPartAssignments(assign).append(Pair.create( - new EdgeImpl(Cardinalidad.MIN_TO_INF(0), RelationTypesWiggle.ARRAYACCESS_EXPR, - RelationTypesWiggle.MEMBER_SELECT_EXPR), - Node.nodeForWiggle("memberSelection", NodeTypes.MEMBER_SELECTION))); - } - - @Override - public MatchElement getLeftMostId(MatchElement assign) { - return getLeftPartAssignments(assign).append(Pair.create( - new EdgeImpl(Cardinalidad.MIN_TO_INF(0), RelationTypesWiggle.ARRAYACCESS_EXPR, - RelationTypesWiggle.MEMBER_SELECT_EXPR), - Node.nodeForWiggle("leftMostId", NodeTypes.IDENTIFIER))); - } -} diff --git a/ProgQuery/src/database/querys/services/CFGServices.java b/ProgQuery/src/database/querys/services/CFGServices.java deleted file mode 100644 index 5e045b5..0000000 --- a/ProgQuery/src/database/querys/services/CFGServices.java +++ /dev/null @@ -1,17 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.Element; -import database.querys.cypherWrapper.MatchElement; - -public interface CFGServices { - - public static final CFGServices PROG_QUERY = new CFGServicesProgQueryImpl(); - public static final CFGServices WIGGLE = new CFGServicesWiggle(); - - // public static final PDGServices WIGGLE = ; - public Element getCFGSuccesorsOf(MatchElement stat); - - public Element getCFGSuccesorsOf(MatchElement stat, String elementsToPreserve); - // (assignStat)-[" + cfgSuccesor + "*0..]->(useStat) " - public MatchElement getCFGSuccesorsAndItSelfOf(MatchElement p); -} diff --git a/ProgQuery/src/database/querys/services/CFGServicesProgQueryImpl.java b/ProgQuery/src/database/querys/services/CFGServicesProgQueryImpl.java deleted file mode 100644 index 39f7365..0000000 --- a/ProgQuery/src/database/querys/services/CFGServicesProgQueryImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.Element; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.relations.CFGRelationTypes; -import utils.dataTransferClasses.Pair; - -public class CFGServicesProgQueryImpl implements CFGServices { - private static final CFGRelationTypes[] toCFGSuccesor = new CFGRelationTypes[] { - CFGRelationTypes.CFG_NEXT_STATEMENT, CFGRelationTypes.CFG_NEXT_STATEMENT_IF_TRUE, - CFGRelationTypes.CFG_NEXT_STATEMENT_IF_FALSE, CFGRelationTypes.CFG_FOR_EACH_HAS_NEXT, - CFGRelationTypes.CFG_FOR_EACH_NO_MORE_ELEMENTS, CFGRelationTypes.CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION, - CFGRelationTypes.CFG_NO_EXCEPTION, CFGRelationTypes.CFG_CAUGHT_EXCEPTION, - CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_BREAK, CFGRelationTypes.CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, - CFGRelationTypes.CFG_SWITCH_CASE_IS_EQUAL_TO, CFGRelationTypes.CFG_SWITCH_DEFAULT_CASE, CFGRelationTypes.CFG_MAY_THROW, - CFGRelationTypes.CFG_THROWS }; - - public Path getCFGSuccesorsOf(MatchElement stat) { - return getCFGSuccesorsAndItSelfOf(new Path(stat)); - } - - // (assignStat)-[" + cfgSuccesor + "*0..]->(useStat) " - public Path getCFGSuccesorsAndItSelfOf(MatchElement p) { - return p.append(Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), toCFGSuccesor), new NodeVar("succ"))); - } - - @Override - public Element getCFGSuccesorsOf(MatchElement stat, String elementsToPreserve) { - throw new IllegalStateException(); - } - -} diff --git a/ProgQuery/src/database/querys/services/CFGServicesWiggle.java b/ProgQuery/src/database/querys/services/CFGServicesWiggle.java deleted file mode 100644 index 847ae4a..0000000 --- a/ProgQuery/src/database/querys/services/CFGServicesWiggle.java +++ /dev/null @@ -1,221 +0,0 @@ -package database.querys.services; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Any; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.ClauseImpl; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.Element; -import database.querys.cypherWrapper.Extract; -import database.querys.cypherWrapper.Filter; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.MultipleClauses; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.Reduce; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.WhereClause; -import database.relations.RelationTypesWiggle; -import utils.dataTransferClasses.Pair; - -public class CFGServicesWiggle implements CFGServices { - - @Override - public Element getCFGSuccesorsOf(MatchElement stat) { - throw new IllegalStateException(); - } - - public Clause OLDgetCFGSuccesorsOf(MatchElement stat, String namesToPreserveInWith) { - String statNodeName = stat.getLastNode().getName(); - return new MultipleClauses( - new MatchClause(new Path( - StatementServices.WIGGLE.getOuterBlockFromStatement(stat, new NodeVar("block")), - Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, RelationTypesWiggle.HAS_METHODDECL_BODY), - database.querys.cypherWrapper.Node.nodeForWiggle(NodeTypes.METHOD_DEF)))), - new MatchClause(true, StatementServices.WIGGLE.getStatementsInStatement(new NodeVar("block"))), - getUnreachebleStats("if", statNodeName, RelationTypesWiggle.IF_ELSE, RelationTypesWiggle.IF_THEN), - - getUnreachebleStats("switch", new NodeVar("case"), new NodeVar("otherCase"), - stat.getLastNode() - .getName(), - RelationTypesWiggle.SWITCH_ENCLOSES_CASES), - new MatchClause(true, - StatementServices.WIGGLE.getUnconditionalStatementsInStatement( - new RelationshipImpl(new NodeVar("switch"), new NodeVar("c"), - new EdgeImpl(RelationTypesWiggle.SWITCH_ENCLOSES_CASES)), - Node.nodeForWiggle(NodeTypes.BREAK_STATEMENT))) - // , - // new SimpleWithClause(namesToPreserveInWith, "ifRel", - // "switch", "if", "case", - // "otherCase IS NULL OR NOT " - // + new Any("COLLECT(DISTINCT c)", - // " x.position>=case.position AND x.position < - // otherCase.position").expToString() - // + " as isSucc, innerStatement,otherifRel,otherCase") - , - - getUnreachebleStats("for", - new WhereClause(WhereClause.isElementOfWiggleType("for", NodeTypes.FOR_LOOP, - NodeTypes.WHILE_LOOP, NodeTypes.FOR_EACH_LOOP, NodeTypes.DO_WHILE_LOOP)), - statNodeName, RelationTypesWiggle.FORLOOP_STATEMENT, RelationTypesWiggle.FORLOOP_UPDATE, - RelationTypesWiggle.ENCLOSES, RelationTypesWiggle.FOREACH_STATEMENT), - getUnreachebleStats("catch", statNodeName, RelationTypesWiggle.TRY_CATCH) - - // new WithClause(new String[] { - // // "assign", "stat", "enclClass", "varDec", - // // "identifications", - // namesToPreserveInWith, - // "innerStatement", "ifRel", "switch", "if", "otherifRel", - // "otherCase", "for", "forRel", - // "otherforRel", "catch", "catchRel", "othercatchRel", "case" - // }, - // Pair.create("middleCases", new ExprImpl("COLLECT(c)"))) - , - new SimpleWithClause( - // "assign", "stat", "enclClass", "varDec", - // "identifications", - namesToPreserveInWith + statNodeName, - new Filter("COLLECT([innerStatement,otherifRel,otherCase, otherforRel,othercatchRel])", - "(innerInfo[0].position > " + statNodeName - + ".position OR innerInfo[0]=for OR NOT innerInfo[3] IS NULL )" - + "AND (innerInfo[1] IS NULL OR innerInfo[1]=ifRel)" - + " AND (innerInfo[4] IS NULL OR innerInfo[4]=catchRel) " - // + "AND"+ - // " isSucc" - // + " AND (innerInfo[2] IS NULL OR NOT " - // + new Any("middleCases", - // " x.position>=case.position AND x.position < - // innerInfo[2].position") - // .expToString() - // + " )" - , "innerInfo").expToString() + " as innerInfos", - "ifRel", "switch", "if", "for", "forRel", "catch", "catchRel", "case", - "COLLECT(DISTINCT c) as middleCases"), - new SimpleWithClause(namesToPreserveInWith + statNodeName + ", ifRel, switch", "if", "catch", - "catchRel", "case", - "COLLECT(" - + new Extract(new Filter("innerInfos", - " innerInfo[2] IS NULL " + "OR NOT " - + new Any(" middleCases ", - " x.position>=case.position AND x.position (c)-[:CASE_STATEMENTS|ENCLOSES|FORLOOP_INIT|HAS_METHODDECL_PARAMETERS|HAS_VARIABLEDECL_INIT|LABELED_STATEMENT|SYNCHRONIZED_BLOCK|TRY_BLOCK|TRY_FINALLY|TRY_RESOURCES*]->({nodeType:'JCBreak'})\r\n"), - new WhereClause("c.position>=case.position AND c.position (mSelect{nodeType:'JCFieldAccess',name:'" - + methodName - + "'})-[:MEMBER_SELECT_EXPR]->(object)"); - - } -} diff --git a/ProgQuery/src/database/querys/services/ModifiersServiceWiggle.java b/ProgQuery/src/database/querys/services/ModifiersServiceWiggle.java deleted file mode 100644 index 4c7c7a6..0000000 --- a/ProgQuery/src/database/querys/services/ModifiersServiceWiggle.java +++ /dev/null @@ -1,21 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.relations.RelationTypesWiggle; -import utils.dataTransferClasses.Pair; - -public class ModifiersServiceWiggle { - - public static MatchElement getClassModifiers(MatchElement classNode) { - return new Path(classNode, - Pair.createP(new NodeVar("classModifiers"), - RelationTypesWiggle.HAS_CLASS_MODIFIERS)); - } - - public static MatchElement getMethodModifiers(MatchElement methodNode) { - return new Path(methodNode, - Pair.createP(new NodeVar("methodModifiers"), RelationTypesWiggle.HAS_METHODDECL_MODIFIERS)); - } -} diff --git a/ProgQuery/src/database/querys/services/PDGServices.java b/ProgQuery/src/database/querys/services/PDGServices.java deleted file mode 100644 index 2106975..0000000 --- a/ProgQuery/src/database/querys/services/PDGServices.java +++ /dev/null @@ -1,40 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.Node; - -public interface PDGServices { - public static final PDGServices PROG_QUERY = new PDGServicesProgQueryImpl(); - // public static final PDGServices WIGGLE = ; - public static final PDGServices WIGGLE = new PDGServicesWiggle(); - - public MatchClause getOptionalUsesAndStateModsAndStatementsOf(Node declaration); - - public MatchClause getOptionalUsesAndStatementsOf(Node declaration); - - public MatchClause getOptionalUsesAndStatementsOf(Node declaration, Node use); - - public MatchElement getUsesOf(Node declaration); - - public MatchElement getUsesOf(Node declaration, Node use); - - public MatchElement getAssingnmentsAndVarDeclarations(MatchElement assignment); - - public MatchElement getAssingnmentsAndVarDeclarations(Node assignment); - - public MatchElement getIdsAndVarDeclarations(MatchElement id); - - MatchElement getIdsAndVarDeclarations(MatchElement id, String varsToPreserve); - - Clause getModificationsOnFields(String fieldSetName, String elementsToPreserve); - - MatchElement getCompleteIdentification(MatchElement id, String varsToPreserve); - - MatchElement getIdsAndVarDeclarations(MatchElement id, MatchElement varDec, String varsToPreserve); - - MatchElement getCompleteIdentificationFromVar(MatchElement varDec, String varsToPreserve); - - MatchElement getCompleteIdentificationFromVar(String varsToPreserve); -} diff --git a/ProgQuery/src/database/querys/services/PDGServicesProgQueryImpl.java b/ProgQuery/src/database/querys/services/PDGServicesProgQueryImpl.java deleted file mode 100644 index d65d6bf..0000000 --- a/ProgQuery/src/database/querys/services/PDGServicesProgQueryImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.relations.PDGRelationTypes; -import utils.dataTransferClasses.Pair; - -public class PDGServicesProgQueryImpl implements PDGServices { - - public MatchClause getOptionalUsesAndStatementsOf(Node declaration) { - return getOptionalUsesAndStatementsOf(declaration, new AnonymousNode()); - } - - public MatchClause getOptionalUsesAndStatementsOf(Node declaration, Node use) { - return new MatchClause(true, ExpressionServices.PROG_QUERY.getStatementFromExp(getUsesOf(declaration, use))); - } - - public Path getUsesOf(Node declaration, Node use) { - return new Path(declaration, Pair.create(new EdgeImpl(PDGRelationTypes.USED_BY), use)); - } - - @Override - public MatchElement getAssingnmentsAndVarDeclarations(MatchElement assignment) { - return assignment.append( - Pair.create(new EdgeImpl(EdgeDirection.OUTGOING, PDGRelationTypes.MODIFIED_BY), new NodeVar("varDec"))); - } - - @Override - public MatchElement getAssingnmentsAndVarDeclarations(Node assignment) { - return getAssingnmentsAndVarDeclarations(new Path(assignment)); - } - - @Override - public MatchElement getIdsAndVarDeclarations(MatchElement assignment) { - throw new IllegalStateException(); - } - - @Override - public Clause getModificationsOnFields(String fieldSetName, String elementsToPreserve) { - throw new IllegalStateException(); - } - - @Override - public MatchElement getIdsAndVarDeclarations(MatchElement id, String varsToPreserve) { - throw new IllegalStateException(); - } - - @Override - public MatchElement getCompleteIdentification(MatchElement id, String varsToPreserve) { - throw new IllegalStateException(); - } - - @Override - public MatchElement getIdsAndVarDeclarations(MatchElement id, MatchElement varDec, String varsToPreserve) { - throw new IllegalStateException(); - } - - @Override - public MatchClause getOptionalUsesAndStateModsAndStatementsOf(Node declaration) { - // TODO Auto-generated method stub - return getOptionalUsesAndStateModsAndStatementsOf(declaration, new AnonymousNode()); - } - - public MatchClause getOptionalUsesAndStateModsAndStatementsOf(Node declaration, Node use) { - return new MatchClause(true, - ExpressionServices.PROG_QUERY.getStatementFromExp(getUsesAndStatModsOf(declaration, use))); - } - - private MatchElement getUsesAndStatModsOf(Node declaration, Node use) { - return new Path(declaration, - Pair.create(new EdgeImpl(PDGRelationTypes.USED_BY, PDGRelationTypes.STATE_MODIFIED_BY), use)); - - } - - @Override - public MatchElement getUsesOf(Node declaration) { - throw new IllegalStateException(); - } - - @Override - public MatchElement getCompleteIdentificationFromVar( String varsToPreserve) { - // TODO Auto-generated method stub - throw new IllegalStateException(); - } - - @Override - public MatchElement getCompleteIdentificationFromVar(MatchElement varDec, String varsToPreserve) { - // TODO Auto-generated method stub - return null; - } -} diff --git a/ProgQuery/src/database/querys/services/PDGServicesWiggle.java b/ProgQuery/src/database/querys/services/PDGServicesWiggle.java deleted file mode 100644 index 6a3d76e..0000000 --- a/ProgQuery/src/database/querys/services/PDGServicesWiggle.java +++ /dev/null @@ -1,286 +0,0 @@ -package database.querys.services; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Clause; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.ExprImpl; -import database.querys.cypherWrapper.MatchClause; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.MatchElements; -import database.querys.cypherWrapper.MatchImpl; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.OrderByClause; -import database.querys.cypherWrapper.Path; -import database.querys.cypherWrapper.PathEnd; -import database.querys.cypherWrapper.RelationshipImpl; -import database.querys.cypherWrapper.SimpleWithClause; -import database.querys.cypherWrapper.UnwindClause; -import database.querys.cypherWrapper.WhereClause; -import database.querys.cypherWrapper.WithClause; -import database.relations.RelationTypes; -import database.relations.RelationTypesWiggle; -import database.relations.TypeRelations; -import utils.dataTransferClasses.Pair; - -public class PDGServicesWiggle extends PDGServicesProgQueryImpl { - @Override - public MatchElement getAssingnmentsAndVarDeclarations(MatchElement assignment) { - - return new PathEnd( - StatementServices.WIGGLE - .getVarDecsInStatement(StatementServices.WIGGLE - .getVarsAndParamsScopesInStatement(ExpressionServices.WIGGLE.getStatementFromExp( - new MatchElements(assignment, - new RelationshipImpl(Node.nodeForWiggle("id", NodeTypes.IDENTIFIER), - assignment.getLastNode(), - new EdgeImpl(EdgeDirection.OUTGOING, - RelationTypes.ASSIGNMENT_LHS))), - new NodeVar("assignStat")), new NodeVar("scope")), - "varDec"), - new WhereClause("varDec.position 0 ? "," : "") + idName, "varDec, p"), - new OrderByClause("-LENGTH(p)"), - new WithClause(new String[] { varsToPreserve + (varsToPreserve.length() > 0 ? "," : "") + idName }, - Pair.create("varDec", new ExprImpl("COLLECT(varDec)[0]")))); - } - - @Override - public MatchElement getIdsAndVarDeclarations(MatchElement id, MatchElement varDec, String varsToPreserve) { - String idName = id.getLastNode().getName(); - String varDecname = varDec.getLastNode().getName(); - NodeVar scope = new NodeVar("scope"); - return new PathEnd(new MatchElements(ExpressionServices.WIGGLE.getStatementFromExp(id), - StatementServices.WIGGLE.getVarsAndParamsScopesInStatement(new Path(new NodeVar("stat"), "p"), scope), - - StatementServices.WIGGLE.getVarDecsInStatement(scope, varDecname)), - new WhereClause(varDecname + ".position(memberSelExpr), - // p=(typeEnclosingField{fullyQualifiedName:memberSelExpr.actualType})-[:IS_SUBTYPE_OF - // | :IS_SUBTYPE_EXTENDS*0..]->(superType), - // (superType)-[:DECLARES_FIELD]->(fieldDec{name:exp.name})")), - // new SimpleWithClause(varsToPreserve + "exp,idents, fieldDec ORDER BY - // -SIZE(NODES(p))"), - // new SimpleWithClause(varsToPreserve + "idents+COLLECT([exp,fieldDec]) as - // idents "), - // new UnwindClause("idents", "pair"), - // new SimpleWithClause(varsToPreserve + "pair[0] as id, pair[1] as dec") - // - // // new WhereClause("fieldDec.name=exp.") - // - // ); - // } - @Override - public MatchElement getCompleteIdentificationFromVar(String varsToPreserve) { -// String varName = varDec.getLastNode().getName(); - NodeVar scope = new NodeVar("scope"); - return new PathEnd(new MatchElements( ExpressionServices.WIGGLE.getStatementFromExp(new NodeVar("id")),StatementServices.WIGGLE - .getVarsAttrsAndParamsScopesInStatement(new Path(new NodeVar("stat"), "p"), scope), - - StatementServices.WIGGLE.getAttrAndVarDecsInStatement(scope)), -// new MatchClause(true,ExpressionServices.WIGGLE.getStatementFromExp(new NodeVar("id"))), - new WhereClause( - "id.nodeType='JCIdent' AND (varDec.position(memberSelExpr), p=(typeEnclosingField)-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS*0..]->(superType), (superType)-[:DECLARES_FIELD]->(fieldDec{name:exp.name})")), - - new WhereClause( - "varDec=fieldDec AND SPLIT(typeEnclosingField.fullyQualifiedName, '<')[0]=SPLIT(memberSelExpr.actualType, '<')[0]"), - - new SimpleWithClause(varsToPreserve - + "varDec,ids+COLLECT(exp) as ids" -// + ", idents+COLLECT([exp,fieldDec]) as auxIdents" - ) - /*,new SimpleWithClause(varsToPreserve + "COLLECT(["+varName+", ids]) as identss" -// + "ORDER BY -SIZE(NODES(p))" - ),new SimpleWithClause(varsToPreserve + "identss, identss as auxIdents" -// + "ORDER BY -SIZE(NODES(p))" - ) - ,new UnwindClause("auxIdents", "pair"), - - new SimpleWithClause(varsToPreserve +" pair[0] as "+varName+", pair[1] as ids, identss") -*/ - - // new WhereClause(varName+"=pair[1]") - // new WhereClause("fieldDec.name=exp.") - - ); - } - - @Override - public MatchElement getCompleteIdentificationFromVar(MatchElement varDec, String varsToPreserve) { - String varName = varDec.getLastNode().getName(); - NodeVar scope = new NodeVar("scope"); - return new PathEnd(new MatchElements( ExpressionServices.WIGGLE.getStatementFromExp(new NodeVar("id")),StatementServices.WIGGLE - .getVarsAttrsAndParamsScopesInStatement(new Path(new NodeVar("stat"), "p"), scope), - - StatementServices.WIGGLE.getAttrAndVarDecsInStatement(scope)), -// new MatchClause(true,ExpressionServices.WIGGLE.getStatementFromExp(new NodeVar("id"))), - new WhereClause( - "id.nodeType='JCIdent' AND (varDec.position(memberSelExpr), p=(typeEnclosingField)-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS*0..]->(superType), (superType)-[:DECLARES_FIELD]->(fieldDec{name:exp.name})")), - - new WhereClause( - varName+"=fieldDec AND SPLIT(typeEnclosingField.fullyQualifiedName, '<')[0]=SPLIT(memberSelExpr.actualType, '<')[0]"), - - new SimpleWithClause(varsToPreserve - + "ids+COLLECT(exp) as ids,"+varName -// + ", idents+COLLECT([exp,fieldDec]) as auxIdents" - ) - /*,new SimpleWithClause(varsToPreserve + "COLLECT(["+varName+", ids]) as identss" -// + "ORDER BY -SIZE(NODES(p))" - ),new SimpleWithClause(varsToPreserve + "identss, identss as auxIdents" -// + "ORDER BY -SIZE(NODES(p))" - ) - ,new UnwindClause("auxIdents", "pair"), - - new SimpleWithClause(varsToPreserve +" pair[0] as "+varName+", pair[1] as ids, identss") -*/ - - // new WhereClause(varName+"=pair[1]") - // new WhereClause("fieldDec.name=exp.") - - ); - } - @Override - public MatchElement getCompleteIdentification(MatchElement id, String varsToPreserve) { - String idName = id.getLastNode().getName(); - NodeVar scope = new NodeVar("scope"); - return new PathEnd(new MatchElements(ExpressionServices.WIGGLE.getStatementFromExp(id), StatementServices.WIGGLE - .getVarsAttrsAndParamsScopesInStatement(new Path(new NodeVar("stat"), "p"), scope), - - StatementServices.WIGGLE.getAttrAndVarDecsInStatement(scope)), - new WhereClause( - idName + ".nodeType='JCIdent' AND (varDec.position(memberSelExpr), p=(typeEnclosingField)-[:IS_SUBTYPE_OF | :IS_SUBTYPE_EXTENDS*0..]->(superType), (superType)-[:DECLARES_FIELD]->(fieldDec{name:exp.name})")), - - new WhereClause( - "SPLIT(typeEnclosingField.fullyQualifiedName, '<')[0]=SPLIT(memberSelExpr.actualType, '<')[0]"), - new SimpleWithClause(varsToPreserve + "exp,idents, fieldDec ORDER BY -SIZE(NODES(p))"), - new SimpleWithClause(varsToPreserve - + "idents+COLLECT([exp,fieldDec]) as identss, idents+COLLECT([exp,fieldDec]) as auxIdents"), - new UnwindClause("auxIdents", "pair"), - - new SimpleWithClause(varsToPreserve + " pair[1] as dec, COLLECT(pair[0]) as ids, identss") - - // new WhereClause("fieldDec.name=exp.") - - ); - } - - @Override - public Clause getModificationsOnFields(String fieldSetName, String varsToPreserve) { - return new MatchClause(true, - new Path( - AssignmentServices.WIGGLE - .getMemberSelectionsLeftSide(Node.nodeForWiggle("assignment", NodeTypes.ASSIGNMENT)), - Pair.create(new EdgeImpl(RelationTypesWiggle.MEMBER_SELECT_EXPR), new NodeVar("memberExpr")), - Pair.create(new EdgeImpl(TypeRelations.ITS_TYPE_IS), new AnonymousNode()), - Pair.create(new EdgeImpl(RelationTypesWiggle.DECLARES_FIELD), new NodeVar("field"))), - ExpressionServices.WIGGLE.getMethodFromExp(new NodeVar("assignment"), - Node.nodeForWiggle("enclosingMethod", NodeTypes.METHOD_DEF))) - .append(new WhereClause(" field IN " + fieldSetName - + " AND field.name=memberSelection.name AND NOT(memberExpr.nodeType='JCIdent' AND memberExpr.name='this' AND enclosingMethod.name='')")) - .append(new SimpleWithClause(varsToPreserve, - "COLLECT(DISTINCT assignment) as assignsMods")) - - .append(new MatchClause(true, - AssignmentServices.WIGGLE - .getLeftMostId(Node.nodeForWiggle("assignment", NodeTypes.ASSIGNMENT)), - new Path( - ExpressionServices.WIGGLE.getMethodFromExp(new NodeVar("assignment"), - Node.nodeForWiggle("enclosingMethod", NodeTypes.METHOD_DEF)), - Pair.create( - new EdgeImpl(EdgeDirection.OUTGOING, - RelationTypesWiggle.DECLARES_METHOD), - new AnonymousNode()), - Pair.create(new EdgeImpl(RelationTypesWiggle.DECLARES_FIELD), - new NodeVar("field")))) - .append(new WhereClause( - "leftMostId.name=field.name AND enclosingMethod.name<>'' AND field IN " - + fieldSetName).append( - - new MatchClause(true, new Path( - PDGServicesWiggle.WIGGLE - .getIdsAndVarDeclarations( - new NodeVar( - "leftMostId"), - varsToPreserve - + ",assignsMods, assignment") - - )).append(new WhereClause(" varDec IS NULL "))))) - - ; - } - -} \ No newline at end of file diff --git a/ProgQuery/src/database/querys/services/StatementServices.java b/ProgQuery/src/database/querys/services/StatementServices.java deleted file mode 100644 index 75c826d..0000000 --- a/ProgQuery/src/database/querys/services/StatementServices.java +++ /dev/null @@ -1,47 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.Path; - -public interface StatementServices { - - public static final StatementServices PROG_QUERY = new StatementServicesProgQueryImpl(); - public static final StatementServices WIGGLE = new StatementServicesWiggle(); - - public MatchElement getEnclosingClassFromStatement(String statement); - - public MatchElement getEnclosingClassFromStatement(MatchElement statement); - - public MatchElement getEnclosingClassFromDeclaration(MatchElement statement); - - public MatchElement getMethodFromStatement(MatchElement statement); - - // public MatchElement getMethodFromDeclaration(MatchElement statement); - - public MatchElement getMethodFromStatement(MatchElement statement, MatchElement method); - - public MatchElement getOuterBlockFromStatement(MatchElement statement); - - public MatchElement getOuterBlockFromStatement(MatchElement statement, MatchElement block); - - public MatchElement getVarsAndParamsScopesInStatement(MatchElement statement); - - public MatchElement getVarsAndParamsScopesInStatement(MatchElement statement, Node scope); - - public MatchElement getVarDecsInStatement(Node statement, String varDecName); - - public MatchElement getVarDecsInStatement(MatchElement statement, String varDecName); - - public MatchElement getStatementsInStatement(MatchElement statement); - - public MatchElement getStatementsInStatement(MatchElement statement, MatchElement innerStatement); - - public MatchElement getUnconditionalStatementsInStatement(MatchElement statement, MatchElement innerStatement); - - Path getVarsAttrsAndParamsScopesInStatement(MatchElement statement, Node scope); - - Path getAttrAndVarDecsInStatement(MatchElement statement); - - Path getAttrAndVarDecsInStatement(MatchElement statement, MatchElement varDec); -} diff --git a/ProgQuery/src/database/querys/services/StatementServicesProgQueryImpl.java b/ProgQuery/src/database/querys/services/StatementServicesProgQueryImpl.java deleted file mode 100644 index 2cd93cb..0000000 --- a/ProgQuery/src/database/querys/services/StatementServicesProgQueryImpl.java +++ /dev/null @@ -1,169 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.CompleteNode; -import database.querys.cypherWrapper.EdgeDirection; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.Path; -import database.relations.RelationTypes; -import database.relations.RelationTypesInterface; -import utils.dataTransferClasses.Pair; - -public class StatementServicesProgQueryImpl implements StatementServices { - - private final RelationTypes[] outerBlockToEnclClass = new RelationTypes[] { RelationTypes.DECLARES_FIELD, - RelationTypes.DECLARES_METHOD, RelationTypes.DECLARES_CONSTRUCTOR, RelationTypes.HAS_STATIC_INIT }; - - private final RelationTypes[] statToEnclMember = new RelationTypes[] { RelationTypes.CALLABLE_HAS_BODY, - RelationTypes.CALLABLE_HAS_PARAMETER, RelationTypes.CASE_STATEMENTS, RelationTypes.CATCH_ENCLOSES_BLOCK, - RelationTypes.CATCH_PARAM, RelationTypes.ENCLOSES,RelationTypes.DO_WHILE_STATEMENT, RelationTypes.WHILE_STATEMENT, RelationTypes.FOREACH_STATEMENT, - RelationTypes.FOREACH_VAR, RelationTypes.FORLOOP_INIT, RelationTypes.FORLOOP_STATEMENT, - RelationTypes.FORLOOP_UPDATE, RelationTypes.CALLABLE_HAS_PARAMETER, RelationTypes.HAS_VARIABLEDECL_INIT, - RelationTypes.IF_THEN, RelationTypes.IF_ELSE, RelationTypes.LABELED_STMT_ENCLOSES, - RelationTypes.SWITCH_ENCLOSES_CASE, RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, RelationTypes.TRY_BLOCK, - RelationTypes.TRY_CATCH, RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES }; - static final RelationTypes[] statToOuterBlock = new RelationTypes[] { RelationTypes.CASE_STATEMENTS, - RelationTypes.CATCH_ENCLOSES_BLOCK, RelationTypes.CATCH_PARAM, RelationTypes.ENCLOSES,RelationTypes.DO_WHILE_STATEMENT, RelationTypes.WHILE_STATEMENT, - RelationTypes.FOREACH_STATEMENT, RelationTypes.FOREACH_VAR, RelationTypes.FORLOOP_INIT, - RelationTypes.FORLOOP_STATEMENT, RelationTypes.FORLOOP_UPDATE, RelationTypes.CALLABLE_HAS_PARAMETER, - RelationTypes.IF_THEN, RelationTypes.IF_ELSE, RelationTypes.LABELED_STMT_ENCLOSES, - RelationTypes.SWITCH_ENCLOSES_CASE, RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, RelationTypes.TRY_BLOCK, - RelationTypes.TRY_CATCH, RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES }; - - static final RelationTypes[] unconditionalStatToOuterBlock = new RelationTypes[] { RelationTypes.CASE_STATEMENTS, - RelationTypes.ENCLOSES, RelationTypes.FORLOOP_INIT, RelationTypes.CALLABLE_HAS_PARAMETER, - RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.LABELED_STMT_ENCLOSES, RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, - RelationTypes.TRY_BLOCK, RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES , RelationTypes.DO_WHILE_STATEMENT}; - private final RelationTypes[] statNameScopes = new RelationTypes[] { RelationTypes.CASE_STATEMENTS, - RelationTypes.CATCH_ENCLOSES_BLOCK, RelationTypes.CATCH_PARAM, RelationTypes.ENCLOSES, - RelationTypes.FOREACH_STATEMENT, RelationTypes.FOREACH_VAR, RelationTypes.FORLOOP_INIT, - RelationTypes.FORLOOP_STATEMENT, RelationTypes.FORLOOP_UPDATE, RelationTypes.CALLABLE_HAS_PARAMETER, - RelationTypes.CALLABLE_HAS_BODY, RelationTypes.HAS_VARIABLEDECL_INIT, RelationTypes.IF_THEN, - RelationTypes.IF_ELSE, RelationTypes.LABELED_STMT_ENCLOSES, RelationTypes.SWITCH_ENCLOSES_CASE, - RelationTypes.SYNCHRONIZED_ENCLOSES_BLOCK, RelationTypes.TRY_BLOCK, RelationTypes.TRY_CATCH,RelationTypes.DO_WHILE_STATEMENT, RelationTypes.WHILE_STATEMENT, - RelationTypes.TRY_FINALLY, RelationTypes.TRY_RESOURCES }; - private final RelationTypes[] statToVarDecs = new RelationTypes[] { RelationTypes.ENCLOSES, - RelationTypes.FOREACH_VAR, RelationTypes.FORLOOP_INIT, RelationTypes.CALLABLE_HAS_PARAMETER, - RelationTypes.TRY_RESOURCES }; - - public Path getEnclosingClassFromStatement(String statement) { - return getEnclosingClassFromStatement(new NodeVar(statement)); - } - - public Path getEnclosingClassFromStatement(MatchElement statement) { - return getMethodFromStatement(statement, new AnonymousNode()).append(Pair.create( - new EdgeImpl(outerBlockToEnclClass).setDirection(EdgeDirection.OUTGOING), new NodeVar("enclClass"))); - } - - @Override - public MatchElement getEnclosingClassFromDeclaration(MatchElement statement) { - // TODO Auto-generated method stub - return getMethodFromDeclaration(statement).append(Pair.create( - new EdgeImpl(outerBlockToEnclClass).setDirection(EdgeDirection.OUTGOING), new NodeVar("enclClass"))); - } - public Path getOuterBlockFromStatement(MatchElement statement) { - - return getBlocksFromStatement(statement, statToOuterBlock); - } - - Path getBlocksFromStatement(MatchElement statement, RelationTypesInterface[] rels) { - return getBlocksFromStatement(statement, new AnonymousNode(), rels); - } - - Path getBlocksFromStatement(MatchElement statement, MatchElement block, RelationTypesInterface[] rels) { - return statement.append(Pair - .create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), rels).setDirection(EdgeDirection.OUTGOING), block)); - } - - public Path getVarsAndParamsScopesInStatement(MatchElement statement) { - return getBlocksFromStatement(statement, statNameScopes); - } - - @Override - public Path getVarsAndParamsScopesInStatement(MatchElement statement, Node scope) { - return getBlocksFromStatement(statement, scope, statNameScopes); - - } - - @Override - public Path getVarDecsInStatement(Node statement, String varDecName) { - return getVarDecsInStatement(new Path(statement), varDecName); - } - - @Override - public Path getVarDecsInStatement(MatchElement statement, String varDecName) { - throw new IllegalStateException(); - } - - private MatchElement getMethodFromDeclaration(MatchElement statement) { - return statement.append( - Pair.create( - new EdgeImpl(Cardinalidad.MIN_TO_INF(0), statToEnclMember).setDirection(EdgeDirection.OUTGOING), - new AnonymousNode())); - } - - @Override - public MatchElement getMethodFromStatement(MatchElement statement, MatchElement method) { - return statement.append(Pair.create( - new EdgeImpl(Cardinalidad.ONE_TO_INF, statToOuterBlock).setDirection(EdgeDirection.OUTGOING), - new AnonymousNode()), - Pair.create(new EdgeImpl(Cardinalidad.JUST_ONE, RelationTypes.CALLABLE_HAS_BODY) - .setDirection(EdgeDirection.OUTGOING), method)); - } - - @Override - public MatchElement getMethodFromStatement(MatchElement statement) { - return getMethodFromStatement(statement, new CompleteNode("method")); - } - - @Override - public MatchElement getStatementsInStatement(MatchElement statement) { - return getStatementsInStatement(statement, new NodeVar("innerStatement")); - } - - MatchElement getStatementsInStatement(MatchElement statement, MatchElement innerStatement, - RelationTypesInterface... rels) { - return statement.append(Pair.create(new EdgeImpl(Cardinalidad.ONE_TO_INF, rels), innerStatement)); - } - - @Override - public MatchElement getStatementsInStatement(MatchElement statement, MatchElement innerStatement) { - return getStatementsInStatement(statement, innerStatement, statToOuterBlock); - } - - @Override - public MatchElement getOuterBlockFromStatement(MatchElement statement, MatchElement block) { - return getBlocksFromStatement(statement, block, statToOuterBlock); - } - - @Override - public MatchElement getUnconditionalStatementsInStatement(MatchElement statement, MatchElement innerStatement) { - return getStatementsInStatement(statement, innerStatement, unconditionalStatToOuterBlock); - } - - @Override - public Path getVarsAttrsAndParamsScopesInStatement(MatchElement statement, Node scope) { - throw new IllegalStateException(); - } - - @Override - public Path getAttrAndVarDecsInStatement(MatchElement statement) { - - throw new IllegalStateException(); - } - - @Override - public Path getAttrAndVarDecsInStatement(MatchElement statement, MatchElement varDec) { - - - throw new IllegalStateException(); - - } - - - -} diff --git a/ProgQuery/src/database/querys/services/StatementServicesWiggle.java b/ProgQuery/src/database/querys/services/StatementServicesWiggle.java deleted file mode 100644 index 3a691e8..0000000 --- a/ProgQuery/src/database/querys/services/StatementServicesWiggle.java +++ /dev/null @@ -1,101 +0,0 @@ -package database.querys.services; - -import database.nodes.NodeTypes; -import database.querys.cypherWrapper.AnonymousNode; -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.Node; -import database.querys.cypherWrapper.Path; -import database.relations.RelationTypesWiggle; -import utils.dataTransferClasses.Pair; - -public class StatementServicesWiggle extends StatementServicesProgQueryImpl { - - private final RelationTypesWiggle[] statNameScopes = new RelationTypesWiggle[] { - RelationTypesWiggle.CASE_STATEMENTS, RelationTypesWiggle.CATCH_BLOCK, RelationTypesWiggle.CATCH_PARAM, - RelationTypesWiggle.ENCLOSES, RelationTypesWiggle.FOREACH_STATEMENT, RelationTypesWiggle.FOREACH_VAR, - RelationTypesWiggle.FORLOOP_INIT, RelationTypesWiggle.FORLOOP_STATEMENT, RelationTypesWiggle.FORLOOP_UPDATE, - RelationTypesWiggle.HAS_METHODDECL_PARAMETERS, RelationTypesWiggle.HAS_METHODDECL_BODY, - RelationTypesWiggle.HAS_VARIABLEDECL_INIT, RelationTypesWiggle.IF_THEN, RelationTypesWiggle.IF_ELSE, - RelationTypesWiggle.LABELED_STATEMENT, RelationTypesWiggle.SWITCH_ENCLOSES_CASES, - RelationTypesWiggle.SYNCHRONIZED_BLOCK, RelationTypesWiggle.TRY_BLOCK, RelationTypesWiggle.TRY_CATCH, - RelationTypesWiggle.TRY_FINALLY, RelationTypesWiggle.TRY_RESOURCES }; - private final RelationTypesWiggle[] completeStatNameScopes = new RelationTypesWiggle[] { - RelationTypesWiggle.CASE_STATEMENTS, RelationTypesWiggle.CATCH_BLOCK, RelationTypesWiggle.CATCH_PARAM, - RelationTypesWiggle.ENCLOSES, RelationTypesWiggle.FOREACH_STATEMENT, RelationTypesWiggle.FOREACH_VAR, - RelationTypesWiggle.FORLOOP_INIT, RelationTypesWiggle.FORLOOP_STATEMENT, RelationTypesWiggle.FORLOOP_UPDATE, - RelationTypesWiggle.HAS_METHODDECL_PARAMETERS, RelationTypesWiggle.HAS_METHODDECL_BODY, - RelationTypesWiggle.HAS_VARIABLEDECL_INIT, RelationTypesWiggle.IF_THEN, RelationTypesWiggle.IF_ELSE, - RelationTypesWiggle.LABELED_STATEMENT, RelationTypesWiggle.SWITCH_ENCLOSES_CASES, - RelationTypesWiggle.SYNCHRONIZED_BLOCK, RelationTypesWiggle.TRY_BLOCK, RelationTypesWiggle.TRY_CATCH, - RelationTypesWiggle.TRY_FINALLY, RelationTypesWiggle.TRY_RESOURCES, - - RelationTypesWiggle.DECLARES_METHOD - ,RelationTypesWiggle.HAS_CLASS_BODY -// RelationTypesWiggle.IS_SUBTYPE_EXTENDS, RelationTypesWiggle.IS_SUBTYPE_IMPLEMENTS, RelationTypesWiggle.IS_SUBTYPE_OF - }; - private final RelationTypesWiggle[] scopesToVarDecs = new RelationTypesWiggle[] { RelationTypesWiggle.CATCH_PARAM, - RelationTypesWiggle.ENCLOSES, RelationTypesWiggle.FOREACH_VAR, RelationTypesWiggle.FORLOOP_INIT, - - RelationTypesWiggle.HAS_METHODDECL_PARAMETERS, RelationTypesWiggle.LABELED_STATEMENT, - RelationTypesWiggle.TRY_RESOURCES }; - private final RelationTypesWiggle[] completeScopesToVarDecs = new RelationTypesWiggle[] { - RelationTypesWiggle.CATCH_PARAM, RelationTypesWiggle.ENCLOSES, RelationTypesWiggle.FOREACH_VAR, - RelationTypesWiggle.FORLOOP_INIT, RelationTypesWiggle.HAS_METHODDECL_PARAMETERS, - RelationTypesWiggle.LABELED_STATEMENT, RelationTypesWiggle.TRY_RESOURCES, - RelationTypesWiggle.DECLARES_FIELD }; - static final RelationTypesWiggle[] unconditionalStatToOuterBlock = new RelationTypesWiggle[] { - RelationTypesWiggle.CASE_STATEMENTS, RelationTypesWiggle.ENCLOSES, RelationTypesWiggle.FORLOOP_INIT, - RelationTypesWiggle.HAS_METHODDECL_PARAMETERS, RelationTypesWiggle.HAS_VARIABLEDECL_INIT, - RelationTypesWiggle.LABELED_STATEMENT, RelationTypesWiggle.SYNCHRONIZED_BLOCK, - RelationTypesWiggle.TRY_BLOCK, RelationTypesWiggle.TRY_FINALLY, RelationTypesWiggle.TRY_RESOURCES }; - - @Override - public Path getVarsAndParamsScopesInStatement(MatchElement statement, Node scope) { - return getBlocksFromStatement(statement, scope, statNameScopes); - - } - - @Override - public Path getVarsAttrsAndParamsScopesInStatement(MatchElement statement, Node scope) { - return getBlocksFromStatement(statement, new AnonymousNode(), completeStatNameScopes).append(Pair.create(new EdgeImpl(Cardinalidad.MIN_TO_INF(0), -new RelationTypesWiggle[]{RelationTypesWiggle. IS_SUBTYPE_EXTENDS,RelationTypesWiggle. IS_SUBTYPE_IMPLEMENTS,RelationTypesWiggle. IS_SUBTYPE_OF} - ), scope)) - - ; - - } - - @Override - public Path getVarDecsInStatement(MatchElement statement, String varDecName) { - - return statement - .append(Pair.create(new EdgeImpl(scopesToVarDecs), Node.nodeForWiggle(varDecName, NodeTypes.LOCAL_VAR_DEF))); - } - - @Override - public Path getAttrAndVarDecsInStatement(MatchElement statement) { - - return statement.append( - Pair.create(new EdgeImpl("scopeToVar", completeScopesToVarDecs), - Node.nodeForWiggle("varDec", NodeTypes.LOCAL_VAR_DEF))); - } - @Override - public Path getAttrAndVarDecsInStatement(MatchElement statement, MatchElement varDec) { - - return statement.append( - Pair.create(new EdgeImpl("scopeToVar", completeScopesToVarDecs), - varDec)); - } - @Override - public MatchElement getMethodFromStatement(MatchElement statement) { - return getMethodFromStatement(statement, Node.nodeForWiggle(NodeTypes.METHOD_DEF)); - } - - @Override - public MatchElement getUnconditionalStatementsInStatement(MatchElement statement, MatchElement innerStatement) { - return getStatementsInStatement(statement, innerStatement, unconditionalStatToOuterBlock); - } - -} diff --git a/ProgQuery/src/database/querys/services/TypeServicesWiggle.java b/ProgQuery/src/database/querys/services/TypeServicesWiggle.java deleted file mode 100644 index c15f7d1..0000000 --- a/ProgQuery/src/database/querys/services/TypeServicesWiggle.java +++ /dev/null @@ -1,23 +0,0 @@ -package database.querys.services; - -import database.querys.cypherWrapper.Cardinalidad; -import database.querys.cypherWrapper.EdgeImpl; -import database.querys.cypherWrapper.MatchElement; -import database.querys.cypherWrapper.NodeVar; -import database.querys.cypherWrapper.RelationshipImpl; -import database.relations.RelationTypesWiggle; - -public class TypeServicesWiggle { - - public static MatchElement getSuperTypesOf(MatchElement type, MatchElement superType) { - return new RelationshipImpl(type, superType, - new EdgeImpl(Cardinalidad.MIN_TO_INF(0), RelationTypesWiggle.IS_SUBTYPE_OF)); - - } - - public static MatchElement getSuperTypesOf(MatchElement type) { - return new RelationshipImpl(type, new NodeVar("superType"), - new EdgeImpl(Cardinalidad.MIN_TO_INF(0), RelationTypesWiggle.IS_SUBTYPE_OF)); - - } -} diff --git a/ProgQuery/src/database/relations/CDGRelationTypes.java b/ProgQuery/src/database/relations/CDGRelationTypes.java deleted file mode 100644 index 7b54d26..0000000 --- a/ProgQuery/src/database/relations/CDGRelationTypes.java +++ /dev/null @@ -1,9 +0,0 @@ -package database.relations; - -public enum CDGRelationTypes implements RelationTypesInterface { - // PACKAGE RELS - DEPENDS_ON_PACKAGE, DEPENDS_ON_NON_DECLARED_PACKAGE, PACKAGE_HAS_COMPILATION_UNIT, PROGRAM_DECLARES_PACKAGE - // Class Rels - , USES_TYPE_DEF, HAS_INNER_TYPE_DEF - -} diff --git a/ProgQuery/src/database/relations/CFGRelationTypes.java b/ProgQuery/src/database/relations/CFGRelationTypes.java deleted file mode 100644 index e72e875..0000000 --- a/ProgQuery/src/database/relations/CFGRelationTypes.java +++ /dev/null @@ -1,22 +0,0 @@ -package database.relations; - -public enum CFGRelationTypes implements RelationTypesInterface { - - CFG_ENTRIES, CFG_END_OF, CFG_FINALLY_TO_LAST_STMT, CFG_NEXT_STATEMENT, - CFG_NEXT_STATEMENT_IF_TRUE, CFG_NEXT_STATEMENT_IF_FALSE, - CFG_FOR_EACH_HAS_NEXT, CFG_FOR_EACH_NO_MORE_ELEMENTS, CFG_SWITCH_CASE_IS_EQUAL_TO, CFG_SWITCH_DEFAULT_CASE, - CFG_AFTER_FINALLY_PREVIOUS_BREAK, CFG_AFTER_FINALLY_PREVIOUS_CONTINUE, - CFG_NO_EXCEPTION, - CFG_IF_THERE_IS_UNCAUGHT_EXCEPTION, - CFG_CAUGHT_EXCEPTION, CFG_MAY_THROW, CFG_THROWS - ; - - - public static String getCFGRelations() { - String ret = ""; - for (CFGRelationTypes cfgRel : CFGRelationTypes.values()) - ret += cfgRel.name() + " | "; - return ret.substring(0, ret.length() - 3); - } - -} diff --git a/ProgQuery/src/database/relations/CGRelationTypes.java b/ProgQuery/src/database/relations/CGRelationTypes.java deleted file mode 100644 index e8cf81d..0000000 --- a/ProgQuery/src/database/relations/CGRelationTypes.java +++ /dev/null @@ -1,6 +0,0 @@ -package database.relations; - -public enum CGRelationTypes implements RelationTypesInterface { - CALLS, HAS_DEF, - REFERS_TO, MAY_REFER_TO -} diff --git a/ProgQuery/src/database/relations/PDGRelationTypes.java b/ProgQuery/src/database/relations/PDGRelationTypes.java deleted file mode 100644 index ce672e7..0000000 --- a/ProgQuery/src/database/relations/PDGRelationTypes.java +++ /dev/null @@ -1,9 +0,0 @@ -package database.relations; - -public enum PDGRelationTypes implements RelationTypesInterface { - - USED_BY, MODIFIED_BY, STATE_MODIFIED_BY, STATE_MAY_BE_MODIFIED_BY, - // For the future - // RETURNS, RETURNS_A_PART_OF, MAY_RETURN, MAY_RETURN_A_PART_OF - HAS_THIS_REFERENCE -} diff --git a/ProgQuery/src/database/relations/PartialRelation.java b/ProgQuery/src/database/relations/PartialRelation.java deleted file mode 100644 index 9dbe67e..0000000 --- a/ProgQuery/src/database/relations/PartialRelation.java +++ /dev/null @@ -1,17 +0,0 @@ -package database.relations; - -import java.util.List; - -import node_wrappers.NodeWrapper; -import node_wrappers.RelationshipWrapper; -import utils.dataTransferClasses.Pair; - -public interface PartialRelation { - - NodeWrapper getStartingNode(); - - T getRelationType(); - - RelationshipWrapper createRelationship(NodeWrapper endNode); - List> getProperties(); -} diff --git a/ProgQuery/src/database/relations/RelationTypesInterface.java b/ProgQuery/src/database/relations/RelationTypesInterface.java deleted file mode 100644 index 20560ce..0000000 --- a/ProgQuery/src/database/relations/RelationTypesInterface.java +++ /dev/null @@ -1,9 +0,0 @@ -package database.relations; - -import org.neo4j.graphdb.RelationshipType; - -public interface RelationTypesInterface - extends RelationshipType -{ - -} diff --git a/ProgQuery/src/database/relations/RelationTypesWiggle.java b/ProgQuery/src/database/relations/RelationTypesWiggle.java deleted file mode 100644 index e64abed..0000000 --- a/ProgQuery/src/database/relations/RelationTypesWiggle.java +++ /dev/null @@ -1,52 +0,0 @@ -package database.relations; - -public enum RelationTypesWiggle implements RelationTypesInterface { - CU_ENCLOSES, - - IS_SUBTYPE_EXTENDS, IS_SUBTYPE_IMPLEMENTS, - - HAS_CLASS_TYPEPARAMETERS, HAS_CLASS_EXTENDS, HAS_CLASS_IMPLEMENTS, HAS_CLASS_BODY, HAS_CLASS_MODIFIERS, - - IMPORTS, HAS_METHODDECL_RETURNS, HAS_METHODDECL_TYPEPARAMETERS, HAS_METHODDECL_PARAMETERS, HAS_METHODDECL_THROWS, - - HAS_METHODDECL_BODY, HAS_METHODDECL_DEFAULT_VALUE, - - ENCLOSES, DECLARES_METHOD, HAS_METHODDECL_MODIFIERS, - - HAS_ANNOTATIONS, HAS_ANNOTATIONS_TYPE, HAS_ANNOTATIONS_ARGUMENTS, - - DOWHILE_CONDITION, WHILE_CONDITION, DECLARES_FIELD, - - HAS_VARIABLEDECL_MODIFIERS, HAS_VARIABLEDECL_TYPE, HAS_VARIABLEDECL_INIT, - - FORLOOP_INIT, FORLOOP_CONDITION, FORLOOP_UPDATE, FORLOOP_STATEMENT, - - FOREACH_VAR, FOREACH_EXPR, FOREACH_STATEMENT, - - LABELED_STATEMENT, ASSIGNMENT_RHS, ASSIGNMENT_LHS, UNARY_ENCLOSES, - - COMPOUND_ASSIGNMENT_LHS, COMPOUND_ASSIGNMENT_RHS, - - PARENTHESIZED_ENCLOSES, NEWARRAY_TYPE, NEWARRAY_DIMENSION, NEWARRAY_INIT, - - BINOP_LHS, BINOP_RHS, CAST_TYPE, CAST_ENCLOSES, WILDCARD_BOUND, - - TYPEPARAMETER_EXTENDS, UNION, PARAMETERIZEDTYPE_TYPE, PARAMETERIZEDTYPE_TYPEARGUMENTS, - - INSTANCEOF_EXPR, INSTANCEOF_TYPE, ARRAYACCESS_EXPR, ARRAYACCESS_INDEX, - - SWITCH_EXPR, SWITCH_ENCLOSES_CASES, CASE_EXPR, CASE_STATEMENTS, SYNCHRONIZED_EXPR, - - SYNCHRONIZED_BLOCK, TRY_RESOURCES, TRY_BLOCK, TRY_CATCH, TRY_FINALLY, CATCH_PARAM, CATCH_BLOCK, - - CONDITIONAL_ELSE, CONDITIONAL_THEN, CONDITIONAL_CONDITION, IF_CONDITION, IF_THEN, IF_ELSE, - - EXPR_ENCLOSES, RETURN_EXPR, THROW_EXPR, ASSERT_CONDITION, ASSERT_DETAIL, NEWCLASS_ENCLOSING_EXPRESSION, - - NEWCLASS_IDENTIFIER, NEW_CLASS_TYPE_ARGUMENTS, NEW_CLASS_ARGUMENTS, NEW_CLASS_BODY, - - MEMBER_SELECT_EXPR, METHODINVOCATION_TYPE_ARGUMENTS, METHODINVOCATION_METHOD_SELECT, METHODINVOCATION_ARGUMENTS, CALLS, - - IS_SUBTYPE_OF - -} diff --git a/ProgQuery/src/database/relations/TypeRelations.java b/ProgQuery/src/database/relations/TypeRelations.java deleted file mode 100644 index 38a2928..0000000 --- a/ProgQuery/src/database/relations/TypeRelations.java +++ /dev/null @@ -1,10 +0,0 @@ -package database.relations; - -public enum TypeRelations implements RelationTypesInterface { - - INHERITS_FIELD, INHERITS_METHOD, IS_SUBTYPE_EXTENDS, - IS_SUBTYPE_IMPLEMENTS, ITS_TYPE_IS, OVERRIDES, - - RETURN_TYPE, THROWS_TYPE, PARAM_TYPE, INSTANCE_ARG_TYPE - , WILDCARD_EXTENDS_BOUND, WILDCARD_SUPER_BOUND -} diff --git a/ProgQuery/src/evaluation/Rule.java b/ProgQuery/src/evaluation/Rule.java deleted file mode 100644 index 6e57515..0000000 --- a/ProgQuery/src/evaluation/Rule.java +++ /dev/null @@ -1,23 +0,0 @@ -package evaluation; - -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Result; - -public class Rule { - - public String[] queries; - - public Rule(String... querys) { - super(); - this.queries = querys; - } - - public Result execute(GraphDatabaseService gs) { - Result res = null; - for (String query : queries) - res = gs.execute(query); - - return res; - } - -} diff --git a/ProgQuery/src/io/Errors.java b/ProgQuery/src/io/Errors.java deleted file mode 100644 index 1bbba8e..0000000 --- a/ProgQuery/src/io/Errors.java +++ /dev/null @@ -1,15 +0,0 @@ -package io; - -import java.io.IOException; - -public class Errors { - - public static void addError(String msg) { - try { - FileUtil.appendFile("symbolErrors.log", msg); - } catch (IOException e) { - e.printStackTrace(); - System.err.println("Errors cannot be written in symbolErrors.log."); - } - } -} diff --git a/ProgQuery/src/io/FileUtil.java b/ProgQuery/src/io/FileUtil.java deleted file mode 100644 index 666c609..0000000 --- a/ProgQuery/src/io/FileUtil.java +++ /dev/null @@ -1,29 +0,0 @@ -package io; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; - -public class FileUtil { - - public static void writeFile(String fileName, String text) throws IOException { - BufferedWriter bw = new BufferedWriter(new FileWriter(fileName)); - bw.write(text); - bw.close(); - } - public static void appendFile(String fileName, String text) throws IOException { - BufferedWriter bw = new BufferedWriter(new FileWriter(fileName,true)); - bw.write(text); - bw.close(); - } - public static String getTextFromFile(String fileName) throws IOException { - BufferedReader br = new BufferedReader(new FileReader(fileName)); - String text = ""; - while (br.ready()) - text += br.readLine() + "\n"; - br.close(); - return text; - } -} diff --git a/ProgQuery/src/mig/HierarchyAnalysis.java b/ProgQuery/src/mig/HierarchyAnalysis.java deleted file mode 100644 index 02fb5aa..0000000 --- a/ProgQuery/src/mig/HierarchyAnalysis.java +++ /dev/null @@ -1,191 +0,0 @@ -package mig; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import database.nodes.NodeUtils; -import database.querys.cypherWrapper.EdgeDirection; -import database.relations.CGRelationTypes; -import database.relations.RelationTypes; -import database.relations.TypeRelations; -import node_wrappers.NodeWrapper; -import node_wrappers.RelationshipWrapper; - -public class HierarchyAnalysis { - - private Map typeToInheritedInfo = new HashMap<>(); - private Set trustableInv; - - public HierarchyAnalysis(Set superCalls) { - this.trustableInv = superCalls; - } - - private static class InfoFromSubtypes { - Map> transitiveOverridersMethods = new HashMap<>(); - Map> subtypesToLastOverrider = new HashMap<>(); - - } - - public InfoFromSubtypes dynamicMethodCallAnalysis(NodeWrapper typeDec) { - InfoFromSubtypes inheritedInfo = typeToInheritedInfo.get(typeDec); -// System.out.println("STARTING FOR " + typeDec.getProperty("fullyQualifiedName")); - if (inheritedInfo != null) - return inheritedInfo; - -// System.out.println("NOT FOUND FOR " + typeDec.getProperty("fullyQualifiedName")); - inheritedInfo = new InfoFromSubtypes(); -// for (RelationshipWrapper subTypeRel : typeDec.getRelationships(EdgeDirection.INCOMING, -// TypeRelations.IS_SUBTYPE_EXTENDS, TypeRelations.IS_SUBTYPE_IMPLEMENTS)) -// System.out.println("REL " + typeDec.getProperty("fullyQualifiedName") + " WITH " -// + subTypeRel.getStartNode().getProperty("fullyQualifiedName")); - - for (RelationshipWrapper subTypeRel : typeDec.getRelationships(EdgeDirection.INCOMING, - TypeRelations.IS_SUBTYPE_EXTENDS, TypeRelations.IS_SUBTYPE_IMPLEMENTS)) { - NodeWrapper subType = subTypeRel.getStartNode(); - // System.out.println("subtype " + - // subType.getProperty("fullyQualifiedName")); - - InfoFromSubtypes infoFromSubtypes = dynamicMethodCallAnalysis(subType); -// System.out.println("ANALYZING " + typeDec.getProperty("fullyQualifiedName") + " WITH " -// + subType.getProperty("fullyQualifiedName")); - - // if - // (typeDec.getProperty("fullyQualifiedName").equals("examples.mig.C") - // || - // typeDec.getProperty("fullyQualifiedName").equals("annotations.MyAnn")) - // { - // System.out.println(infoFromSubtypes.subtypesToLastOverrider); - // System.out.println(infoFromSubtypes.transitiveOverridersMethods); - // } - - inheritedInfo.subtypesToLastOverrider.putAll(infoFromSubtypes.subtypesToLastOverrider); - - Map> subtypeOverriders = infoFromSubtypes.transitiveOverridersMethods; - for (Entry> entry : subtypeOverriders.entrySet()) { - Set groupedMethods = inheritedInfo.transitiveOverridersMethods.get(entry.getKey()); - if (groupedMethods == null) - inheritedInfo.transitiveOverridersMethods.put(entry.getKey(), groupedMethods = new HashSet<>()); - groupedMethods.addAll(entry.getValue()); - } - - } - // AQuí tenemos el mapa subtypesToLastOverrider lleno con la info de los - // subtypes - Iterable declaredFields = typeDec.getRelationships(EdgeDirection.OUTGOING, - RelationTypes.DECLARES_FIELD), - declaredMethods = typeDec.getRelationships(EdgeDirection.OUTGOING, RelationTypes.DECLARES_METHOD); - for (Entry> subTypeInfo : inheritedInfo.subtypesToLastOverrider - .entrySet()) { -// System.out.println("FIELDS OF "+typeDec + " TO "+ subTypeInfo.getKey()); - fieldAnalysis(subTypeInfo.getKey(), declaredFields); - - for (RelationshipWrapper declaredMethodRel : declaredMethods) { - - NodeWrapper declaredMethod = declaredMethodRel.getEndNode(); - if ((boolean) declaredMethod.getProperty("isStatic")) - continue; - String typedName = declaredMethod.getProperty("fullyQualifiedName").toString().split(":")[1] - .split("\\)")[0]; - - NodeWrapper overriderMethodInThisSubtype = subTypeInfo.getValue().get(typedName); - if (overriderMethodInThisSubtype == null) { -// System.out -// .println("NO OVERRIDER FOUND SO, " + subTypeInfo.getKey() + " INHERITS " + declaredMethod); - - subTypeInfo.getKey().createRelationshipTo(declaredMethod, TypeRelations.INHERITS_METHOD); -// subTypeInfo.getValue().put(typedName, declaredMethod); - } else { -// System.out.println( -// "OVERRIDER FOUND FOR " + typeDec + " WITH " + subTypeInfo.getKey() + " AND " + typedName); -// System.out.println(overriderMethodInThisSubtype); -// if (!subTypeInfo.getValue().get(typedName) -// .getSingleRelationship(EdgeDirection.OUTGOING, TypeRelations.OVERRIDES).getEndNode() -// .equals(declaredMethod)) - subTypeInfo.getValue().get(typedName).createRelationshipTo(declaredMethod, - TypeRelations.OVERRIDES); - inheritedInfo.subtypesToLastOverrider.get(subTypeInfo.getKey()).remove(typedName); - } - } - } - - inheritedInfo.subtypesToLastOverrider.put(typeDec, new HashMap<>()); - // POR CADA DECLARACIÓN DE mËTODO SE HACE EL ANALYSIS Y LOS DE MISMA - // CLAVE SON SOBREESCRITOS SI LOS HAY - // Todas las claves, menos los metodos sobreescritos son heredados,pero - // hablando de metodos solo la ultima - // if - // (typeDec.getProperty("fullyQualifiedName").equals("examples.mig.C") - // || - // typeDec.getProperty("fullyQualifiedName").equals("annotations.MyAnn") - // || - // typeDec.getProperty("fullyQualifiedName").equals("java.lang.Object") - // ) { - // System.out.println("INHERITED INFO BEFORE OV"); - // System.out.println("TO LAST"); - // System.out.println(inheritedInfo.subtypesToLastOverrider); - // System.out.println("TRANSITIVE"); - // System.out.println(inheritedInfo.transitiveOverridersMethods); - // } - for (RelationshipWrapper declaredMethodRel : declaredMethods) { - - NodeWrapper declaredMethod = declaredMethodRel.getEndNode(); - if ((boolean) declaredMethod.getProperty("isStatic")) - continue; - - String typedName = declaredMethod.getProperty("fullyQualifiedName").toString().split(":")[1] - .split("\\)")[0]; - inheritedInfo.subtypesToLastOverrider.get(typeDec).put(typedName, declaredMethod); - - Set overriderMethods = inheritedInfo.transitiveOverridersMethods.get(typedName); - boolean isAbstract = (boolean) declaredMethod.getProperty("isAbstract"); - - Iterable invocationRels = declaredMethod.getRelationships(EdgeDirection.INCOMING, - CGRelationTypes.REFERS_TO); - if (overriderMethods == null) - inheritedInfo.transitiveOverridersMethods.put(typedName, overriderMethods = new HashSet<>()); - - else { - boolean mayRefer = !isAbstract || overriderMethods.size() > 1; - - // MAY_REFER OR REFER TO THE OV_METHOD - overriderMethods.forEach(ovMethod -> { - // inheritedInfo. - if (!(boolean) ovMethod.getProperty("isAbstract")) - invocationRels.forEach(r -> { - if (!trustableInv.contains(r.getStartNode())) - r.getStartNode().createRelationshipTo(ovMethod, - mayRefer ? CGRelationTypes.MAY_REFER_TO : CGRelationTypes.REFERS_TO); - - }); - }); - // MAY_REFER INSTEAD OF REFER FOR THE DECLARED METHOD - if (!isAbstract) - invocationRels.forEach(r -> { - if (!trustableInv.contains(r.getStartNode())) { - r.getStartNode().createRelationshipTo(declaredMethod, CGRelationTypes.MAY_REFER_TO); - r.delete(); - } - }); - - } - - if (isAbstract) - invocationRels.forEach(r -> r.delete()); - overriderMethods.add(declaredMethod); - - } - - typeToInheritedInfo.put(typeDec, inheritedInfo); - return inheritedInfo; - } - - private void fieldAnalysis(NodeWrapper subtype, Iterable declaredFields) { - for (RelationshipWrapper declaredFieldRel : declaredFields) - if (!(Boolean) declaredFieldRel.getEndNode().getProperty("isStatic")) - subtype.createRelationshipTo(declaredFieldRel.getEndNode(), TypeRelations.INHERITS_FIELD); - - } -} diff --git a/ProgQuery/src/node_wrappers/Neo4jLazyServerDriverRelationship.java b/ProgQuery/src/node_wrappers/Neo4jLazyServerDriverRelationship.java deleted file mode 100644 index 9774b9d..0000000 --- a/ProgQuery/src/node_wrappers/Neo4jLazyServerDriverRelationship.java +++ /dev/null @@ -1,54 +0,0 @@ -package node_wrappers; - -import database.insertion.lazy.InfoToInsert; -import database.relations.RelationTypesInterface; - -public class Neo4jLazyServerDriverRelationship extends AbstractNeo4jLazyServerDriverElement - implements RelationshipWrapper { - private NodeWrapper start, end; - private RelationTypesInterface rType; - - public Neo4jLazyServerDriverRelationship(NodeWrapper start, NodeWrapper end, RelationTypesInterface rType) { - this(start, rType); - this.end = end; - - } - - public Neo4jLazyServerDriverRelationship(NodeWrapper start, RelationTypesInterface rType) { - this.start = start; - this.rType = rType; - InfoToInsert.INFO_TO_INSERT.addNewRel(this); - } - - @Override - public RelationTypesInterface getType() { - return rType; - } - - @Override - public NodeWrapper getStartNode() { - return start; - } - - @Override - public NodeWrapper getEndNode() { - return end; - } - - // private static int i = 0; - - @Override - public void delete() { - // System.out.println(i++); - InfoToInsert.INFO_TO_INSERT.deleteRel(this); - start.removeOutgoingRel(this); - end.removeIncomingRel(this); - } - - @Override - public String getTypeString() { - // TODO Auto-generated method stub - return rType.toString(); - } - -} diff --git a/ProgQuery/src/node_wrappers/NodeWrapper.java b/ProgQuery/src/node_wrappers/NodeWrapper.java deleted file mode 100644 index 5e2f60f..0000000 --- a/ProgQuery/src/node_wrappers/NodeWrapper.java +++ /dev/null @@ -1,51 +0,0 @@ -package node_wrappers; - -import java.util.List; -import java.util.Set; - -import org.neo4j.graphdb.Label; - -import database.querys.cypherWrapper.EdgeDirection; -import database.relations.RelationTypesInterface; - -public interface NodeWrapper extends Propertiable{ - - Long getId(); - - RelationshipWrapper createRelationshipTo(NodeWrapper end, RelationTypesInterface relType); - - List getRelationships(); - - // List getRelationshipsXX(RelationTypesInterface... - // relTypes); - - RelationshipWrapper getSingleRelationship(EdgeDirection direction, RelationTypesInterface relTypes); - - List getRelationships(EdgeDirection direction, RelationTypesInterface... possibleRelTypes); - - List getRelationships(EdgeDirection direction); - - boolean hasRelationship(RelationTypesInterface relType, EdgeDirection incoming); - - Set