forked from JavaTX/JavaCompilerCore
* Extend PackageCrawler
* Dummy methods for converting imports
This commit is contained in:
parent
d63fe45d08
commit
d5ba34e620
@ -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<String> getClassNames(String packageName){
|
||||
List<String> nameList = new ArrayList();
|
||||
// Returns a list of JavaClassNames.
|
||||
public static List<JavaClassName> getClassNames(String packageName){
|
||||
List<JavaClassName> nameList = new ArrayList();
|
||||
Set<Class<?>> classes = getClassesInPackage(packageName);
|
||||
for(Class c : classes){
|
||||
nameList.add(c.getName());
|
||||
nameList.add(new JavaClassName(c.getName()));
|
||||
}
|
||||
return nameList;
|
||||
}
|
||||
|
@ -107,6 +107,41 @@ public class SyntaxTreeGenerator{
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setImports(Java8Parser.CompilationUnitContext ctx){
|
||||
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.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<ClassOrInterface> classes = new ArrayList<>();
|
||||
this.getNames(ctx);
|
||||
|
@ -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("[.]");
|
||||
|
Loading…
Reference in New Issue
Block a user