Einsetzen von Generics geändert. Unvollständiger Zustand
This commit is contained in:
parent
eec8e4d1a8
commit
edfa85df7f
6
.project
6
.project
@ -7,12 +7,16 @@
|
|||||||
<buildSpec>
|
<buildSpec>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||||
<triggers>clean,incremental,</triggers>
|
<triggers>clean,full,incremental,</triggers>
|
||||||
<arguments>
|
<arguments>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>LaunchConfigHandle</key>
|
<key>LaunchConfigHandle</key>
|
||||||
<value><project>/.externalToolBuilders/JavaParserBuilder.launch</value>
|
<value><project>/.externalToolBuilders/JavaParserBuilder.launch</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
|
<dictionary>
|
||||||
|
<key>incclean</key>
|
||||||
|
<value>true</value>
|
||||||
|
</dictionary>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
|
@ -211,6 +211,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%type <ClassAndParameter> classidentifier
|
%type <ClassAndParameter> classidentifier
|
||||||
%type <InterfaceAndParameter> interfaceidentifier
|
%type <InterfaceAndParameter> interfaceidentifier
|
||||||
%type <Constant> constantdeclaration
|
%type <Constant> constantdeclaration
|
||||||
|
%type <GenericDeclarationList> genericdeclarationlist
|
||||||
%type <Field> fielddeclaration
|
%type <Field> fielddeclaration
|
||||||
%type <Method> methodheader
|
%type <Method> methodheader
|
||||||
%type <Method> methoddeclaration
|
%type <Method> methoddeclaration
|
||||||
@ -901,6 +902,14 @@ fielddeclarator :
|
|||||||
$$=ret;
|
$$=ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
genericdeclarationlist : '<' boundedMethodParameters '>'
|
||||||
|
{
|
||||||
|
GenericDeclarationList ret = new GenericDeclarationList($2);
|
||||||
|
ret.setOffset($3.getOffset());
|
||||||
|
$$ = ret;
|
||||||
|
}
|
||||||
|
|
||||||
fielddeclaration : fielddeclarator ';'
|
fielddeclaration : fielddeclarator ';'
|
||||||
{
|
{
|
||||||
$$=$1;
|
$$=$1;
|
||||||
@ -910,11 +919,11 @@ fielddeclaration : fielddeclarator ';'
|
|||||||
$2.setType($1);
|
$2.setType($1);
|
||||||
$$=$2;
|
$$=$2;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' type fielddeclarator ';'
|
| genericdeclarationlist type fielddeclarator ';'
|
||||||
{//angefügt von Andreas Stadelmeier
|
{//angefügt von Andreas Stadelmeier
|
||||||
$5.setType($4);
|
$3.setType($2);
|
||||||
$5.setGenericParameter($2);
|
$3.setGenericParameter($1);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
variabledeclarators ';'
|
variabledeclarators ';'
|
||||||
@ -1063,13 +1072,13 @@ boundedMethodParameters : boundedMethodParameter
|
|||||||
$$=$1;
|
$$=$1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns Method
|
// returns Method
|
||||||
methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
methodheader :genericdeclarationlist type methoddeclarator
|
||||||
{
|
{
|
||||||
$5.setType($4);
|
$3.setType($2);
|
||||||
$5.setGenericMethodParameters($2);
|
$3.setGenericParameter($1);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| type methoddeclarator
|
| type methoddeclarator
|
||||||
{
|
{
|
||||||
@ -1082,12 +1091,12 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
$3.setType($2);
|
$3.setType($2);
|
||||||
$$=$3;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers '<' boundedMethodParameters '>' type methoddeclarator
|
| modifiers genericdeclarationlist type methoddeclarator
|
||||||
{
|
{
|
||||||
$6.set_Modifiers($1);
|
$4.set_Modifiers($1);
|
||||||
$6.setGenericMethodParameters($3);
|
$4.setGenericParameter($2);
|
||||||
$6.setType($5);
|
$4.setType($3);
|
||||||
$$=$6;
|
$$=$4;
|
||||||
}
|
}
|
||||||
| type methoddeclarator throws
|
| type methoddeclarator throws
|
||||||
{
|
{
|
||||||
@ -1095,12 +1104,12 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
$2.set_ExceptionList($3);
|
$2.set_ExceptionList($3);
|
||||||
$$=$2;
|
$$=$2;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' type methoddeclarator throws
|
| genericdeclarationlist type methoddeclarator throws
|
||||||
{
|
{
|
||||||
$5.setGenericMethodParameters($2);
|
$3.setGenericParameter($1);
|
||||||
$5.setType($4);
|
$3.setType($2);
|
||||||
$5.set_ExceptionList($6);
|
$3.set_ExceptionList($4);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers type methoddeclarator throws
|
| modifiers type methoddeclarator throws
|
||||||
{
|
{
|
||||||
@ -1109,13 +1118,13 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
$3.set_ExceptionList($4);
|
$3.set_ExceptionList($4);
|
||||||
$$=$3;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers '<' boundedMethodParameters '>' type methoddeclarator throws
|
| modifiers genericdeclarationlist type methoddeclarator throws
|
||||||
{
|
{
|
||||||
$6.set_Modifiers($1);
|
$4.set_Modifiers($1);
|
||||||
$6.setGenericMethodParameters($3);
|
$4.setGenericParameter($2);
|
||||||
$6.setType($5);
|
$4.setType($3);
|
||||||
$6.set_ExceptionList($7);
|
$4.set_ExceptionList($5);
|
||||||
$$=$6;
|
$$=$4;
|
||||||
}
|
}
|
||||||
| VOID methoddeclarator
|
| VOID methoddeclarator
|
||||||
{
|
{
|
||||||
@ -1145,37 +1154,37 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
$3.set_ExceptionList($4);
|
$3.set_ExceptionList($4);
|
||||||
$$=$3;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' VOID methoddeclarator
|
| genericdeclarationlist VOID methoddeclarator
|
||||||
{
|
{
|
||||||
Void Voit = new Void($4.getOffset());
|
Void Voit = new Void($2.getOffset());
|
||||||
$5.setType(Voit);
|
$3.setType(Voit);
|
||||||
$5.setGenericMethodParameters($2);
|
$3.setGenericParameter($1);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers '<' boundedMethodParameters '>' VOID methoddeclarator
|
| modifiers genericdeclarationlist VOID methoddeclarator
|
||||||
{
|
{
|
||||||
Void voit = new Void($5.getOffset());
|
Void voit = new Void($3.getOffset());
|
||||||
$6.set_Modifiers($1);
|
$4.set_Modifiers($1);
|
||||||
$6.setType(voit);
|
$4.setType(voit);
|
||||||
$6.setGenericMethodParameters($3);
|
$4.setGenericParameter($2);
|
||||||
$$=$6;
|
$$=$4;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' VOID methoddeclarator throws
|
| genericdeclarationlist VOID methoddeclarator throws
|
||||||
{
|
{
|
||||||
Void voyt = new Void($4.getOffset());
|
Void voyt = new Void($2.getOffset());
|
||||||
$5.setType(voyt);
|
$3.setType(voyt);
|
||||||
$5.set_ExceptionList($6);
|
$3.set_ExceptionList($4);
|
||||||
$5.setGenericMethodParameters($2);
|
$3.setGenericParameter($1);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers '<' boundedMethodParameters '>' VOID methoddeclarator throws
|
| modifiers genericdeclarationlist VOID methoddeclarator throws
|
||||||
{
|
{
|
||||||
Void voyd = new Void($5.getOffset());
|
Void voyd = new Void($3.getOffset());
|
||||||
$6.set_Modifiers($1);
|
$4.set_Modifiers($1);
|
||||||
$6.setType(voyd);
|
$4.setType(voyd);
|
||||||
$6.set_ExceptionList($7);
|
$4.set_ExceptionList($5);
|
||||||
$6.setGenericMethodParameters($3);
|
$4.setGenericParameter($2);
|
||||||
$$=$6;
|
$$=$4;
|
||||||
}
|
}
|
||||||
|
|
||||||
| methoddeclarator
|
| methoddeclarator
|
||||||
@ -1183,11 +1192,11 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
||||||
$$=$1;
|
$$=$1;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' methoddeclarator
|
| genericdeclarationlist methoddeclarator
|
||||||
{
|
{
|
||||||
//auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh());
|
//auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh());
|
||||||
$4.setGenericMethodParameters($2);
|
$2.setGenericParameter($1);
|
||||||
$$=$4;
|
$$=$2;
|
||||||
}
|
}
|
||||||
|
|
||||||
| modifiers methoddeclarator
|
| modifiers methoddeclarator
|
||||||
|
@ -2,11 +2,11 @@ package mycompiler;
|
|||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import typinferenz.GenericTypeInsertPoint;
|
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
import typinferenz.TypeInsertable;
|
import typinferenz.TypeInsertable;
|
||||||
import typinferenz.exceptions.DebugException;
|
import typinferenz.exceptions.DebugException;
|
||||||
import typinferenz.exceptions.TypeinferenceException;
|
import typinferenz.exceptions.TypeinferenceException;
|
||||||
|
import typinferenz.typedeployment.GenericTypeInsertPoint;
|
||||||
import typinferenz.typedeployment.TypeInsertPoint;
|
import typinferenz.typedeployment.TypeInsertPoint;
|
||||||
import typinferenz.typedeployment.TypeInsertSet;
|
import typinferenz.typedeployment.TypeInsertSet;
|
||||||
import mycompiler.myclass.Class;
|
import mycompiler.myclass.Class;
|
||||||
@ -86,17 +86,12 @@ public abstract class SyntaxTreeNode{
|
|||||||
tip = that.createTypeInsertPoint((TypePlaceholder) t, result);
|
tip = that.createTypeInsertPoint((TypePlaceholder) t, result);
|
||||||
insertSet.add(tip);//ret.addAll(((TypePlaceholder)t).getTypeInsertPoints(result));
|
insertSet.add(tip);//ret.addAll(((TypePlaceholder)t).getTypeInsertPoints(result));
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
//Für den Fall, dass dieser Knoten Generische Variablen halten kann.
|
//Für den Fall, dass dieser Knoten Generische Variablen halten kann.
|
||||||
if(that instanceof Generic && that.getOffset()>=0){
|
if(that instanceof Generic && that.getOffset()>=0){
|
||||||
//Alle unresolvedTPHs ermitteln und GenericTypeVarInsertPoints bilden:
|
//Alle unresolvedTPHs ermitteln und GenericTypeVarInsertPoints bilden:
|
||||||
Vector<TypePlaceholder> uTPHs = insertSet.getUnresolvedTPHs();
|
Vector<TypePlaceholder> uTPHs = insertSet.getUnresolvedTPHs();
|
||||||
/*
|
|
||||||
for(TypePlaceholder tph : uTPHs){//GenericInsertPoints für diese TPHs bilden:
|
|
||||||
GenericTypeInsertPoint genericTIP = new GenericTypeInsertPoint(that,tph,result);
|
|
||||||
insertSet.add(genericTIP);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if(uTPHs.size()>0){//Nur wenn es auch unresolvedTPHs gibt:
|
if(uTPHs.size()>0){//Nur wenn es auch unresolvedTPHs gibt:
|
||||||
Vector<Pair> gPairs = result.getConstraintsFor(uTPHs);
|
Vector<Pair> gPairs = result.getConstraintsFor(uTPHs);
|
||||||
if(gPairs.size()>0){
|
if(gPairs.size()>0){
|
||||||
@ -105,7 +100,7 @@ public abstract class SyntaxTreeNode{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
import typinferenz.ConstraintsSet;
|
import typinferenz.ConstraintsSet;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
@ -162,7 +163,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
public static boolean isFirstLocalVarDecl; //Hilfsvariable fuer Offsets, hoth
|
public static boolean isFirstLocalVarDecl; //Hilfsvariable fuer Offsets, hoth
|
||||||
// ino.end
|
// ino.end
|
||||||
|
|
||||||
private Vector<GenericTypeVar> genericClassParameters=new Vector<GenericTypeVar>();
|
//private Vector<GenericTypeVar> genericClassParameters=new Vector<GenericTypeVar>();
|
||||||
|
|
||||||
// ino.attribute.containedTypes.23032.decldescription type=line
|
// ino.attribute.containedTypes.23032.decldescription type=line
|
||||||
// PL 05-07-30 eingefuegt. Vektor aller Typdeklarationen, die in der Klasse
|
// PL 05-07-30 eingefuegt. Vektor aller Typdeklarationen, die in der Klasse
|
||||||
@ -183,6 +184,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
protected Logger typinferenzLog = Logger.getLogger("Typeinference");
|
protected Logger typinferenzLog = Logger.getLogger("Typeinference");
|
||||||
private SyntaxTreeNode parent;
|
private SyntaxTreeNode parent;
|
||||||
private Vector<Field> fielddecl = new Vector<Field>();
|
private Vector<Field> fielddecl = new Vector<Field>();
|
||||||
|
private GenericDeclarationList genericClassParameters;
|
||||||
|
|
||||||
|
|
||||||
// ino.method.Class.23041.definition
|
// ino.method.Class.23041.definition
|
||||||
@ -1218,7 +1220,7 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
* @param tphs : Alle übriggebliebenen TypePLaceholder
|
* @param tphs : Alle übriggebliebenen TypePLaceholder
|
||||||
*/
|
*/
|
||||||
private void createGenericTypeVars(Vector<TypePlaceholder> tphs){
|
private void createGenericTypeVars(Vector<TypePlaceholder> tphs){
|
||||||
this.genericClassParameters = new Vector<GenericTypeVar>();
|
this.genericClassParameters = new GenericDeclarationList(new Vector<GenericTypeVar>());
|
||||||
for(TypePlaceholder tph : tphs){
|
for(TypePlaceholder tph : tphs){
|
||||||
GenericTypeVar toAdd = new GenericTypeVar(tph,this.getOffset());
|
GenericTypeVar toAdd = new GenericTypeVar(tph,this.getOffset());
|
||||||
if(!this.genericClassParameters.contains(toAdd))this.genericClassParameters.add(toAdd);
|
if(!this.genericClassParameters.contains(toAdd))this.genericClassParameters.add(toAdd);
|
||||||
@ -1362,10 +1364,17 @@ public class Class extends SyntaxTreeNode implements AClassOrInterface, IItemWit
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGenericParameter(Vector<GenericTypeVar> params) {
|
public void setGenericParameter(GenericDeclarationList params) {
|
||||||
this.genericClassParameters = params;
|
this.genericClassParameters = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGenericDeclOffset() {
|
||||||
|
//TODO: Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -25,6 +25,8 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
|
|||||||
private Type typ;
|
private Type typ;
|
||||||
|
|
||||||
private int offset;
|
private int offset;
|
||||||
|
|
||||||
|
private GenericDeclarationList genericParameters;
|
||||||
|
|
||||||
public Field(int offset){
|
public Field(int offset){
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
@ -128,6 +130,14 @@ public abstract class Field extends SyntaxTreeNode implements TypeInsertable, Ty
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGenericDeclOffset() {
|
||||||
|
//TODO: Falls Generische Parameterliste vorhanden, hier Wert der Liste zurückgegebn
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGenericParameter(GenericDeclarationList params) {
|
||||||
|
this.genericParameters = params;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class FieldDeclaration extends Field{
|
|||||||
|
|
||||||
private Expr wert;
|
private Expr wert;
|
||||||
//private Type type;
|
//private Type type;
|
||||||
private Vector<GenericTypeVar> parameter;
|
//private Vector<GenericTypeVar> parameter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dieser Konstruktor der FieldDeclaration erstellt den Syntaxknoten vollständig.
|
* Dieser Konstruktor der FieldDeclaration erstellt den Syntaxknoten vollständig.
|
||||||
@ -164,9 +164,4 @@ public class FieldDeclaration extends Field{
|
|||||||
if(this.getWert()!=null)this.getWert().wandleRefTypeAttributes2GenericAttributes(paralist, new Vector<GenericTypeVar>()); //FieldDeclaration hat keine Generischen Variablen, daher leere Liste übergeben
|
if(this.getWert()!=null)this.getWert().wandleRefTypeAttributes2GenericAttributes(paralist, new Vector<GenericTypeVar>()); //FieldDeclaration hat keine Generischen Variablen, daher leere Liste übergeben
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGenericParameter(Vector<GenericTypeVar> params) {
|
|
||||||
this.parameter = params;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,10 @@ import mycompiler.mytype.GenericTypeVar;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface Generic {
|
public interface Generic {
|
||||||
public void setGenericParameter(Vector<GenericTypeVar> params);
|
public void setGenericParameter(GenericDeclarationList params);
|
||||||
//public int getGenericParameterOffset();
|
/**
|
||||||
}
|
* Gibt den Offset im Quellcode an, an dem neue Deklarationen von generischen Variablen eingesetzt werden können.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getGenericDeclOffset();
|
||||||
|
}
|
@ -753,10 +753,7 @@ public class Method extends Field implements IItemWithOffset, TypeInsertable
|
|||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGenericParameter(Vector<GenericTypeVar> params) {
|
|
||||||
this.genericMethodParameters = params;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -211,6 +211,7 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
|||||||
%type <ClassAndParameter> classidentifier
|
%type <ClassAndParameter> classidentifier
|
||||||
%type <InterfaceAndParameter> interfaceidentifier
|
%type <InterfaceAndParameter> interfaceidentifier
|
||||||
%type <Constant> constantdeclaration
|
%type <Constant> constantdeclaration
|
||||||
|
%type <GenericDeclarationList> genericdeclarationlist
|
||||||
%type <Field> fielddeclaration
|
%type <Field> fielddeclaration
|
||||||
%type <Method> methodheader
|
%type <Method> methodheader
|
||||||
%type <Method> methoddeclaration
|
%type <Method> methoddeclaration
|
||||||
@ -901,6 +902,14 @@ fielddeclarator :
|
|||||||
$$=ret;
|
$$=ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
genericdeclarationlist : '<' boundedMethodParameters '>'
|
||||||
|
{
|
||||||
|
GenericDeclarationList ret = new GenericDeclarationList($2);
|
||||||
|
ret.setOffset($3.getOffset());
|
||||||
|
$$ = ret;
|
||||||
|
}
|
||||||
|
|
||||||
fielddeclaration : fielddeclarator ';'
|
fielddeclaration : fielddeclarator ';'
|
||||||
{
|
{
|
||||||
$$=$1;
|
$$=$1;
|
||||||
@ -910,11 +919,11 @@ fielddeclaration : fielddeclarator ';'
|
|||||||
$2.setType($1);
|
$2.setType($1);
|
||||||
$$=$2;
|
$$=$2;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' type fielddeclarator ';'
|
| genericdeclarationlist type fielddeclarator ';'
|
||||||
{//angefügt von Andreas Stadelmeier
|
{//angefügt von Andreas Stadelmeier
|
||||||
$5.setType($4);
|
$3.setType($2);
|
||||||
$5.setGenericParameter($2);
|
$3.setGenericParameter($1);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
|
|
|
|
||||||
variabledeclarators ';'
|
variabledeclarators ';'
|
||||||
@ -1063,13 +1072,13 @@ boundedMethodParameters : boundedMethodParameter
|
|||||||
$$=$1;
|
$$=$1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// returns Method
|
// returns Method
|
||||||
methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
methodheader :genericdeclarationlist type methoddeclarator
|
||||||
{
|
{
|
||||||
$5.setType($4);
|
$3.setType($2);
|
||||||
$5.setGenericMethodParameters($2);
|
$3.setGenericParameter($1);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| type methoddeclarator
|
| type methoddeclarator
|
||||||
{
|
{
|
||||||
@ -1082,12 +1091,12 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
$3.setType($2);
|
$3.setType($2);
|
||||||
$$=$3;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers '<' boundedMethodParameters '>' type methoddeclarator
|
| modifiers genericdeclarationlist type methoddeclarator
|
||||||
{
|
{
|
||||||
$6.set_Modifiers($1);
|
$4.set_Modifiers($1);
|
||||||
$6.setGenericMethodParameters($3);
|
$4.setGenericParameter($2);
|
||||||
$6.setType($5);
|
$4.setType($3);
|
||||||
$$=$6;
|
$$=$4;
|
||||||
}
|
}
|
||||||
| type methoddeclarator throws
|
| type methoddeclarator throws
|
||||||
{
|
{
|
||||||
@ -1095,12 +1104,12 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
$2.set_ExceptionList($3);
|
$2.set_ExceptionList($3);
|
||||||
$$=$2;
|
$$=$2;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' type methoddeclarator throws
|
| genericdeclarationlist type methoddeclarator throws
|
||||||
{
|
{
|
||||||
$5.setGenericMethodParameters($2);
|
$3.setGenericParameter($1);
|
||||||
$5.setType($4);
|
$3.setType($2);
|
||||||
$5.set_ExceptionList($6);
|
$3.set_ExceptionList($4);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers type methoddeclarator throws
|
| modifiers type methoddeclarator throws
|
||||||
{
|
{
|
||||||
@ -1109,13 +1118,13 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
$3.set_ExceptionList($4);
|
$3.set_ExceptionList($4);
|
||||||
$$=$3;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers '<' boundedMethodParameters '>' type methoddeclarator throws
|
| modifiers genericdeclarationlist type methoddeclarator throws
|
||||||
{
|
{
|
||||||
$6.set_Modifiers($1);
|
$4.set_Modifiers($1);
|
||||||
$6.setGenericMethodParameters($3);
|
$4.setGenericParameter($2);
|
||||||
$6.setType($5);
|
$4.setType($3);
|
||||||
$6.set_ExceptionList($7);
|
$4.set_ExceptionList($5);
|
||||||
$$=$6;
|
$$=$4;
|
||||||
}
|
}
|
||||||
| VOID methoddeclarator
|
| VOID methoddeclarator
|
||||||
{
|
{
|
||||||
@ -1145,37 +1154,37 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
$3.set_ExceptionList($4);
|
$3.set_ExceptionList($4);
|
||||||
$$=$3;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' VOID methoddeclarator
|
| genericdeclarationlist VOID methoddeclarator
|
||||||
{
|
{
|
||||||
Void Voit = new Void($4.getOffset());
|
Void Voit = new Void($2.getOffset());
|
||||||
$5.setType(Voit);
|
$3.setType(Voit);
|
||||||
$5.setGenericMethodParameters($2);
|
$3.setGenericParameter($1);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers '<' boundedMethodParameters '>' VOID methoddeclarator
|
| modifiers genericdeclarationlist VOID methoddeclarator
|
||||||
{
|
{
|
||||||
Void voit = new Void($5.getOffset());
|
Void voit = new Void($3.getOffset());
|
||||||
$6.set_Modifiers($1);
|
$4.set_Modifiers($1);
|
||||||
$6.setType(voit);
|
$4.setType(voit);
|
||||||
$6.setGenericMethodParameters($3);
|
$4.setGenericParameter($2);
|
||||||
$$=$6;
|
$$=$4;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' VOID methoddeclarator throws
|
| genericdeclarationlist VOID methoddeclarator throws
|
||||||
{
|
{
|
||||||
Void voyt = new Void($4.getOffset());
|
Void voyt = new Void($2.getOffset());
|
||||||
$5.setType(voyt);
|
$3.setType(voyt);
|
||||||
$5.set_ExceptionList($6);
|
$3.set_ExceptionList($4);
|
||||||
$5.setGenericMethodParameters($2);
|
$3.setGenericParameter($1);
|
||||||
$$=$5;
|
$$=$3;
|
||||||
}
|
}
|
||||||
| modifiers '<' boundedMethodParameters '>' VOID methoddeclarator throws
|
| modifiers genericdeclarationlist VOID methoddeclarator throws
|
||||||
{
|
{
|
||||||
Void voyd = new Void($5.getOffset());
|
Void voyd = new Void($3.getOffset());
|
||||||
$6.set_Modifiers($1);
|
$4.set_Modifiers($1);
|
||||||
$6.setType(voyd);
|
$4.setType(voyd);
|
||||||
$6.set_ExceptionList($7);
|
$4.set_ExceptionList($5);
|
||||||
$6.setGenericMethodParameters($3);
|
$4.setGenericParameter($2);
|
||||||
$$=$6;
|
$$=$4;
|
||||||
}
|
}
|
||||||
|
|
||||||
| methoddeclarator
|
| methoddeclarator
|
||||||
@ -1183,11 +1192,11 @@ methodheader :'<' boundedMethodParameters '>' type methoddeclarator
|
|||||||
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
//auskommentiert von Andreas Stadelmeier (a10023) $1.setType(TypePlaceholder.fresh());
|
||||||
$$=$1;
|
$$=$1;
|
||||||
}
|
}
|
||||||
| '<' boundedMethodParameters '>' methoddeclarator
|
| genericdeclarationlist methoddeclarator
|
||||||
{
|
{
|
||||||
//auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh());
|
//auskommentiert von Andreas Stadelmeier (a10023) $4.setType(TypePlaceholder.fresh());
|
||||||
$4.setGenericMethodParameters($2);
|
$2.setGenericParameter($1);
|
||||||
$$=$4;
|
$$=$2;
|
||||||
}
|
}
|
||||||
|
|
||||||
| modifiers methoddeclarator
|
| modifiers methoddeclarator
|
||||||
|
@ -20,6 +20,7 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
@ -769,6 +770,15 @@ public class RefType extends Type implements IMatchable
|
|||||||
ret.addAll(this.printJavaCode(resultSet).getUnresolvedTPH());
|
ret.addAll(this.printJavaCode(resultSet).getUnresolvedTPH());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||||
|
Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||||
|
for(Type param : this.parameter){
|
||||||
|
ret.addAll(param.getInvolvedTypePlaceholder());
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -291,5 +291,14 @@ public class Type implements IItemWithOffset
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sammelt alle TypePlaceholder, welche in diesem Typ vorkommen.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Vector<TypePlaceholder> getInvolvedTypePlaceholder(){
|
||||||
|
Vector<TypePlaceholder> ret = new Vector<>();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// ino.end
|
// ino.end
|
||||||
|
@ -115,7 +115,14 @@ public class TypePlaceholder extends Type implements IReplaceTypeEventProvider
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ino.method.makeNewName.26803.defdescription type=javadoc
|
@Override
|
||||||
|
public Vector<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||||
|
Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||||
|
ret.add(this);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ino.method.makeNewName.26803.defdescription type=javadoc
|
||||||
/**
|
/**
|
||||||
* Berechnet einen neuen, eindeutigen Namen f<EFBFBD>r eine neue
|
* Berechnet einen neuen, eindeutigen Namen f<EFBFBD>r eine neue
|
||||||
* <code>TypePlaceholder</code>. <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
* <code>TypePlaceholder</code>. <br>Author: J<EFBFBD>rg B<EFBFBD>uerle
|
||||||
|
@ -9,6 +9,7 @@ import mycompiler.mytype.TypePlaceholder;
|
|||||||
public class JavaCodeResult{
|
public class JavaCodeResult{
|
||||||
|
|
||||||
private String javaCode = "";
|
private String javaCode = "";
|
||||||
|
//TODO: unresolvedTPHs entfernen. BROKEN!
|
||||||
private Vector<TypePlaceholder> unresolvedTPHs = new Vector<TypePlaceholder>();
|
private Vector<TypePlaceholder> unresolvedTPHs = new Vector<TypePlaceholder>();
|
||||||
|
|
||||||
public JavaCodeResult(){
|
public JavaCodeResult(){
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package typinferenz;
|
package typinferenz.typedeployment;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import typinferenz.JavaCodeResult;
|
||||||
|
import typinferenz.ResultSet;
|
||||||
|
import typinferenz.TypeInsertable;
|
||||||
import typinferenz.exceptions.DebugException;
|
import typinferenz.exceptions.DebugException;
|
||||||
import typinferenz.typedeployment.TypeInsertPoint;
|
|
||||||
import mycompiler.IItemWithOffset;
|
import mycompiler.IItemWithOffset;
|
||||||
import mycompiler.SyntaxTreeNode;
|
import mycompiler.SyntaxTreeNode;
|
||||||
import mycompiler.mytype.GenericTypeVar;
|
import mycompiler.mytype.GenericTypeVar;
|
||||||
@ -18,41 +20,38 @@ import mycompiler.mytype.TypePlaceholder;
|
|||||||
* @author janulrich
|
* @author janulrich
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GenericTypeInsertPoint extends TypeInsertPoint {
|
public class GenericTypeInsertPoint extends SourcePatchPoint {
|
||||||
|
|
||||||
|
|
||||||
private Vector<Pair> genericPairs = new Vector<Pair>();
|
private GenericVarPatch patch;
|
||||||
|
|
||||||
public GenericTypeInsertPoint(TypeInsertPoint p) {
|
|
||||||
super(p.point, p.type, p.resultSet);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: Der Generic Type Insert Point sollte mit Generics konstruiert werden.
|
||||||
|
* Dabei hält jeder InsertPoint nur ein Generic. Die <>-Klammern fügt das insertSet in den Quellcode ein.
|
||||||
|
* Die Reihenfolge der GenericTIPs ist beim Einsetzen dann egal.
|
||||||
|
*/
|
||||||
public GenericTypeInsertPoint(TypeInsertable syntaxTreeNode,
|
public GenericTypeInsertPoint(TypeInsertable syntaxTreeNode,
|
||||||
TypePlaceholder tph ,ResultSet resultSet) {
|
GenericVarPatch gtv ,ResultSet resultSet) {
|
||||||
super(syntaxTreeNode, tph, resultSet);
|
this.patch = gtv;
|
||||||
|
this.point = syntaxTreeNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public GenericTypeInsertPoint(TypeInsertable syntaxTreeNode,
|
public GenericTypeInsertPoint(TypeInsertable syntaxTreeNode,
|
||||||
Vector<Pair> pairs,ResultSet resultSet) {
|
Vector<Pair> pairs,ResultSet resultSet) {
|
||||||
super(syntaxTreeNode, null, resultSet);
|
super(syntaxTreeNode, null, resultSet);
|
||||||
this.genericPairs = pairs;
|
this.genericPairs = pairs;
|
||||||
if(this.genericPairs.size() == 0)throw new DebugException("Menge der generischen Paare ist leer");
|
if(this.genericPairs.size() == 0)throw new DebugException("Menge der generischen Paare ist leer");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
/**
|
|
||||||
* 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
|
@Override
|
||||||
public JavaCodeResult getTypeInsertString() {
|
public JavaCodeResult getTypeInsertString() {
|
||||||
//if(genericPairs.size()==0)return new JavaCodeResult();
|
return this.patch.getInsertString();
|
||||||
return super.getTypeInsertString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
protected Type getInsertType(){
|
protected Type getInsertType(){
|
||||||
if(genericPairs.size()==0){
|
if(genericPairs.size()==0){
|
||||||
@ -83,6 +82,7 @@ public class GenericTypeInsertPoint extends TypeInsertPoint {
|
|||||||
this.type = new RefType(genericTypeParameters,0);
|
this.type = new RefType(genericTypeParameters,0);
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj){
|
public boolean equals(Object obj){
|
||||||
@ -91,19 +91,15 @@ public class GenericTypeInsertPoint extends TypeInsertPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(TypeInsertPoint arg0) {
|
public int compareTo(SourcePatchPoint arg0) {
|
||||||
int ret = new Integer(this.getOffset()).compareTo(new Integer(arg0.getOffset()));
|
int ret = super.compareTo(arg0);
|
||||||
if(ret == 0){
|
if(ret == 0)ret = -1;//Hack der dazu führt, dass GTIP vor anderen InsertTypes eingesetzt werden.
|
||||||
if(! (arg0 instanceof GenericTypeInsertPoint)){
|
|
||||||
ret = new Integer(this.getOffset()-1).compareTo(new Integer(arg0.getOffset()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TypeInsertable getInsertNode(){
|
public TypeInsertable getInsertNode(){
|
||||||
return super.getGenericTypeVarInsertNode();
|
return this.point;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +107,7 @@ public class GenericTypeInsertPoint extends TypeInsertPoint {
|
|||||||
* basierend auf ihren insertPoints.
|
* basierend auf ihren insertPoints.
|
||||||
* @param p2
|
* @param p2
|
||||||
* @return - Die bei der Zusammenf<FC>hrung entstandene GenericTypeInser
|
* @return - Die bei der Zusammenf<FC>hrung entstandene GenericTypeInser
|
||||||
*/
|
|
||||||
public Vector<GenericTypeInsertPoint> merge(GenericTypeInsertPoint p2) {
|
public Vector<GenericTypeInsertPoint> merge(GenericTypeInsertPoint p2) {
|
||||||
Vector<GenericTypeInsertPoint> ret = new Vector<GenericTypeInsertPoint>();
|
Vector<GenericTypeInsertPoint> ret = new Vector<GenericTypeInsertPoint>();
|
||||||
if(this.getInsertNode().equals(p2.getInsertNode())){
|
if(this.getInsertNode().equals(p2.getInsertNode())){
|
||||||
@ -123,14 +119,15 @@ public class GenericTypeInsertPoint extends TypeInsertPoint {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public JavaCodeResult insertType(String fileContent, int additionalOffset) {
|
public JavaCodeResult patch(String fileContent, int additionalOffset) {
|
||||||
//TODO: Es kann sein, dass eine Methode bereits Generische Variablen hat, diese müssen dann an diese Liste angefügt werden.
|
//TODO: Es kann sein, dass eine Methode bereits Generische Variablen hat, diese müssen dann an diese Liste angefügt werden.
|
||||||
|
|
||||||
return super.insertType(fileContent, additionalOffset);
|
return super.patch(fileContent, additionalOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public boolean associatedWith(TypeInsertPoint tip, ResultSet resultSet) {
|
public boolean associatedWith(TypeInsertPoint tip, ResultSet resultSet) {
|
||||||
if((tip.type instanceof TypePlaceholder)){
|
if((tip.type instanceof TypePlaceholder)){
|
||||||
Vector<TypePlaceholder> tphs = new Vector<>();
|
Vector<TypePlaceholder> tphs = new Vector<>();
|
||||||
@ -144,4 +141,9 @@ public class GenericTypeInsertPoint extends TypeInsertPoint {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int getOffset() {
|
||||||
|
return point.getOffset();
|
||||||
|
}
|
||||||
}
|
}
|
@ -19,11 +19,10 @@ import mycompiler.mytypereconstruction.replacementlistener.ITypeReplacementListe
|
|||||||
* @author janulrich
|
* @author janulrich
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TypeInsertPoint implements Comparable<TypeInsertPoint>{
|
public class TypeInsertPoint extends SourcePatchPoint {
|
||||||
|
|
||||||
public TypeInsertable point;
|
|
||||||
public Type type;
|
public Type type;
|
||||||
public ResultSet resultSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dieser Konstruktor erstellt einen TypInsertPoint
|
* Dieser Konstruktor erstellt einen TypInsertPoint
|
||||||
@ -44,7 +43,7 @@ public class TypeInsertPoint implements Comparable<TypeInsertPoint>{
|
|||||||
* @param additionalOffset - Falls mehrere Typen in einen Quellcode eingesetzet werden muss die Verschiebung der Offsets mit einbezogen werden.
|
* @param additionalOffset - Falls mehrere Typen in einen Quellcode eingesetzet werden muss die Verschiebung der Offsets mit einbezogen werden.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public JavaCodeResult insertType(String fileContent, int additionalOffset) {
|
public JavaCodeResult patch(String fileContent, int additionalOffset) {
|
||||||
String anfang = fileContent.substring(0, this.getInsertNode().getOffset()+additionalOffset);
|
String anfang = fileContent.substring(0, this.getInsertNode().getOffset()+additionalOffset);
|
||||||
JavaCodeResult mitte = this.getTypeInsertString();
|
JavaCodeResult mitte = this.getTypeInsertString();
|
||||||
String ende = fileContent.substring(this.getInsertNode().getOffset()+additionalOffset);
|
String ende = fileContent.substring(this.getInsertNode().getOffset()+additionalOffset);
|
||||||
@ -94,23 +93,16 @@ public class TypeInsertPoint implements Comparable<TypeInsertPoint>{
|
|||||||
if(! (obj instanceof TypeInsertPoint))return false;
|
if(! (obj instanceof TypeInsertPoint))return false;
|
||||||
TypeInsertPoint equals = (TypeInsertPoint) obj;
|
TypeInsertPoint equals = (TypeInsertPoint) obj;
|
||||||
if(!(equals.getInsertNode().equals(this.getInsertNode())))return false;
|
if(!(equals.getInsertNode().equals(this.getInsertNode())))return false;
|
||||||
if(!(equals.resultSet.equals(this.resultSet)))return false; //ResultSet spielt bei Equals keine Rolle
|
if(!(equals.getResultSet().equals(this.getResultSet())))return false; //ResultSet spielt bei Equals keine Rolle
|
||||||
if(!(equals.getInsertType().equals(this.getInsertType())))return false;
|
if(!(equals.getInsertType().equals(this.getInsertType())))return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compareTo(TypeInsertPoint arg0) {
|
|
||||||
return new Integer(this.getOffset()).compareTo(new Integer(arg0.getOffset()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResultSet getResultSet() {
|
|
||||||
return resultSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public TypeInsertable getGenericTypeVarInsertNode() {
|
public TypeInsertable getGenericTypeVarInsertNode() {
|
||||||
SyntaxTreeNode ret = (SyntaxTreeNode)this.point;
|
SyntaxTreeNode ret = (SyntaxTreeNode)this.getTIP();
|
||||||
while(!(ret instanceof Field || ret instanceof Class)){
|
while(!(ret instanceof Field || ret instanceof Class)){
|
||||||
ret = ret.getParent();
|
ret = ret.getParent();
|
||||||
if(ret == null){
|
if(ret == null){
|
||||||
|
@ -5,7 +5,6 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import typinferenz.GenericTypeInsertPoint;
|
|
||||||
import typinferenz.JavaCodeResult;
|
import typinferenz.JavaCodeResult;
|
||||||
import typinferenz.ResultSet;
|
import typinferenz.ResultSet;
|
||||||
import typinferenz.TypeInsertable;
|
import typinferenz.TypeInsertable;
|
||||||
@ -19,8 +18,7 @@ import mycompiler.mytype.TypePlaceholder;
|
|||||||
/*
|
/*
|
||||||
* Der Plan:
|
* Der Plan:
|
||||||
* SyntaxTreeNode generiert die TypeInsertPoints.
|
* SyntaxTreeNode generiert die TypeInsertPoints.
|
||||||
* Beim Einsetzen eines TIP werden die ebenfalls von den SyntaxTreeNodes berechneten GenericInsertPoints durchsucht nach den Punkten
|
* SyntaxTreeNode berechnet nicht die GenericInsertPoints. Das wird vom InsertSet übernommen.
|
||||||
* die mit dem einzusetzenden TIP zusammenhängen.
|
|
||||||
* Das funktioniert mithilfe des ResultSets. Denn es müssen alle Constraints mit einbezogen werden, da der Unify
|
* Das funktioniert mithilfe des ResultSets. Denn es müssen alle Constraints mit einbezogen werden, da der Unify
|
||||||
* Algorithmus als Ergebnis nur die zu einem RefType aufgelösten TPHs ausgibt.
|
* Algorithmus als Ergebnis nur die zu einem RefType aufgelösten TPHs ausgibt.
|
||||||
*/
|
*/
|
||||||
@ -68,13 +66,16 @@ public class TypeInsertSet {
|
|||||||
*/
|
*/
|
||||||
public String insertType(TypeInsertPoint tip, String fileContent){
|
public String insertType(TypeInsertPoint tip, String fileContent){
|
||||||
TypePatchJob tpj = new TypePatchJob();
|
TypePatchJob tpj = new TypePatchJob();
|
||||||
|
/*
|
||||||
int additionalOffset = 0;
|
int additionalOffset = 0;
|
||||||
String ret = fileContent;
|
String ret = fileContent;
|
||||||
JavaCodeResult unresolvedTPHs = tip.insertType(ret, additionalOffset);
|
JavaCodeResult unresolvedTPHs = tip.patch(ret, additionalOffset);
|
||||||
for(TypePlaceholder tph : unresolvedTPHs.getUnresolvedTPH()){
|
for(TypePlaceholder tph : unresolvedTPHs.getUnresolvedTPH()){
|
||||||
GenericTypeInsertPoint genericTIP = new GenericTypeInsertPoint(tip.getGenericTypeVarInsertNode(),tph,tip.getResultSet());
|
GenericTypeInsertPoint genericTIP = new GenericTypeInsertPoint(tip.getGenericTypeVarInsertNode(),tph,tip.getResultSet());
|
||||||
tpj.add(genericTIP);
|
tpj.add(genericTIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
tpj.add(tip);
|
tpj.add(tip);
|
||||||
|
|
||||||
return tpj.run(fileContent);
|
return tpj.run(fileContent);
|
||||||
@ -86,12 +87,13 @@ public class TypeInsertSet {
|
|||||||
* @param tpj
|
* @param tpj
|
||||||
*/
|
*/
|
||||||
public void insertType(TypeInsertPoint tip, TypePatchJob tpj){
|
public void insertType(TypeInsertPoint tip, TypePatchJob tpj){
|
||||||
for(GenericTypeInsertPoint gip : this.genericTypeInsertPoints){
|
GenericVarPatch gPatch = new GenericVarPatch();//Set der Einzusetzenden generischen Variablendeklarationen
|
||||||
if(gip.associatedWith(tip, this.resultSet)){
|
for(Pair pair : this.resultSet.getConstraintsFor(tip.getInsertType().getInvolvedTypePlaceholder())){
|
||||||
tpj.add(gip);
|
gPatch.add(pair);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
GenericTypeInsertPoint gip = new GenericTypeInsertPoint(tip.getGenericTypeVarInsertNode(), gPatch, resultSet);
|
||||||
tpj.add(tip);
|
tpj.add(tip);
|
||||||
|
tpj.add(gip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -208,17 +210,17 @@ public class TypeInsertSet {
|
|||||||
* Stellt eine Reihe von TypeInsertions dar
|
* Stellt eine Reihe von TypeInsertions dar
|
||||||
*/
|
*/
|
||||||
class TypePatchJob{
|
class TypePatchJob{
|
||||||
private Vector<TypeInsertPoint> points = new Vector<>();
|
private Vector<SourcePatchPoint> points = new Vector<>();
|
||||||
void add(TypeInsertPoint tip){
|
void add(SourcePatchPoint tip){
|
||||||
points.add(tip);
|
points.add(tip);
|
||||||
}
|
}
|
||||||
String run(String fileContent){
|
String run(String fileContent){
|
||||||
//sortieren (nach dem Offset der InsertPoints):
|
//sortieren (nach dem Offset der InsertPoints):
|
||||||
Collections.sort(points);
|
Collections.sort(points);
|
||||||
int additionalOffset = 0;
|
int additionalOffset = 0;
|
||||||
for(TypeInsertPoint p : points){
|
for(SourcePatchPoint p : points){
|
||||||
//Zuerst den Typ einsetzen
|
//Zuerst den Typ einsetzen
|
||||||
JavaCodeResult insertCode = p.insertType(fileContent, additionalOffset);
|
JavaCodeResult insertCode = p.patch(fileContent, additionalOffset);
|
||||||
fileContent = insertCode.toString();
|
fileContent = insertCode.toString();
|
||||||
//Dann Additional Offset korrigieren:
|
//Dann Additional Offset korrigieren:
|
||||||
additionalOffset += p.getInsertLength();
|
additionalOffset += p.getInsertLength();
|
||||||
|
Loading…
Reference in New Issue
Block a user