Aufräumen

This commit is contained in:
JanUlrich 2017-12-15 13:12:18 +01:00
parent 9919ecd083
commit 3a444c0172
2 changed files with 2 additions and 50 deletions

View File

@ -52,6 +52,7 @@ public class JavaTXCompiler {
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
for(File forSourceFile : sourceFiles.keySet())
for(JavaClassName name : sourceFiles.get(forSourceFile).getImports()){
//TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet
ClassOrInterface importedClass = ASTFactory.createClass(
ClassLoader.getSystemClassLoader().loadClass(name.toString()));
importedClasses.add(importedClass);
@ -96,7 +97,7 @@ public class JavaTXCompiler {
private SourceFile parse(File sourceFile) throws IOException, java.lang.ClassNotFoundException {
CompilationUnitContext tree = JavaTXParser.parse(sourceFile);
SyntaxTreeGenerator generator = new SyntaxTreeGenerator(environment.getRegistry(sourceFile), new GenericsRegistry(null));
SourceFile ret = generator.convert(tree,environment.packageCrawler);
SourceFile ret = generator.convert(tree, environment.packageCrawler);
return ret;
}

View File

@ -71,55 +71,6 @@ public class SyntaxTreeGenerator{
}
return ret;
}
/*
public void setImports(Java8Parser.CompilationUnitContext ctx) throws ClassNotFoundException {
List<JavaClassName> newImports = new ArrayList();
for(Java8Parser.ImportDeclarationContext importDeclCtx : ctx.importDeclaration()){
if(importDeclCtx.singleTypeImportDeclaration() != null){
newImports.add(convertSingleTypeImportDeclaration(importDeclCtx.singleTypeImportDeclaration()));
}
else if(importDeclCtx.typeImportOnDemandDeclaration() != null){
newImports.addAll(convertTypeImportOnDemandDeclaration(importDeclCtx.typeImportOnDemandDeclaration()));
}
else if(importDeclCtx.singleStaticImportDeclaration() != null){
newImports.add(convertSingleStaticImportDeclaration(importDeclCtx.singleStaticImportDeclaration()));
}
else{
newImports.addAll(convertStaticImportOnDemandDeclaration(importDeclCtx.staticImportOnDemandDeclaration()));
}
}
this.imports.addAll(newImports);
}
private JavaClassName convertSingleTypeImportDeclaration(Java8Parser.SingleTypeImportDeclarationContext ctx) throws ClassNotFoundException{
String typeName = convertTypeName(ctx.typeName());
JavaClassName ret = reg.getName(typeName);
return ret;
}
private List<JavaClassName> convertTypeImportOnDemandDeclaration(Java8Parser.TypeImportOnDemandDeclarationContext ctx){
return reg.getAllFromPackage(ctx.packageOrTypeName().getText());
}
private JavaClassName convertSingleStaticImportDeclaration(Java8Parser.SingleStaticImportDeclarationContext ctx){
throw new NotImplementedException();
}
private List<JavaClassName> convertStaticImportOnDemandDeclaration(Java8Parser.StaticImportOnDemandDeclarationContext ctx){
return reg.getAllFromPackage(ctx.typeName().getText());
}
*/
private String getPackageFromClass(String cls){
String ret = "";
String[] parts = cls.split("\\.");
for(int i = 0; i < parts.length - 1; i++){
ret = ret + "." + parts[i];
}
ret = ret.substring(1);
return ret;
}
public SourceFile convert(Java8Parser.CompilationUnitContext ctx, PackageCrawler packageCrawler) throws ClassNotFoundException{
List<ClassOrInterface> classes = new ArrayList<>();