From db4442628b443aed87f38839ffbb26cad0201bcf Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Wed, 23 Apr 2014 14:36:26 +0200 Subject: [PATCH] Bugfix --- src/mycompiler/mytype/Pair.java | 1 + src/mycompiler/mytype/Type.java | 4 ++-- src/typinferenz/ResultSet.java | 7 +++++++ src/typinferenz/TypeInsertPoint.java | 24 ++++++++++-------------- test/plugindevelopment/TRMEqualTest.java | 5 ++++- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/mycompiler/mytype/Pair.java b/src/mycompiler/mytype/Pair.java index f594797d..35ce4b3d 100755 --- a/src/mycompiler/mytype/Pair.java +++ b/src/mycompiler/mytype/Pair.java @@ -303,6 +303,7 @@ public class Pair { boolean ret = true; ret &= (obj instanceof Pair); + if(!ret)return ret; ret &= ((Pair)obj).TA1.equals(this.TA1); ret &= ((Pair)obj).TA2.equals(this.TA2); return ret; diff --git a/src/mycompiler/mytype/Type.java b/src/mycompiler/mytype/Type.java index f1765fb7..ba7cdca4 100755 --- a/src/mycompiler/mytype/Type.java +++ b/src/mycompiler/mytype/Type.java @@ -174,8 +174,8 @@ public class Type implements IItemWithOffset // ino.method.equals.26765.body { if(obj instanceof Type){ - String name2 = ((Type)obj).name; - return getName().equals(name2); + String name2 = ((Type)obj).printJavaCode(new ResultSet()).toString(); + return printJavaCode(new ResultSet()).toString().equals(name2); } else{ return false; diff --git a/src/typinferenz/ResultSet.java b/src/typinferenz/ResultSet.java index 5470d806..997c5c1d 100755 --- a/src/typinferenz/ResultSet.java +++ b/src/typinferenz/ResultSet.java @@ -21,6 +21,13 @@ public class ResultSet implements Iterable { resultPairs = resultSet; } + /** + * Erstellt ein leeres ResultSet + */ + public ResultSet() { + this(new Vector()); + } + public Vector getResultSet(){ return resultPairs; } diff --git a/src/typinferenz/TypeInsertPoint.java b/src/typinferenz/TypeInsertPoint.java index 3d17be9f..5f221900 100644 --- a/src/typinferenz/TypeInsertPoint.java +++ b/src/typinferenz/TypeInsertPoint.java @@ -21,26 +21,18 @@ public class TypeInsertPoint implements Comparable{ protected IItemWithOffset point; protected Type type; protected ResultSet resultSet; - protected Vector generics = null; - - public TypeInsertPoint(IItemWithOffset insertPoint, Type insertType, ResultSet resultSet){ - this(insertPoint, insertType, resultSet, null); - this.generics = this.getUnresolvedTPH();//Alle im insertType vorkommenden TPH müssen als Generics eingesetzt werden. - } /** - * Dieser Konstruktor erstellt einen TypInsertPoint, welcher nicht nur insertType einsetzt, - * sonder auch die übergebenen generischen Variablen einsetzt. + * Dieser Konstruktor erstellt einen TypInsertPoint * @param insertPoint * @param insertType * @param resultSet * @param generics - die generischen Parameter des einzusetzenden Typs */ - public TypeInsertPoint(IItemWithOffset insertPoint, Type insertType, ResultSet resultSet, Vector generics){ + public TypeInsertPoint(IItemWithOffset insertPoint, Type insertType, ResultSet resultSet){ this.point = insertPoint; this.type = insertType; this.resultSet = resultSet; - this.generics = generics; } /** @@ -62,7 +54,7 @@ public class TypeInsertPoint implements Comparable{ public Vector getUnresolvedTPH(){ Vector ret = new Vector(); - ret.addAll(this.type.getUnresolvedTPH(resultSet)); + ret.addAll(this.getInsertType().getUnresolvedTPH(resultSet)); return ret; } @@ -74,12 +66,16 @@ public class TypeInsertPoint implements Comparable{ return this.getInsertNode().getOffset(); } + protected Type getInsertType(){ + return this.type; + } + /** * Die Zeichenkette die durch diesen TypeInsertPoint eingesetzt wird. (Der Typ als String) * @return */ public JavaCodeResult getTypeInsertString(){ - JavaCodeResult ret = type.printJavaCode(this.resultSet).attach(" "); + JavaCodeResult ret = this.getInsertType().printJavaCode(this.resultSet).attach(" "); return ret; } @@ -94,9 +90,9 @@ public class TypeInsertPoint implements Comparable{ public boolean equals(Object obj){ if(! (obj instanceof TypeInsertPoint))return false; TypeInsertPoint equals = (TypeInsertPoint) obj; - if(!(equals.point.equals(this.point)))return false; + if(!(equals.getInsertNode().equals(this.getInsertNode())))return false; if(!(equals.resultSet.equals(this.resultSet)))return false; - if(!(equals.type.equals(this.type)))return false; + if(!(equals.getInsertType().equals(this.getInsertType())))return false; return true; } diff --git a/test/plugindevelopment/TRMEqualTest.java b/test/plugindevelopment/TRMEqualTest.java index 18585bc5..b3ae20d6 100644 --- a/test/plugindevelopment/TRMEqualTest.java +++ b/test/plugindevelopment/TRMEqualTest.java @@ -56,7 +56,10 @@ public class TRMEqualTest { resultContent.add(pair); ResultSet resultSet = new ResultSet(resultContent); Vector tphs = tph.getTypeInsertPoints(resultSet); - TypeInsertSet toAdd = new TypeInsertSet(tphs); + TypeInsertSet toAdd = new TypeInsertSet(); + for(TypeInsertPoint tip : tphs){ + toAdd.add(tip); + } System.out.println("Füge hinzu: "+toAdd); if(!replaceSet.contains(toAdd))replaceSet.add(toAdd); }