parser.jay Fehler beheben
This commit is contained in:
parent
b910584c29
commit
7d4009b6ae
@ -3,7 +3,7 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry excluding=".classpath|.cvsignore|.externalToolBuilders/|.project|.settings/|Papers/|bin/|doc/|examples/|lib/|notizen/|src/|test/|tools/" including="log4j.xml" kind="src" path=""/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 8 [1.8.0]"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/CDC-1.0%Foundation-1.0"/>
|
||||
<classpathentry kind="lib" path="lib/junit-4.0.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -147,7 +147,6 @@ public Vector<Pair> testPair = new Vector<Pair>();
|
||||
%type <DeclId> variabledeclarator
|
||||
%type <DeclId> variabledeclaratorid
|
||||
%type <UsedId> simplename
|
||||
%type <UsedId> typename
|
||||
%type <UsedId> qualifiedname
|
||||
%type <UsedId> importqualifiedname
|
||||
%type <UsedId> importdeclaration
|
||||
@ -1237,8 +1236,9 @@ explicitconstructorinvocation : THIS '(' ')' ';'
|
||||
|
||||
classtypelist : classtype
|
||||
{
|
||||
RefType RT = new RefType(RT.get_UsedId().get_Name_1Element(),null,-1);
|
||||
RT.set_UsedId($1);
|
||||
//RefType RT = new RefType(RT.get_UsedId().get_Name_1Element(),null,-1);
|
||||
RefType RT = new RefType($1.get_Name_1Element(),null,-1);
|
||||
//RT.set_UsedId($1);
|
||||
//RT.setName(RT.get_UsedId().get_Name_1Element());
|
||||
$$=RT;
|
||||
}
|
||||
@ -1291,27 +1291,6 @@ primitivetype :BOOLEAN
|
||||
$$=$1;
|
||||
}
|
||||
|
||||
referencelongtype : typename parameter
|
||||
{
|
||||
if ($2 != null) {
|
||||
//$1.set_ParaList($2.get_ParaList());
|
||||
$1.set_ParaList($2);//Änderung von Andreas Stadelmeier. Type statt GenericVarType
|
||||
/* otth: originale (also diese) Parameterliste retten */
|
||||
//((UsedId)$1).vParaOrg = new Vector<Type>( $2.get_ParaList() );
|
||||
}
|
||||
UsedId uid = $1;
|
||||
RefType RT = new RefType(uid.getQualifiedName(),null,uid.getOffset());
|
||||
|
||||
RT.set_ParaList(uid.get_RealParaList());
|
||||
//RT.setName(uid.getQualifiedName());
|
||||
|
||||
|
||||
//PL 05-07-30 eingefuegt containedTypes ANFANG
|
||||
containedTypes.addElement(RT);
|
||||
//PL 05-07-30 eingefuegt containedTypes ENDE
|
||||
|
||||
$$=RT;
|
||||
}
|
||||
|
||||
referencetype :classorinterfacetype
|
||||
{
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.dhbwstuttgart.syntaxtree.type;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import de.dhbwstuttgart.parser.JavaClassName;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
@ -133,4 +135,11 @@ public class ExtendsWildcardType extends WildcardType implements ITypeContainer,
|
||||
return new JavaCodeResult("? extends "+this.extendsType.printJavaCode(resultSet));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||
Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||
ret.addAll(this.extendsType.getInvolvedTypePlaceholder());
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -763,6 +763,12 @@ public class RefType extends Type implements IMatchable
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type applyResultSet(ResultSet result) {
|
||||
|
||||
return super.applyResultSet(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert alle SuperWildcardTypes, die in diesem Typ enthalten sind.
|
||||
* Dabei werden auch die parameter auf SuperWildcardTypes durchsucht.
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.dhbwstuttgart.syntaxtree.type;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
@ -130,4 +132,10 @@ public class SuperWildcardType extends WildcardType implements ITypeContainer, I
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector<TypePlaceholder> getInvolvedTypePlaceholder() {
|
||||
Vector<TypePlaceholder> ret = super.getInvolvedTypePlaceholder();
|
||||
ret.addAll(this.superType.getInvolvedTypePlaceholder());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -262,6 +262,10 @@ public abstract class Type extends SyntaxTreeNode implements IItemWithOffset
|
||||
return new JavaCodeResult(this.name.toString());
|
||||
}
|
||||
|
||||
public Type applyResultSet(ResultSet result){
|
||||
return this.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert alle SuperWildcardTypes, die in diesem Typ enthalten sind.
|
||||
* @return
|
||||
|
@ -1,5 +1,7 @@
|
||||
package de.dhbwstuttgart.syntaxtree.type;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.ResultSet;
|
||||
@ -88,5 +90,4 @@ public class WildcardType extends Type{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -395,5 +395,15 @@ public class Pair
|
||||
if(this.TA2 instanceof TypePlaceholder)ret.add((TypePlaceholder)TA2);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Vector aus TA1 und TA2
|
||||
*/
|
||||
public Vector<Type> getTypes(){
|
||||
Vector<Type> ret = new Vector<>();
|
||||
ret.add(this.TA1);
|
||||
ret.add(this.TA2);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -103,6 +103,7 @@ class GenericVarPatch {
|
||||
}
|
||||
|
||||
public String getInsertString(ResultSet rs){
|
||||
//Hier sollten TPHs nicht aufgelöst sondern in Generische Variablen umgewandelt werden:
|
||||
String ret = "";
|
||||
Iterator<GenericVarDeclarationPatch> it1 = this.genericVarDeclarations.iterator();
|
||||
while(it1.hasNext()){
|
||||
@ -124,6 +125,14 @@ class GenericVarPatch {
|
||||
GenericVarDeclarationPatch toAdd = new GenericVarDeclarationPatch(tph);
|
||||
if(!this.genericVarDeclarations.contains(toAdd))this.genericVarDeclarations.add(toAdd);
|
||||
}
|
||||
|
||||
public void addTPHs(Vector<TypePlaceholder> TPHs) {
|
||||
for(TypePlaceholder tph: TPHs)this.add(tph);
|
||||
}
|
||||
|
||||
public void addPairs(Vector<Pair> pairs) {
|
||||
for(Pair pair : pairs)this.add(pair);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -156,6 +165,10 @@ class GenericVarExtendsDeclarationPatch {
|
||||
if(!(this.genericPair.equals(((GenericVarExtendsDeclarationPatch)o).genericPair)))return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return this.genericPair.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -174,7 +187,8 @@ class GenericVarDeclarationPatch {
|
||||
public String getInsertString(ResultSet resultSet){
|
||||
String ret = "";
|
||||
if(this.genericPair != null){
|
||||
ret += this.genericPair.printJavaCode(resultSet);
|
||||
//ret += this.genericPair.printJavaCode(resultSet);
|
||||
ret += this.genericPair.getName().toString();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class TypeInsertPoint extends SourcePatchPoint {
|
||||
* Dieser Konstruktor erstellt einen TypInsertPoint
|
||||
* @param insertPoint
|
||||
* @param insertNode - muss das gleiche sein wie "insertPoint"
|
||||
* @param insertType
|
||||
* @param insertType - der einzusetzende Typ
|
||||
* @param resultSet
|
||||
* @param generics - die generischen Parameter des einzusetzenden Typs
|
||||
*/
|
||||
|
@ -11,6 +11,7 @@ import de.dhbwstuttgart.core.IItemWithOffset;
|
||||
import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode;
|
||||
import de.dhbwstuttgart.syntaxtree.type.GenericTypeVar;
|
||||
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
||||
import de.dhbwstuttgart.syntaxtree.type.Type;
|
||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
||||
import de.dhbwstuttgart.typeinference.JavaCodeResult;
|
||||
import de.dhbwstuttgart.typeinference.Pair;
|
||||
@ -64,12 +65,44 @@ public class TypeInsertSet {
|
||||
* @param tpj
|
||||
*/
|
||||
private void insertType(TypeInsertPoint tip, TypePatchJob tpj){
|
||||
/*
|
||||
* Ablauf:
|
||||
* 1. Alle TypePlaceholder im einzusetzenden Typ ermitteln.
|
||||
* 2. Alle Constraints die mit diesen TPHs zusammenhängen ermitteln
|
||||
* 3. Alle TPHs, aus Schritt 1 und 2 zusammenfügen.
|
||||
* 4. Kontrollieren, welche TPHs in dem InsertKontext noch nicht bekannt sind.
|
||||
* 5. Alle Unbekannten TPHs herausfiltern (von den Pairs nur TA2)
|
||||
* 6. Alle unbekannten TPHs + Pairs als GenericTypeInsertPoint deklarieren.
|
||||
*/
|
||||
GenericVarPatch gPatch = new GenericVarPatch();//Set der Einzusetzenden generischen Variablendeklarationen
|
||||
//Schritt 1:
|
||||
Vector<TypePlaceholder> involvedTPHs = tip.getInsertType().getUnresolvedTPH(resultSet);//.getInvolvedTypePlaceholder();
|
||||
//Schritt 2:
|
||||
Vector<Pair> pairs = new Vector<>();
|
||||
for(Pair pair : this.resultSet.getConstraintsFor(tip.getInsertType().getInvolvedTypePlaceholder())){
|
||||
gPatch.add(pair);
|
||||
for(Pair pair : this.resultSet.getConstraintsFor(involvedTPHs)){
|
||||
//gPatch.add(pair); //Schritt 6 (Teil 2)
|
||||
pairs.add(pair);
|
||||
}
|
||||
//Schritt 3:
|
||||
Vector<TypePlaceholder> allTPHs = new Vector<>();
|
||||
for(TypePlaceholder tph : involvedTPHs){
|
||||
if(!allTPHs.contains(tph)){
|
||||
allTPHs.add(tph);
|
||||
}
|
||||
}
|
||||
//TODO: Schritt 4 (Es wird nicht kontrolliert, ob der TPH in dem Kontext schon bekannt ist)
|
||||
// und Schritt 5: (Es werden nur die TPHs übernommen, welche noch nicht in den involvedTPHs vorkommen)
|
||||
for(Pair pair : pairs)for(Type t : pair.getTypes())for(TypePlaceholder tph : t.getInvolvedTypePlaceholder()){
|
||||
if(!allTPHs.contains(tph)){
|
||||
allTPHs.add(tph);
|
||||
}
|
||||
}
|
||||
|
||||
//gPatch.addPairs(pairs);
|
||||
gPatch.addTPHs(allTPHs);
|
||||
|
||||
/*
|
||||
//TODO: Nur die TPH aus den Paaren entnehmen und Generische Variablen bilden
|
||||
//Kontrollieren ob alle in den Paaren vorhandenen Generischen Variablen in dem Bereich vorkommen:
|
||||
for(Pair pair : pairs){
|
||||
if(! tip.getInsertNode().seesType(pair.TA2)){
|
||||
@ -80,6 +113,8 @@ public class TypeInsertSet {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
GenericTypeInsertPoint gip = new GenericTypeInsertPoint(tip.getGenericTypeVarInsertNode(), gPatch, resultSet);
|
||||
typinferenzLog.debug("Erstellter GenericTypeInsertPoint: "+gip, Section.TYPEINFERENCE);
|
||||
tpj.add(tip);
|
||||
|
Loading…
Reference in New Issue
Block a user