forked from JavaTX/JavaCompilerCore
* 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.ParserRuleContext;
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
|
import de.dhbwstuttgart.typecheck.*;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -25,6 +26,9 @@ public class RunParser{
|
|||||||
SyntaxTreeGenerator generator = new SyntaxTreeGenerator();
|
SyntaxTreeGenerator generator = new SyntaxTreeGenerator();
|
||||||
// generator.convert((Java8Parser.CompilationUnitContext) tree);
|
// generator.convert((Java8Parser.CompilationUnitContext) tree);
|
||||||
generator.getNames(tree);
|
generator.getNames(tree);
|
||||||
|
for(JavaClassName name : generator.reg.existingClasses){
|
||||||
|
System.out.println(name.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(Exception e){
|
catch(Exception e){
|
||||||
System.out.println("An exception occured which is unknown and on our TODO list.");
|
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();
|
JavaClassRegistry reg = new JavaClassRegistry();
|
||||||
|
|
||||||
public void getNames(Java8Parser.CompilationUnitContext ctx){
|
public void getNames(Java8Parser.CompilationUnitContext ctx){
|
||||||
List<JavaClassName> names = new ArrayList();
|
|
||||||
String packageDecl = "";
|
String packageDecl = "";
|
||||||
List<TerminalNode> decls = ctx.packageDeclaration().Identifier();
|
List<TerminalNode> decls = ctx.packageDeclaration().Identifier();
|
||||||
if(decls != null){
|
if(decls != null){
|
||||||
@ -20,7 +19,14 @@ public class SyntaxTreeGenerator{
|
|||||||
packageDecl = packageDecl + "." + t.toString();
|
packageDecl = packageDecl + "." + t.toString();
|
||||||
}
|
}
|
||||||
packageDecl = packageDecl.substring(1);
|
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 String name;
|
||||||
private PackageName packageName;
|
private PackageName packageName;
|
||||||
|
|
||||||
JavaClassName(String name){
|
public JavaClassName(String name){
|
||||||
if(name == null)throw new NullPointerException();
|
if(name == null)throw new NullPointerException();
|
||||||
|
|
||||||
String[] names = name.split("[.]");
|
String[] names = name.split("[.]");
|
||||||
|
Loading…
Reference in New Issue
Block a user