From 4263ff671d6fc84f580277449fde9eb6c7de11a6 Mon Sep 17 00:00:00 2001 From: Aldaron7 Date: Wed, 21 Mar 2018 14:06:59 +0100 Subject: [PATCH] generics in Construct --- src/de/dhbwstuttgart/strucTypes/Construct.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/de/dhbwstuttgart/strucTypes/Construct.java b/src/de/dhbwstuttgart/strucTypes/Construct.java index 3535ce80..37ef6c9a 100644 --- a/src/de/dhbwstuttgart/strucTypes/Construct.java +++ b/src/de/dhbwstuttgart/strucTypes/Construct.java @@ -7,6 +7,8 @@ import java.util.List; import org.antlr.v4.runtime.Token; import de.dhbwstuttgart.parser.NullToken; +import de.dhbwstuttgart.parser.SyntaxTreeGenerator.GenericContext; +import de.dhbwstuttgart.parser.scope.GenericTypeName; import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.strucTypes.constraint.ConstraintsSet; import de.dhbwstuttgart.strucTypes.constraint.SubTypeConstraint; @@ -82,7 +84,7 @@ public class Construct extends DefaultASTVisitor { List methods = new ArrayList<>(); List generics = new ArrayList<>(); List parameterInhTyterm = new ArrayList<>(); - final Token offset = i.getOffset(); + final Token offset = new NullToken(); // For über alle FieldConstraints mit ClassType i this.constraintsSet.getFieldConstraints().stream().filter(fc -> fc.getClassType().equals(i)).forEach(fc -> { @@ -90,7 +92,9 @@ public class Construct extends DefaultASTVisitor { parameterInhTyterm.add(fc.getFieldType()); // TODO generics.add(new GenericTypeVar(s, bounds, offset, // endOffset)); mit type - Field field = new Field(fc.getFieldName(), type, Modifier.fieldModifiers(), i.getOffset()); + generics.add(new GenericTypeVar(new GenericTypeName(new GenericContext(name, null), type.getName()), + new ArrayList<>(), offset, offset)); + Field field = new Field(fc.getFieldName(), type, Modifier.PUBLIC, i.getOffset()); fielddecl.add(field); }); @@ -100,6 +104,7 @@ public class Construct extends DefaultASTVisitor { parameterInhTyterm.add(mc.getReturnType()); // TODO generics.add(new GenericTypeVar(s, bounds, offset, // endOffset)); mit retrunType + generics.add(new GenericTypeVar(new GenericTypeName(new GenericContext(name, null), returnType.getName()), new ArrayList<>(), offset, offset)); Block block = new Block(new ArrayList<>(), offset); GenericDeclarationList gtvDeclarations = new GenericDeclarationList(new ArrayList<>(), offset); List params = new ArrayList<>(); @@ -109,9 +114,10 @@ public class Construct extends DefaultASTVisitor { parameterInhTyterm.add(supertype); // TODO generics.add(new GenericTypeVar(s, bounds, offset, // endOffset)); mit tph + generics.add(new GenericTypeVar(new GenericTypeName(new GenericContext(name, null), tph.getName()), new ArrayList<>(), offset, offset)); }); ParameterList parameterList = new ParameterList(params, offset); - Method method = new Method(Modifier.PUBLIC, mc.getMethodName(), returnType, Modifier.methodModifiers(), + Method method = new Method(Modifier.PUBLIC, mc.getMethodName(), returnType, Modifier.PUBLIC, parameterList, block, gtvDeclarations, offset); methods.add(method); }); @@ -123,7 +129,7 @@ public class Construct extends DefaultASTVisitor { this.subTypeConstraints.forEach(sc -> sc.inferTypes(this.inferredTypes)); - final int modifiers = Modifier.interfaceModifiers(); + final int modifiers = Modifier.PUBLIC; final RefType superClass = this.createSuperClass(); final boolean isInterface = true; final List constructors = new ArrayList<>();