forked from JavaTX/JavaCompilerCore
Helper methods to convert type names.
This commit is contained in:
parent
15f8a1b99d
commit
d63fe45d08
@ -14,6 +14,7 @@ import de.dhbwstuttgart.typecheck.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.lang.ClassNotFoundException;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||||
@ -82,6 +83,30 @@ public class SyntaxTreeGenerator{
|
|||||||
return this.reg;
|
return this.reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Converts type name to String.
|
||||||
|
public String convertTypeName(Java8Parser.TypeNameContext ctx){
|
||||||
|
String ret;
|
||||||
|
if(ctx.packageOrTypeName() == null){
|
||||||
|
ret = ctx.Identifier().toString();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ret = convertPackageOrTypeName(ctx.packageOrTypeName()) + "." + ctx.Identifier().toString();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Converts PackageOrTypeName to String.
|
||||||
|
public String convertPackageOrTypeName(Java8Parser.PackageOrTypeNameContext ctx){
|
||||||
|
String ret;
|
||||||
|
if(ctx.packageOrTypeName() == null){
|
||||||
|
ret = ctx.Identifier().toString();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
ret = convertPackageOrTypeName(ctx.packageOrTypeName()) + "." + ctx.Identifier().toString();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
public SourceFile convert(Java8Parser.CompilationUnitContext ctx){
|
public SourceFile convert(Java8Parser.CompilationUnitContext ctx){
|
||||||
List<ClassOrInterface> classes = new ArrayList<>();
|
List<ClassOrInterface> classes = new ArrayList<>();
|
||||||
this.getNames(ctx);
|
this.getNames(ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user