* Set JavaClassName constroctur to public.
* Implemented "class resolution" for interfaces.
This commit is contained in:
parent
599c8b2573
commit
fb10220da9
@ -5,6 +5,7 @@ import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.ParserRuleContext;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.typecheck.*;
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.io.ByteArrayInputStream;
|
||||
@ -25,6 +26,9 @@ public class RunParser{
|
||||
SyntaxTreeGenerator generator = new SyntaxTreeGenerator();
|
||||
// generator.convert((Java8Parser.CompilationUnitContext) tree);
|
||||
generator.getNames(tree);
|
||||
for(JavaClassName name : generator.reg.existingClasses){
|
||||
System.out.println(name.toString());
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
System.out.println("An exception occured which is unknown and on our TODO list.");
|
||||
|
@ -12,7 +12,6 @@ public class SyntaxTreeGenerator{
|
||||
JavaClassRegistry reg = new JavaClassRegistry();
|
||||
|
||||
public void getNames(Java8Parser.CompilationUnitContext ctx){
|
||||
List<JavaClassName> names = new ArrayList();
|
||||
String packageDecl = "";
|
||||
List<TerminalNode> decls = ctx.packageDeclaration().Identifier();
|
||||
if(decls != null){
|
||||
@ -20,7 +19,14 @@ public class SyntaxTreeGenerator{
|
||||
packageDecl = packageDecl + "." + t.toString();
|
||||
}
|
||||
packageDecl = packageDecl.substring(1);
|
||||
System.out.println(packageDecl);
|
||||
}
|
||||
for (Java8Parser.TypeDeclarationContext typeDecl : ctx.typeDeclaration()){
|
||||
if(typeDecl.interfaceDeclaration() != null){
|
||||
if(typeDecl.interfaceDeclaration().normalInterfaceDeclaration() != null){
|
||||
String nameString = packageDecl + "." + typeDecl.interfaceDeclaration().normalInterfaceDeclaration().Identifier().toString();
|
||||
this.reg.existingClasses.add(new JavaClassName(nameString));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,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