package de.dhbwstuttgart.syntaxtree; import java.util.*; import de.dhbwstuttgart.parser.NullToken; import de.dhbwstuttgart.typecheck.JavaClassName; import de.dhbwstuttgart.typeinference.ConstraintSet; import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation; public class SourceFile extends SyntaxTreeNode{ private String pkgName; private List KlassenVektor = new ArrayList<>(); private List imports; /** * Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei. * SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar. */ public SourceFile(String pkgName,List classDefinitions,List imports){ super(new NullToken()); this.KlassenVektor = classDefinitions; if(pkgName != null){ this.pkgName = pkgName; } if(imports != null){ this.imports = imports; } } public SourceFile(List classDefinitions){ this(null, classDefinitions, null); } public SourceFile(String pkgName, List classDefinitions){ this(pkgName, classDefinitions, null); } public SourceFile(List classDefinitions, List imports){ this(null, classDefinitions, imports); } public String getPkgName(){ return this.pkgName; } // Get imports (to test implementation) public List getImports(){ return this.imports; } public ConstraintSet getConstraints(TypeInferenceInformation info) { ConstraintSet ret = new ConstraintSet(); for (ClassOrInterface cl : this.KlassenVektor) { ret.addAll(cl.getConstraints(info)); } return ret; } public TypeInferenceInformation getTypeInferenceInformation(List sourceFiles){ Set classes = new HashSet<>(); for(SourceFile sourceFile : sourceFiles){ classes.addAll(sourceFile.KlassenVektor); } return new TypeInferenceInformation(classes); } public List getClasses() { return KlassenVektor; } }