forked from JavaTX/JavaCompilerCore
Method Parameter parsen
This commit is contained in:
parent
656b014ad4
commit
3299f329ea
@ -250,7 +250,16 @@ public class SyntaxTreeGenerator{
|
||||
private ParameterList convert(Java8Parser.FormalParameterListContext formalParameterListContext) {
|
||||
List<FormalParameter> ret = new ArrayList<>();
|
||||
if(formalParameterListContext != null){
|
||||
|
||||
for(Java8Parser.FormalParameterContext fp : formalParameterListContext.formalParameters().formalParameter()){
|
||||
String paramName = convert(fp.variableDeclaratorId());
|
||||
RefTypeOrTPH type;
|
||||
if(fp.unannType() != null){
|
||||
type = convert(fp.unannType());
|
||||
}else{
|
||||
type = TypePlaceholder.fresh(fp.getStart());
|
||||
}
|
||||
ret.add(new FormalParameter(paramName, type, fp.getStart()));
|
||||
}
|
||||
}
|
||||
return new ParameterList(ret);
|
||||
}
|
||||
@ -268,7 +277,7 @@ public class SyntaxTreeGenerator{
|
||||
}
|
||||
RefTypeOrTPH fieldType = convert(fieldDeclarationContext.unannType());
|
||||
for(Java8Parser.VariableDeclaratorContext varCtx : fieldDeclarationContext.variableDeclaratorList().variableDeclarator()){
|
||||
String fieldName = varCtx.variableDeclaratorId().getText();
|
||||
String fieldName = convert(varCtx.variableDeclaratorId());
|
||||
if(varCtx.variableInitializer() != null){
|
||||
initializeField(fieldDeclarationContext);
|
||||
}
|
||||
@ -278,7 +287,11 @@ public class SyntaxTreeGenerator{
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
private String convert(Java8Parser.VariableDeclaratorIdContext variableDeclaratorIdContext) {
|
||||
return variableDeclaratorIdContext.getText();
|
||||
}
|
||||
|
||||
// Initialize a field by creating implicit constructor.
|
||||
private void initializeField(Java8Parser.FieldDeclarationContext ctx){
|
||||
//TODO
|
||||
|
@ -1,13 +1,14 @@
|
||||
package de.dhbwstuttgart.syntaxtree;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPH;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
public class FormalParameter extends SyntaxTreeNode
|
||||
{
|
||||
private RefTypeOrTPH type;
|
||||
private String name;
|
||||
|
||||
public FormalParameter(String name, RefTypeOrTPH type, int offset){
|
||||
public FormalParameter(String name, RefTypeOrTPH type, Token offset){
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import de.dhbwstuttgart.syntaxtree.FormalParameter;
|
||||
public class LambdaParameter extends FormalParameter {
|
||||
|
||||
public LambdaParameter(FormalParameter fp) {
|
||||
super(null,null,0);
|
||||
super(null,null,null);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user