modified: src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java
Tests insertGenerics funtionieren modified: src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java modified: src/main/java/de/dhbwstuttgart/syntaxtree/factory/NameGenerator.java reset-Funktion eingefuegt, damit bei jedem Test die Namen der TypepLaceholdert von vorne beginnen modified: src/test/java/insertGenerics/TestContraVariant.java modified: src/test/java/insertGenerics/TestTPHsAndGenerics.java modified: src/test/java/insertGenerics/TestThreeArgs.java
This commit is contained in:
parent
9be64e4905
commit
0cb1f244bc
@ -195,7 +195,7 @@ public class TPHExtractor extends AbstractASTWalker {
|
||||
public void visit(Method method) {
|
||||
inMethod = true;
|
||||
String id = MethodUtility.createID(resolver,method);
|
||||
Predicate<Pair> filterUndConstraints = cs -> ((cs.TA1 instanceof TypePlaceholder) && (cs.TA1 instanceof TypePlaceholder) &&
|
||||
Predicate<Pair> filterUndConstraints = cs -> ((cs.TA1 instanceof TypePlaceholder) && (cs.TA2 instanceof TypePlaceholder) &&
|
||||
(resultSet.resolveType((TypePlaceholder)(cs.TA1)).resolvedType instanceof TypePlaceholder) &&
|
||||
(resultSet.resolveType((TypePlaceholder)(cs.TA2)).resolvedType instanceof TypePlaceholder));
|
||||
|
||||
|
@ -505,9 +505,11 @@ public class FamilyOfGeneratedGenerics {
|
||||
}
|
||||
MethodConstraint mc = new MethodConstraint(ta1, ta2, r);
|
||||
if(mc.getRel() == Relation.EXTENDS) {
|
||||
if(!checkForDuplicates(mc, tempMC)) {
|
||||
tempMC.add(mc);
|
||||
}
|
||||
if (!mc.getLeft().equals(mc.getRight())) { //eliminieren der Fälle wie AA<.AA
|
||||
if(!checkForDuplicates(mc, tempMC)) {
|
||||
tempMC.add(mc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return tempMC;
|
||||
@ -611,7 +613,7 @@ public class FamilyOfGeneratedGenerics {
|
||||
if(newPair.TA1 != newPair.TA2) { //eliminieren der Fälle wie AA<.AA
|
||||
if (!checkForDuplicatesForSets(newPair, tempSet)) {
|
||||
//TODO: evtl. pairExtends hinzufuegen
|
||||
tempSet.add(newPair);
|
||||
//tempSet.add(newPair);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -662,6 +664,7 @@ public class FamilyOfGeneratedGenerics {
|
||||
while(itExtends2.hasNext()) {
|
||||
Pair pairExtends2 = itExtends2.next();
|
||||
Iterator<Pair> itEqual2 = equalSet.iterator();
|
||||
|
||||
while (itEqual2.hasNext()) {
|
||||
boolean transClo = false;
|
||||
Pair pairEqual2 = itEqual2.next();
|
||||
@ -693,15 +696,17 @@ public class FamilyOfGeneratedGenerics {
|
||||
// break;
|
||||
//}
|
||||
//}
|
||||
if (tcOfCs.contains(newPairTPHConstraint)) {
|
||||
if (tcOfCs.contains(newPairTPHConstraint)|| (newPairTPHConstraint.getLeft().equals(newPairTPHConstraint.getRight()))) {
|
||||
transClo = true;
|
||||
}
|
||||
TypePlaceholder tphR = (TypePlaceholder) pairEqual2.TA2;
|
||||
Iterator<Pair> itUndCons = undCons.iterator();
|
||||
boolean rEqExRtilde = false;
|
||||
while (itUndCons.hasNext()) {
|
||||
Pair pairUndCons2 = itUndCons.next();
|
||||
boolean rEqExRtilde = (tphR == pairUndCons2.TA1);
|
||||
rEqExRtilde = rEqExRtilde || (tphR == pairUndCons2.TA1);
|
||||
// Pair rExRtildePair = new Pair(resSet.resolveType((TypePlaceholder) (tphR)).resolvedType, resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, PairOperator.SMALLERDOT);
|
||||
}
|
||||
boolean isPairInTExTapostrophe = false;
|
||||
// Constraint<Pair> allOfOr = new Constraint<Pair>();
|
||||
for(Set<Constraint<Pair>> scp: orCons) {
|
||||
@ -716,10 +721,10 @@ public class FamilyOfGeneratedGenerics {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ((rEqExRtilde || isPairInTExTapostrophe)) {
|
||||
|
||||
if (transClo && (rEqExRtilde || isPairInTExTapostrophe)) {
|
||||
if (!newPair2.TA1.equals(newPair2.TA2)) { //eliminieren der Fälle wie AA<.AA
|
||||
if (transClo && !checkForDuplicatesForSets(newPair2, tempSet2))
|
||||
tempSet2.add(newPair2);
|
||||
@ -727,10 +732,13 @@ public class FamilyOfGeneratedGenerics {
|
||||
if (!checkForDuplicatesForSets(pairExtends2, tempSet2))
|
||||
tempSet2.add(pairExtends2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
String key = ((TypePlaceholder)pairExtends2.TA2).getName();
|
||||
if (posOfTphs.containsKey(key)) {
|
||||
if (posOfTphs.get(key).contains(new PairTphMethod<>(PositionFinder.Position.METHOD, methodAndTPH.getId()))) {
|
||||
tempSet2.add(pairExtends2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,6 +102,7 @@ public class JavaTXCompiler {
|
||||
}
|
||||
classLoader = new DirectoryClassLoader(contextPath, ClassLoader.getSystemClassLoader());
|
||||
environment = new CompilationEnvironment(sources);
|
||||
de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset();
|
||||
for (File s : sources) {
|
||||
sourceFiles.put(s, parse(s));
|
||||
}
|
||||
|
@ -4,6 +4,16 @@ public class NameGenerator {
|
||||
|
||||
private static String strNextName = "A";
|
||||
|
||||
/**
|
||||
* Setzt den zu Beginn der Typinferenz auf "A" zurueck.
|
||||
* Dies ist beio den JUnit-Test noetig
|
||||
* <code>TypePlaceholder</code>. <br>Author: Martin Pluemicke
|
||||
* @return void
|
||||
*/
|
||||
public static void reset() {
|
||||
strNextName = "A";
|
||||
}
|
||||
|
||||
/**
|
||||
* Berechnet einen neuen, eindeutigen Namen f�r eine neue
|
||||
* <code>TypePlaceholder</code>. <br>Author: J�rg B�uerle
|
||||
|
@ -57,8 +57,8 @@ public class TestContraVariant {
|
||||
lmc.add(new MethodConstraint("O", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH Rm(TPH O)", lmc);
|
||||
lmc = new HashSet<>();
|
||||
lmc.add(new MethodConstraint("S", "O", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("O", "java/lang/Object", Relation.EXTENDS));
|
||||
//lmc.add(new MethodConstraint("S", "O", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("S", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH Rmain(TPH S)", lmc);
|
||||
|
||||
|
@ -70,9 +70,9 @@ public class TestTPHsAndGenerics {
|
||||
|
||||
lmc.add(new MethodConstraint("AI", "AE", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AD", "AI", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS));
|
||||
//lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AE", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AB", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc);
|
||||
lmc = new HashSet<>();
|
||||
lmc.add(new MethodConstraint("V", "UD", Relation.EXTENDS));
|
||||
@ -89,9 +89,9 @@ public class TestTPHsAndGenerics {
|
||||
|
||||
lmc.add(new MethodConstraint("AI", "AE", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AD", "AI", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS));
|
||||
//lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AE", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AB", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc);
|
||||
lmc = new HashSet<>();
|
||||
lmc.add(new MethodConstraint("V", "ETW", Relation.EXTENDS));
|
||||
@ -108,9 +108,9 @@ public class TestTPHsAndGenerics {
|
||||
|
||||
lmc.add(new MethodConstraint("AI", "AE", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AD", "AI", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS));
|
||||
//lmc.add(new MethodConstraint("AB", "AM", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AE", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AB", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH ABm(TPH ABTPH AD)", lmc);
|
||||
lmc = new HashSet<>();
|
||||
lmc.add(new MethodConstraint("V", "VK", Relation.EXTENDS));
|
||||
|
@ -59,8 +59,9 @@ public class TestThreeArgs {
|
||||
HashMap<String, Set<MethodConstraint>> methodConstraintsWithPositionTest = new HashMap<>();
|
||||
Set<MethodConstraint> lmc;
|
||||
lmc = new HashSet<>();
|
||||
lmc.add(new MethodConstraint("P", "R", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("P", "AF", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("Q", "java/lang/Object", Relation.EXTENDS));
|
||||
lmc.add(new MethodConstraint("AF", "java/lang/Object", Relation.EXTENDS));
|
||||
methodConstraintsWithPositionTest.put("TPH AFid(TPH P)", lmc);
|
||||
lmc = new HashSet<>();
|
||||
lmc.add(new MethodConstraint("AF", "W", Relation.EXTENDS));
|
||||
@ -84,7 +85,8 @@ public class TestThreeArgs {
|
||||
compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles);
|
||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||
classToTest = loader.loadClass(className);
|
||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
//liefert Fehler, da Variable "a" nicht initialisiert ist.
|
||||
//instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||
return new TestResultSet();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user