forked from JavaTX/JavaCompilerCore
63 lines
1.8 KiB
Java
63 lines
1.8 KiB
Java
package de.dhbwstuttgart.syntaxtree;
|
|
|
|
import java.io.File;
|
|
import java.util.*;
|
|
|
|
import de.dhbwstuttgart.parser.NullToken;
|
|
import de.dhbwstuttgart.parser.scope.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;
|
|
|
|
public final List<ClassOrInterface> KlassenVektor;
|
|
public final Set<JavaClassName> 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<ClassOrInterface> classDefinitions, Set<JavaClassName> imports) {
|
|
super(new NullToken());
|
|
//if (classDefinitions.size() > 0) { // Enthält die Liste Klassen?
|
|
this.KlassenVektor = classDefinitions; // Klassen werden übernommen
|
|
//} else {
|
|
// this.KlassenVektor = null; // es handelt sich um ein "Java Module"
|
|
//}
|
|
this.pkgName = pkgName;
|
|
this.imports = imports;
|
|
}
|
|
|
|
public SourceFile(SourceFile sf) {
|
|
super(new NullToken());
|
|
this.KlassenVektor = new ArrayList<>(sf.KlassenVektor);
|
|
this.imports = new HashSet<>(sf.imports);
|
|
}
|
|
|
|
public String getPkgName() {
|
|
return this.pkgName;
|
|
}
|
|
|
|
// Get imports (to test implementation)
|
|
public Set<JavaClassName> getImports() {
|
|
return this.imports;
|
|
}
|
|
|
|
public List<ClassOrInterface> getClasses() {
|
|
return KlassenVektor;
|
|
}
|
|
|
|
public List<Method> getAllMethods() {
|
|
List<Method> ret = new ArrayList<>();
|
|
getClasses().forEach(cl -> ret.addAll(cl.getMethods()));
|
|
return ret;
|
|
}
|
|
|
|
@Override
|
|
public void accept(ASTVisitor visitor) {
|
|
visitor.visit(this);
|
|
}
|
|
}
|