diff --git a/src/de/dhbwstuttgart/parser/PackageCrawler.java b/src/de/dhbwstuttgart/parser/PackageCrawler.java index 007b4736..18bcd444 100644 --- a/src/de/dhbwstuttgart/parser/PackageCrawler.java +++ b/src/de/dhbwstuttgart/parser/PackageCrawler.java @@ -1,5 +1,6 @@ package de.dhbwstuttgart.parser; +import de.dhbwstuttgart.typecheck.JavaClassName; import org.reflections.Reflections; import org.reflections.scanners.ResourcesScanner; import org.reflections.scanners.SubTypesScanner; @@ -34,11 +35,12 @@ public class PackageCrawler { return classes; } - public static List getClassNames(String packageName){ - List nameList = new ArrayList(); + // Returns a list of JavaClassNames. + public static List getClassNames(String packageName){ + List nameList = new ArrayList(); Set> classes = getClassesInPackage(packageName); for(Class c : classes){ - nameList.add(c.getName()); + nameList.add(new JavaClassName(c.getName())); } return nameList; } diff --git a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java index 0d659d63..6e23c95d 100644 --- a/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java +++ b/src/de/dhbwstuttgart/parser/SyntaxTreeGenerator.java @@ -107,6 +107,41 @@ public class SyntaxTreeGenerator{ return ret; } + public void setImports(Java8Parser.CompilationUnitContext ctx){ + List newImports = new ArrayList(); + for(Java8Parser.ImportDeclarationContext importDeclCtx : ctx.importDeclaration()){ + if(importDeclCtx.singleTypeImportDeclaration() != null){ + newImports.add(convertSingleTypeImportDeclaration(importDeclCtx.singleTypeImportDeclaration())); + } + else if(importDeclCtx.typeImportOnDemandDeclaration() != null){ + newImports.add(convertTypeImportOnDemandDeclaration(importDeclCtx.typeImportOnDemandDeclaration())); + } + else if(importDeclCtx.singleStaticImportDeclaration() != null){ + newImports.add(convertSingleStaticImportDeclaration(importDeclCtx.singleStaticImportDeclaration())); + } + else{ + newImports.add(convertStaticImportOnDemandDeclaration(importDeclCtx.staticImportOnDemandDeclaration())); + } + } + this.imports.addAll(newImports); + } + + private JavaClassName convertSingleTypeImportDeclaration(Java8Parser.SingleTypeImportDeclarationContext ctx){ + return null; + } + + private JavaClassName convertTypeImportOnDemandDeclaration(Java8Parser.TypeImportOnDemandDeclarationContext ctx){ + return null; + } + + private JavaClassName convertSingleStaticImportDeclaration(Java8Parser.SingleStaticImportDeclarationContext ctx){ + return null; + } + + private JavaClassName convertStaticImportOnDemandDeclaration(Java8Parser.StaticImportOnDemandDeclarationContext ctx){ + return null; + } + public SourceFile convert(Java8Parser.CompilationUnitContext ctx){ List classes = new ArrayList<>(); this.getNames(ctx); diff --git a/src/de/dhbwstuttgart/typecheck/JavaClassName.java b/src/de/dhbwstuttgart/typecheck/JavaClassName.java index f037a5ba..669cd469 100644 --- a/src/de/dhbwstuttgart/typecheck/JavaClassName.java +++ b/src/de/dhbwstuttgart/typecheck/JavaClassName.java @@ -15,7 +15,7 @@ public class JavaClassName { private String name; private PackageName packageName; - JavaClassName(String name){ + public JavaClassName(String name){ if(name == null)throw new NullPointerException(); String[] names = name.split("[.]");