2014-09-04 16:35:44 +02:00
|
|
|
package de.dhbwstuttgart.syntaxtree;
|
2016-12-16 00:00:37 +01:00
|
|
|
import java.util.*;
|
2015-08-27 13:36:14 +02:00
|
|
|
|
|
|
|
|
2017-03-02 18:16:14 +01:00
|
|
|
import de.dhbwstuttgart.parser.NullToken;
|
2016-12-15 15:45:23 +01:00
|
|
|
import de.dhbwstuttgart.typecheck.JavaClassName;
|
2017-03-06 17:59:01 +01:00
|
|
|
import de.dhbwstuttgart.typeinference.ConstraintSet;
|
2017-03-08 03:43:47 +01:00
|
|
|
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
2013-10-18 13:33:46 +02:00
|
|
|
|
|
|
|
|
2017-01-11 16:42:02 +01:00
|
|
|
public class SourceFile extends SyntaxTreeNode{
|
|
|
|
private String pkgName;
|
2016-12-16 00:00:37 +01:00
|
|
|
|
2017-01-11 16:42:02 +01:00
|
|
|
public List<ClassOrInterface> KlassenVektor = new ArrayList<>();
|
2016-12-07 14:32:48 +01:00
|
|
|
private List<JavaClassName> imports;
|
|
|
|
|
2013-10-18 13:33:46 +02:00
|
|
|
/**
|
2015-05-12 19:49:27 +02:00
|
|
|
* Die SourceFile repräsntiert eine zu einem Syntaxbaum eingelesene Java-Datei.
|
2014-02-11 16:30:38 +01:00
|
|
|
* SourceFile stellt dabei den Wurzelknoten des Syntaxbaumes dar.
|
2013-10-18 13:33:46 +02:00
|
|
|
*/
|
2017-01-11 16:42:02 +01:00
|
|
|
public SourceFile(String pkgName,List<ClassOrInterface> classDefinitions,List<JavaClassName> imports){
|
2017-03-02 18:16:14 +01:00
|
|
|
super(new NullToken());
|
2017-01-11 16:42:02 +01:00
|
|
|
this.KlassenVektor = classDefinitions;
|
|
|
|
if(pkgName != null){
|
|
|
|
this.pkgName = pkgName;
|
|
|
|
}
|
|
|
|
if(imports != null){
|
|
|
|
this.imports = imports;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public SourceFile(List<ClassOrInterface> classDefinitions){
|
|
|
|
this(null, classDefinitions, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SourceFile(String pkgName, List<ClassOrInterface> classDefinitions){
|
|
|
|
this(pkgName, classDefinitions, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SourceFile(List<ClassOrInterface> classDefinitions, List<JavaClassName> imports){
|
|
|
|
this(null, classDefinitions, imports);
|
|
|
|
}
|
2017-01-16 23:32:12 +01:00
|
|
|
|
|
|
|
public String getPkgName(){
|
|
|
|
return this.pkgName;
|
|
|
|
}
|
2017-02-22 21:25:57 +01:00
|
|
|
|
|
|
|
// Get imports (to test implementation)
|
|
|
|
public List<JavaClassName> getImports(){
|
|
|
|
return this.imports;
|
|
|
|
}
|
2017-03-06 17:59:01 +01:00
|
|
|
|
|
|
|
public ConstraintSet getConstraints(TypeInferenceInformation info){
|
|
|
|
ConstraintSet ret = new ConstraintSet();
|
|
|
|
for(ClassOrInterface cl : this.KlassenVektor){
|
|
|
|
ret.addAll(cl.getConstraints(info));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2013-10-18 13:33:46 +02:00
|
|
|
}
|