]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.graph.compiler/src/org/simantics/graph/compiler/internal/store/VariableStore.java
7accba99302724492bc802ea193eb1dc143f0822
[simantics/platform.git] / bundles / org.simantics.graph.compiler / src / org / simantics / graph / compiler / internal / store / VariableStore.java
1 package org.simantics.graph.compiler.internal.store;
2
3 import gnu.trove.map.hash.TIntIntHashMap;
4
5 import java.util.ArrayList;
6 import java.util.List;
7
8 import org.simantics.graph.compiler.SourceInfo;
9 import org.simantics.graph.compiler.SourceInfo.DefinitionPosition;
10 import org.simantics.graph.compiler.SourceInfo.SourceFile;
11 import org.simantics.graph.compiler.SourceInfo.Variable;
12 import org.simantics.graph.store.IStore;
13
14 public class VariableStore implements IStore {
15         
16         public List<SourceFile> sourceFiles = new ArrayList<SourceFile>();
17         
18         @Override
19         public void map(TIntIntHashMap map) {
20                 for(SourceFile file : sourceFiles) {
21                         for(Variable variable : file.variables)
22                                 if(map.contains(variable.resource))
23                                         variable.resource = map.get(variable.resource);
24                         for(DefinitionPosition pos : file.definitionPositions)
25                                 if(map.contains(pos.resource))
26                                         pos.resource = map.get(pos.resource);
27                 }
28         }
29                 
30         public SourceInfo getSourceInfo() {             
31                 return new SourceInfo(sourceFiles);
32         }
33
34         public void addSourceFile(SourceFile sourceFile) {
35                 sourceFiles.add(sourceFile);
36         }
37
38 }