JavaPatternMatching/src/de/dhbwstuttgart/syntaxtree/SourceFile.java

66 lines
1.8 KiB
Java
Raw Normal View History

2014-09-04 14:35:44 +00:00
package de.dhbwstuttgart.syntaxtree;
import java.io.File;
import java.util.*;
2015-08-27 11:36:14 +00:00
2017-03-02 17:16:14 +00:00
import de.dhbwstuttgart.parser.NullToken;
2016-12-15 14:45:23 +00:00
import de.dhbwstuttgart.typecheck.JavaClassName;
2017-03-16 19:02:53 +00:00
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
//import sun.security.x509.X509CertInfo;
2013-10-18 11:33:46 +00:00
2017-01-11 15:42:02 +00:00
public class SourceFile extends SyntaxTreeNode{
private String pkgName;
private final List<ClassOrInterface> KlassenVektor;
private final List<JavaClassName> imports;
private final File file;
2016-12-07 13:32:48 +00:00
/**
* Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei.
* SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar.
2013-10-18 11:33:46 +00:00
*/
public SourceFile(File file, String pkgName, List<ClassOrInterface> classDefinitions, List<JavaClassName> imports){
2017-03-02 17:16:14 +00:00
super(new NullToken());
2017-01-11 15:42:02 +00:00
this.KlassenVektor = classDefinitions;
this.pkgName = pkgName;
this.imports = imports;
this.file = file;
2017-01-11 15:42:02 +00:00
}
public String getPkgName(){
return this.pkgName;
}
2017-03-15 15:17:07 +00:00
// Get imports (to test implementation)
public List<JavaClassName> getImports(){
return this.imports;
}
2017-03-06 16:59:01 +00:00
2017-03-15 15:17:07 +00:00
public ConstraintSet getConstraints(TypeInferenceInformation info) {
2017-03-06 16:59:01 +00:00
ConstraintSet ret = new ConstraintSet();
2017-03-15 15:17:07 +00:00
for (ClassOrInterface cl : this.KlassenVektor) {
2017-03-06 16:59:01 +00:00
ret.addAll(cl.getConstraints(info));
}
return ret;
}
2017-03-15 15:17:07 +00:00
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;
}
2013-10-18 11:33:46 +00:00
}