]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/validation/ReportCollisions.java
Check statement collisions
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / validation / ReportCollisions.java
index e7346e94570c92edd76c0e46e4df56b2b87935d0..28a53381e3ca5f2cdac83a5be2cc9181f79ccaf5 100644 (file)
@@ -2,18 +2,22 @@ package org.simantics.graph.compiler.internal.validation;
 \r
 import java.util.Collection;\r
 \r
+import org.simantics.graph.compiler.GraphCompilerPreferences;\r
 import org.simantics.graph.compiler.internal.store.LocationStore;\r
 import org.simantics.graph.compiler.internal.templates.TemplateDefinitionStore;\r
 import org.simantics.graph.store.GraphStore;\r
+import org.simantics.graph.store.StatementCollision;\r
 import org.simantics.ltk.Problem;\r
 \r
 public class ReportCollisions implements Runnable {\r
+    GraphCompilerPreferences preferences;\r
        Collection<Problem> problems;\r
        GraphStore store;\r
 \r
        public ReportCollisions(\r
-                       Collection<Problem> problems,\r
+                       GraphCompilerPreferences preferences, Collection<Problem> problems,\r
                        GraphStore store) {\r
+           this.preferences = preferences;\r
                this.problems = problems;\r
                this.store = store;\r
        }\r
@@ -32,7 +36,15 @@ public class ReportCollisions implements Runnable {
                for(int c : store.getStore(TemplateDefinitionStore.class).getCollisions().toArray())\r
                        problems.add(new Problem(\r
                                        locations.getLocation(c), \r
-                                       "Two tempalate definitions are given for the same resource."));\r
+                                       "Two template definitions are given for the same resource."));\r
+               if(preferences.validate)\r
+                   for(StatementCollision collision : store.statements.getCollisions()) {\r
+                       problems.add(new Problem(\r
+                               locations.getLocation(collision.subject), \r
+                               "The same statement is defined twice: " +\r
+                                       store.idToRes(collision.predicate) + ", " +\r
+                                       store.idToRes(collision.object)));\r
+                   }\r
        }\r
        \r
 }\r