TypeInsert ausbessern
This commit is contained in:
parent
77c59de0f0
commit
397ac3cd58
@ -15,13 +15,9 @@ public class GenericTypeName extends JavaClassName {
|
|||||||
this.methodName = genericContext.parentMethod;
|
this.methodName = genericContext.parentMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString(){
|
public String getUniqueIdentifier() {
|
||||||
return parentClass.toString()
|
return parentClass.toString()
|
||||||
+ DELIMITER + methodName
|
+ DELIMITER + methodName
|
||||||
+ DELIMITER + super.toString();
|
+ DELIMITER + super.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getShortName() {
|
|
||||||
return super.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
package de.dhbwstuttgart.typedeployment;
|
package de.dhbwstuttgart.typedeployment;
|
||||||
|
|
||||||
import de.dhbwstuttgart.exceptions.DebugException;
|
|
||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||||
import de.dhbwstuttgart.syntaxtree.*;
|
import de.dhbwstuttgart.syntaxtree.*;
|
||||||
import de.dhbwstuttgart.syntaxtree.factory.ASTFactory;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.*;
|
import de.dhbwstuttgart.syntaxtree.type.*;
|
||||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||||
import org.antlr.v4.runtime.Token;
|
import org.antlr.v4.runtime.Token;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,9 +56,13 @@ public class TypeInsertFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(insertPoint == null){ //Dann muss es ein TPH sein, welcher nicht im Result auftaucht
|
if(insertPoint == null ){ //Dann muss es ein TPH sein, welcher nicht im Result auftaucht
|
||||||
insertPoint = new TypeInsertPoint(offset, ((TypePlaceholder) type).getName());
|
if(type instanceof TypePlaceholder){
|
||||||
additionalInserts.add(((TypePlaceholder) type));
|
insertPoint = new TypeInsertPoint(offset, ((TypePlaceholder) type).getName());
|
||||||
|
additionalInserts.add(((TypePlaceholder) type));
|
||||||
|
}else if(type instanceof GenericRefType){
|
||||||
|
insertPoint = new TypeInsertPoint(offset, ((GenericRefType) type).getName().toString());
|
||||||
|
}else throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Alle Bounds finden:
|
//Alle Bounds finden:
|
||||||
|
@ -27,37 +27,11 @@ public class TypeInsertPlacer extends AbstractASTWalker{
|
|||||||
TypeInsertPlacerClass cl = new TypeInsertPlacerClass(classOrInterface, withResults);
|
TypeInsertPlacerClass cl = new TypeInsertPlacerClass(classOrInterface, withResults);
|
||||||
this.inserts.addAll(cl.inserts);
|
this.inserts.addAll(cl.inserts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
List<TypeInsert> ret = new ArrayList<>();
|
|
||||||
|
|
||||||
for(ClassOrInterface cl : forSourcefile.getClasses()){
|
|
||||||
//Felder:
|
|
||||||
for(Field field : cl.getFieldDecl()){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
for(Method m : cl.getMethods()){
|
|
||||||
if(m.getReturnType() instanceof TypePlaceholder)for(Set<Pair> pairs : withResults.results) {
|
|
||||||
ret.add(createInsertPoints(
|
|
||||||
m.getReturnType(), m.getReturnType().getOffset(), cl, m, pairs));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(FormalParameter param : m.getParameterList().getFormalparalist()){
|
|
||||||
if(param.getType() instanceof TypePlaceholder)for(Set<Pair> pairs : withResults.results)
|
|
||||||
ret.add(createInsertPoints(
|
|
||||||
param.getType(), param.getType().getOffset(), cl, m, pairs));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TypeInsertPlacerClass extends AbstractASTWalker{
|
class TypeInsertPlacerClass extends AbstractASTWalker{
|
||||||
private final ResultSet results;
|
protected final ResultSet results;
|
||||||
private final ClassOrInterface cl;
|
protected final ClassOrInterface cl;
|
||||||
public final Set<TypeInsert> inserts = new HashSet<>();
|
public final Set<TypeInsert> inserts = new HashSet<>();
|
||||||
|
|
||||||
TypeInsertPlacerClass(ClassOrInterface forClass, ResultSet withResults){
|
TypeInsertPlacerClass(ClassOrInterface forClass, ResultSet withResults){
|
||||||
@ -68,7 +42,9 @@ class TypeInsertPlacerClass extends AbstractASTWalker{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(Method method) {
|
public void visit(Method method) {
|
||||||
TypeInsertPlacerMethod mWalker = new TypeInsertPlacerMethod(method);
|
for(Set<Pair> pairs : results.results)
|
||||||
|
inserts.add(TypeInsertFactory.createInsertPoints(
|
||||||
|
method.getReturnType(), method.getReturnType().getOffset(), cl, null, pairs));
|
||||||
super.visit(method);
|
super.visit(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,15 +57,14 @@ class TypeInsertPlacerClass extends AbstractASTWalker{
|
|||||||
}
|
}
|
||||||
super.visit(field);
|
super.visit(field);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class TypeInsertPlacerMethod extends AbstractASTWalker{
|
|
||||||
TypeInsertPlacerMethod(Method forMethod){
|
|
||||||
forMethod.accept(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(ParameterList params) {
|
public void visit(ParameterList params) {
|
||||||
|
for(FormalParameter param : params){
|
||||||
|
for(Set<Pair> pairs : results.results)
|
||||||
|
inserts.add(TypeInsertFactory.createInsertPoints(
|
||||||
|
param.getType(), param.getType().getOffset(), cl, null, pairs));
|
||||||
|
}
|
||||||
super.visit(params);
|
super.visit(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,5 +72,4 @@ class TypeInsertPlacerMethod extends AbstractASTWalker{
|
|||||||
public void visit(LambdaExpression lambdaExpression) {
|
public void visit(LambdaExpression lambdaExpression) {
|
||||||
//Lambda-Ausdrücke brauchen keine Typeinsetzungen
|
//Lambda-Ausdrücke brauchen keine Typeinsetzungen
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user