lots of changes
[cdsspec-compiler.git] / src / edu / uci / eecs / specCompiler / specExtraction / SpecExtractor.java
index 2de7be92f0448ba74459180dcd2f0f3a069b2115..a130d972c6229861b8891cb065cb2e26be1d8b20 100644 (file)
@@ -8,6 +8,7 @@ import java.io.IOException;
 import java.io.LineNumberReader;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 
 import edu.uci.eecs.specCompiler.grammerParser.ParseException;
 import edu.uci.eecs.specCompiler.grammerParser.SpecParser;
@@ -25,14 +26,18 @@ import edu.uci.eecs.specCompiler.grammerParser.TokenMgrError;
  * 
  */
 public class SpecExtractor {
-       public final ArrayList<Construct> constructs;
-       
-       public final HashMap<File, ArrayList<String>> contents;
-       
+       public final HashMap<File, SourceFileInfo> srcFilesInfo;
 
        public SpecExtractor() {
-               constructs = new ArrayList<Construct>();
-               contents = new HashMap<File, ArrayList<String>>();
+               srcFilesInfo = new HashMap<File, SourceFileInfo>();
+       }
+       
+       public ArrayList<Construct> getConstructs() {
+               ArrayList<Construct> constructs = new ArrayList<Construct>();
+               for (File f : srcFilesInfo.keySet()) {
+                       constructs.addAll(srcFilesInfo.get(f).constructs);
+               }
+               return constructs;
        }
        
        /**
@@ -50,14 +55,12 @@ public class SpecExtractor {
        }
 
        public void extract(File file) {
-               if (contents.containsKey(file))
+               if (srcFilesInfo.containsKey(file))
                        return;
-               ArrayList<String> content = new ArrayList<String>();
-               ArrayList<Construct> localConstructs = new ArrayList<Construct>();
+               SourceFileInfo srcFileInfo;
                try {
-                       SpecParser.ParseFile(file, content, localConstructs);
-                       contents.put(file, content);
-                       constructs.addAll(localConstructs);
+                       srcFileInfo = SpecParser.ParseFile(file);
+                       srcFilesInfo.put(file, srcFileInfo);
                } catch (ParseException e) {
                        e.printStackTrace();
                } catch (TokenMgrError e) {