From ec4defd087a861e30ebffb541850d3d1198b1c24 Mon Sep 17 00:00:00 2001 From: Michael Uhl Date: Thu, 28 Mar 2019 14:56:36 +0100 Subject: [PATCH 1/4] Getter and setter for token. --- .../dhbwstuttgart/typedeployment/TypeInsertPoint.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsertPoint.java b/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsertPoint.java index 14c86b65..2551260b 100644 --- a/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsertPoint.java +++ b/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsertPoint.java @@ -8,7 +8,7 @@ import java.util.List; import java.util.stream.Collectors; public class TypeInsertPoint { - public final Token point; + public Token point; private String insertString; public TypeInsertPoint(Token point, String toInsert){ @@ -28,6 +28,14 @@ public class TypeInsertPoint { return insertString; } + public Token getToken() { + return this.point; + } + + public void setToken(Token point) { + this.point = point; + } + /* PL 2018-06-19 * Zwei TypeInsertPoint's sind gleich, wenn ihre point's gleich sind * eingefuegt damit man TypeReplaceMarker vergleichen kann From 1edc023ed9ec8c1ce7fc9fbb738e4014e882e709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pl=C3=BCmicke?= Date: Thu, 28 Mar 2019 17:44:42 +0100 Subject: [PATCH 2/4] modified: ../../../main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java modified: ../../../main/java/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java Generische Typvariablen im Unify durch Tag im ReferenceType eingefuehrt --- .../syntaxtree/factory/UnifyTypeFactory.java | 3 +++ .../unify/model/ReferenceType.java | 19 ++++++++++++++++++- src/test/java/bytecode/applyLambdaTest.java | 1 + src/test/resources/bytecode/javFiles/Id.jav | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java index a764db6e..d7528fad 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java @@ -225,12 +225,15 @@ public class UnifyTypeFactory { return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (RefType) tr); }else if(tr instanceof WildcardType){ return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (WildcardType) tr); + }else if(tr instanceof GenericRefType){ + return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (GenericRefType) tr); }else throw new NotImplementedException(); }else throw new NotImplementedException(); } public static RefTypeOrTPHOrWildcardOrGeneric convert(ReferenceType t, Map tphs) { if(JavaClassName.Void.equals(t.getName()))return new Void(new NullToken()); + if (t.isGenTypeVar()) return new GenericRefType(t.getName(),new NullToken()); RefType ret = new RefType(new JavaClassName(t.getName()),convert(t.getTypeParams(), tphs),new NullToken()); return ret; } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java index 5b17538e..4bd51b27 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/model/ReferenceType.java @@ -11,28 +11,45 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.UnifyTypeVisitor; * @author Florian Steurer * */ -public final class ReferenceType extends UnifyType { +public class ReferenceType extends UnifyType { /** * The buffered hashCode */ private final int hashCode; + /** + * gibt an, ob der ReferenceType eine generische Typvariable ist + */ + private final boolean genericTypeVar; + public UnifyType accept(UnifyTypeVisitor visitor, T ht) { return visitor.visit(this, ht); } + public ReferenceType(String name) { + super(name, new TypeParams()); + hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode(); + genericTypeVar = true; + } + public ReferenceType(String name, UnifyType... params) { super(name, new TypeParams(params)); hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode(); + genericTypeVar = false; } public ReferenceType(String name, TypeParams params) { super(name, params); hashCode = 31 + 17 * typeName.hashCode() + 17 * typeParams.hashCode(); + genericTypeVar = false; } + public boolean isGenTypeVar () { + return genericTypeVar; + } + @Override Set smArg(IFiniteClosure fc, Set fBounded) { return fc.smArg(this, fBounded); diff --git a/src/test/java/bytecode/applyLambdaTest.java b/src/test/java/bytecode/applyLambdaTest.java index 3c7ea452..6fb4722e 100644 --- a/src/test/java/bytecode/applyLambdaTest.java +++ b/src/test/java/bytecode/applyLambdaTest.java @@ -1,3 +1,4 @@ + package bytecode; import static org.junit.Assert.assertEquals; diff --git a/src/test/resources/bytecode/javFiles/Id.jav b/src/test/resources/bytecode/javFiles/Id.jav index 6cb5d4b0..03614a1b 100644 --- a/src/test/resources/bytecode/javFiles/Id.jav +++ b/src/test/resources/bytecode/javFiles/Id.jav @@ -1,6 +1,6 @@ public class Id { - id(b){ + id(A b){ return b; } } \ No newline at end of file From 2b5b677682c30f163f77779c3952c1013c23c463 Mon Sep 17 00:00:00 2001 From: Michael Uhl Date: Sun, 31 Mar 2019 11:39:57 +0200 Subject: [PATCH 3/4] =?UTF-8?q?F=C3=BCr=20Eclipse-Plugin:=20Vorl=C3=A4ufig?= =?UTF-8?q?e=20L=C3=B6sung=20zum=20Einsetzen=20von=20Generics=20nur=20an?= =?UTF-8?q?=20Klassen=20ausgeschaltet.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 4 ++-- src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java | 5 +++++ .../de/dhbwstuttgart/typedeployment/TypeInsertFactory.java | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index b90b76e2..f6a1fc87 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ http://maven.apache.org/maven-v4_0_0.xsd"> JavaTXcompiler jar - 0.1 + 0.2 JavaTXcompiler http://maven.apache.org @@ -127,7 +127,7 @@ http://maven.apache.org/maven-v4_0_0.xsd"> - de.dhbwstuttgart:JavaTXcompiler:0.1 + de.dhbwstuttgart:JavaTXcompiler:0.2 org.reflections:reflections:0.9.11 diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index e52cb826..7860fae9 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -60,6 +60,11 @@ public class JavaTXCompiler { public final Map sourceFiles = new HashMap<>(); Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll? + /** + * Äußerste Liste der Source-Files. + * Danach Liste der Klassen in Source File. + * Danach Map Klassenname + */ private List>> simplifyResultsSF = new ArrayList<>(); public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException { diff --git a/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java b/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java index 8834f859..a2abf30b 100644 --- a/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java +++ b/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsertFactory.java @@ -32,7 +32,7 @@ public class TypeInsertFactory { ResolvedType resolvedType = resultSet.resolveType(type); TypeInsertPoint insertPoint = new TypeInsertPoint(offset, new TypeToInsertString(resolvedType.resolvedType).insert); - return new TypeInsert(insertPoint, new HashSet<>(Arrays.asList(createGenericInsert(resolvedType.additionalGenerics, cl, m)))); + return new TypeInsert(insertPoint, new HashSet<>()); } private static TypeInsertPoint createGenericInsert(Set toInsert, ClassOrInterface cl, Method m){ From 6c94404f277d11aa6dc78b275707fec2995efcc9 Mon Sep 17 00:00:00 2001 From: Michael Uhl Date: Sun, 31 Mar 2019 11:45:49 +0200 Subject: [PATCH 4/4] [MINOR]: Optimized imports. --- src/main/java/de/dhbwstuttgart/typedeployment/TypeInsert.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsert.java b/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsert.java index 665bd380..04ee340c 100644 --- a/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsert.java +++ b/src/main/java/de/dhbwstuttgart/typedeployment/TypeInsert.java @@ -1,9 +1,6 @@ package de.dhbwstuttgart.typedeployment; -import org.antlr.v4.runtime.Token; - import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Set;