2014-09-04 16:35:44 +02:00
|
|
|
package de.dhbwstuttgart.syntaxtree;
|
2017-05-18 13:17:52 +02:00
|
|
|
import java.io.File;
|
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-16 20:02:53 +01:00
|
|
|
import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
2017-03-08 03:43:47 +01:00
|
|
|
import de.dhbwstuttgart.typeinference.assumptions.TypeInferenceInformation;
|
2017-05-18 13:17:52 +02:00
|
|
|
import sun.security.x509.X509CertInfo;
|
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-05-18 13:17:52 +02:00
|
|
|
private final List<ClassOrInterface> KlassenVektor;
|
|
|
|
private final List<JavaClassName> imports;
|
|
|
|
private final File file;
|
2016-12-07 14:32:48 +01:00
|
|
|
|
2017-05-18 13:17:52 +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-05-18 13:17:52 +02:00
|
|
|
public SourceFile(File file, 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;
|
2017-05-18 13:17:52 +02:00
|
|
|
this.pkgName = pkgName;
|
|
|
|
this.imports = imports;
|
|
|
|
this.file = file;
|
2017-01-11 16:42:02 +01:00
|
|
|
}
|
2017-01-16 23:32:12 +01:00
|
|
|
|
|
|
|
public String getPkgName(){
|
|
|
|
return this.pkgName;
|
|
|
|
}
|
2017-03-15 16:17:07 +01:00
|
|
|
|
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
|
|
|
|
2017-03-15 16:17:07 +01:00
|
|
|
public ConstraintSet getConstraints(TypeInferenceInformation info) {
|
2017-03-06 17:59:01 +01:00
|
|
|
ConstraintSet ret = new ConstraintSet();
|
2017-03-15 16:17:07 +01:00
|
|
|
for (ClassOrInterface cl : this.KlassenVektor) {
|
2017-03-06 17:59:01 +01:00
|
|
|
ret.addAll(cl.getConstraints(info));
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2017-03-15 16:17:07 +01: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;
|
|
|
|
}
|
2017-05-18 13:17:52 +02:00
|
|
|
|
|
|
|
public File getFile() {
|
|
|
|
return file;
|
|
|
|
}
|
2013-10-18 13:33:46 +02:00
|
|
|
}
|