Fix bei Typeinsetzung
This commit is contained in:
parent
e18439918c
commit
0c80a4c343
@ -3,6 +3,7 @@ package de.dhbwstuttgart.syntaxtree.factory;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dhbwstuttgart.exceptions.DebugException;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.parser.NullToken;
|
||||
import de.dhbwstuttgart.parser.scope.JavaClassName;
|
||||
@ -148,11 +149,11 @@ public class UnifyTypeFactory {
|
||||
if(tl instanceof TypePlaceholder){
|
||||
if(tr instanceof TypePlaceholder) {
|
||||
if(mp.getPairOp().equals(PairOperator.EQUALSDOT))
|
||||
return new PairTPHequalRefType((TypePlaceholder)tl, tr);
|
||||
throw new DebugException("TPH =. TPH ist ein ungültiges Ergebnis");
|
||||
else
|
||||
return new PairTPHsmallerTPH((TypePlaceholder)tl, (TypePlaceholder)tr);
|
||||
}
|
||||
return new PairTPHequalRefType((TypePlaceholder)tl, tr);
|
||||
return new PairTPHequalRefType((TypePlaceholder)tl, (RefType) tr);
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ public class TypeInsertFactory {
|
||||
|
||||
public static TypeInsert createInsertPoints(RefTypeOrTPHOrWildcardOrGeneric type, Token offset, ClassOrInterface cl, Method m,
|
||||
ResultSet resultSet) {
|
||||
Set<TypeInsertPoint> ret = new HashSet<>();
|
||||
ResolvedType resolvedType = resultSet.resolveType(type);
|
||||
TypeInsertPoint insertPoint = new TypeInsertPoint(offset,
|
||||
new TypeToInsertString(resolvedType.resolvedType).insert);
|
||||
|
@ -9,9 +9,9 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
*/
|
||||
public class PairTPHequalRefType extends ResultPair{
|
||||
public final TypePlaceholder left;
|
||||
public final RefTypeOrTPHOrWildcardOrGeneric right;
|
||||
public final RefType right;
|
||||
|
||||
public PairTPHequalRefType(TypePlaceholder left, RefTypeOrTPHOrWildcardOrGeneric right){
|
||||
public PairTPHequalRefType(TypePlaceholder left, RefType right){
|
||||
super(left, right);
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
|
@ -72,34 +72,11 @@ class Resolver implements ResultSetVisitor {
|
||||
|
||||
@Override
|
||||
public void visit(PairTPHequalRefType p) {
|
||||
RefTypeOrTPHOrWildcardOrGeneric otherSide = null;
|
||||
if(p.left.equals(toResolve)){
|
||||
resolved = p.right;
|
||||
otherSide = p.left;
|
||||
}
|
||||
if(p.right.equals(toResolve)){
|
||||
resolved = p.left;
|
||||
otherSide = p.right;
|
||||
}
|
||||
if(otherSide != null){
|
||||
if(resolved instanceof RefType){
|
||||
RelatedTypeWalker related = new RelatedTypeWalker(null, result);
|
||||
otherSide.accept(related);
|
||||
p.right.accept(related);
|
||||
additionalTPHs.addAll(related.relatedTPHs);
|
||||
}else if(resolved instanceof TypePlaceholder){
|
||||
RelatedTypeWalker related = new RelatedTypeWalker(null, result);
|
||||
resolved.accept(related);
|
||||
Set<ResultPair> newResultSet = new HashSet<>(result.results);
|
||||
newResultSet.remove(p);
|
||||
additionalTPHs.add(new GenericInsertPair((TypePlaceholder)resolved, null));
|
||||
ResolvedType resolvedType = new Resolver(new ResultSet(newResultSet)).resolve((TypePlaceholder) resolved);
|
||||
this.resolved = resolvedType.resolvedType;
|
||||
this.additionalTPHs.addAll(resolvedType.additionalGenerics);
|
||||
resolved.accept(related);
|
||||
this.additionalTPHs.addAll(related.relatedTPHs);
|
||||
}else {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,14 +137,10 @@ class TPHResolver implements ResultSetVisitor {
|
||||
@Override
|
||||
public void visit(PairTPHequalRefType p) {
|
||||
TypePlaceholder otherSide = null;
|
||||
if(p.left.equals(tph) && p.right instanceof TypePlaceholder){
|
||||
otherSide = (TypePlaceholder) p.right;
|
||||
}
|
||||
if(p.right.equals(tph)){
|
||||
otherSide = p.left;
|
||||
}
|
||||
if(otherSide != null){
|
||||
resolved.add(new GenericInsertPair(p.left, (TypePlaceholder) p.right));
|
||||
Set<ResultPair> newResultSet = new HashSet<>(this.resultSet.results);
|
||||
newResultSet.remove(p);
|
||||
resolved.addAll(new TPHResolver(otherSide, new ResultSet(newResultSet)).resolved);
|
||||
|
Loading…
Reference in New Issue
Block a user