]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/VariableStore.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / store / VariableStore.java
diff --git a/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/VariableStore.java b/bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/VariableStore.java
new file mode 100644 (file)
index 0000000..567435a
--- /dev/null
@@ -0,0 +1,38 @@
+package org.simantics.graph.compiler.internal.store;\r
+\r
+import gnu.trove.map.hash.TIntIntHashMap;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.simantics.graph.compiler.SourceInfo;\r
+import org.simantics.graph.compiler.SourceInfo.DefinitionPosition;\r
+import org.simantics.graph.compiler.SourceInfo.SourceFile;\r
+import org.simantics.graph.compiler.SourceInfo.Variable;\r
+import org.simantics.graph.store.IStore;\r
+\r
+public class VariableStore implements IStore {\r
+       \r
+       public List<SourceFile> sourceFiles = new ArrayList<SourceFile>();\r
+       \r
+       @Override\r
+       public void map(TIntIntHashMap map) {\r
+               for(SourceFile file : sourceFiles) {\r
+                       for(Variable variable : file.variables)\r
+                               if(map.contains(variable.resource))\r
+                                       variable.resource = map.get(variable.resource);\r
+                       for(DefinitionPosition pos : file.definitionPositions)\r
+                               if(map.contains(pos.resource))\r
+                                       pos.resource = map.get(pos.resource);\r
+               }\r
+       }\r
+               \r
+       public SourceInfo getSourceInfo() {             \r
+               return new SourceInfo(sourceFiles);\r
+       }\r
+\r
+       public void addSourceFile(SourceFile sourceFile) {\r
+               sourceFiles.add(sourceFile);\r
+       }\r
+\r
+}\r