66 lines
1.8 KiB
Java
Executable File

package de.dhbwstuttgart.syntaxtree;
import java.io.File;
import java.util.*;
import de.dhbwstuttgart.parser.NullToken;
import de.dhbwstuttgart.typecheck.JavaClassName;
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
import sun.security.x509.X509CertInfo;
public class SourceFile extends SyntaxTreeNode{
private String pkgName;
private final List<ClassOrInterface> KlassenVektor;
private final List<JavaClassName> imports;
private final File file;
/**
* Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei.
* SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar.
*/
public SourceFile(File file, String pkgName, List<ClassOrInterface> classDefinitions, List<JavaClassName> imports){
super(new NullToken());
this.KlassenVektor = classDefinitions;
this.pkgName = pkgName;
this.imports = imports;
this.file = file;
}
public String getPkgName(){
return this.pkgName;
}
// Get imports (to test implementation)
public List<JavaClassName> 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<SourceFile> sourceFiles){
Set<ClassOrInterface> classes = new HashSet<>();
for(SourceFile sourceFile : sourceFiles){
classes.addAll(sourceFile.KlassenVektor);
}
return new TypeInferenceInformation(classes);
}
public List<ClassOrInterface> getClasses() {
return KlassenVektor;
}
public File getFile() {
return file;
}
}