fehler beheben
This commit is contained in:
parent
ea1e81bb95
commit
a355fe7786
@ -147,8 +147,7 @@ public class UnifyTypeFactory {
|
||||
RefTypeOrTPHOrWildcardOrGeneric tr = UnifyTypeFactory.convert(mp.getRhsType(), tphs);
|
||||
if(tl instanceof TypePlaceholder){
|
||||
if(tr instanceof TypePlaceholder) return new PairTPHsmallerTPH((TypePlaceholder)tl, (TypePlaceholder)tr);
|
||||
if(tr instanceof RefType)return new PairTPHequalRefType((TypePlaceholder)tl, (RefType)tr);
|
||||
throw new NotImplementedException();
|
||||
return new PairTPHequalRefType((TypePlaceholder)tl, tr);
|
||||
}else throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,7 @@ package de.dhbwstuttgart.typedeployment;
|
||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||
import de.dhbwstuttgart.typeinference.result.GenericInsertPair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResolvedType;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
import de.dhbwstuttgart.typeinference.result.*;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
|
||||
import java.util.*;
|
||||
@ -35,10 +33,8 @@ public class TypeInsertFactory {
|
||||
Set<TypeInsertPoint> ret = new HashSet<>();
|
||||
TypeInsertPoint insertPoint = null;
|
||||
ResolvedType resolvedType = resultSet.resolveType(type);
|
||||
if(resolvedType.resolvedType instanceof RefType){
|
||||
insertPoint = new TypeInsertPoint(offset,
|
||||
createInsertString((RefType) resolvedType.resolvedType));
|
||||
}
|
||||
new TypeToInsertString(resolvedType.resolvedType).insert);
|
||||
return new TypeInsert(insertPoint, new HashSet<>(Arrays.asList(createGenericInsert(resolvedType.additionalGenerics, cl, m))));
|
||||
/*
|
||||
for (Pair pair : pairs) {
|
||||
@ -107,29 +103,6 @@ public class TypeInsertFactory {
|
||||
*/
|
||||
}
|
||||
|
||||
private static String createInsertString(RefType resolved) {
|
||||
String insert = resolved.getName().toString();
|
||||
if(resolved.getParaList().size() > 0){
|
||||
insert += "<";
|
||||
Iterator<RefTypeOrTPHOrWildcardOrGeneric> iterator = resolved.getParaList().iterator();
|
||||
while(iterator.hasNext()){
|
||||
RefTypeOrTPHOrWildcardOrGeneric typeParam = iterator.next();
|
||||
if(typeParam instanceof TypePlaceholder){
|
||||
insert += ((TypePlaceholder) typeParam).getName();
|
||||
}else if(typeParam instanceof RefType) {
|
||||
insert += createInsertString((RefType) typeParam);
|
||||
}else if(typeParam instanceof SuperWildcardType){
|
||||
insert += "? super " + createInsertString(((SuperWildcardType) typeParam).getInnerType());
|
||||
}else if(typeParam instanceof ExtendsWildcardType){
|
||||
insert += "? extends " + createInsertString(((ExtendsWildcardType) typeParam).getInnerType());
|
||||
}else throw new NotImplementedException();
|
||||
if(iterator.hasNext())insert += ", ";
|
||||
}
|
||||
insert += ">";
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
|
||||
private static TypeInsertPoint createGenericInsert(Set<GenericInsertPair> toInsert, ClassOrInterface cl, Method m){
|
||||
//Momentan wird Methode ignoriert. Parameter werden immer als Klassenparameter angefügt:
|
||||
//Offset zum Einstzen bestimmen:
|
||||
@ -180,4 +153,57 @@ public class TypeInsertFactory {
|
||||
}
|
||||
return new TypeInsertPoint(offset, insert + end);
|
||||
}
|
||||
}
|
||||
|
||||
class TypeToInsertString implements ResultSetVisitor{
|
||||
String insert = "";
|
||||
|
||||
TypeToInsertString(RefTypeOrTPHOrWildcardOrGeneric type){
|
||||
type.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(PairTPHsmallerTPH p) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(PairTPHequalRefType p) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RefType resolved) {
|
||||
insert = resolved.getName().toString();
|
||||
if(resolved.getParaList().size() > 0){
|
||||
insert += "<";
|
||||
Iterator<RefTypeOrTPHOrWildcardOrGeneric> iterator = resolved.getParaList().iterator();
|
||||
while(iterator.hasNext()){
|
||||
RefTypeOrTPHOrWildcardOrGeneric typeParam = iterator.next();
|
||||
insert += new TypeToInsertString(typeParam).insert;
|
||||
if(iterator.hasNext())insert += ", ";
|
||||
}
|
||||
insert += ">";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(GenericRefType genericRefType) {
|
||||
insert += genericRefType.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(SuperWildcardType superWildcardType) {
|
||||
insert += "? super " + new TypeToInsertString(superWildcardType.getInnerType()).insert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(TypePlaceholder typePlaceholder) {
|
||||
insert += typePlaceholder.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(ExtendsWildcardType extendsWildcardType) {
|
||||
insert += "? extends " + new TypeToInsertString(extendsWildcardType.getInnerType()).insert;
|
||||
}
|
||||
}
|
@ -3,8 +3,6 @@ package de.dhbwstuttgart.typedeployment;
|
||||
import de.dhbwstuttgart.syntaxtree.*;
|
||||
import de.dhbwstuttgart.syntaxtree.statement.LambdaExpression;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultPair;
|
||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package de.dhbwstuttgart.typeinference.result;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
|
||||
/**
|
||||
@ -8,9 +9,9 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
*/
|
||||
public class PairTPHequalRefType extends ResultPair{
|
||||
public final TypePlaceholder left;
|
||||
public final RefType right;
|
||||
public final RefTypeOrTPHOrWildcardOrGeneric right;
|
||||
|
||||
public PairTPHequalRefType(TypePlaceholder left, RefType right){
|
||||
public PairTPHequalRefType(TypePlaceholder left, RefTypeOrTPHOrWildcardOrGeneric right){
|
||||
super(left, right);
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
|
@ -36,7 +36,7 @@ public class ResultSet {
|
||||
class Resolver implements ResultSetVisitor {
|
||||
private final ResultSet result;
|
||||
private TypePlaceholder toResolve;
|
||||
private RefType resolved;
|
||||
private RefTypeOrTPHOrWildcardOrGeneric resolved;
|
||||
private final Set<GenericInsertPair> additionalTPHs = new HashSet<>();
|
||||
|
||||
public Resolver(ResultSet resultPairs){
|
||||
@ -50,7 +50,6 @@ class Resolver implements ResultSetVisitor {
|
||||
resultPair.accept(this);
|
||||
}
|
||||
if(resolved==null){//TPH kommt nicht im Result vor:
|
||||
|
||||
}
|
||||
|
||||
return new ResolvedType(resolved, additionalTPHs);//resolved;
|
||||
@ -71,7 +70,7 @@ class Resolver implements ResultSetVisitor {
|
||||
if(p.left.equals(toResolve)){
|
||||
resolved = p.right;
|
||||
RelatedTypeWalker related = new RelatedTypeWalker(null, result);
|
||||
related.visit(p.right);
|
||||
p.right.accept(related);
|
||||
additionalTPHs.addAll(related.relatedTPHs);
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ public class JavaTXCompilerTest extends JavaTXCompiler {
|
||||
@Test
|
||||
public void test() throws IOException, java.lang.ClassNotFoundException {
|
||||
//filesToTest.add(new File(rootDirectory+"Faculty.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
||||
filesToTest.add(new File(rootDirectory+"test.jav"));
|
||||
filesToTest.add(new File(rootDirectory+"mathStruc.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"test.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda2.jav"));
|
||||
//filesToTest.add(new File(rootDirectory+"Lambda3.jav"));
|
||||
|
Loading…
Reference in New Issue
Block a user