Konvertierung von Methoden begonnen
This commit is contained in:
parent
4f4ca50c75
commit
ca327375c8
@ -21,11 +21,16 @@ import de.dhbwstuttgart.parser.antlr.Java17Parser;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.ClassBodyDeclarationContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.ClassOrInterfaceModifierContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.ClassorinterfacedeclContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.GenericDeclarationListContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.GenericmethodContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.MemberclassorinterfaceContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.MemberconstructorContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.MemberdeclContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.MemberfieldContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.MembermethodContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.MethodDeclarationContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.MethodHeaderContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.MethoddeclContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.ModifierContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.NoclassorinterfaceContext;
|
||||
import de.dhbwstuttgart.parser.antlr.Java17Parser.SrcfileContext;
|
||||
@ -180,6 +185,7 @@ public class ASTGen {
|
||||
for (ModifierContext mod : member.modifier()) {
|
||||
membermodifiers += allmodifiers.get(mod.getText());
|
||||
}
|
||||
String membername;
|
||||
switch (member.memberDeclaration()) {
|
||||
case MemberclassorinterfaceContext memberclsoif: {
|
||||
break;
|
||||
@ -189,7 +195,7 @@ public class ASTGen {
|
||||
break;
|
||||
}
|
||||
case MembermethodContext membermethod: {
|
||||
// TODO: parse methods
|
||||
methods.add(convert(membermodifiers, membermethod.method(), name, superClass, generics));
|
||||
break;
|
||||
}
|
||||
case MemberconstructorContext memberconstructor: {
|
||||
@ -230,7 +236,6 @@ public class ASTGen {
|
||||
Optional.of(this.generatePseudoConstructor(ctx.identifier().getText(), name, superClass, genericClassParameters,
|
||||
offset)),
|
||||
methods, constructors, genericClassParameters, superClass, isInterface, implementedInterfaces, offset);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -289,8 +294,33 @@ public class ASTGen {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Method convert(Java17Parser.MethodDeclarationContext methodDeclarationContext, JavaClassName parentClass,
|
||||
public Method convert(int modifiers, Java17Parser.MethodContext methodContext, JavaClassName parentClass,
|
||||
RefType superClass, GenericsRegistry generics) {
|
||||
GenericsRegistry localgenerics = generics;
|
||||
MethodDeclarationContext methoddeclaration;
|
||||
GenericDeclarationListContext genericdeclarations;GenericDeclarationList gtvDeclarations;
|
||||
MethodHeaderContext header;
|
||||
String name;
|
||||
if(methodContext instanceof GenericmethodContext){
|
||||
GenericmethodContext gmc = new GenericmethodContext(methodContext);
|
||||
genericdeclarations = gmc.genericMethodDeclaration().genericDeclarationList();
|
||||
methoddeclaration = gmc.genericMethodDeclaration().methodDeclaration();
|
||||
header = methoddeclaration.methodHeader();
|
||||
name = header.identifier().getText();
|
||||
localgenerics.putAll(createGenerics(genericdeclarations, parentClass, name, reg, generics));
|
||||
gtvDeclarations = TypeGenerator.convert(genericdeclarations, parentClass, name, reg, localgenerics);
|
||||
}else{
|
||||
MethoddeclContext mdc = new MethoddeclContext(methodContext);
|
||||
methoddeclaration = mdc.methodDeclaration();
|
||||
header = methoddeclaration.methodHeader();
|
||||
gtvDeclarations = new GenericDeclarationList(new ArrayList<>(), header.getStart());
|
||||
}
|
||||
|
||||
RefTypeOrTPHOrWildcardOrGeneric retType;
|
||||
if(header.refType() != null){
|
||||
retType = TypeGenerator.convert(header.refType())
|
||||
}
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user