Dateien vergessen
This commit is contained in:
parent
db4442628b
commit
b2e79b35f3
93
src/typinferenz/GenericTypeInsertPoint.java
Normal file
93
src/typinferenz/GenericTypeInsertPoint.java
Normal file
@ -0,0 +1,93 @@
|
||||
package typinferenz;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.IItemWithOffset;
|
||||
import mycompiler.mytype.GenericTypeVar;
|
||||
import mycompiler.mytype.Pair;
|
||||
import mycompiler.mytype.RefType;
|
||||
import mycompiler.mytype.Type;
|
||||
|
||||
/**
|
||||
* Ein InsertPoint für Generische Variablen
|
||||
* @author janulrich
|
||||
*
|
||||
*/
|
||||
public class GenericTypeInsertPoint extends TypeInsertPoint {
|
||||
|
||||
private Vector<Pair> genericPairs = new Vector<Pair>();
|
||||
|
||||
public GenericTypeInsertPoint(TypeInsertPoint p) {
|
||||
super(p.point, p.type, p.resultSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt eine generische Variable in Form eines Pairs an.
|
||||
* @param p
|
||||
*/
|
||||
public void addGenericPair(Pair p){
|
||||
if(!this.genericPairs.contains(p))this.genericPairs.add(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaCodeResult getTypeInsertString() {
|
||||
if(genericPairs.size()==0)return new JavaCodeResult();
|
||||
return super.getTypeInsertString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Type getInsertType(){
|
||||
if(genericPairs.size()==0)return this.type;
|
||||
Iterator<Pair> it = genericPairs.iterator();
|
||||
String genericTypeParameters = "<";
|
||||
while(it.hasNext()){
|
||||
genericTypeParameters += new GenericTypeVar(it.next(), 0).printJavaCode(this.getResultSet());
|
||||
if(it.hasNext())genericTypeParameters += ", ";
|
||||
}
|
||||
genericTypeParameters += ">";
|
||||
//Der Generische Variablen String zum Einsetzen ist nun vorhanden
|
||||
this.type = new RefType(genericTypeParameters,0);
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(obj instanceof GenericTypeInsertPoint)return super.equals(obj);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TypeInsertPoint arg0) {
|
||||
int ret = new Integer(this.getOffset()).compareTo(new Integer(arg0.getOffset()));
|
||||
if(ret == 0){
|
||||
if(! (arg0 instanceof GenericTypeInsertPoint)){
|
||||
ret = new Integer(this.getOffset()-1).compareTo(new Integer(arg0.getOffset()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemWithOffset getInsertNode(){
|
||||
return super.getGenericTypeVarInsertNode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Versucht den GenericTypeInsertPoint mit dem übergebenenen p2 zusammenzuführen,
|
||||
* basierend auf ihren insertPoints.
|
||||
* @param p2
|
||||
* @return - Die bei der Zusammenführung entstandene GenericTypeInsertPoints
|
||||
*/
|
||||
public Vector<GenericTypeInsertPoint> merge(GenericTypeInsertPoint p2) {
|
||||
Vector<GenericTypeInsertPoint> ret = new Vector<GenericTypeInsertPoint>();
|
||||
if(this.getInsertNode().equals(p2.getInsertNode())){
|
||||
for(Pair p : p2.genericPairs)this.addGenericPair(p);
|
||||
ret.add(this);
|
||||
}else{
|
||||
ret.add(this);
|
||||
ret.add(p2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
17
src/typinferenz/TIPConstraints.java
Normal file
17
src/typinferenz/TIPConstraints.java
Normal file
@ -0,0 +1,17 @@
|
||||
package typinferenz;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import mycompiler.mytype.TypePlaceholder;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author janulrich
|
||||
*
|
||||
*/
|
||||
public class TIPConstraints {
|
||||
|
||||
public TIPConstraints(Vector<TypePlaceholder> involvedTPHs){
|
||||
|
||||
}
|
||||
}
|
3
test/plugindevelopment/TypeInsertTests/LambdaTest6.jav
Normal file
3
test/plugindevelopment/TypeInsertTests/LambdaTest6.jav
Normal file
@ -0,0 +1,3 @@
|
||||
class Matrix{
|
||||
op = (m) -> (f) -> f.apply(this, m);
|
||||
}
|
18
test/plugindevelopment/TypeInsertTests/LambdaTest6.java
Normal file
18
test/plugindevelopment/TypeInsertTests/LambdaTest6.java
Normal file
@ -0,0 +1,18 @@
|
||||
package plugindevelopment.TypeInsertTests;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class LambdaTest6 {
|
||||
|
||||
private static final String TEST_FILE = "LambdaTest6.jav";
|
||||
|
||||
@Test
|
||||
public void run(){
|
||||
Vector<String> mustContain = new Vector<String>();
|
||||
//mustContain.add("A var");
|
||||
MultipleTypesInsertTester.test(this.TEST_FILE, mustContain);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user