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