diff --git a/.gitignore b/.gitignore index b080f27c..2d0d6112 100644 --- a/.gitignore +++ b/.gitignore @@ -29,4 +29,3 @@ logFiles/** src/main/java/de/dhbwstuttgart/parser/antlr/ src/main/java/de/dhbwstuttgart/sat/asp/parser/antlr/ -/pull.sh diff --git a/src/main/java/de/dhbwstuttgart/bytecode/TPHExtractor.java b/src/main/java/de/dhbwstuttgart/bytecode/TPHExtractor.java index f6292f3b..6f443a47 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/TPHExtractor.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/TPHExtractor.java @@ -10,6 +10,9 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.function.Function; +import java.util.function.Predicate; +import java.util.stream.Collectors; import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; @@ -30,6 +33,9 @@ import de.dhbwstuttgart.syntaxtree.type.GenericRefType; import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; +import de.dhbwstuttgart.typeinference.constraints.Constraint; +import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; +import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.result.GenericInsertPair; import de.dhbwstuttgart.typeinference.result.ResultPair; import de.dhbwstuttgart.typeinference.result.ResultSet; @@ -49,6 +55,10 @@ public class TPHExtractor extends AbstractASTWalker { boolean inLocalOrParamOrReturn = false; public final ArrayList ListOfMethodsAndTph = new ArrayList<>(); + + // Alle Constraints in einer Menge (Und- & Oder-Constraints) + public Set oldConstraints = new HashSet<>(); + final ArrayList> allPairs = new ArrayList<>(); public final ArrayList allCons = new ArrayList<>(); private ResultSet resultSet; @@ -78,15 +88,25 @@ public class TPHExtractor extends AbstractASTWalker { public void visit(TypePlaceholder tph) { if (resultSet.resolveType(tph).resolvedType instanceof TypePlaceholder) { TypePlaceholder resolvedTPH = (TypePlaceholder) resultSet.resolveType(tph).resolvedType; - if (inMethod) { - methodAndTph.getTphs().add(resolvedTPH.getName()); - if (inLocalOrParamOrReturn) - methodAndTph.getLocalTphs().add(resolvedTPH.getName()); - }else { - tphsClass.add(resolvedTPH.getName()); + String tphName = resolvedTPH.getName(); + if (inMethod && !tphsClass.contains(tphName)) { + ArrayList tphs = null; + if (!(tphs = methodAndTph.getTphs()).contains(tphName)) { + methodAndTph.addTph(tphName); + } + if (inLocalOrParamOrReturn) { + if (!(tphs = methodAndTph.getLocalTphs()).contains(tphName)) { + tphs.add(tphName); + } + } + } else { + if (!tphsClass.contains(tphName)) { + tphsClass.add(tphName); + } + } + if (!allTPHS.containsKey(tphName)) { + allTPHS.put(tphName, inMethod); } - - allTPHS.put(resolvedTPH.getName(), inMethod); // final List cons = new ArrayList<>(); // resultSet.resolveType(tph).additionalGenerics.forEach(ag -> { // TPHConstraint con = new ExtendsConstraint(ag.TA1.getName(), ag.TA2.getName(), Relation.EXTENDS); @@ -153,7 +173,7 @@ public class TPHExtractor extends AbstractASTWalker { public void visit(GenericRefType genericRefType) { String name = genericRefType.getParsedName(); if (inMethod) { - methodAndTph.getTphs().add(name); + methodAndTph.addTph(name); if (inLocalOrParamOrReturn) methodAndTph.getLocalTphs().add(name); }else { @@ -175,7 +195,33 @@ public class TPHExtractor extends AbstractASTWalker { public void visit(Method method) { inMethod = true; String id = MethodUtility.createID(resolver,method); - methodAndTph = new MethodAndTPH(id); + Predicate 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)); + + Function, ConstraintSet> filterConstrRemainingTVar = + csS -> { + ConstraintSet ret = new ConstraintSet<>(); + ret.addAllUndConstraint( + csS.getUndConstraints() + .stream().filter(filterUndConstraints) + .collect(Collectors.toCollection(Constraint::new))); + + csS.getOderConstraints() + .forEach(oConSSet -> { Set> setCons = new HashSet<>(); + oConSSet.forEach(OConS -> { Constraint newConsPair = new Constraint(); + newConsPair.isStatement = OConS.isStatement; + setCons.add( + OConS.stream() + .filter(filterUndConstraints) + .collect(Collectors.toCollection(() -> newConsPair)) ); + } ); + ret.addOderConstraint(setCons);} ); + return ret; + }; + ConstraintSet filteredConstraints = filterConstrRemainingTVar.apply(method.getConstraints()); + methodAndTph = new MethodAndTPH(id, filteredConstraints); + oldConstraints.addAll(filteredConstraints.getAll()); inLocalOrParamOrReturn = true; method.getReturnType().accept(this); @@ -184,7 +230,7 @@ public class TPHExtractor extends AbstractASTWalker { if(method.block != null) method.block.accept(this); - + inMethod = false; ListOfMethodsAndTph.add(methodAndTph); } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java b/src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java index 6bd8bcab..0533a028 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/constraint/TPHConstraint.java @@ -1,13 +1,25 @@ package de.dhbwstuttgart.bytecode.constraint; +import de.dhbwstuttgart.typeinference.constraints.Pair; +import de.dhbwstuttgart.typeinference.unify.model.PairOperator; +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; + public class TPHConstraint { protected String left; protected String right; protected Relation rel; + protected int variance; //noch nicht benutzt public enum Relation{ EXTENDS, EQUAL } + public TPHConstraint(Pair p) { + this.left = ((TypePlaceholder)p.TA1).getName(); + this.right = ((TypePlaceholder)p.TA2).getName(); + this.rel = p.GetOperator().equals(PairOperator.SMALLERDOT) ? Relation.EXTENDS : Relation.EQUAL; + } + public TPHConstraint(String left, String right, Relation rel) { this.left = left; this.right = right; @@ -48,6 +60,25 @@ public class TPHConstraint { return rel == constraint.getRel() && left.equals(constraint.getLeft()) && right.equals(constraint.getRight()); } + @Override + public int hashCode() { + return (left+right).hashCode(); + } + + @Override + public boolean equals (Object o) { + if (o instanceof TPHConstraint) { + TPHConstraint o_tphcons = (TPHConstraint)o; + return (this.left.equals(o_tphcons.getLeft()) + && this.right.equals(o_tphcons.getRight()) + && this.rel.equals(o_tphcons.rel)); + } + else { + return false; + } + } + + @Override public String toString() { if(rel == Relation.EXTENDS) { diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java index 871dd300..e25958d1 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGenerator/GeneratedGenericsFinder.java @@ -3,16 +3,14 @@ */ package de.dhbwstuttgart.bytecode.genericsGenerator; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; +import java.util.*; import de.dhbwstuttgart.bytecode.TPHExtractor; +import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint; +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.*; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; -import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; -import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericsGeneratorResultForClass; -import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.MethodAndConstraints; import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; import de.dhbwstuttgart.bytecode.utilities.MethodUtility; import de.dhbwstuttgart.bytecode.utilities.Resolver; @@ -81,6 +79,7 @@ public class GeneratedGenericsFinder implements ASTVisitor { private JavaClassName className; private Resolver resolver; + /** * @param sf * @param listOfResultSets @@ -95,6 +94,14 @@ public class GeneratedGenericsFinder implements ASTVisitor { return generatedGenericsForSF; } + /** + * returns the family of Generated Generics + * insbesondere fuer Testzwecke + */ + public FamilyOfGeneratedGenerics getFogg() { + return fogg; + } + /* * (non-Javadoc) * @@ -127,6 +134,7 @@ public class GeneratedGenericsFinder implements ASTVisitor { ConstraintsSimplierResult simplifiedConstraints = null; GenericsGeneratorResultForClass ggResult = null; + GenericsGeneratorResultForClass ggResultAlternative = null; for (int i = 0; i < listOfResultSetsList.size(); i++) { resultSet = listOfResultSetsList.get(i); @@ -135,9 +143,19 @@ public class GeneratedGenericsFinder implements ASTVisitor { classOrInterface.accept(tphExtractor); //PL 2020-10-16: Ab hier GGenerics implementieren durch Ali //Rueckgabe an generatedGenericsForSF - fogg = new FamilyOfGeneratedGenerics(tphExtractor); - + fogg = new FamilyOfGeneratedGenerics(tphExtractor, resultSet); + + System.out.println("fogg.allConstraints: "+ fogg.allConstraints); + System.out.println("fogg.posOfTPHs: "+ fogg.posOfTPHs); + System.out.println("fogg.classConstraints: "+ fogg.classConstraints); + System.out.println("fogg.methodConstraintsWithPosition: "+ fogg.methodConstraintsWithPosition); + System.out.println(fogg); + + ///* + //Fayez Ansatz Anfang tphsClass = tphExtractor.tphsClass; + //PL 2020-01-15 + //Es muss ggResult aus fogg gebildet werden simplifiedConstraints = GenericsGenerator.simplifyConstraints(tphExtractor, tphsClass); if(!isVisited) { ggResult = GenericsGenerator.generateConstraints(className, tphExtractor, tphsClass,simplifiedConstraints); @@ -146,12 +164,45 @@ public class GeneratedGenericsFinder implements ASTVisitor { for(Method m : classOrInterface.getMethods()) { addMethodConstraints(simplifiedConstraints, ggResult, m); - + } - if(ggResult != null) + + if(ggResult != null) { //Hinzufuegen von Fayez ggResult generatedGenericsForSF.addGenericGeneratorResultClass(ggResult); - System.out.println("ddd"); + } + // Fayez Ansatz Ende + //*/ + + //Ali Ansatz Anfang + List listOfClassCons = new ArrayList<>(); + for(TPHConstraint clCons: fogg.classConstraints) { +// ExtendsConstraint ec = new ExtendsConstraint(clCons.getLeft(), clCons.getRight()); + GenericsGeneratorResult ggR = new GenericsGeneratorResult(clCons, new HashSet<>()); + listOfClassCons.add(ggR); + } + + GenericGeneratorResultsForAllMethods ggRfaM = null; + List listOfMethAndCons = new ArrayList<>(); + for(String methID: fogg.methodConstraintsWithPosition.keySet()) { + List listOfGGR = new ArrayList<>(); + for(TPHConstraint methCons: fogg.methodConstraintsWithPosition.get(methID)) { +// ExtendsConstraint ec = new ExtendsConstraint(methCons.getLeft(),methCons.getRight()); + GenericsGeneratorResult ggR = new GenericsGeneratorResult(methCons, new HashSet<>()); + listOfGGR.add(ggR); + } + MethodAndConstraints mac = new MethodAndConstraints(methID, listOfGGR); + listOfMethAndCons.add(mac); + } + ggRfaM = new GenericGeneratorResultsForAllMethods(listOfMethAndCons); + ggResultAlternative = new GenericsGeneratorResultForClass(className, listOfClassCons, ggRfaM); + + if(ggResultAlternative != null) {//hinzufuegen von Alis ggResult + //generatedGenericsForSF.addGenericGeneratorResultClass(ggResultAlternative); + System.out.println(generatedGenericsForSF); + } + System.out.println(ggResultAlternative); + //Ali Ansatz Ende } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericGeneratorResultsForAllMethods.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericGeneratorResultsForAllMethods.java index 40f7692a..091587ff 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericGeneratorResultsForAllMethods.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericGeneratorResultsForAllMethods.java @@ -29,5 +29,13 @@ public class GenericGeneratorResultsForAllMethods { public List getMethodsAndConstraints() { return methodsAndConstraints; } + + @Override + public String toString() { + String ret = ""; + ret = ret + methodsAndConstraints.stream().reduce("", (x,y) -> x + y.toString(), (x,y) -> x + y); + //ret = ret + "\n"; + return ret; + } } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResult.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResult.java index c0d1251a..fe23f239 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResult.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResult.java @@ -52,4 +52,8 @@ public class GenericsGeneratorResult { this.equalsTPHs = equalsTPHs; } + @Override + public String toString() { + return constraint.toString() + " EqualsTPS: " + equalsTPHs.toString(); + } } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResultForClass.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResultForClass.java index 79eaabd0..0a3626d2 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResultForClass.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/GenericsGeneratorResultForClass.java @@ -73,4 +73,12 @@ public class GenericsGeneratorResultForClass { return Collections.emptyList(); } } + + @Override + public String toString() { + String ret = "Classconstraints: "; + ret = ret + classConstraints.stream().reduce("", (x,y) -> x + y.toString(), (x,y) -> x + y); + ret = ret + "\n" + methodsAndTheirConstraints.toString(); + return ret; + } } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/MethodAndConstraints.java b/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/MethodAndConstraints.java index 3f034f6d..bf582707 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/MethodAndConstraints.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/genericsGeneratorTypes/MethodAndConstraints.java @@ -33,4 +33,14 @@ public class MethodAndConstraints { return constraints; } + + @Override + public String toString() { + String ret = methodID + ": "; + ret = ret + constraints.stream().reduce("", + (x,y) -> x + y.toString(), + (x,y) -> x + y); + ret = ret + "\n"; + return ret; + } } diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java index 3f1d19d2..130f0ac6 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/ClassConstraint.java @@ -1,6 +1,7 @@ package de.dhbwstuttgart.bytecode.insertGenerics; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; public class ClassConstraint extends TPHConstraint { //private TPHConstraint constraint; diff --git a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java index 0625aa00..ed46e816 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/insertGenerics/FamilyOfGeneratedGenerics.java @@ -1,34 +1,47 @@ package de.dhbwstuttgart.bytecode.insertGenerics; -import com.ibm.icu.text.CurrencyMetaInfo; import de.dhbwstuttgart.bytecode.TPHExtractor; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH; -import de.dhbwstuttgart.exceptions.NotImplementedException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.*; +import java.util.function.Predicate; + +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; +import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; +import de.dhbwstuttgart.typeinference.constraints.Constraint; +import de.dhbwstuttgart.typeinference.constraints.Pair; +import de.dhbwstuttgart.typeinference.result.ResultPair; +import de.dhbwstuttgart.typeinference.result.ResultSet; +import de.dhbwstuttgart.typeinference.unify.model.PairOperator; +import org.objectweb.asm.Type; public class FamilyOfGeneratedGenerics { public List allConstraints = new ArrayList<>(); // HashMap speichert ob TPH in einer Methode oder in der Klasse ist; und wenn es in der Methode ist, in welcher Methode - public HashMap> posOfTPHs = new HashMap<>(); + public HashMap>> posOfTPHs = new HashMap<>(); public List classConstraints = new ArrayList<>(); + private HashMap mapMethodsAndTph = new HashMap<>(); public List methodConstraints = new ArrayList<>(); - public HashMap methodsWithPosition = new HashMap<>(); + public HashMap> methodConstraintsWithPosition = new HashMap<>(); + public ResultSet resSet; + public Set oldCons = new HashSet<>(); + private static final String objectType = Type.getInternalName(Object.class); - public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor) { + public FamilyOfGeneratedGenerics(TPHExtractor tphExtractor, ResultSet resultSet) { + this.resSet = resultSet; + this.oldCons = tphExtractor.oldConstraints; this.allConstraints = tphExtractor.allCons; this.posOfTPHs = positionConverter(tphExtractor.allTPHS, tphExtractor.ListOfMethodsAndTph); this.classConstraints = getClassConstraints(allConstraints,posOfTPHs); -// this.methodConstraints = getMethodConstraints(allConstraints,classConstraints,posOfTPHs); - + tphExtractor.ListOfMethodsAndTph.forEach(matph -> this.mapMethodsAndTph.put(matph.getId(), matph)); + this.methodConstraints = getMethodConstraints(allConstraints,classConstraints,posOfTPHs, tphExtractor.ListOfMethodsAndTph); + this.methodConstraintsWithPosition = getMethodConstraintsWithPositionNew(allConstraints,classConstraints,posOfTPHs, tphExtractor.ListOfMethodsAndTph, resSet, oldCons); } - public static List getClassConstraints(List cs, HashMap> posOfTphs) { //Inputparameter List constraintsSet weg + public static List getClassConstraints(List cs, HashMap>> posOfTphs) { //Inputparameter List constraintsSet weg List cs_cl = new ArrayList<>(); List classConstraints1 = typeOfANodeOfAField(cs, posOfTphs); for (ClassConstraint cons: classConstraints1) { @@ -36,13 +49,21 @@ public class FamilyOfGeneratedGenerics { cs_cl.add(cons); } } - List classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher - for (ClassConstraint cons: classConstraints2) { - if (!checkForDuplicates(cons, cs_cl)) { - cs_cl.add(cons); + + // if sth new is added to cs_cl, then do same step again + boolean addedToConstraintsListForCC2 = false; + do { + addedToConstraintsListForCC2 = false; + List classConstraints2 = transitiveSubtypeForClassTypes(cs, cs_cl); // in Klammer classConstraints1 oder constraintsSet? beides eher + for (ClassConstraint cons: classConstraints2) { + if (!checkForDuplicates(cons, cs_cl)) { + cs_cl.add(cons); + addedToConstraintsListForCC2 = true; + } } - } - List classConstraints3 = hasNoSupertypeForClassTypes(cs, cs_cl, posOfTphs); + } while (addedToConstraintsListForCC2); + + List classConstraints3 = hasNoSupertypeForClassTypes(cs_cl, posOfTphs); for (ClassConstraint cons: classConstraints3) { if (!checkForDuplicates(cons, cs_cl)) { cs_cl.add(cons); @@ -51,58 +72,123 @@ public class FamilyOfGeneratedGenerics { return cs_cl; } -// public static List getMethodConstraints(List cs, List cs_cl, HashMap> posOfTphs) { -// //TODO: Regeln -// List cs_m = new ArrayList<>(); -// List methodConstraints1 = typeOfTheMethodInClSigma(cs, posOfTphs); -// for (MethodConstraint cons: methodConstraints1) { -// if (!checkForDuplicates(cons, cs_m)) { -// cs_m.add(cons); -// } -// } -// List methodConstraints2 = firstTransitiveSubtypeForMethodTypes(cs, cs_m); -// for (MethodConstraint cons: methodConstraints2) { -// if (!checkForDuplicates(cons, cs_m)) { -// cs_m.add(cons); -// } -// } -// List methodConstraints3 = secondTransitiveSubtypeForMethodTypes(cs, cs_cl, cs_m); -// for (MethodConstraint cons: methodConstraints3) { -// if (!checkForDuplicates(cons, cs_m)) { -// cs_m.add(cons); -// } -// } -// List methodConstraints4 = hasNoSupertypeForMethodTypes(cs, posOfTphs); -// for (MethodConstraint cons: methodConstraints4) { -// if (!checkForDuplicates(cons, cs_m)) { -// cs_m.add(cons); -// } -// } -// List methodConstraints5 = methodTypesWithoutClassTypes(cs_cl, cs_m); -// cs_m = methodConstraints5; -// return cs_m; -// } + public List getMethodConstraints(List cs, List cs_cl, HashMap>> posOfTphs, List listOfMethodsAndTph) { + List cs_m = new ArrayList<>(); + List methodConstraints1 = typeOfTheMethodInClSigma(cs, posOfTphs); + for (MethodConstraint cons: methodConstraints1) { + if (!checkForDuplicates(cons, cs_m)) { + cs_m.add(cons); + } + } - public static HashMap getMethodConstraints(List cs, List cs_cl, HashMap> posOfTphs) { - throw new NotImplementedException(); + // if sth new is added to cs_cl, then do same step again + boolean addedToConstraintsListForMC2 = false; + do { + addedToConstraintsListForMC2 = false; + List methodConstraints2 = firstTransitiveSubtypeForMethodTypes(cs, cs_m); + for (MethodConstraint cons : methodConstraints2) { + if (!checkForDuplicates(cons, cs_m)) { + cs_m.add(cons); + addedToConstraintsListForMC2 = true; + } + } + } while (addedToConstraintsListForMC2); + + // if sth new is added to cs_cl, then do same step again + boolean addedToConstraintsListForMC3 = false; + do { + addedToConstraintsListForMC3 = false; + List methodConstraints3 = secondTransitiveSubtypeForMethodTypes(cs, cs_cl, cs_m); + for (MethodConstraint cons : methodConstraints3) { + if (!checkForDuplicates(cons, cs_m)) { + cs_m.add(cons); + addedToConstraintsListForMC3 = true; + } + } + } while (addedToConstraintsListForMC3); + List methodConstraints4 = hasNoSupertypeForMethodTypes(cs, cs_m, posOfTphs, listOfMethodsAndTph); + for (MethodConstraint cons: methodConstraints4) { + if (!checkForDuplicates(cons, cs_m)) { + cs_m.add(cons); + } + } + List methodConstraints5 = methodTypesWithoutClassTypes(cs_cl, cs_m); + cs_m = methodConstraints5; + return cs_m; } + public HashMap> getMethodConstraintsWithPosition(List cs, List cs_cl, HashMap>> posOfTphs, List listOfMethodsAndTph, ResultSet resSet, Set oldCons) { + HashMap> tempMethodConstraintsWithPosition = new HashMap<>(); + for(MethodAndTPH method: listOfMethodsAndTph){ + List methodsAddedToHashMap = new ArrayList<>(); + String currentMethod = method.getId(); + boolean containsCurrentMethod = false; + if(!containsCurrentMethod) { + methodsAddedToHashMap.add(currentMethod); + containsCurrentMethod = true; + List listOfThisMethod = new ArrayList<>(); + HashMap>> posOfTPHsForThisMethod = new HashMap<>(); + for(String s: posOfTphs.keySet()) { + for(PairTphMethod pair: posOfTphs.get(s)) { + if(pair.snd == currentMethod && pair.snd != null) { + posOfTPHsForThisMethod.put(s,posOfTphs.get(s)); + } + } + } + listOfThisMethod = getMethodConstraints(cs,cs_cl,posOfTPHsForThisMethod,listOfMethodsAndTph); + tempMethodConstraintsWithPosition.put(currentMethod, listOfThisMethod); + List newMCList = firstLineMethodDefinition(cs, posOfTphs, method, resSet); + List newMCList2 = secondLineMethodDefinition(cs, posOfTphs, method, resSet, oldCons); + System.out.println(newMCList); + System.out.println(newMCList2); + } + } + + for(String curMeth: tempMethodConstraintsWithPosition.keySet()){ + for(int i=0; i tempList = new ArrayList<>(list); + for(TPHConstraint tphC: tempList) { + if(tph == tphC.getLeft()) { + return true; + } + } + return false; + } /** * Def. FGG: erste Zeile von cs_cl * {T < .T' | T is a type variable in a type of a node of a field} */ - public static List typeOfANodeOfAField(List allConstraints, HashMap> posOfTphs) { + public static List typeOfANodeOfAField(List allConstraints, HashMap>> posOfTphs) { //RuntimeException re = new RuntimeException("enthält EQUALS-Relation"); - List tempCC= new ArrayList<>(); + List tempCC = new ArrayList<>(); for(TPHConstraint allCons: allConstraints){ if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) { for(String tph: posOfTphs.keySet()) { - if(tph == allCons.getLeft() && posOfTphs.get(tph).fst == PositionFinder.Position.FIELD) { - ClassConstraint consToAdd = new ClassConstraint(tph, allCons.getRight(), allCons.getRel()); - if (!checkForDuplicates(consToAdd, tempCC)) { - tempCC.add(consToAdd); + for(PairTphMethod pair: posOfTphs.get(tph)) { + if(tph == allCons.getLeft() && pair.fst == PositionFinder.Position.FIELD) { + ClassConstraint consToAdd = new ClassConstraint(tph, allCons.getRight(), allCons.getRel()); + if (!checkForDuplicates(consToAdd, tempCC)) { + tempCC.add(consToAdd); + } + /*}else if(pair.fst == PositionFinder.Position.FIELD){ + ClassConstraint consToAdd = new ClassConstraint(tph, objectType, Relation.EXTENDS); + if (!checkForDuplicates(consToAdd, tempCC)) { + tempCC.add(consToAdd); + }*/ } } } @@ -119,12 +205,13 @@ public class FamilyOfGeneratedGenerics { * {T' <. T'' | \exists T: (T <. T') \in cs_cl, (T' <. T'') \in cs } */ public static List transitiveSubtypeForClassTypes(List allConstraints, List cs_cl) { - List tempCC= new ArrayList<>(); + List tempCC = new ArrayList<>(); + ClassConstraint consToAdd; for(ClassConstraint cCons: cs_cl) { if(cCons.getLeft() != null && cCons.getRel()==Relation.EXTENDS) { for(TPHConstraint allCons: allConstraints) { if(cCons.getRight() == allCons.getLeft() && allCons.getRight() != null && allCons.getRel()==Relation.EXTENDS){ - ClassConstraint consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel()); + consToAdd = new ClassConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel()); if (!checkForDuplicates(consToAdd, tempCC)) { tempCC.add(consToAdd); } @@ -140,40 +227,50 @@ public class FamilyOfGeneratedGenerics { * {T <. Object | ((T is a type variable in a type of a node of a field * or (\exists T~: (T~ <. T) \in cs_cl)) and (\existsnot T': T <. T') \in cs)} */ - public static List hasNoSupertypeForClassTypes(List allConstraints, List cs_cl, HashMap> posOfTphs) { + public static List hasNoSupertypeForClassTypes(List cs_cl, HashMap>> posOfTphs) { List tempCC= new ArrayList<>(); - for(TPHConstraint allCons: allConstraints) { - for(ClassConstraint cCons: cs_cl) { - for(String tph: posOfTphs.keySet()) { - boolean tvInField = posOfTphs.get(tph).fst == PositionFinder.Position.FIELD; - boolean hasSmallerTVInClCons = (posOfTphs.containsKey(cCons.getRight()) && cCons.getRight() == tph && cCons.getLeft() != null); - if( ((tvInField || hasSmallerTVInClCons) && cCons.getRel()==Relation.EXTENDS) && - checkUpperBound(allConstraints, tph) && allCons.getRel()==Relation.EXTENDS) { - ClassConstraint consToAdd = new ClassConstraint(tph, "Object", Relation.EXTENDS); - if (!checkForDuplicates(consToAdd, tempCC)){ + List clCons = new ArrayList<>(cs_cl); + for(String tph: posOfTphs.keySet()) { + for(PairTphMethod pair: posOfTphs.get(tph)) { + boolean tvInField = pair.fst == PositionFinder.Position.FIELD; + boolean hasSmallerTVInClCons = hasSmallerTVInClCons(tph, cs_cl); + if ((tvInField || hasSmallerTVInClCons) && + !checkUpperBound(clCons, tph)) { + ClassConstraint consToAdd = new ClassConstraint(tph, objectType, Relation.EXTENDS); + if (!checkForDuplicates(consToAdd, tempCC)) { tempCC.add(consToAdd); } } } } - } return tempCC; } + public static boolean hasSmallerTVInClCons(String tph, List cs_cl) { + for(ClassConstraint cC: cs_cl) { + if(tph == cC.getRight() && cC.getRel() == Relation.EXTENDS) { + return true; + } + } + return false; + } + /** * Def. FGG: erste Zeile von cs_m * {T < .T' | T is a type variable in a type of the method/constructor m in cl_\sigma, (T <. T') \in cs} */ - public static HashMap typeOfTheMethodInClSigma(List allConstraints, HashMap> posOfTphs) { // cl_\sigma?? + public static List typeOfTheMethodInClSigma(List allConstraints, HashMap>> posOfTphs) { // cl_\sigma?? //TODO: - HashMap tempMC= new HashMap<>(); + List tempMC= new ArrayList<>(); for(TPHConstraint allCons: allConstraints){ if(posOfTphs.containsKey(allCons.getLeft()) && allCons.getRight()!=null && allCons.getRel()==Relation.EXTENDS) { for(String tph: posOfTphs.keySet()) { - if(tph == allCons.getLeft() && (posOfTphs.get(tph).fst == PositionFinder.Position.METHOD || posOfTphs.get(tph).fst == PositionFinder.Position.CONSTRUCTOR)) { - MethodConstraint consToAdd = new MethodConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel()); - if (!checkForDuplicatesInMethods(consToAdd, tempMC, posOfTphs)) { - tempMC.put(consToAdd, posOfTphs.get(tph).snd); + for(PairTphMethod pair: posOfTphs.get(tph)) { + if(tph == allCons.getLeft() && (pair.fst == PositionFinder.Position.METHOD || pair.fst == PositionFinder.Position.CONSTRUCTOR)) { + MethodConstraint consToAdd = new MethodConstraint(allCons.getLeft(), allCons.getRight(), allCons.getRel()); + if (!checkForDuplicates(consToAdd, tempMC)) { + tempMC.add(consToAdd); + } } } } @@ -183,6 +280,130 @@ public class FamilyOfGeneratedGenerics { } + /** + * Def. FGG: zweite Zeile von cs_m + * {R' <. S | (R <. R'), (S <. S') \in cs_m and (R',S) is in the transitive closure of cs} + */ + public List firstTransitiveSubtypeForMethodTypes(List allConstraints, List cs_m) { //transitive closure of cs + //TODO: + List tempMC= new ArrayList<>(); + List tcOfCs = buildTransitiveClosure(allConstraints); + for(MethodConstraint mC1 : cs_m) { //(R <. R') + for(MethodConstraint mC2 : cs_m) { //(S <. S') + String lSide = mC1.getRight(); //R' + String rSide = mC2.getLeft(); //S + for(TPHConstraint tphC : tcOfCs) { + if(tphC.getLeft().equals(lSide)&&tphC.getRight().equals(rSide)) { //is it (R',S) + MethodConstraint consToAdd = new MethodConstraint(lSide, rSide, tphC.getRel()); //create (R'<.S) + if (!checkForDuplicates(consToAdd, tempMC)) { + tempMC.add(consToAdd); + } + } + } + } + } + return tempMC; + } + + /** + * Def. FGG: dritte Zeile von cs_m + * {R' <. S | (R <. R') \in cs_m, (S <. S') \in cs_cl and (R',S) is in the transitive closure of cs} + */ + public List secondTransitiveSubtypeForMethodTypes(List allConstraints, List cs_cl, List cs_m) { + //TODO: + List tempMC= new ArrayList<>(); + List tcOfCs = buildTransitiveClosure(allConstraints); + for(ClassConstraint cC : cs_cl) { + for(MethodConstraint mC : cs_m) { + String leftSide = mC.getRight(); + String rightSide = cC.getLeft(); + for(TPHConstraint tphC : tcOfCs) { + if(tphC.getLeft().equals(leftSide)&&tphC.getRight().equals(rightSide)) { + MethodConstraint consToAdd = new MethodConstraint(tphC.getLeft(), tphC.getRight(), tphC.getRel()); + if (!checkForDuplicates(consToAdd, tempMC)) { + tempMC.add(consToAdd); + } + + } + } + } + } + return tempMC; + } + +/** + * Def. FGG: vierte Zeile von cs_m + * {T <. Object | (T is a type variable in a type of a node of the method/constructor m in cl_\sigma), + * (\existsnot T': T <. T') \in cs)} + */ + public static List hasNoSupertypeForMethodTypes(List allConstraints, List cs_m, HashMap>> posOfTphs, List listOfMethodsAndTph) { + //TODO: + List tempMC= new ArrayList<>(); + for(String tph: posOfTphs.keySet()) { + for(PairTphMethod pair: posOfTphs.get(tph)) { + for(TPHConstraint allCons: allConstraints) { + if((pair.fst.equals(PositionFinder.Position.METHOD) || pair.fst.equals(PositionFinder.Position.CONSTRUCTOR)) && !checkUpperBound(allConstraints,tph)) { + MethodConstraint consToAdd = new MethodConstraint(tph, objectType, Relation.EXTENDS); + if (!checkForDuplicates(consToAdd, tempMC)) { + tempMC.add(consToAdd); + } + } + } + List tempMCObject1 = new ArrayList<>(cs_m); + String currentMethod = ""; + for(MethodAndTPH mat: listOfMethodsAndTph) { + if(mat.getId().equals(pair.snd)) { + currentMethod = mat.getId(); + } + for(TPHConstraint mc1: tempMCObject1) { + if(tph==mc1.getRight() && !checkUpperBound(tempMCObject1,tph)) { + MethodConstraint consToAdd = new MethodConstraint(tph, objectType, Relation.EXTENDS); + if (!checkForDuplicates(consToAdd, tempMC)) { + tempMC.add(consToAdd); + } + } + } + } + } + } + return tempMC; + } + +/** + * nimm die Menge cs_cl aus cs_m raus + */ + public List methodTypesWithoutClassTypes(List cs_cl, List cs_m) { + // erstelle Kopie der Liste cs_cl + List tempCC = new ArrayList<>(); + for(ClassConstraint cc: cs_cl) { + TPHConstraint tphC = new TPHConstraint(cc.getLeft(), cc.getRight(), cc.getRel()); + tempCC.add(tphC); + } + // Transitive Hülle von cs_cl + List tcOfCsCl = buildTransitiveClosure(tempCC); + + List tempMC = new ArrayList<>(); + for(MethodConstraint mc: cs_m) { + TPHConstraint tphC = new TPHConstraint(mc.getLeft(), mc.getRight(), mc.getRel()); + tempMC.add(tphC); + } + List tempMC2 = new ArrayList<>(); + tempMC2.addAll(tempMC); + List tempMCToReturn = new ArrayList<>(); + + for(TPHConstraint cc: tcOfCsCl) { + for(TPHConstraint mc: tempMC) { + if(cc.getLeft().equals(mc.getLeft()) && cc.getRight().equals(mc.getRight())) { + tempMC2.remove(mc); + } + } + } + for(TPHConstraint tphC: tempMC2) { + MethodConstraint mCons = new MethodConstraint(tphC.getLeft(), tphC.getRight(), tphC.getRel()); + tempMCToReturn.add(mCons); + } + return tempMCToReturn; + } public static boolean checkForDuplicates(TPHConstraint constraint, List list) { List tempList = list; @@ -197,11 +418,7 @@ public class FamilyOfGeneratedGenerics { return false; } - public static boolean checkForDuplicatesInMethods(TPHConstraint constraint, HashMap hashMap, HashMap> posOfTphs) { - throw new NotImplementedException(); - } - - public static List buildTransitiveClosure(List list) { + public List buildTransitiveClosure(List list) { List iterList = new ArrayList<>(list); List runList = new ArrayList<>(list); List tcList = new ArrayList<>(list); @@ -226,25 +443,28 @@ public class FamilyOfGeneratedGenerics { public static boolean checkUpperBound(List cs, String tph) { for(int i=0; i> positionConverter(HashMap allTphs, List listOfMethodsAndTphs) { - HashMap> convertedPositions = new HashMap<>(); + public static HashMap>> positionConverter(HashMap allTphs, List listOfMethodsAndTphs) { + HashMap>> convertedPositions = new HashMap<>(); for(String tph: allTphs.keySet()) { + List> currMeth = new ArrayList<>(); if(allTphs.get(tph)) { //if true, then tph is a method-TPH for(MethodAndTPH methTph: listOfMethodsAndTphs) { if (methTph.getTphs().contains(tph)) { - convertedPositions.put(tph, new PairTphMethod<>(PositionFinder.Position.METHOD, methTph.getId())); + currMeth.add(new PairTphMethod<>(PositionFinder.Position.METHOD, methTph.getId())); } } } else { // else it is in the class-TPH - convertedPositions.put(tph, new PairTphMethod<>(PositionFinder.Position.FIELD, null)); + currMeth.add(new PairTphMethod<>(PositionFinder.Position.FIELD, null)); } + convertedPositions.put(tph, currMeth); } return convertedPositions; } @@ -268,4 +488,393 @@ public class FamilyOfGeneratedGenerics { } */ + public static List firstLineMethodDefinition(List allConstraints, HashMap>> posOfTphs, MethodAndTPH methodAndTPH, ResultSet resSet) { + List tempMC= new ArrayList<>(); + MethodAndTPH methAndTphs = methodAndTPH; + Set undCons = methAndTphs.constraints.getUndConstraints(); + List>> orCons = methAndTphs.constraints.getOderConstraints(); + Iterator it = undCons.iterator(); + while(it.hasNext()) { + Pair p = it.next(); + String ta1 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(); + String ta2 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(); + Relation r = null; + if(p.GetOperator() == PairOperator.SMALLERDOT) { + r = Relation.EXTENDS; + } else if(p.GetOperator() == PairOperator.EQUALSDOT) { + r = Relation.EQUAL; + } + MethodConstraint mc = new MethodConstraint(ta1, ta2, r); + if(mc.getRel() == Relation.EXTENDS) { + if (!mc.getLeft().equals(mc.getRight())) { //eliminieren der Fälle wie AA<.AA + if(!checkForDuplicates(mc, tempMC)) { + tempMC.add(mc); + } + } + } + } + return tempMC; + } + + public List secondLineMethodDefinition(List allConstraints, HashMap>> posOfTphs, MethodAndTPH methodAndTPH, ResultSet resSet, Set oldCons) { + List tempMC = new ArrayList<>(); //für Ergebnisse basierend auf der neuen Datenstruktur (Ali) + Set tempSet = new HashSet<>(); //für Ergebnisse des ersten Teils der Bedinung basierend auf der alten Datenstruktur + Set tempSet2 = new HashSet<>(); //für Ergebnisse des zweiten Teils der Bedingung basierend auf der alten Datenstruktur + Set tcOfoldConsSet = buildTransitiveClosureForCP(oldCons, resSet); + List tcOfCs = buildTransitiveClosure(allConstraints); + MethodAndTPH methAndTphs = methodAndTPH; + Set undCons = methAndTphs.constraints.getUndConstraints(); + List>> orCons = methAndTphs.constraints.getOderConstraints(); + List>> orConsListConverted = new ArrayList<>(); + //gehe die OrConstraints der aktuellen Methode durch und teile nach Operator auf ( + for(int i=0; i orConsWithEQUAL = new ArrayList(); + List orConsWithEXTENDS = new ArrayList(); + HashMap> orConsInternal = new HashMap<>(); + for(Constraint con: orCons.get(i)) { + Iterator it = con.iterator(); + while(it.hasNext()) { + Pair p = it.next(); + Relation r = null; + if(p.GetOperator() == PairOperator.SMALLERDOT) { + r = Relation.EXTENDS; + orConsWithEXTENDS.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r)); + /*MethodConstraint mc = new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r); + if(!checkForDuplicates(mc, tempMC)) { + tempMC.add(mc); + }*/ + } else if(p.GetOperator() == PairOperator.EQUALSDOT) { + r = Relation.EQUAL; + orConsWithEQUAL.add(new TPHConstraint(((TypePlaceholder) p.TA1).getName(), ((TypePlaceholder) p.TA2).getName(), r)); + /*MethodConstraint mc = new MethodConstraint(((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(), ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(), r); + if(!checkForDuplicates(mc, tempMC)) { + tempMC.add(mc); + }*/ + } + } + } + orConsInternal.put(Relation.EXTENDS, orConsWithEXTENDS); + orConsInternal.put(Relation.EQUAL, orConsWithEQUAL); + orConsListConverted.add(orConsInternal); + } + + // oldCons sind alle Und- und Oder-Constraints + // zunächst in meine Datenstruktur(Ali) konvertieren + List oldConsList = new ArrayList<>(oldCons); + List oldConsListConverted = new ArrayList<>(); + for(Pair pair: oldConsList) { + Relation r = null; + if(pair.GetOperator() == PairOperator.SMALLERDOT) { + r = Relation.EXTENDS; + } else if(pair.GetOperator() == PairOperator.EQUALSDOT) { + r = Relation.EQUAL; + } + oldConsListConverted.add(new TPHConstraint(((TypePlaceholder) pair.TA1).getName(), ((TypePlaceholder) pair.TA2).getName(), r)); + } + + + // Berechnung des zweiten Teils der Bedingung der Regel + for(int i=0; i extendsSet = new Constraint(); + Constraint equalSet = new Constraint(); + //für jede einzelne OrConstraint-Menge gehe durch + for (Constraint con : orCons.get(i)) { + Iterator it = con.iterator(); + while (it.hasNext()) { + Pair p = it.next(); + if (p.OperatorSmallerDot()) { + extendsSet.add(p); + } else if (p.OperatorEqual()) { + equalSet.add(p); + } + } + Iterator itExtends2 = extendsSet.iterator(); + while(itExtends2.hasNext()) { + Pair pairExtends2 = itExtends2.next(); + Set containedVars = new HashSet<>(methodAndTPH.getTphs()); + String pairExtends2RHSName = ((TypePlaceholder)((resSet.resolveType((TypePlaceholder)pairExtends2.TA2)).resolvedType)).getName(); + Iterator itEqual2 = equalSet.iterator(); + while (itEqual2.hasNext()) { + boolean transClo = false; + Pair pairEqual2 = itEqual2.next(); + //TODO: Auf trans.FamilyOfGeneratedGenerics Huelle pruefen + Pair newPairOld = new Pair(pairExtends2.TA2, pairEqual2.TA1); + Pair newPair2 = new Pair(resSet.resolveType((TypePlaceholder) (pairExtends2.TA2)).resolvedType, resSet.resolveType((TypePlaceholder) (pairEqual2.TA1)).resolvedType, PairOperator.SMALLERDOT); + TPHConstraint newPairTPHConstraint = new TPHConstraint(newPair2); + if (tcOfCs.contains(newPairTPHConstraint)|| (newPairTPHConstraint.getLeft().equals(newPairTPHConstraint.getRight()))) { + transClo = true; + } + TypePlaceholder tphR = (TypePlaceholder) pairEqual2.TA2; + Iterator itUndCons = undCons.iterator(); + boolean rEqExRtilde = false; + while (itUndCons.hasNext()) { + Pair pairUndCons2 = itUndCons.next(); + rEqExRtilde = rEqExRtilde || (tphR == pairUndCons2.TA1); + } + boolean isPairInTExTapostrophe = false; + for(Set> scp: orCons) { + Iterator> itSCP = scp.iterator(); + while(itSCP.hasNext()) { + Constraint cp = itSCP.next(); + Iterator itCP = cp.iterator(); + while(itCP.hasNext()) { + Pair p = itCP.next(); + if(p.OperatorSmallerDot()) { + isPairInTExTapostrophe = isPairInTExTapostrophe || tphR.equals(p.TA1); + } + } + } + + } + + if (transClo && (rEqExRtilde || isPairInTExTapostrophe)) { + if (!newPair2.TA1.equals(newPair2.TA2)) { //eliminieren der Fälle wie AA<.AA + if (!checkForDuplicatesForSets(newPair2, tempSet2)) { + tempSet2.add(newPair2); + } + } + if (!checkForDuplicatesForSets(pairExtends2, tempSet2)) { + tempSet2.add(pairExtends2); + } + } + else { + //containedVars.remove(((TypePlaceholder)newPair2.TA2).getName()); + } + + } + + //String key = ((TypePlaceholder)((resSet.resolveType((TypePlaceholder)pairExtends2.TA2)).resolvedType)).getName(); + //TODO: containedVars stimmt noch nicht. Ueberpruefen, ob ggf. mit den containedVars möglicherweise auch die anderen Faelle + // rEqExRtilde isPairInTExTapostrophe abgedeckt sind => ggf. integrieren + /* + posOfTphs.forEach((x,y) -> { + if (y.contains(new PairTphMethod<>(PositionFinder.Position.METHOD, methodAndTPH.getId()))) { + containedVars.add(x); + }; + } + ); + */ + //Referenzbeispiel Put.jav + if (containedVars.stream().filter(v -> tcOfCs.contains(new TPHConstraint(pairExtends2RHSName, v, Relation.EXTENDS))) + .count() > 0) { + System.out.println(); + //tempSet2.add(pairExtends2); + } + if (posOfTphs.containsKey(pairExtends2RHSName)) {//Refrenzbeispiel TestVector.jav + if (posOfTphs.get(pairExtends2RHSName).contains(new PairTphMethod<>(PositionFinder.Position.METHOD, methodAndTPH.getId()))) { + tempSet2.add(pairExtends2); + } + } + } + } + } + + + // aus der alten Datenstruktur in die neue Datenstruktur (von Ali) für ersten Teil + Iterator itTemp = tempSet.iterator(); + while(itTemp.hasNext()) { + Pair p = itTemp.next(); + String ta1 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(); + String ta2 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(); + Relation r = null; + if(p.GetOperator() == PairOperator.SMALLERDOT) { + r = Relation.EXTENDS; + } else if(p.GetOperator() == PairOperator.EQUALSDOT) { + r = Relation.EQUAL; + } + MethodConstraint mc = new MethodConstraint(ta1, ta2, r); + if(mc.getRel() == Relation.EXTENDS) { + if(!checkForDuplicates(mc, tempMC)) { + tempMC.add(mc); + } + } + } + + // aus der alten Datenstruktur in die neue Datenstruktur (von Ali) für zweiten Teil + Iterator itTemp2 = tempSet2.iterator(); + while(itTemp2.hasNext()) { + Pair p = itTemp2.next(); + String ta1 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA1)).resolvedType)).getName(); + String ta2 = ((TypePlaceholder) (resSet.resolveType(((TypePlaceholder) p.TA2)).resolvedType)).getName(); + Relation r = null; + if (p.GetOperator() == PairOperator.SMALLERDOT) { + r = Relation.EXTENDS; + } else if (p.GetOperator() == PairOperator.EQUALSDOT) { + r = Relation.EQUAL; + } + for(TPHConstraint tphCons: tcOfCs) {//TODO: hier werden Elemente der Trans. clo herausgenommen, aber die dazugehoerigen OrCons nicht. + if(ta1 == tphCons.getLeft() && ta2 == tphCons.getRight() && r==Relation.EXTENDS) { + MethodConstraint mc = new MethodConstraint(ta1, ta2, r); + if(!checkForDuplicates(mc, tempMC)) { + tempMC.add(mc); + } + } + } + } + + return tempMC; + } + + + public static Set buildTransitiveClosureForCP(Set constraint, ResultSet resSet) { + Set iterSet = new HashSet<>(constraint); + Set runSet = new HashSet<>(constraint); + Set tcSet = new HashSet<>(constraint); + boolean addedConToList = false; +// for (TPHConstraint cons: iterList) { + Iterator itIterSet = iterSet.iterator(); + while(itIterSet.hasNext()) { + Pair pairIterSet = itIterSet.next(); +// for (TPHConstraint cons2: runList) { + Iterator itRunSet = runSet.iterator(); + while (itRunSet.hasNext()) { + Pair pairRunSet = itRunSet.next(); +// if(cons.getRight() == cons2.getLeft()) { + if(pairIterSet.TA2 == pairRunSet.TA1 && pairIterSet.OperatorSmallerDot() && pairRunSet.OperatorSmallerDot()) { +// TPHConstraint consToAdd = new TPHConstraint(cons.getLeft(), cons2.getRight(), Relation.EXTENDS); + Pair p = new Pair(resSet.resolveType((TypePlaceholder)(pairIterSet.TA1)).resolvedType, resSet.resolveType((TypePlaceholder)(pairRunSet.TA2)).resolvedType, PairOperator.SMALLERDOT); +// if (!checkForDuplicates(consToAdd,tcList)) { + if(!checkForDuplicatesForSets(p, tcSet)) { +// tcList.add(consToAdd); + tcSet.add(p); + addedConToList = true; + if (addedConToList) { + return buildTransitiveClosureForCP(tcSet, resSet); + } + } + } + } + } + System.out.println("tcSet: " + tcSet); + return tcSet; + } + + public static boolean checkForDuplicatesForSets(Pair pair, Set set) { + Set tempSet = set; + boolean hasSame = false; +// for (TPHConstraint tphC: tempList) { + Iterator it = tempSet.iterator(); + while (it.hasNext()) { + Pair p = it.next(); +// hasSame = constraint.getLeft() == tphC.getLeft() && +// constraint.getRight() == tphC.getRight() && +// constraint.getRel() == tphC.getRel(); //constraint already in ArrayList if true + hasSame = pair.TA1 == p.TA1 && + pair.TA2 == p.TA2 && + pair.OperatorSmallerDot() && p.OperatorSmallerDot(); //constraint already in Set if true + if (hasSame) + return true; + } + return false; + } + + public static List hasNoSupertypeForMethodTypesNew(HashMap>> posOfTphs, MethodAndTPH methodAndTPH, List cs_m) { + List tempMC = new ArrayList<>(); + List methCons = new ArrayList<>(cs_m); + MethodAndTPH methAndTphs = methodAndTPH; + for(String tph: posOfTphs.keySet()) { + for(int i=0; i methodTypesWithoutClassTypesNEW(List tphsToCompute, List cs_m) { + List tempMC = new ArrayList<>(cs_m); + List tempMC2 = new ArrayList<>(cs_m); + List toRemove = new ArrayList<>(); + for(String tph: tphsToCompute) { + for(TPHConstraint tphCons: tempMC) { + if(tphCons.getLeft() == tph) { + toRemove.add(tphCons.getRight()); + tempMC2.remove(tphCons); + tempMC2 = methodTypesWithoutClassTypesNEW(toRemove,tempMC2); + } + } + } + return tempMC2; + } + + + + public HashMap> getMethodConstraintsWithPositionNew(List cs, List cs_cl, HashMap>> posOfTphs, List listOfMethodsAndTph, ResultSet resSet, Set oldCons) { + HashMap> tempMethodConstraintsWithPosition = new HashMap<>(); + List newMCList = new ArrayList<>(); + List newMCList2 = new ArrayList<>(); + List hasNoSupType = new ArrayList<>(); + List mcWithoutCc = new ArrayList<>(); + + List methodsAddedToHashMap = new ArrayList<>(); + for(MethodAndTPH method: listOfMethodsAndTph){ + String currentMethod = method.getId(); + boolean containsCurrentMethod = false; + if(!containsCurrentMethod) { + methodsAddedToHashMap.add(currentMethod); + containsCurrentMethod = true; + List listToAdd = new ArrayList<>(); + HashMap>> posOfTPHsForThisMethod = new HashMap<>(); + for(String s: posOfTphs.keySet()) { + for(PairTphMethod pair: posOfTphs.get(s)) { + if(pair.snd == currentMethod && pair.snd != null) { + posOfTPHsForThisMethod.put(s,posOfTphs.get(s)); + } + } + } + + newMCList = firstLineMethodDefinition(cs, posOfTphs, method, resSet); + for(int i=0; i tphs = new ArrayList<>(); + for(String tph: posOfTphs.keySet()) { + for (PairTphMethod p : posOfTphs.get(tph)) { + if(p.fst == PositionFinder.Position.FIELD) { + tphs.add(tph); + mcWithoutCc = methodTypesWithoutClassTypesNEW(tphs, listToAdd); + } + } + } + + tempMethodConstraintsWithPosition.put(currentMethod, mcWithoutCc); + } + for(String curMeth: tempMethodConstraintsWithPosition.keySet()){ + for(int i=0; iThis is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ + + +public class PairMethodAndConstraint { + public final A fst; + public final B snd; + + public PairMethodAndConstraint(A fst, B snd) { + this.fst = fst; + this.snd = snd; + } + + public String toString() { + return "PairTphMethod[" + fst + "," + snd + "]"; + } + + public boolean equals(Object other) { + return + other instanceof PairMethodAndConstraint && + Objects.equals(fst, ((PairMethodAndConstraint)other).fst) && + Objects.equals(snd, ((PairMethodAndConstraint)other).snd); + } + + public int hashCode() { + if (fst == null) return (snd == null) ? 0 : snd.hashCode() + 1; + else if (snd == null) return fst.hashCode() + 2; + else return fst.hashCode() * 17 + snd.hashCode(); + } + + public static PairMethodAndConstraint of(A a, B b) { + return new PairMethodAndConstraint<>(a,b); + } + + public PairMethodAndConstraint add(A fst, B snd){ + return new PairMethodAndConstraint<>(fst,snd); + } +} diff --git a/src/main/java/de/dhbwstuttgart/bytecode/utilities/MethodAndTPH.java b/src/main/java/de/dhbwstuttgart/bytecode/utilities/MethodAndTPH.java index d8eed39c..caaad1be 100644 --- a/src/main/java/de/dhbwstuttgart/bytecode/utilities/MethodAndTPH.java +++ b/src/main/java/de/dhbwstuttgart/bytecode/utilities/MethodAndTPH.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; +import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; +import de.dhbwstuttgart.typeinference.constraints.Pair; import de.dhbwstuttgart.typeinference.result.GenericInsertPair; import de.dhbwstuttgart.typeinference.result.ResultPair; @@ -15,11 +17,21 @@ public class MethodAndTPH { private final ArrayList> pairs = new ArrayList<>(); // tphs of local variables and parameters private final ArrayList localTphs = new ArrayList<>(); + /* + * its Constraints + * eingefuegt PL 2021-02-15 + */ + public final ConstraintSet constraints; - public MethodAndTPH(String name) { + public MethodAndTPH(String name, ConstraintSet constraints) { this.id = name; + this.constraints = constraints; } - + + public void addTph(String tph) { + tphs.add(tph); + } + public ArrayList getTphs() { return tphs; } @@ -39,4 +51,9 @@ public class MethodAndTPH { return localTphs; } + @Override + public String toString() { + return id; + } + } diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index 1066e047..5f77e3a5 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -1,47 +1,32 @@ //PL 2018-12-19: typeInferenceOld nach typeInference uebertragen package de.dhbwstuttgart.core; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; - import com.google.common.collect.Lists; - import de.dhbwstuttgart.bytecode.BytecodeGen; import de.dhbwstuttgart.bytecode.Exception.BytecodeGeneratorError; import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder; import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; import de.dhbwstuttgart.environment.CompilationEnvironment; import de.dhbwstuttgart.environment.DirectoryClassLoader; import de.dhbwstuttgart.exceptions.DebugException; import de.dhbwstuttgart.parser.JavaTXParser; import de.dhbwstuttgart.parser.NullToken; +import de.dhbwstuttgart.parser.scope.GenericsRegistry; import de.dhbwstuttgart.parser.SyntaxTreeGenerator.SyntaxTreeGenerator; import de.dhbwstuttgart.parser.antlr.Java8Parser.CompilationUnitContext; -import de.dhbwstuttgart.parser.scope.GenericsRegistry; import de.dhbwstuttgart.parser.scope.JavaClassName; import de.dhbwstuttgart.syntaxtree.ClassOrInterface; -import de.dhbwstuttgart.syntaxtree.FormalParameter; -import de.dhbwstuttgart.syntaxtree.GenericDeclarationList; import de.dhbwstuttgart.syntaxtree.GenericTypeVar; import de.dhbwstuttgart.syntaxtree.Method; import de.dhbwstuttgart.syntaxtree.ParameterList; import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.TypeScope; +import de.dhbwstuttgart.syntaxtree.FormalParameter; +import de.dhbwstuttgart.syntaxtree.GenericDeclarationList; import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; import de.dhbwstuttgart.syntaxtree.factory.UnifyTypeFactory; +import de.dhbwstuttgart.syntaxtree.statement.Block; import de.dhbwstuttgart.syntaxtree.type.ExtendsWildcardType; import de.dhbwstuttgart.syntaxtree.type.GenericRefType; import de.dhbwstuttgart.syntaxtree.type.RefType; @@ -57,17 +42,32 @@ import de.dhbwstuttgart.typeinference.result.ResultSet; import de.dhbwstuttgart.typeinference.typeAlgo.TYPE; import de.dhbwstuttgart.typeinference.unify.RuleSet; import de.dhbwstuttgart.typeinference.unify.TypeUnify; -import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask; -import de.dhbwstuttgart.typeinference.unify.UnifyResultListener; -import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl; -import de.dhbwstuttgart.typeinference.unify.UnifyResultModel; -import de.dhbwstuttgart.typeinference.unify.UnifyTaskModel; import de.dhbwstuttgart.typeinference.unify.distributeVariance; import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure; import de.dhbwstuttgart.typeinference.unify.model.PairOperator; import de.dhbwstuttgart.typeinference.unify.model.PlaceholderType; import de.dhbwstuttgart.typeinference.unify.model.UnifyPair; import de.dhbwstuttgart.typeinference.unify.model.UnifyType; +import de.dhbwstuttgart.typeinference.unify.TypeUnifyTask; +import de.dhbwstuttgart.typeinference.unify.UnifyResultListener; +import de.dhbwstuttgart.typeinference.unify.UnifyResultListenerImpl; +import de.dhbwstuttgart.typeinference.unify.UnifyResultModel; +import de.dhbwstuttgart.typeinference.unify.UnifyTaskModel; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.io.OutputStreamWriter; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +import org.antlr.v4.runtime.Token; +import org.apache.commons.io.output.NullOutputStream; public class JavaTXCompiler { @@ -75,19 +75,26 @@ public class JavaTXCompiler { //public static JavaTXCompiler INSTANCE; final CompilationEnvironment environment; Boolean resultmodel = true; - // TODO change the AST for replace generics with TPH public final Map sourceFiles = new HashMap<>(); Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"src/test/java/logFiles" geschrieben werden soll? public volatile UnifyTaskModel usedTasks = new UnifyTaskModel(); private final ClassLoader classLoader; + + //nur fuer Testzwecke of Generated Generics + //wieder loeschen PL 2021-03-22 + public FamilyOfGeneratedGenerics fogg; - public JavaTXCompiler (File... sourceFile) throws IOException, ClassNotFoundException { + + public JavaTXCompiler(File sourceFile) throws IOException, ClassNotFoundException { this(Arrays.asList(sourceFile), null); } public JavaTXCompiler(File sourceFile, Boolean log) throws IOException, ClassNotFoundException { this(sourceFile); this.log = log; } + public JavaTXCompiler(File[] sourceFiles) throws IOException, ClassNotFoundException { + this(Arrays.asList(sourceFiles), null); + } public JavaTXCompiler(List sourceFiles) throws IOException, ClassNotFoundException { this(sourceFiles, null); } @@ -104,11 +111,8 @@ public class JavaTXCompiler { //INSTANCE = this; } - public Map getSourceFiles () { - return sourceFiles; - } - public ConstraintSet getConstraints() throws ClassNotFoundException, IOException { + public ConstraintSet getConstraints() throws ClassNotFoundException, IOException { List allClasses = new ArrayList<>();//environment.getAllAvailableClasses(); List importedClasses = new ArrayList<>(); ClassOrInterface objectClass = ASTFactory.createClass( @@ -126,11 +130,11 @@ public class JavaTXCompiler { importedClasses.add(importedClass); } } - for (File f : this.sourceFiles.keySet()) { + for (File f : this.sourceFiles.keySet()) { SourceFile sf = sourceFiles.get(f); sf = new SourceFile(sf.getPkgName(), sf.KlassenVektor.stream() - .map(ClassOrInterface::new) + .map(cl -> new ClassOrInterface(cl)) .collect(Collectors.toCollection(ArrayList::new)), sf.imports); //sf enthaelt neues Source-File, neue Klassen-Objekte und neue @@ -615,7 +619,7 @@ public class JavaTXCompiler { }); Set constructorParaTypeVarNames = allClasses.stream().map(x -> x.getConstructors().stream() - .filter(y -> y != null).map(y -> y.getParameterList().getFormalparalist().stream() + .map(y -> y.getParameterList().getFormalparalist().stream() .filter(z -> z.getType() instanceof TypePlaceholder) .map(z -> ((TypePlaceholder) z.getType()).getName()) .collect(Collectors.toCollection(HashSet::new))) @@ -878,6 +882,7 @@ public class JavaTXCompiler { SourceFile sf = sourceFiles.get(f); GeneratedGenericsFinder sResFinder = new GeneratedGenericsFinder(sf, typeinferenceResult); GenericGenratorResultForSourceFile simplifyResOfSF = sResFinder.findGeneratedGenerics(); + this.fogg = sResFinder.getFogg(); result.add(simplifyResOfSF); } return result; diff --git a/src/main/java/de/dhbwstuttgart/inferWildcards/JavaTXCompilerWildcards.java b/src/main/java/de/dhbwstuttgart/inferWildcards/JavaTXCompilerWildcards.java index 8a4f49a5..132981eb 100644 --- a/src/main/java/de/dhbwstuttgart/inferWildcards/JavaTXCompilerWildcards.java +++ b/src/main/java/de/dhbwstuttgart/inferWildcards/JavaTXCompilerWildcards.java @@ -2,6 +2,7 @@ package de.dhbwstuttgart.inferWildcards; import java.io.File; import java.io.IOException; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -36,7 +37,7 @@ public class JavaTXCompilerWildcards private final Map tphMap; public JavaTXCompilerWildcards (File... sourceFile) throws IOException, ClassNotFoundException { - super(sourceFile); + super(Arrays.asList(sourceFile)); this.tphMap = TypePlaceholderReplaceUtils.generateTypePlaceholder(this); } diff --git a/src/main/java/de/dhbwstuttgart/inferWildcards/TypePlaceholderReplaceUtils.java b/src/main/java/de/dhbwstuttgart/inferWildcards/TypePlaceholderReplaceUtils.java index c6758467..a7f232f8 100644 --- a/src/main/java/de/dhbwstuttgart/inferWildcards/TypePlaceholderReplaceUtils.java +++ b/src/main/java/de/dhbwstuttgart/inferWildcards/TypePlaceholderReplaceUtils.java @@ -33,7 +33,7 @@ public final class TypePlaceholderReplaceUtils */ public static Map generateTypePlaceholder ( JavaTXCompiler compiler) { - Map sourceFiles = compiler.getSourceFiles(); + Map sourceFiles = compiler.sourceFiles; ReplaceTypeparamVisitor visitor = new ReplaceTypeparamVisitor(); sourceFiles.forEach( (k, v) -> v.accept(visitor)); return visitor.getTphMap(); diff --git a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java index c4625a7a..90ba659c 100644 --- a/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java +++ b/src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/StatementGenerator.java @@ -216,6 +216,7 @@ public class StatementGenerator { MethodCall ret = new MethodCall(TypePlaceholder.fresh(methodInvocationContext.getStart()), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(methodInvocationContext.getStart()), argTypes, methodInvocationContext.getStart()); + ret.setStatement(); return ret; } @@ -302,33 +303,45 @@ public class StatementGenerator { ArrayList argTypes = args.getArguments().stream() .map(x -> TypePlaceholder.fresh(newExpression.getStart())) .collect(Collectors.toCollection(ArrayList::new)); - return new NewClass(newClass, args, null, argTypes, newExpression.getStart()); + Statement ret = new NewClass(newClass, args, null, argTypes, newExpression.getStart()); + ret.setStatement(); + return ret; } private Statement convert(Java8Parser.PreIncrementExpressionContext stmt) { Expression argument = convert(stmt.unaryExpression()); Token offset = stmt.getStart(); - return new UnaryExpr(UnaryExpr.Operation.PREINCREMENT, argument, TypePlaceholder.fresh(offset), offset); - } + Statement ret = new UnaryExpr(UnaryExpr.Operation.PREINCREMENT, argument, TypePlaceholder.fresh(offset), offset); + ret.setStatement(); + return ret; + } private Statement convert(Java8Parser.PreDecrementExpressionContext stmt) { - return new UnaryExpr(UnaryExpr.Operation.PREDECREMENT, convert(stmt.unaryExpression()), + Statement ret = new UnaryExpr(UnaryExpr.Operation.PREDECREMENT, convert(stmt.unaryExpression()), TypePlaceholder.fresh(stmt.getStart()), stmt.getStart()); + ret.setStatement(); + return ret; } private Statement convert(Java8Parser.PostIncrementExpressionContext stmt) { - return new UnaryExpr(UnaryExpr.Operation.POSTINCREMENT, convert(stmt.postfixExpression()), + Statement ret = new UnaryExpr(UnaryExpr.Operation.POSTINCREMENT, convert(stmt.postfixExpression()), TypePlaceholder.fresh(stmt.getStart()), stmt.getStart()); + ret.setStatement(); + return ret; } private Statement convert(Java8Parser.PostDecrementExpressionContext stmt) { - return new UnaryExpr(UnaryExpr.Operation.POSTDECREMENT, convert(stmt.postfixExpression()), + Statement ret = new UnaryExpr(UnaryExpr.Operation.POSTDECREMENT, convert(stmt.postfixExpression()), TypePlaceholder.fresh(stmt.getStart()), stmt.getStart()); + ret.setStatement(); + return ret; } private Statement convert(Java8Parser.AssignmentContext stmt) { AssignLeftSide leftHandSide = convert(stmt.leftHandSide()); - return new Assign(leftHandSide, convert(stmt.expression()), stmt.getStart()); + Statement ret = new Assign(leftHandSide, convert(stmt.expression()), stmt.getStart()); + ret.setStatement(); + return ret; } private AssignLeftSide convert(Java8Parser.LeftHandSideContext leftHandSide) { diff --git a/src/main/java/de/dhbwstuttgart/parser/antlr/Java8BaseListener.java b/src/main/java/de/dhbwstuttgart/parser/antlr/Java8BaseListener.java index 644786ac..1c94febc 100644 --- a/src/main/java/de/dhbwstuttgart/parser/antlr/Java8BaseListener.java +++ b/src/main/java/de/dhbwstuttgart/parser/antlr/Java8BaseListener.java @@ -1,4 +1,4 @@ -// Generated from Java8.g4 by ANTLR 4.8 +// Generated from Java8.g4 by ANTLR 4.7 package de.dhbwstuttgart.parser.antlr; import org.antlr.v4.runtime.ParserRuleContext; diff --git a/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Lexer.java b/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Lexer.java index c346153e..9c2e22c4 100644 --- a/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Lexer.java +++ b/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Lexer.java @@ -1,4 +1,4 @@ -// Generated from Java8.g4 by ANTLR 4.8 +// Generated from Java8.g4 by ANTLR 4.7 package de.dhbwstuttgart.parser.antlr; import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.CharStream; @@ -11,7 +11,7 @@ import org.antlr.v4.runtime.misc.*; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class Java8Lexer extends Lexer { - static { RuntimeMetaData.checkVersion("4.8", RuntimeMetaData.VERSION); } + static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = @@ -42,79 +42,68 @@ public class Java8Lexer extends Lexer { "DEFAULT_MODE" }; - private static String[] makeRuleNames() { - return new String[] { - "T__0", "ABSTRACT", "ASSERT", "BOOLEAN", "BREAK", "BYTE", "CASE", "CATCH", - "CHAR", "CLASS", "CONST", "CONTINUE", "DEFAULT", "DO", "DOUBLE", "ELSE", - "ENUM", "EXTENDS", "FINAL", "FINALLY", "FLOAT", "FOR", "IF", "GOTO", - "IMPLEMENTS", "IMPORT", "INSTANCEOF", "INT", "INTERFACE", "LONG", "NATIVE", - "NEW", "PACKAGE", "PRIVATE", "PROTECTED", "PUBLIC", "RETURN", "SHORT", - "STATIC", "STRICTFP", "SUPER", "SWITCH", "SYNCHRONIZED", "THIS", "THROW", - "THROWS", "TRANSIENT", "TRY", "VOID", "VOLATILE", "WHILE", "IntegerLiteral", - "DecimalIntegerLiteral", "HexIntegerLiteral", "OctalIntegerLiteral", - "BinaryIntegerLiteral", "IntegerTypeSuffix", "DecimalNumeral", "Digits", - "Digit", "NonZeroDigit", "DigitsAndUnderscores", "DigitOrUnderscore", - "Underscores", "HexNumeral", "HexDigits", "HexDigit", "HexDigitsAndUnderscores", - "HexDigitOrUnderscore", "OctalNumeral", "OctalDigits", "OctalDigit", - "OctalDigitsAndUnderscores", "OctalDigitOrUnderscore", "BinaryNumeral", - "BinaryDigits", "BinaryDigit", "BinaryDigitsAndUnderscores", "BinaryDigitOrUnderscore", - "FloatingPointLiteral", "DecimalFloatingPointLiteral", "ExponentPart", - "ExponentIndicator", "SignedInteger", "Sign", "FloatTypeSuffix", "HexadecimalFloatingPointLiteral", - "HexSignificand", "BinaryExponent", "BinaryExponentIndicator", "BooleanLiteral", - "CharacterLiteral", "SingleCharacter", "StringLiteral", "StringCharacters", - "StringCharacter", "EscapeSequence", "OctalEscape", "ZeroToThree", "UnicodeEscape", - "NullLiteral", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK", - "SEMI", "COMMA", "DOT", "ASSIGN", "GT", "LT", "BANG", "TILDE", "QUESTION", - "COLON", "EQUAL", "LE", "GE", "NOTEQUAL", "AND", "OR", "INC", "DEC", - "ADD", "SUB", "MUL", "DIV", "BITAND", "BITOR", "CARET", "MOD", "ARROW", - "COLONCOLON", "ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", - "AND_ASSIGN", "OR_ASSIGN", "XOR_ASSIGN", "MOD_ASSIGN", "LSHIFT_ASSIGN", - "RSHIFT_ASSIGN", "URSHIFT_ASSIGN", "Identifier", "JavaLetter", "JavaLetterOrDigit", - "AT", "ELLIPSIS", "WS", "COMMENT", "LINE_COMMENT" - }; - } - public static final String[] ruleNames = makeRuleNames(); + public static final String[] ruleNames = { + "T__0", "ABSTRACT", "ASSERT", "BOOLEAN", "BREAK", "BYTE", "CASE", "CATCH", + "CHAR", "CLASS", "CONST", "CONTINUE", "DEFAULT", "DO", "DOUBLE", "ELSE", + "ENUM", "EXTENDS", "FINAL", "FINALLY", "FLOAT", "FOR", "IF", "GOTO", "IMPLEMENTS", + "IMPORT", "INSTANCEOF", "INT", "INTERFACE", "LONG", "NATIVE", "NEW", "PACKAGE", + "PRIVATE", "PROTECTED", "PUBLIC", "RETURN", "SHORT", "STATIC", "STRICTFP", + "SUPER", "SWITCH", "SYNCHRONIZED", "THIS", "THROW", "THROWS", "TRANSIENT", + "TRY", "VOID", "VOLATILE", "WHILE", "IntegerLiteral", "DecimalIntegerLiteral", + "HexIntegerLiteral", "OctalIntegerLiteral", "BinaryIntegerLiteral", "IntegerTypeSuffix", + "DecimalNumeral", "Digits", "Digit", "NonZeroDigit", "DigitsAndUnderscores", + "DigitOrUnderscore", "Underscores", "HexNumeral", "HexDigits", "HexDigit", + "HexDigitsAndUnderscores", "HexDigitOrUnderscore", "OctalNumeral", "OctalDigits", + "OctalDigit", "OctalDigitsAndUnderscores", "OctalDigitOrUnderscore", "BinaryNumeral", + "BinaryDigits", "BinaryDigit", "BinaryDigitsAndUnderscores", "BinaryDigitOrUnderscore", + "FloatingPointLiteral", "DecimalFloatingPointLiteral", "ExponentPart", + "ExponentIndicator", "SignedInteger", "Sign", "FloatTypeSuffix", "HexadecimalFloatingPointLiteral", + "HexSignificand", "BinaryExponent", "BinaryExponentIndicator", "BooleanLiteral", + "CharacterLiteral", "SingleCharacter", "StringLiteral", "StringCharacters", + "StringCharacter", "EscapeSequence", "OctalEscape", "ZeroToThree", "UnicodeEscape", + "NullLiteral", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK", + "SEMI", "COMMA", "DOT", "ASSIGN", "GT", "LT", "BANG", "TILDE", "QUESTION", + "COLON", "EQUAL", "LE", "GE", "NOTEQUAL", "AND", "OR", "INC", "DEC", "ADD", + "SUB", "MUL", "DIV", "BITAND", "BITOR", "CARET", "MOD", "ARROW", "COLONCOLON", + "ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", "AND_ASSIGN", + "OR_ASSIGN", "XOR_ASSIGN", "MOD_ASSIGN", "LSHIFT_ASSIGN", "RSHIFT_ASSIGN", + "URSHIFT_ASSIGN", "Identifier", "JavaLetter", "JavaLetterOrDigit", "AT", + "ELLIPSIS", "WS", "COMMENT", "LINE_COMMENT" + }; - private static String[] makeLiteralNames() { - return new String[] { - null, "'var'", "'abstract'", "'assert'", "'boolean'", "'break'", "'byte'", - "'case'", "'catch'", "'char'", "'class'", "'const'", "'continue'", "'default'", - "'do'", "'double'", "'else'", "'enum'", "'extends'", "'final'", "'finally'", - "'float'", "'for'", "'if'", "'goto'", "'implements'", "'import'", "'instanceof'", - "'int'", "'interface'", "'long'", "'native'", "'new'", "'package'", "'private'", - "'protected'", "'public'", "'return'", "'short'", "'static'", "'strictfp'", - "'super'", "'switch'", "'synchronized'", "'this'", "'throw'", "'throws'", - "'transient'", "'try'", "'void'", "'volatile'", "'while'", null, null, - null, null, null, "'null'", "'('", "')'", "'{'", "'}'", "'['", "']'", - "';'", "','", "'.'", "'='", "'>'", "'<'", "'!'", "'~'", "'?'", "':'", - "'=='", "'<='", "'>='", "'!='", "'&&'", "'||'", "'++'", "'--'", "'+'", - "'-'", "'*'", "'/'", "'&'", "'|'", "'^'", "'%'", "'->'", "'::'", "'+='", - "'-='", "'*='", "'/='", "'&='", "'|='", "'^='", "'%='", "'<<='", "'>>='", - "'>>>='", null, "'@'", "'...'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, null, "ABSTRACT", "ASSERT", "BOOLEAN", "BREAK", "BYTE", "CASE", - "CATCH", "CHAR", "CLASS", "CONST", "CONTINUE", "DEFAULT", "DO", "DOUBLE", - "ELSE", "ENUM", "EXTENDS", "FINAL", "FINALLY", "FLOAT", "FOR", "IF", - "GOTO", "IMPLEMENTS", "IMPORT", "INSTANCEOF", "INT", "INTERFACE", "LONG", - "NATIVE", "NEW", "PACKAGE", "PRIVATE", "PROTECTED", "PUBLIC", "RETURN", - "SHORT", "STATIC", "STRICTFP", "SUPER", "SWITCH", "SYNCHRONIZED", "THIS", - "THROW", "THROWS", "TRANSIENT", "TRY", "VOID", "VOLATILE", "WHILE", "IntegerLiteral", - "FloatingPointLiteral", "BooleanLiteral", "CharacterLiteral", "StringLiteral", - "NullLiteral", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK", - "SEMI", "COMMA", "DOT", "ASSIGN", "GT", "LT", "BANG", "TILDE", "QUESTION", - "COLON", "EQUAL", "LE", "GE", "NOTEQUAL", "AND", "OR", "INC", "DEC", - "ADD", "SUB", "MUL", "DIV", "BITAND", "BITOR", "CARET", "MOD", "ARROW", - "COLONCOLON", "ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", - "AND_ASSIGN", "OR_ASSIGN", "XOR_ASSIGN", "MOD_ASSIGN", "LSHIFT_ASSIGN", - "RSHIFT_ASSIGN", "URSHIFT_ASSIGN", "Identifier", "AT", "ELLIPSIS", "WS", - "COMMENT", "LINE_COMMENT" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + private static final String[] _LITERAL_NAMES = { + null, "'var'", "'abstract'", "'assert'", "'boolean'", "'break'", "'byte'", + "'case'", "'catch'", "'char'", "'class'", "'const'", "'continue'", "'default'", + "'do'", "'double'", "'else'", "'enum'", "'extends'", "'final'", "'finally'", + "'float'", "'for'", "'if'", "'goto'", "'implements'", "'import'", "'instanceof'", + "'int'", "'interface'", "'long'", "'native'", "'new'", "'package'", "'private'", + "'protected'", "'public'", "'return'", "'short'", "'static'", "'strictfp'", + "'super'", "'switch'", "'synchronized'", "'this'", "'throw'", "'throws'", + "'transient'", "'try'", "'void'", "'volatile'", "'while'", null, null, + null, null, null, "'null'", "'('", "')'", "'{'", "'}'", "'['", "']'", + "';'", "','", "'.'", "'='", "'>'", "'<'", "'!'", "'~'", "'?'", "':'", + "'=='", "'<='", "'>='", "'!='", "'&&'", "'||'", "'++'", "'--'", "'+'", + "'-'", "'*'", "'/'", "'&'", "'|'", "'^'", "'%'", "'->'", "'::'", "'+='", + "'-='", "'*='", "'/='", "'&='", "'|='", "'^='", "'%='", "'<<='", "'>>='", + "'>>>='", null, "'@'", "'...'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, "ABSTRACT", "ASSERT", "BOOLEAN", "BREAK", "BYTE", "CASE", + "CATCH", "CHAR", "CLASS", "CONST", "CONTINUE", "DEFAULT", "DO", "DOUBLE", + "ELSE", "ENUM", "EXTENDS", "FINAL", "FINALLY", "FLOAT", "FOR", "IF", "GOTO", + "IMPLEMENTS", "IMPORT", "INSTANCEOF", "INT", "INTERFACE", "LONG", "NATIVE", + "NEW", "PACKAGE", "PRIVATE", "PROTECTED", "PUBLIC", "RETURN", "SHORT", + "STATIC", "STRICTFP", "SUPER", "SWITCH", "SYNCHRONIZED", "THIS", "THROW", + "THROWS", "TRANSIENT", "TRY", "VOID", "VOLATILE", "WHILE", "IntegerLiteral", + "FloatingPointLiteral", "BooleanLiteral", "CharacterLiteral", "StringLiteral", + "NullLiteral", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK", + "SEMI", "COMMA", "DOT", "ASSIGN", "GT", "LT", "BANG", "TILDE", "QUESTION", + "COLON", "EQUAL", "LE", "GE", "NOTEQUAL", "AND", "OR", "INC", "DEC", "ADD", + "SUB", "MUL", "DIV", "BITAND", "BITOR", "CARET", "MOD", "ARROW", "COLONCOLON", + "ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", "AND_ASSIGN", + "OR_ASSIGN", "XOR_ASSIGN", "MOD_ASSIGN", "LSHIFT_ASSIGN", "RSHIFT_ASSIGN", + "URSHIFT_ASSIGN", "Identifier", "AT", "ELLIPSIS", "WS", "COMMENT", "LINE_COMMENT" + }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** diff --git a/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Listener.java b/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Listener.java index 88b4f7e7..a875c96f 100644 --- a/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Listener.java +++ b/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Listener.java @@ -1,4 +1,4 @@ -// Generated from Java8.g4 by ANTLR 4.8 +// Generated from Java8.g4 by ANTLR 4.7 package de.dhbwstuttgart.parser.antlr; import org.antlr.v4.runtime.tree.ParseTreeListener; diff --git a/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Parser.java b/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Parser.java index 2d2fdd46..398dd5f8 100644 --- a/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Parser.java +++ b/src/main/java/de/dhbwstuttgart/parser/antlr/Java8Parser.java @@ -1,4 +1,4 @@ -// Generated from Java8.g4 by ANTLR 4.8 +// Generated from Java8.g4 by ANTLR 4.7 package de.dhbwstuttgart.parser.antlr; import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; @@ -11,7 +11,7 @@ import java.util.ArrayList; @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class Java8Parser extends Parser { - static { RuntimeMetaData.checkVersion("4.8", RuntimeMetaData.VERSION); } + static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; protected static final PredictionContextCache _sharedContextCache = @@ -122,119 +122,108 @@ public class Java8Parser extends Parser { RULE_postfixExpression = 232, RULE_postIncrementExpression = 233, RULE_postIncrementExpression_lf_postfixExpression = 234, RULE_postDecrementExpression = 235, RULE_postDecrementExpression_lf_postfixExpression = 236, RULE_castExpression = 237; - private static String[] makeRuleNames() { - return new String[] { - "literal", "type", "primitiveType", "numericType", "integralType", "floatingPointType", - "referenceType", "classOrInterfaceType", "classType", "classType_lf_classOrInterfaceType", - "classType_lfno_classOrInterfaceType", "interfaceType", "interfaceType_lf_classOrInterfaceType", - "interfaceType_lfno_classOrInterfaceType", "typeVariable", "arrayType", - "dims", "typeParameter", "typeParameterModifier", "typeBound", "additionalBound", - "typeArguments", "typeArgumentList", "typeArgument", "wildcard", "wildcardBounds", - "packageName", "typeName", "packageOrTypeName", "expressionName", "methodName", - "ambiguousName", "compilationUnit", "packageDeclaration", "packageModifier", - "importDeclaration", "singleTypeImportDeclaration", "typeImportOnDemandDeclaration", - "singleStaticImportDeclaration", "staticImportOnDemandDeclaration", "typeDeclaration", - "classDeclaration", "normalClassDeclaration", "classModifier", "typeParameters", - "typeParameterList", "superclass", "superinterfaces", "interfaceTypeList", - "classBody", "classBodyDeclaration", "classMemberDeclaration", "fieldDeclaration", - "fieldModifier", "variableDeclaratorList", "variableDeclarator", "variableDeclaratorId", - "variableInitializer", "unannType", "unannPrimitiveType", "unannReferenceType", - "unannClassOrInterfaceType", "unannClassType", "unannClassType_lf_unannClassOrInterfaceType", - "unannClassType_lfno_unannClassOrInterfaceType", "unannInterfaceType", - "unannInterfaceType_lf_unannClassOrInterfaceType", "unannInterfaceType_lfno_unannClassOrInterfaceType", - "unannTypeVariable", "unannArrayType", "methodDeclaration", "methodModifier", - "methodHeader", "result", "methodDeclarator", "formalParameterList", - "formalParameters", "formalParameter", "variableModifier", "lastFormalParameter", - "receiverParameter", "throws_", "exceptionTypeList", "exceptionType", - "methodBody", "instanceInitializer", "staticInitializer", "constructorDeclaration", - "constructorModifier", "constructorDeclarator", "simpleTypeName", "constructorBody", - "explicitConstructorInvocation", "enumDeclaration", "enumBody", "enumConstantList", - "enumConstant", "enumConstantModifier", "enumBodyDeclarations", "interfaceDeclaration", - "normalInterfaceDeclaration", "interfaceModifier", "extendsInterfaces", - "interfaceBody", "interfaceMemberDeclaration", "constantDeclaration", - "constantModifier", "interfaceMethodDeclaration", "interfaceMethodModifier", - "annotationTypeDeclaration", "annotationTypeBody", "annotationTypeMemberDeclaration", - "annotationTypeElementDeclaration", "annotationTypeElementModifier", - "defaultValue", "annotation", "normalAnnotation", "elementValuePairList", - "elementValuePair", "elementValue", "elementValueArrayInitializer", "elementValueList", - "markerAnnotation", "singleElementAnnotation", "arrayInitializer", "variableInitializerList", - "block", "blockStatements", "blockStatement", "localVariableDeclarationStatement", - "unannTypeOrAuto", "localVariableDeclaration", "statement", "statementNoShortIf", - "statementWithoutTrailingSubstatement", "emptyStatement", "labeledStatement", - "labeledStatementNoShortIf", "expressionStatement", "statementExpression", - "ifThenStatement", "ifThenElseStatement", "ifThenElseStatementNoShortIf", - "assertStatement", "switchStatement", "switchBlock", "switchBlockStatementGroup", - "switchLabels", "switchLabel", "enumConstantName", "whileStatement", - "whileStatementNoShortIf", "doStatement", "forStatement", "forStatementNoShortIf", - "basicForStatement", "basicForStatementNoShortIf", "forInit", "forUpdate", - "statementExpressionList", "enhancedForStatement", "enhancedForStatementNoShortIf", - "breakStatement", "continueStatement", "returnStatement", "throwStatement", - "synchronizedStatement", "tryStatement", "catches", "catchClause", "catchFormalParameter", - "catchType", "finally_", "tryWithResourcesStatement", "resourceSpecification", - "resourceList", "resource", "primary", "primaryNoNewArray", "primaryNoNewArray_lf_arrayAccess", - "primaryNoNewArray_lfno_arrayAccess", "primaryNoNewArray_lf_primary", - "primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary", "primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary", - "primaryNoNewArray_lfno_primary", "primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary", - "primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary", "classInstanceCreationExpression", - "classInstanceCreationExpression_lf_primary", "classInstanceCreationExpression_lfno_primary", - "typeArgumentsOrDiamond", "fieldAccess", "fieldAccess_lf_primary", "fieldAccess_lfno_primary", - "arrayAccess", "arrayAccess_lf_primary", "arrayAccess_lfno_primary", - "methodInvocation", "methodInvocation_lf_primary", "methodInvocation_lfno_primary", - "argumentList", "methodReference", "methodReference_lf_primary", "methodReference_lfno_primary", - "arrayCreationExpression", "dimExprs", "dimExpr", "constantExpression", - "expression", "lambdaExpression", "lambdaParameters", "inferredFormalParameterList", - "lambdaBody", "assignmentExpression", "assignment", "leftHandSide", "assignmentOperator", - "conditionalExpression", "conditionalOrExpression", "conditionalAndExpression", - "inclusiveOrExpression", "exclusiveOrExpression", "andExpression", "equalityExpression", - "relationalExpression", "shiftExpression", "additiveExpression", "multiplicativeExpression", - "unaryExpression", "preIncrementExpression", "preDecrementExpression", - "unaryExpressionNotPlusMinus", "postfixExpression", "postIncrementExpression", - "postIncrementExpression_lf_postfixExpression", "postDecrementExpression", - "postDecrementExpression_lf_postfixExpression", "castExpression" - }; - } - public static final String[] ruleNames = makeRuleNames(); + public static final String[] ruleNames = { + "literal", "type", "primitiveType", "numericType", "integralType", "floatingPointType", + "referenceType", "classOrInterfaceType", "classType", "classType_lf_classOrInterfaceType", + "classType_lfno_classOrInterfaceType", "interfaceType", "interfaceType_lf_classOrInterfaceType", + "interfaceType_lfno_classOrInterfaceType", "typeVariable", "arrayType", + "dims", "typeParameter", "typeParameterModifier", "typeBound", "additionalBound", + "typeArguments", "typeArgumentList", "typeArgument", "wildcard", "wildcardBounds", + "packageName", "typeName", "packageOrTypeName", "expressionName", "methodName", + "ambiguousName", "compilationUnit", "packageDeclaration", "packageModifier", + "importDeclaration", "singleTypeImportDeclaration", "typeImportOnDemandDeclaration", + "singleStaticImportDeclaration", "staticImportOnDemandDeclaration", "typeDeclaration", + "classDeclaration", "normalClassDeclaration", "classModifier", "typeParameters", + "typeParameterList", "superclass", "superinterfaces", "interfaceTypeList", + "classBody", "classBodyDeclaration", "classMemberDeclaration", "fieldDeclaration", + "fieldModifier", "variableDeclaratorList", "variableDeclarator", "variableDeclaratorId", + "variableInitializer", "unannType", "unannPrimitiveType", "unannReferenceType", + "unannClassOrInterfaceType", "unannClassType", "unannClassType_lf_unannClassOrInterfaceType", + "unannClassType_lfno_unannClassOrInterfaceType", "unannInterfaceType", + "unannInterfaceType_lf_unannClassOrInterfaceType", "unannInterfaceType_lfno_unannClassOrInterfaceType", + "unannTypeVariable", "unannArrayType", "methodDeclaration", "methodModifier", + "methodHeader", "result", "methodDeclarator", "formalParameterList", "formalParameters", + "formalParameter", "variableModifier", "lastFormalParameter", "receiverParameter", + "throws_", "exceptionTypeList", "exceptionType", "methodBody", "instanceInitializer", + "staticInitializer", "constructorDeclaration", "constructorModifier", + "constructorDeclarator", "simpleTypeName", "constructorBody", "explicitConstructorInvocation", + "enumDeclaration", "enumBody", "enumConstantList", "enumConstant", "enumConstantModifier", + "enumBodyDeclarations", "interfaceDeclaration", "normalInterfaceDeclaration", + "interfaceModifier", "extendsInterfaces", "interfaceBody", "interfaceMemberDeclaration", + "constantDeclaration", "constantModifier", "interfaceMethodDeclaration", + "interfaceMethodModifier", "annotationTypeDeclaration", "annotationTypeBody", + "annotationTypeMemberDeclaration", "annotationTypeElementDeclaration", + "annotationTypeElementModifier", "defaultValue", "annotation", "normalAnnotation", + "elementValuePairList", "elementValuePair", "elementValue", "elementValueArrayInitializer", + "elementValueList", "markerAnnotation", "singleElementAnnotation", "arrayInitializer", + "variableInitializerList", "block", "blockStatements", "blockStatement", + "localVariableDeclarationStatement", "unannTypeOrAuto", "localVariableDeclaration", + "statement", "statementNoShortIf", "statementWithoutTrailingSubstatement", + "emptyStatement", "labeledStatement", "labeledStatementNoShortIf", "expressionStatement", + "statementExpression", "ifThenStatement", "ifThenElseStatement", "ifThenElseStatementNoShortIf", + "assertStatement", "switchStatement", "switchBlock", "switchBlockStatementGroup", + "switchLabels", "switchLabel", "enumConstantName", "whileStatement", "whileStatementNoShortIf", + "doStatement", "forStatement", "forStatementNoShortIf", "basicForStatement", + "basicForStatementNoShortIf", "forInit", "forUpdate", "statementExpressionList", + "enhancedForStatement", "enhancedForStatementNoShortIf", "breakStatement", + "continueStatement", "returnStatement", "throwStatement", "synchronizedStatement", + "tryStatement", "catches", "catchClause", "catchFormalParameter", "catchType", + "finally_", "tryWithResourcesStatement", "resourceSpecification", "resourceList", + "resource", "primary", "primaryNoNewArray", "primaryNoNewArray_lf_arrayAccess", + "primaryNoNewArray_lfno_arrayAccess", "primaryNoNewArray_lf_primary", + "primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary", "primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary", + "primaryNoNewArray_lfno_primary", "primaryNoNewArray_lfno_primary_lf_arrayAccess_lfno_primary", + "primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary", "classInstanceCreationExpression", + "classInstanceCreationExpression_lf_primary", "classInstanceCreationExpression_lfno_primary", + "typeArgumentsOrDiamond", "fieldAccess", "fieldAccess_lf_primary", "fieldAccess_lfno_primary", + "arrayAccess", "arrayAccess_lf_primary", "arrayAccess_lfno_primary", "methodInvocation", + "methodInvocation_lf_primary", "methodInvocation_lfno_primary", "argumentList", + "methodReference", "methodReference_lf_primary", "methodReference_lfno_primary", + "arrayCreationExpression", "dimExprs", "dimExpr", "constantExpression", + "expression", "lambdaExpression", "lambdaParameters", "inferredFormalParameterList", + "lambdaBody", "assignmentExpression", "assignment", "leftHandSide", "assignmentOperator", + "conditionalExpression", "conditionalOrExpression", "conditionalAndExpression", + "inclusiveOrExpression", "exclusiveOrExpression", "andExpression", "equalityExpression", + "relationalExpression", "shiftExpression", "additiveExpression", "multiplicativeExpression", + "unaryExpression", "preIncrementExpression", "preDecrementExpression", + "unaryExpressionNotPlusMinus", "postfixExpression", "postIncrementExpression", + "postIncrementExpression_lf_postfixExpression", "postDecrementExpression", + "postDecrementExpression_lf_postfixExpression", "castExpression" + }; - private static String[] makeLiteralNames() { - return new String[] { - null, "'var'", "'abstract'", "'assert'", "'boolean'", "'break'", "'byte'", - "'case'", "'catch'", "'char'", "'class'", "'const'", "'continue'", "'default'", - "'do'", "'double'", "'else'", "'enum'", "'extends'", "'final'", "'finally'", - "'float'", "'for'", "'if'", "'goto'", "'implements'", "'import'", "'instanceof'", - "'int'", "'interface'", "'long'", "'native'", "'new'", "'package'", "'private'", - "'protected'", "'public'", "'return'", "'short'", "'static'", "'strictfp'", - "'super'", "'switch'", "'synchronized'", "'this'", "'throw'", "'throws'", - "'transient'", "'try'", "'void'", "'volatile'", "'while'", null, null, - null, null, null, "'null'", "'('", "')'", "'{'", "'}'", "'['", "']'", - "';'", "','", "'.'", "'='", "'>'", "'<'", "'!'", "'~'", "'?'", "':'", - "'=='", "'<='", "'>='", "'!='", "'&&'", "'||'", "'++'", "'--'", "'+'", - "'-'", "'*'", "'/'", "'&'", "'|'", "'^'", "'%'", "'->'", "'::'", "'+='", - "'-='", "'*='", "'/='", "'&='", "'|='", "'^='", "'%='", "'<<='", "'>>='", - "'>>>='", null, "'@'", "'...'" - }; - } - private static final String[] _LITERAL_NAMES = makeLiteralNames(); - private static String[] makeSymbolicNames() { - return new String[] { - null, null, "ABSTRACT", "ASSERT", "BOOLEAN", "BREAK", "BYTE", "CASE", - "CATCH", "CHAR", "CLASS", "CONST", "CONTINUE", "DEFAULT", "DO", "DOUBLE", - "ELSE", "ENUM", "EXTENDS", "FINAL", "FINALLY", "FLOAT", "FOR", "IF", - "GOTO", "IMPLEMENTS", "IMPORT", "INSTANCEOF", "INT", "INTERFACE", "LONG", - "NATIVE", "NEW", "PACKAGE", "PRIVATE", "PROTECTED", "PUBLIC", "RETURN", - "SHORT", "STATIC", "STRICTFP", "SUPER", "SWITCH", "SYNCHRONIZED", "THIS", - "THROW", "THROWS", "TRANSIENT", "TRY", "VOID", "VOLATILE", "WHILE", "IntegerLiteral", - "FloatingPointLiteral", "BooleanLiteral", "CharacterLiteral", "StringLiteral", - "NullLiteral", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK", - "SEMI", "COMMA", "DOT", "ASSIGN", "GT", "LT", "BANG", "TILDE", "QUESTION", - "COLON", "EQUAL", "LE", "GE", "NOTEQUAL", "AND", "OR", "INC", "DEC", - "ADD", "SUB", "MUL", "DIV", "BITAND", "BITOR", "CARET", "MOD", "ARROW", - "COLONCOLON", "ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", - "AND_ASSIGN", "OR_ASSIGN", "XOR_ASSIGN", "MOD_ASSIGN", "LSHIFT_ASSIGN", - "RSHIFT_ASSIGN", "URSHIFT_ASSIGN", "Identifier", "AT", "ELLIPSIS", "WS", - "COMMENT", "LINE_COMMENT" - }; - } - private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + private static final String[] _LITERAL_NAMES = { + null, "'var'", "'abstract'", "'assert'", "'boolean'", "'break'", "'byte'", + "'case'", "'catch'", "'char'", "'class'", "'const'", "'continue'", "'default'", + "'do'", "'double'", "'else'", "'enum'", "'extends'", "'final'", "'finally'", + "'float'", "'for'", "'if'", "'goto'", "'implements'", "'import'", "'instanceof'", + "'int'", "'interface'", "'long'", "'native'", "'new'", "'package'", "'private'", + "'protected'", "'public'", "'return'", "'short'", "'static'", "'strictfp'", + "'super'", "'switch'", "'synchronized'", "'this'", "'throw'", "'throws'", + "'transient'", "'try'", "'void'", "'volatile'", "'while'", null, null, + null, null, null, "'null'", "'('", "')'", "'{'", "'}'", "'['", "']'", + "';'", "','", "'.'", "'='", "'>'", "'<'", "'!'", "'~'", "'?'", "':'", + "'=='", "'<='", "'>='", "'!='", "'&&'", "'||'", "'++'", "'--'", "'+'", + "'-'", "'*'", "'/'", "'&'", "'|'", "'^'", "'%'", "'->'", "'::'", "'+='", + "'-='", "'*='", "'/='", "'&='", "'|='", "'^='", "'%='", "'<<='", "'>>='", + "'>>>='", null, "'@'", "'...'" + }; + private static final String[] _SYMBOLIC_NAMES = { + null, null, "ABSTRACT", "ASSERT", "BOOLEAN", "BREAK", "BYTE", "CASE", + "CATCH", "CHAR", "CLASS", "CONST", "CONTINUE", "DEFAULT", "DO", "DOUBLE", + "ELSE", "ENUM", "EXTENDS", "FINAL", "FINALLY", "FLOAT", "FOR", "IF", "GOTO", + "IMPLEMENTS", "IMPORT", "INSTANCEOF", "INT", "INTERFACE", "LONG", "NATIVE", + "NEW", "PACKAGE", "PRIVATE", "PROTECTED", "PUBLIC", "RETURN", "SHORT", + "STATIC", "STRICTFP", "SUPER", "SWITCH", "SYNCHRONIZED", "THIS", "THROW", + "THROWS", "TRANSIENT", "TRY", "VOID", "VOLATILE", "WHILE", "IntegerLiteral", + "FloatingPointLiteral", "BooleanLiteral", "CharacterLiteral", "StringLiteral", + "NullLiteral", "LPAREN", "RPAREN", "LBRACE", "RBRACE", "LBRACK", "RBRACK", + "SEMI", "COMMA", "DOT", "ASSIGN", "GT", "LT", "BANG", "TILDE", "QUESTION", + "COLON", "EQUAL", "LE", "GE", "NOTEQUAL", "AND", "OR", "INC", "DEC", "ADD", + "SUB", "MUL", "DIV", "BITAND", "BITOR", "CARET", "MOD", "ARROW", "COLONCOLON", + "ADD_ASSIGN", "SUB_ASSIGN", "MUL_ASSIGN", "DIV_ASSIGN", "AND_ASSIGN", + "OR_ASSIGN", "XOR_ASSIGN", "MOD_ASSIGN", "LSHIFT_ASSIGN", "RSHIFT_ASSIGN", + "URSHIFT_ASSIGN", "Identifier", "AT", "ELLIPSIS", "WS", "COMMENT", "LINE_COMMENT" + }; public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** @@ -284,7 +273,6 @@ public class Java8Parser extends Parser { super(input); _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); } - public static class LiteralContext extends ParserRuleContext { public TerminalNode IntegerLiteral() { return getToken(Java8Parser.IntegerLiteral, 0); } public TerminalNode FloatingPointLiteral() { return getToken(Java8Parser.FloatingPointLiteral, 0); } @@ -401,7 +389,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation(int i) { return getRuleContext(AnnotationContext.class,i); } - public TerminalNode BOOLEAN() { return getToken(Java8Parser.BOOLEAN, 0); } public PrimitiveTypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -542,11 +529,6 @@ public class Java8Parser extends Parser { } public static class IntegralTypeContext extends ParserRuleContext { - public TerminalNode BYTE() { return getToken(Java8Parser.BYTE, 0); } - public TerminalNode SHORT() { return getToken(Java8Parser.SHORT, 0); } - public TerminalNode INT() { return getToken(Java8Parser.INT, 0); } - public TerminalNode LONG() { return getToken(Java8Parser.LONG, 0); } - public TerminalNode CHAR() { return getToken(Java8Parser.CHAR, 0); } public IntegralTypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -592,8 +574,6 @@ public class Java8Parser extends Parser { } public static class FloatingPointTypeContext extends ParserRuleContext { - public TerminalNode FLOAT() { return getToken(Java8Parser.FLOAT, 0); } - public TerminalNode DOUBLE() { return getToken(Java8Parser.DOUBLE, 0); } public FloatingPointTypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -756,7 +736,7 @@ public class Java8Parser extends Parser { setState(518); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,7,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -796,7 +776,6 @@ public class Java8Parser extends Parser { public ClassOrInterfaceTypeContext classOrInterfaceType() { return getRuleContext(ClassOrInterfaceTypeContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public ClassTypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -899,7 +878,6 @@ public class Java8Parser extends Parser { } public static class ClassType_lf_classOrInterfaceTypeContext extends ParserRuleContext { - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public List annotation() { return getRuleContexts(AnnotationContext.class); @@ -1293,14 +1271,6 @@ public class Java8Parser extends Parser { } public static class DimsContext extends ParserRuleContext { - public List LBRACK() { return getTokens(Java8Parser.LBRACK); } - public TerminalNode LBRACK(int i) { - return getToken(Java8Parser.LBRACK, i); - } - public List RBRACK() { return getTokens(Java8Parser.RBRACK); } - public TerminalNode RBRACK(int i) { - return getToken(Java8Parser.RBRACK, i); - } public List annotation() { return getRuleContexts(AnnotationContext.class); } @@ -1350,7 +1320,7 @@ public class Java8Parser extends Parser { setState(609); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,21,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -1503,7 +1473,6 @@ public class Java8Parser extends Parser { } public static class TypeBoundContext extends ParserRuleContext { - public TerminalNode EXTENDS() { return getToken(Java8Parser.EXTENDS, 0); } public TypeVariableContext typeVariable() { return getRuleContext(TypeVariableContext.class,0); } @@ -1584,7 +1553,6 @@ public class Java8Parser extends Parser { } public static class AdditionalBoundContext extends ParserRuleContext { - public TerminalNode BITAND() { return getToken(Java8Parser.BITAND, 0); } public InterfaceTypeContext interfaceType() { return getRuleContext(InterfaceTypeContext.class,0); } @@ -1626,11 +1594,9 @@ public class Java8Parser extends Parser { } public static class TypeArgumentsContext extends ParserRuleContext { - public TerminalNode LT() { return getToken(Java8Parser.LT, 0); } public TypeArgumentListContext typeArgumentList() { return getRuleContext(TypeArgumentListContext.class,0); } - public TerminalNode GT() { return getToken(Java8Parser.GT, 0); } public TypeArgumentsContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -1677,10 +1643,6 @@ public class Java8Parser extends Parser { public TypeArgumentContext typeArgument(int i) { return getRuleContext(TypeArgumentContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public TypeArgumentListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -1789,7 +1751,6 @@ public class Java8Parser extends Parser { } public static class WildcardContext extends ParserRuleContext { - public TerminalNode QUESTION() { return getToken(Java8Parser.QUESTION, 0); } public List annotation() { return getRuleContexts(AnnotationContext.class); } @@ -1860,11 +1821,9 @@ public class Java8Parser extends Parser { } public static class WildcardBoundsContext extends ParserRuleContext { - public TerminalNode EXTENDS() { return getToken(Java8Parser.EXTENDS, 0); } public ReferenceTypeContext referenceType() { return getRuleContext(ReferenceTypeContext.class,0); } - public TerminalNode SUPER() { return getToken(Java8Parser.SUPER, 0); } public WildcardBoundsContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -1924,7 +1883,6 @@ public class Java8Parser extends Parser { public PackageNameContext packageName() { return getRuleContext(PackageNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public PackageNameContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -1962,7 +1920,7 @@ public class Java8Parser extends Parser { setState(679); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,31,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -2001,7 +1959,6 @@ public class Java8Parser extends Parser { public PackageOrTypeNameContext packageOrTypeName() { return getRuleContext(PackageOrTypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public TypeNameContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2059,7 +2016,6 @@ public class Java8Parser extends Parser { public PackageOrTypeNameContext packageOrTypeName() { return getRuleContext(PackageOrTypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public PackageOrTypeNameContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2097,7 +2053,7 @@ public class Java8Parser extends Parser { setState(697); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,33,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -2136,7 +2092,6 @@ public class Java8Parser extends Parser { public AmbiguousNameContext ambiguousName() { return getRuleContext(AmbiguousNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public ExpressionNameContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2231,7 +2186,6 @@ public class Java8Parser extends Parser { public AmbiguousNameContext ambiguousName() { return getRuleContext(AmbiguousNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public AmbiguousNameContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2269,7 +2223,7 @@ public class Java8Parser extends Parser { setState(717); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,35,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -2395,22 +2349,16 @@ public class Java8Parser extends Parser { } public static class PackageDeclarationContext extends ParserRuleContext { - public TerminalNode PACKAGE() { return getToken(Java8Parser.PACKAGE, 0); } public List Identifier() { return getTokens(Java8Parser.Identifier); } public TerminalNode Identifier(int i) { return getToken(Java8Parser.Identifier, i); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public List packageModifier() { return getRuleContexts(PackageModifierContext.class); } public PackageModifierContext packageModifier(int i) { return getRuleContext(PackageModifierContext.class,i); } - public List DOT() { return getTokens(Java8Parser.DOT); } - public TerminalNode DOT(int i) { - return getToken(Java8Parser.DOT, i); - } public PackageDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2596,11 +2544,9 @@ public class Java8Parser extends Parser { } public static class SingleTypeImportDeclarationContext extends ParserRuleContext { - public TerminalNode IMPORT() { return getToken(Java8Parser.IMPORT, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public SingleTypeImportDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2641,13 +2587,9 @@ public class Java8Parser extends Parser { } public static class TypeImportOnDemandDeclarationContext extends ParserRuleContext { - public TerminalNode IMPORT() { return getToken(Java8Parser.IMPORT, 0); } public PackageOrTypeNameContext packageOrTypeName() { return getRuleContext(PackageOrTypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } - public TerminalNode MUL() { return getToken(Java8Parser.MUL, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public TypeImportOnDemandDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2692,14 +2634,10 @@ public class Java8Parser extends Parser { } public static class SingleStaticImportDeclarationContext extends ParserRuleContext { - public TerminalNode IMPORT() { return getToken(Java8Parser.IMPORT, 0); } - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public SingleStaticImportDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2746,14 +2684,9 @@ public class Java8Parser extends Parser { } public static class StaticImportOnDemandDeclarationContext extends ParserRuleContext { - public TerminalNode IMPORT() { return getToken(Java8Parser.IMPORT, 0); } - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } - public TerminalNode MUL() { return getToken(Java8Parser.MUL, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public StaticImportOnDemandDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2806,7 +2739,6 @@ public class Java8Parser extends Parser { public InterfaceDeclarationContext interfaceDeclaration() { return getRuleContext(InterfaceDeclarationContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public TypeDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -2918,7 +2850,6 @@ public class Java8Parser extends Parser { } public static class NormalClassDeclarationContext extends ParserRuleContext { - public TerminalNode CLASS() { return getToken(Java8Parser.CLASS, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public ClassBodyContext classBody() { return getRuleContext(ClassBodyContext.class,0); @@ -3026,13 +2957,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode PUBLIC() { return getToken(Java8Parser.PUBLIC, 0); } - public TerminalNode PROTECTED() { return getToken(Java8Parser.PROTECTED, 0); } - public TerminalNode PRIVATE() { return getToken(Java8Parser.PRIVATE, 0); } - public TerminalNode ABSTRACT() { return getToken(Java8Parser.ABSTRACT, 0); } - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } - public TerminalNode FINAL() { return getToken(Java8Parser.FINAL, 0); } - public TerminalNode STRICTFP() { return getToken(Java8Parser.STRICTFP, 0); } public ClassModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -3126,11 +3050,9 @@ public class Java8Parser extends Parser { } public static class TypeParametersContext extends ParserRuleContext { - public TerminalNode LT() { return getToken(Java8Parser.LT, 0); } public TypeParameterListContext typeParameterList() { return getRuleContext(TypeParameterListContext.class,0); } - public TerminalNode GT() { return getToken(Java8Parser.GT, 0); } public TypeParametersContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -3177,10 +3099,6 @@ public class Java8Parser extends Parser { public TypeParameterContext typeParameter(int i) { return getRuleContext(TypeParameterContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public TypeParameterListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -3234,7 +3152,6 @@ public class Java8Parser extends Parser { } public static class SuperclassContext extends ParserRuleContext { - public TerminalNode EXTENDS() { return getToken(Java8Parser.EXTENDS, 0); } public ClassTypeContext classType() { return getRuleContext(ClassTypeContext.class,0); } @@ -3276,7 +3193,6 @@ public class Java8Parser extends Parser { } public static class SuperinterfacesContext extends ParserRuleContext { - public TerminalNode IMPLEMENTS() { return getToken(Java8Parser.IMPLEMENTS, 0); } public InterfaceTypeListContext interfaceTypeList() { return getRuleContext(InterfaceTypeListContext.class,0); } @@ -3324,10 +3240,6 @@ public class Java8Parser extends Parser { public InterfaceTypeContext interfaceType(int i) { return getRuleContext(InterfaceTypeContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public InterfaceTypeListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -3381,8 +3293,6 @@ public class Java8Parser extends Parser { } public static class ClassBodyContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public List classBodyDeclaration() { return getRuleContexts(ClassBodyDeclarationContext.class); } @@ -3519,7 +3429,6 @@ public class Java8Parser extends Parser { public InterfaceDeclarationContext interfaceDeclaration() { return getRuleContext(InterfaceDeclarationContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public ClassMemberDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -3593,7 +3502,6 @@ public class Java8Parser extends Parser { public VariableDeclaratorListContext variableDeclaratorList() { return getRuleContext(VariableDeclaratorListContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public List fieldModifier() { return getRuleContexts(FieldModifierContext.class); } @@ -3669,13 +3577,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode PUBLIC() { return getToken(Java8Parser.PUBLIC, 0); } - public TerminalNode PROTECTED() { return getToken(Java8Parser.PROTECTED, 0); } - public TerminalNode PRIVATE() { return getToken(Java8Parser.PRIVATE, 0); } - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } - public TerminalNode FINAL() { return getToken(Java8Parser.FINAL, 0); } - public TerminalNode TRANSIENT() { return getToken(Java8Parser.TRANSIENT, 0); } - public TerminalNode VOLATILE() { return getToken(Java8Parser.VOLATILE, 0); } public FieldModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -3775,10 +3676,6 @@ public class Java8Parser extends Parser { public VariableDeclaratorContext variableDeclarator(int i) { return getRuleContext(VariableDeclaratorContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public VariableDeclaratorListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -3835,7 +3732,6 @@ public class Java8Parser extends Parser { public VariableDeclaratorIdContext variableDeclaratorId() { return getRuleContext(VariableDeclaratorIdContext.class,0); } - public TerminalNode ASSIGN() { return getToken(Java8Parser.ASSIGN, 0); } public VariableInitializerContext variableInitializer() { return getRuleContext(VariableInitializerContext.class,0); } @@ -4080,7 +3976,6 @@ public class Java8Parser extends Parser { public NumericTypeContext numericType() { return getRuleContext(NumericTypeContext.class,0); } - public TerminalNode BOOLEAN() { return getToken(Java8Parser.BOOLEAN, 0); } public UnannPrimitiveTypeContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -4261,7 +4156,7 @@ public class Java8Parser extends Parser { setState(935); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,66,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { setState(933); @@ -4307,7 +4202,6 @@ public class Java8Parser extends Parser { public UnannClassOrInterfaceTypeContext unannClassOrInterfaceType() { return getRuleContext(UnannClassOrInterfaceTypeContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public List annotation() { return getRuleContexts(AnnotationContext.class); } @@ -4402,7 +4296,6 @@ public class Java8Parser extends Parser { } public static class UnannClassType_lf_unannClassOrInterfaceTypeContext extends ParserRuleContext { - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public List annotation() { return getRuleContexts(AnnotationContext.class); @@ -4823,15 +4716,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode PUBLIC() { return getToken(Java8Parser.PUBLIC, 0); } - public TerminalNode PROTECTED() { return getToken(Java8Parser.PROTECTED, 0); } - public TerminalNode PRIVATE() { return getToken(Java8Parser.PRIVATE, 0); } - public TerminalNode ABSTRACT() { return getToken(Java8Parser.ABSTRACT, 0); } - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } - public TerminalNode FINAL() { return getToken(Java8Parser.FINAL, 0); } - public TerminalNode SYNCHRONIZED() { return getToken(Java8Parser.SYNCHRONIZED, 0); } - public TerminalNode NATIVE() { return getToken(Java8Parser.NATIVE, 0); } - public TerminalNode STRICTFP() { return getToken(Java8Parser.STRICTFP, 0); } public MethodModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -5077,7 +4961,6 @@ public class Java8Parser extends Parser { public UnannTypeContext unannType() { return getRuleContext(UnannTypeContext.class,0); } - public TerminalNode VOID() { return getToken(Java8Parser.VOID, 0); } public ResultContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -5138,8 +5021,6 @@ public class Java8Parser extends Parser { public static class MethodDeclaratorContext extends ParserRuleContext { public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public FormalParameterListContext formalParameterList() { return getRuleContext(FormalParameterListContext.class,0); } @@ -5210,7 +5091,6 @@ public class Java8Parser extends Parser { public FormalParametersContext formalParameters() { return getRuleContext(FormalParametersContext.class,0); } - public TerminalNode COMMA() { return getToken(Java8Parser.COMMA, 0); } public LastFormalParameterContext lastFormalParameter() { return getRuleContext(LastFormalParameterContext.class,0); } @@ -5273,10 +5153,6 @@ public class Java8Parser extends Parser { public FormalParameterContext formalParameter(int i) { return getRuleContext(FormalParameterContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public ReceiverParameterContext receiverParameter() { return getRuleContext(ReceiverParameterContext.class,0); } @@ -5310,7 +5186,7 @@ public class Java8Parser extends Parser { setState(1059); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,87,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -5335,7 +5211,7 @@ public class Java8Parser extends Parser { setState(1067); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,88,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -5442,7 +5318,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode FINAL() { return getToken(Java8Parser.FINAL, 0); } public VariableModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -5497,7 +5372,6 @@ public class Java8Parser extends Parser { public UnannTypeContext unannType() { return getRuleContext(UnannTypeContext.class,0); } - public TerminalNode ELLIPSIS() { return getToken(Java8Parser.ELLIPSIS, 0); } public VariableDeclaratorIdContext variableDeclaratorId() { return getRuleContext(VariableDeclaratorIdContext.class,0); } @@ -5601,7 +5475,6 @@ public class Java8Parser extends Parser { public UnannTypeContext unannType() { return getRuleContext(UnannTypeContext.class,0); } - public TerminalNode THIS() { return getToken(Java8Parser.THIS, 0); } public List annotation() { return getRuleContexts(AnnotationContext.class); } @@ -5609,7 +5482,6 @@ public class Java8Parser extends Parser { return getRuleContext(AnnotationContext.class,i); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public ReceiverParameterContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -5675,7 +5547,6 @@ public class Java8Parser extends Parser { } public static class Throws_Context extends ParserRuleContext { - public TerminalNode THROWS() { return getToken(Java8Parser.THROWS, 0); } public ExceptionTypeListContext exceptionTypeList() { return getRuleContext(ExceptionTypeListContext.class,0); } @@ -5723,10 +5594,6 @@ public class Java8Parser extends Parser { public ExceptionTypeContext exceptionType(int i) { return getRuleContext(ExceptionTypeContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public ExceptionTypeListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -5838,7 +5705,6 @@ public class Java8Parser extends Parser { public BlockContext block() { return getRuleContext(BlockContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public MethodBodyContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -5929,7 +5795,6 @@ public class Java8Parser extends Parser { } public static class StaticInitializerContext extends ParserRuleContext { - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } public BlockContext block() { return getRuleContext(BlockContext.class,0); } @@ -6052,9 +5917,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode PUBLIC() { return getToken(Java8Parser.PUBLIC, 0); } - public TerminalNode PROTECTED() { return getToken(Java8Parser.PROTECTED, 0); } - public TerminalNode PRIVATE() { return getToken(Java8Parser.PRIVATE, 0); } public ConstructorModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -6123,8 +5985,6 @@ public class Java8Parser extends Parser { public SimpleTypeNameContext simpleTypeName() { return getRuleContext(SimpleTypeNameContext.class,0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public TypeParametersContext typeParameters() { return getRuleContext(TypeParametersContext.class,0); } @@ -6229,8 +6089,6 @@ public class Java8Parser extends Parser { } public static class ConstructorBodyContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public ExplicitConstructorInvocationContext explicitConstructorInvocation() { return getRuleContext(ExplicitConstructorInvocationContext.class,0); } @@ -6296,21 +6154,15 @@ public class Java8Parser extends Parser { } public static class ExplicitConstructorInvocationContext extends ParserRuleContext { - public TerminalNode THIS() { return getToken(Java8Parser.THIS, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); } public ArgumentListContext argumentList() { return getRuleContext(ArgumentListContext.class,0); } - public TerminalNode SUPER() { return getToken(Java8Parser.SUPER, 0); } public ExpressionNameContext expressionName() { return getRuleContext(ExpressionNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public PrimaryContext primary() { return getRuleContext(PrimaryContext.class,0); } @@ -6490,7 +6342,6 @@ public class Java8Parser extends Parser { } public static class EnumDeclarationContext extends ParserRuleContext { - public TerminalNode ENUM() { return getToken(Java8Parser.ENUM, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public EnumBodyContext enumBody() { return getRuleContext(EnumBodyContext.class,0); @@ -6569,12 +6420,9 @@ public class Java8Parser extends Parser { } public static class EnumBodyContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public EnumConstantListContext enumConstantList() { return getRuleContext(EnumConstantListContext.class,0); } - public TerminalNode COMMA() { return getToken(Java8Parser.COMMA, 0); } public EnumBodyDeclarationsContext enumBodyDeclarations() { return getRuleContext(EnumBodyDeclarationsContext.class,0); } @@ -6653,10 +6501,6 @@ public class Java8Parser extends Parser { public EnumConstantContext enumConstant(int i) { return getRuleContext(EnumConstantContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public EnumConstantListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -6683,7 +6527,7 @@ public class Java8Parser extends Parser { setState(1260); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,122,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -6719,8 +6563,6 @@ public class Java8Parser extends Parser { public EnumConstantModifierContext enumConstantModifier(int i) { return getRuleContext(EnumConstantModifierContext.class,i); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public ClassBodyContext classBody() { return getRuleContext(ClassBodyContext.class,0); } @@ -6849,7 +6691,6 @@ public class Java8Parser extends Parser { } public static class EnumBodyDeclarationsContext extends ParserRuleContext { - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public List classBodyDeclaration() { return getRuleContexts(ClassBodyDeclarationContext.class); } @@ -6962,7 +6803,6 @@ public class Java8Parser extends Parser { } public static class NormalInterfaceDeclarationContext extends ParserRuleContext { - public TerminalNode INTERFACE() { return getToken(Java8Parser.INTERFACE, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public InterfaceBodyContext interfaceBody() { return getRuleContext(InterfaceBodyContext.class,0); @@ -7057,12 +6897,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode PUBLIC() { return getToken(Java8Parser.PUBLIC, 0); } - public TerminalNode PROTECTED() { return getToken(Java8Parser.PROTECTED, 0); } - public TerminalNode PRIVATE() { return getToken(Java8Parser.PRIVATE, 0); } - public TerminalNode ABSTRACT() { return getToken(Java8Parser.ABSTRACT, 0); } - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } - public TerminalNode STRICTFP() { return getToken(Java8Parser.STRICTFP, 0); } public InterfaceModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -7149,7 +6983,6 @@ public class Java8Parser extends Parser { } public static class ExtendsInterfacesContext extends ParserRuleContext { - public TerminalNode EXTENDS() { return getToken(Java8Parser.EXTENDS, 0); } public InterfaceTypeListContext interfaceTypeList() { return getRuleContext(InterfaceTypeListContext.class,0); } @@ -7191,8 +7024,6 @@ public class Java8Parser extends Parser { } public static class InterfaceBodyContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public List interfaceMemberDeclaration() { return getRuleContexts(InterfaceMemberDeclarationContext.class); } @@ -7264,7 +7095,6 @@ public class Java8Parser extends Parser { public InterfaceDeclarationContext interfaceDeclaration() { return getRuleContext(InterfaceDeclarationContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public InterfaceMemberDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -7341,7 +7171,6 @@ public class Java8Parser extends Parser { public VariableDeclaratorListContext variableDeclaratorList() { return getRuleContext(VariableDeclaratorListContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public List constantModifier() { return getRuleContexts(ConstantModifierContext.class); } @@ -7406,9 +7235,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode PUBLIC() { return getToken(Java8Parser.PUBLIC, 0); } - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } - public TerminalNode FINAL() { return getToken(Java8Parser.FINAL, 0); } public ConstantModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -7542,11 +7368,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode PUBLIC() { return getToken(Java8Parser.PUBLIC, 0); } - public TerminalNode ABSTRACT() { return getToken(Java8Parser.ABSTRACT, 0); } - public TerminalNode DEFAULT() { return getToken(Java8Parser.DEFAULT, 0); } - public TerminalNode STATIC() { return getToken(Java8Parser.STATIC, 0); } - public TerminalNode STRICTFP() { return getToken(Java8Parser.STRICTFP, 0); } public InterfaceMethodModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -7626,8 +7447,6 @@ public class Java8Parser extends Parser { } public static class AnnotationTypeDeclarationContext extends ParserRuleContext { - public TerminalNode AT() { return getToken(Java8Parser.AT, 0); } - public TerminalNode INTERFACE() { return getToken(Java8Parser.INTERFACE, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public AnnotationTypeBodyContext annotationTypeBody() { return getRuleContext(AnnotationTypeBodyContext.class,0); @@ -7662,7 +7481,7 @@ public class Java8Parser extends Parser { setState(1373); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,139,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -7697,8 +7516,6 @@ public class Java8Parser extends Parser { } public static class AnnotationTypeBodyContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public List annotationTypeMemberDeclaration() { return getRuleContexts(AnnotationTypeMemberDeclarationContext.class); } @@ -7770,7 +7587,6 @@ public class Java8Parser extends Parser { public InterfaceDeclarationContext interfaceDeclaration() { return getRuleContext(InterfaceDeclarationContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public AnnotationTypeMemberDeclarationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -7845,9 +7661,6 @@ public class Java8Parser extends Parser { return getRuleContext(UnannTypeContext.class,0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public List annotationTypeElementModifier() { return getRuleContexts(AnnotationTypeElementModifierContext.class); } @@ -7942,8 +7755,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation() { return getRuleContext(AnnotationContext.class,0); } - public TerminalNode PUBLIC() { return getToken(Java8Parser.PUBLIC, 0); } - public TerminalNode ABSTRACT() { return getToken(Java8Parser.ABSTRACT, 0); } public AnnotationTypeElementModifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -8002,7 +7813,6 @@ public class Java8Parser extends Parser { } public static class DefaultValueContext extends ParserRuleContext { - public TerminalNode DEFAULT() { return getToken(Java8Parser.DEFAULT, 0); } public ElementValueContext elementValue() { return getRuleContext(ElementValueContext.class,0); } @@ -8109,12 +7919,9 @@ public class Java8Parser extends Parser { } public static class NormalAnnotationContext extends ParserRuleContext { - public TerminalNode AT() { return getToken(Java8Parser.AT, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public ElementValuePairListContext elementValuePairList() { return getRuleContext(ElementValuePairListContext.class,0); } @@ -8177,10 +7984,6 @@ public class Java8Parser extends Parser { public ElementValuePairContext elementValuePair(int i) { return getRuleContext(ElementValuePairContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public ElementValuePairListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -8235,7 +8038,6 @@ public class Java8Parser extends Parser { public static class ElementValuePairContext extends ParserRuleContext { public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode ASSIGN() { return getToken(Java8Parser.ASSIGN, 0); } public ElementValueContext elementValue() { return getRuleContext(ElementValueContext.class,0); } @@ -8344,12 +8146,9 @@ public class Java8Parser extends Parser { } public static class ElementValueArrayInitializerContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public ElementValueListContext elementValueList() { return getRuleContext(ElementValueListContext.class,0); } - public TerminalNode COMMA() { return getToken(Java8Parser.COMMA, 0); } public ElementValueArrayInitializerContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -8415,10 +8214,6 @@ public class Java8Parser extends Parser { public ElementValueContext elementValue(int i) { return getRuleContext(ElementValueContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public ElementValueListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -8445,7 +8240,7 @@ public class Java8Parser extends Parser { setState(1467); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,152,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -8474,7 +8269,6 @@ public class Java8Parser extends Parser { } public static class MarkerAnnotationContext extends ParserRuleContext { - public TerminalNode AT() { return getToken(Java8Parser.AT, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } @@ -8516,15 +8310,12 @@ public class Java8Parser extends Parser { } public static class SingleElementAnnotationContext extends ParserRuleContext { - public TerminalNode AT() { return getToken(Java8Parser.AT, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ElementValueContext elementValue() { return getRuleContext(ElementValueContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public SingleElementAnnotationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -8569,12 +8360,9 @@ public class Java8Parser extends Parser { } public static class ArrayInitializerContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public VariableInitializerListContext variableInitializerList() { return getRuleContext(VariableInitializerListContext.class,0); } - public TerminalNode COMMA() { return getToken(Java8Parser.COMMA, 0); } public ArrayInitializerContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -8640,10 +8428,6 @@ public class Java8Parser extends Parser { public VariableInitializerContext variableInitializer(int i) { return getRuleContext(VariableInitializerContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public VariableInitializerListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -8670,7 +8454,7 @@ public class Java8Parser extends Parser { setState(1493); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,155,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -8699,8 +8483,6 @@ public class Java8Parser extends Parser { } public static class BlockContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public BlockStatementsContext blockStatements() { return getRuleContext(BlockStatementsContext.class,0); } @@ -8878,7 +8660,6 @@ public class Java8Parser extends Parser { public LocalVariableDeclarationContext localVariableDeclaration() { return getRuleContext(LocalVariableDeclarationContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public LocalVariableDeclarationStatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -9403,7 +9184,6 @@ public class Java8Parser extends Parser { } public static class EmptyStatementContext extends ParserRuleContext { - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public EmptyStatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -9441,7 +9221,6 @@ public class Java8Parser extends Parser { public static class LabeledStatementContext extends ParserRuleContext { public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode COLON() { return getToken(Java8Parser.COLON, 0); } public StatementContext statement() { return getRuleContext(StatementContext.class,0); } @@ -9486,7 +9265,6 @@ public class Java8Parser extends Parser { public static class LabeledStatementNoShortIfContext extends ParserRuleContext { public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode COLON() { return getToken(Java8Parser.COLON, 0); } public StatementNoShortIfContext statementNoShortIf() { return getRuleContext(StatementNoShortIfContext.class,0); } @@ -9533,7 +9311,6 @@ public class Java8Parser extends Parser { public StatementExpressionContext statementExpression() { return getRuleContext(StatementExpressionContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public ExpressionStatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -9677,12 +9454,9 @@ public class Java8Parser extends Parser { } public static class IfThenStatementContext extends ParserRuleContext { - public TerminalNode IF() { return getToken(Java8Parser.IF, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public StatementContext statement() { return getRuleContext(StatementContext.class,0); } @@ -9730,16 +9504,12 @@ public class Java8Parser extends Parser { } public static class IfThenElseStatementContext extends ParserRuleContext { - public TerminalNode IF() { return getToken(Java8Parser.IF, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public StatementNoShortIfContext statementNoShortIf() { return getRuleContext(StatementNoShortIfContext.class,0); } - public TerminalNode ELSE() { return getToken(Java8Parser.ELSE, 0); } public StatementContext statement() { return getRuleContext(StatementContext.class,0); } @@ -9791,19 +9561,15 @@ public class Java8Parser extends Parser { } public static class IfThenElseStatementNoShortIfContext extends ParserRuleContext { - public TerminalNode IF() { return getToken(Java8Parser.IF, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public List statementNoShortIf() { return getRuleContexts(StatementNoShortIfContext.class); } public StatementNoShortIfContext statementNoShortIf(int i) { return getRuleContext(StatementNoShortIfContext.class,i); } - public TerminalNode ELSE() { return getToken(Java8Parser.ELSE, 0); } public IfThenElseStatementNoShortIfContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -9852,15 +9618,12 @@ public class Java8Parser extends Parser { } public static class AssertStatementContext extends ParserRuleContext { - public TerminalNode ASSERT() { return getToken(Java8Parser.ASSERT, 0); } public List expression() { return getRuleContexts(ExpressionContext.class); } public ExpressionContext expression(int i) { return getRuleContext(ExpressionContext.class,i); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } - public TerminalNode COLON() { return getToken(Java8Parser.COLON, 0); } public AssertStatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -9922,12 +9685,9 @@ public class Java8Parser extends Parser { } public static class SwitchStatementContext extends ParserRuleContext { - public TerminalNode SWITCH() { return getToken(Java8Parser.SWITCH, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public SwitchBlockContext switchBlock() { return getRuleContext(SwitchBlockContext.class,0); } @@ -9975,8 +9735,6 @@ public class Java8Parser extends Parser { } public static class SwitchBlockContext extends ParserRuleContext { - public TerminalNode LBRACE() { return getToken(Java8Parser.LBRACE, 0); } - public TerminalNode RBRACE() { return getToken(Java8Parser.RBRACE, 0); } public List switchBlockStatementGroup() { return getRuleContexts(SwitchBlockStatementGroupContext.class); } @@ -10016,7 +9774,7 @@ public class Java8Parser extends Parser { setState(1625); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,166,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -10160,15 +9918,12 @@ public class Java8Parser extends Parser { } public static class SwitchLabelContext extends ParserRuleContext { - public TerminalNode CASE() { return getToken(Java8Parser.CASE, 0); } public ConstantExpressionContext constantExpression() { return getRuleContext(ConstantExpressionContext.class,0); } - public TerminalNode COLON() { return getToken(Java8Parser.COLON, 0); } public EnumConstantNameContext enumConstantName() { return getRuleContext(EnumConstantNameContext.class,0); } - public TerminalNode DEFAULT() { return getToken(Java8Parser.DEFAULT, 0); } public SwitchLabelContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -10272,12 +10027,9 @@ public class Java8Parser extends Parser { } public static class WhileStatementContext extends ParserRuleContext { - public TerminalNode WHILE() { return getToken(Java8Parser.WHILE, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public StatementContext statement() { return getRuleContext(StatementContext.class,0); } @@ -10325,12 +10077,9 @@ public class Java8Parser extends Parser { } public static class WhileStatementNoShortIfContext extends ParserRuleContext { - public TerminalNode WHILE() { return getToken(Java8Parser.WHILE, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public StatementNoShortIfContext statementNoShortIf() { return getRuleContext(StatementNoShortIfContext.class,0); } @@ -10378,17 +10127,12 @@ public class Java8Parser extends Parser { } public static class DoStatementContext extends ParserRuleContext { - public TerminalNode DO() { return getToken(Java8Parser.DO, 0); } public StatementContext statement() { return getRuleContext(StatementContext.class,0); } - public TerminalNode WHILE() { return getToken(Java8Parser.WHILE, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public DoStatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -10547,13 +10291,6 @@ public class Java8Parser extends Parser { } public static class BasicForStatementContext extends ParserRuleContext { - public TerminalNode FOR() { return getToken(Java8Parser.FOR, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public List SEMI() { return getTokens(Java8Parser.SEMI); } - public TerminalNode SEMI(int i) { - return getToken(Java8Parser.SEMI, i); - } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public StatementContext statement() { return getRuleContext(StatementContext.class,0); } @@ -10643,13 +10380,6 @@ public class Java8Parser extends Parser { } public static class BasicForStatementNoShortIfContext extends ParserRuleContext { - public TerminalNode FOR() { return getToken(Java8Parser.FOR, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public List SEMI() { return getTokens(Java8Parser.SEMI); } - public TerminalNode SEMI(int i) { - return getToken(Java8Parser.SEMI, i); - } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public StatementNoShortIfContext statementNoShortIf() { return getRuleContext(StatementNoShortIfContext.class,0); } @@ -10839,10 +10569,6 @@ public class Java8Parser extends Parser { public StatementExpressionContext statementExpression(int i) { return getRuleContext(StatementExpressionContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public StatementExpressionListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -10896,19 +10622,15 @@ public class Java8Parser extends Parser { } public static class EnhancedForStatementContext extends ParserRuleContext { - public TerminalNode FOR() { return getToken(Java8Parser.FOR, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public UnannTypeContext unannType() { return getRuleContext(UnannTypeContext.class,0); } public VariableDeclaratorIdContext variableDeclaratorId() { return getRuleContext(VariableDeclaratorIdContext.class,0); } - public TerminalNode COLON() { return getToken(Java8Parser.COLON, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public StatementContext statement() { return getRuleContext(StatementContext.class,0); } @@ -10983,19 +10705,15 @@ public class Java8Parser extends Parser { } public static class EnhancedForStatementNoShortIfContext extends ParserRuleContext { - public TerminalNode FOR() { return getToken(Java8Parser.FOR, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public UnannTypeContext unannType() { return getRuleContext(UnannTypeContext.class,0); } public VariableDeclaratorIdContext variableDeclaratorId() { return getRuleContext(VariableDeclaratorIdContext.class,0); } - public TerminalNode COLON() { return getToken(Java8Parser.COLON, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public StatementNoShortIfContext statementNoShortIf() { return getRuleContext(StatementNoShortIfContext.class,0); } @@ -11070,8 +10788,6 @@ public class Java8Parser extends Parser { } public static class BreakStatementContext extends ParserRuleContext { - public TerminalNode BREAK() { return getToken(Java8Parser.BREAK, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public BreakStatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); @@ -11122,8 +10838,6 @@ public class Java8Parser extends Parser { } public static class ContinueStatementContext extends ParserRuleContext { - public TerminalNode CONTINUE() { return getToken(Java8Parser.CONTINUE, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public ContinueStatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); @@ -11174,8 +10888,6 @@ public class Java8Parser extends Parser { } public static class ReturnStatementContext extends ParserRuleContext { - public TerminalNode RETURN() { return getToken(Java8Parser.RETURN, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } @@ -11228,11 +10940,9 @@ public class Java8Parser extends Parser { } public static class ThrowStatementContext extends ParserRuleContext { - public TerminalNode THROW() { return getToken(Java8Parser.THROW, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public ThrowStatementContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -11273,12 +10983,9 @@ public class Java8Parser extends Parser { } public static class SynchronizedStatementContext extends ParserRuleContext { - public TerminalNode SYNCHRONIZED() { return getToken(Java8Parser.SYNCHRONIZED, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public BlockContext block() { return getRuleContext(BlockContext.class,0); } @@ -11326,7 +11033,6 @@ public class Java8Parser extends Parser { } public static class TryStatementContext extends ParserRuleContext { - public TerminalNode TRY() { return getToken(Java8Parser.TRY, 0); } public BlockContext block() { return getRuleContext(BlockContext.class,0); } @@ -11471,12 +11177,9 @@ public class Java8Parser extends Parser { } public static class CatchClauseContext extends ParserRuleContext { - public TerminalNode CATCH() { return getToken(Java8Parser.CATCH, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public CatchFormalParameterContext catchFormalParameter() { return getRuleContext(CatchFormalParameterContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public BlockContext block() { return getRuleContext(BlockContext.class,0); } @@ -11592,10 +11295,6 @@ public class Java8Parser extends Parser { public UnannClassTypeContext unannClassType() { return getRuleContext(UnannClassTypeContext.class,0); } - public List BITOR() { return getTokens(Java8Parser.BITOR); } - public TerminalNode BITOR(int i) { - return getToken(Java8Parser.BITOR, i); - } public List classType() { return getRuleContexts(ClassTypeContext.class); } @@ -11655,7 +11354,6 @@ public class Java8Parser extends Parser { } public static class Finally_Context extends ParserRuleContext { - public TerminalNode FINALLY() { return getToken(Java8Parser.FINALLY, 0); } public BlockContext block() { return getRuleContext(BlockContext.class,0); } @@ -11697,7 +11395,6 @@ public class Java8Parser extends Parser { } public static class TryWithResourcesStatementContext extends ParserRuleContext { - public TerminalNode TRY() { return getToken(Java8Parser.TRY, 0); } public ResourceSpecificationContext resourceSpecification() { return getRuleContext(ResourceSpecificationContext.class,0); } @@ -11771,12 +11468,9 @@ public class Java8Parser extends Parser { } public static class ResourceSpecificationContext extends ParserRuleContext { - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ResourceListContext resourceList() { return getRuleContext(ResourceListContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } - public TerminalNode SEMI() { return getToken(Java8Parser.SEMI, 0); } public ResourceSpecificationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -11834,10 +11528,6 @@ public class Java8Parser extends Parser { public ResourceContext resource(int i) { return getRuleContext(ResourceContext.class,i); } - public List SEMI() { return getTokens(Java8Parser.SEMI); } - public TerminalNode SEMI(int i) { - return getToken(Java8Parser.SEMI, i); - } public ResourceListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -11864,7 +11554,7 @@ public class Java8Parser extends Parser { setState(1860); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,193,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -11899,7 +11589,6 @@ public class Java8Parser extends Parser { public VariableDeclaratorIdContext variableDeclaratorId() { return getRuleContext(VariableDeclaratorIdContext.class,0); } - public TerminalNode ASSIGN() { return getToken(Java8Parser.ASSIGN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } @@ -12018,7 +11707,7 @@ public class Java8Parser extends Parser { setState(1881); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,196,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -12051,23 +11740,9 @@ public class Java8Parser extends Parser { public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } - public TerminalNode CLASS() { return getToken(Java8Parser.CLASS, 0); } - public List LBRACK() { return getTokens(Java8Parser.LBRACK); } - public TerminalNode LBRACK(int i) { - return getToken(Java8Parser.LBRACK, i); - } - public List RBRACK() { return getTokens(Java8Parser.RBRACK); } - public TerminalNode RBRACK(int i) { - return getToken(Java8Parser.RBRACK, i); - } - public TerminalNode VOID() { return getToken(Java8Parser.VOID, 0); } - public TerminalNode THIS() { return getToken(Java8Parser.THIS, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public ClassInstanceCreationExpressionContext classInstanceCreationExpression() { return getRuleContext(ClassInstanceCreationExpressionContext.class,0); } @@ -12268,23 +11943,9 @@ public class Java8Parser extends Parser { public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } - public TerminalNode CLASS() { return getToken(Java8Parser.CLASS, 0); } - public List LBRACK() { return getTokens(Java8Parser.LBRACK); } - public TerminalNode LBRACK(int i) { - return getToken(Java8Parser.LBRACK, i); - } - public List RBRACK() { return getTokens(Java8Parser.RBRACK); } - public TerminalNode RBRACK(int i) { - return getToken(Java8Parser.RBRACK, i); - } - public TerminalNode VOID() { return getToken(Java8Parser.VOID, 0); } - public TerminalNode THIS() { return getToken(Java8Parser.THIS, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public ClassInstanceCreationExpressionContext classInstanceCreationExpression() { return getRuleContext(ClassInstanceCreationExpressionContext.class,0); } @@ -12635,26 +12296,12 @@ public class Java8Parser extends Parser { public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } - public TerminalNode CLASS() { return getToken(Java8Parser.CLASS, 0); } - public List LBRACK() { return getTokens(Java8Parser.LBRACK); } - public TerminalNode LBRACK(int i) { - return getToken(Java8Parser.LBRACK, i); - } - public List RBRACK() { return getTokens(Java8Parser.RBRACK); } - public TerminalNode RBRACK(int i) { - return getToken(Java8Parser.RBRACK, i); - } public UnannPrimitiveTypeContext unannPrimitiveType() { return getRuleContext(UnannPrimitiveTypeContext.class,0); } - public TerminalNode VOID() { return getToken(Java8Parser.VOID, 0); } - public TerminalNode THIS() { return getToken(Java8Parser.THIS, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public ClassInstanceCreationExpression_lfno_primaryContext classInstanceCreationExpression_lfno_primary() { return getRuleContext(ClassInstanceCreationExpression_lfno_primaryContext.class,0); } @@ -12882,26 +12529,12 @@ public class Java8Parser extends Parser { public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } - public TerminalNode CLASS() { return getToken(Java8Parser.CLASS, 0); } - public List LBRACK() { return getTokens(Java8Parser.LBRACK); } - public TerminalNode LBRACK(int i) { - return getToken(Java8Parser.LBRACK, i); - } - public List RBRACK() { return getTokens(Java8Parser.RBRACK); } - public TerminalNode RBRACK(int i) { - return getToken(Java8Parser.RBRACK, i); - } public UnannPrimitiveTypeContext unannPrimitiveType() { return getRuleContext(UnannPrimitiveTypeContext.class,0); } - public TerminalNode VOID() { return getToken(Java8Parser.VOID, 0); } - public TerminalNode THIS() { return getToken(Java8Parser.THIS, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public ClassInstanceCreationExpression_lfno_primaryContext classInstanceCreationExpression_lfno_primary() { return getRuleContext(ClassInstanceCreationExpression_lfno_primaryContext.class,0); } @@ -13079,13 +12712,10 @@ public class Java8Parser extends Parser { } public static class ClassInstanceCreationExpressionContext extends ParserRuleContext { - public TerminalNode NEW() { return getToken(Java8Parser.NEW, 0); } public List Identifier() { return getTokens(Java8Parser.Identifier); } public TerminalNode Identifier(int i) { return getToken(Java8Parser.Identifier, i); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); } @@ -13095,10 +12725,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation(int i) { return getRuleContext(AnnotationContext.class,i); } - public List DOT() { return getTokens(Java8Parser.DOT); } - public TerminalNode DOT(int i) { - return getToken(Java8Parser.DOT, i); - } public TypeArgumentsOrDiamondContext typeArgumentsOrDiamond() { return getRuleContext(TypeArgumentsOrDiamondContext.class,0); } @@ -13389,11 +13015,7 @@ public class Java8Parser extends Parser { } public static class ClassInstanceCreationExpression_lf_primaryContext extends ParserRuleContext { - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } - public TerminalNode NEW() { return getToken(Java8Parser.NEW, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); } @@ -13511,13 +13133,10 @@ public class Java8Parser extends Parser { } public static class ClassInstanceCreationExpression_lfno_primaryContext extends ParserRuleContext { - public TerminalNode NEW() { return getToken(Java8Parser.NEW, 0); } public List Identifier() { return getTokens(Java8Parser.Identifier); } public TerminalNode Identifier(int i) { return getToken(Java8Parser.Identifier, i); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); } @@ -13527,10 +13146,6 @@ public class Java8Parser extends Parser { public AnnotationContext annotation(int i) { return getRuleContext(AnnotationContext.class,i); } - public List DOT() { return getTokens(Java8Parser.DOT); } - public TerminalNode DOT(int i) { - return getToken(Java8Parser.DOT, i); - } public TypeArgumentsOrDiamondContext typeArgumentsOrDiamond() { return getRuleContext(TypeArgumentsOrDiamondContext.class,0); } @@ -13752,8 +13367,6 @@ public class Java8Parser extends Parser { public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); } - public TerminalNode LT() { return getToken(Java8Parser.LT, 0); } - public TerminalNode GT() { return getToken(Java8Parser.GT, 0); } public TypeArgumentsOrDiamondContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -13808,12 +13421,7 @@ public class Java8Parser extends Parser { public PrimaryContext primary() { return getRuleContext(PrimaryContext.class,0); } - public List DOT() { return getTokens(Java8Parser.DOT); } - public TerminalNode DOT(int i) { - return getToken(Java8Parser.DOT, i); - } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode SUPER() { return getToken(Java8Parser.SUPER, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } @@ -13889,7 +13497,6 @@ public class Java8Parser extends Parser { } public static class FieldAccess_lf_primaryContext extends ParserRuleContext { - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public FieldAccess_lf_primaryContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); @@ -13929,11 +13536,6 @@ public class Java8Parser extends Parser { } public static class FieldAccess_lfno_primaryContext extends ParserRuleContext { - public TerminalNode SUPER() { return getToken(Java8Parser.SUPER, 0); } - public List DOT() { return getTokens(Java8Parser.DOT); } - public TerminalNode DOT(int i) { - return getToken(Java8Parser.DOT, i); - } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); @@ -14004,20 +13606,12 @@ public class Java8Parser extends Parser { public ExpressionNameContext expressionName() { return getRuleContext(ExpressionNameContext.class,0); } - public List LBRACK() { return getTokens(Java8Parser.LBRACK); } - public TerminalNode LBRACK(int i) { - return getToken(Java8Parser.LBRACK, i); - } public List expression() { return getRuleContexts(ExpressionContext.class); } public ExpressionContext expression(int i) { return getRuleContext(ExpressionContext.class,i); } - public List RBRACK() { return getTokens(Java8Parser.RBRACK); } - public TerminalNode RBRACK(int i) { - return getToken(Java8Parser.RBRACK, i); - } public PrimaryNoNewArray_lfno_arrayAccessContext primaryNoNewArray_lfno_arrayAccess() { return getRuleContext(PrimaryNoNewArray_lfno_arrayAccessContext.class,0); } @@ -14113,20 +13707,12 @@ public class Java8Parser extends Parser { public PrimaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primaryContext primaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primary() { return getRuleContext(PrimaryNoNewArray_lf_primary_lfno_arrayAccess_lf_primaryContext.class,0); } - public List LBRACK() { return getTokens(Java8Parser.LBRACK); } - public TerminalNode LBRACK(int i) { - return getToken(Java8Parser.LBRACK, i); - } public List expression() { return getRuleContexts(ExpressionContext.class); } public ExpressionContext expression(int i) { return getRuleContext(ExpressionContext.class,i); } - public List RBRACK() { return getTokens(Java8Parser.RBRACK); } - public TerminalNode RBRACK(int i) { - return getToken(Java8Parser.RBRACK, i); - } public List primaryNoNewArray_lf_primary_lf_arrayAccess_lf_primary() { return getRuleContexts(PrimaryNoNewArray_lf_primary_lf_arrayAccess_lf_primaryContext.class); } @@ -14167,7 +13753,7 @@ public class Java8Parser extends Parser { setState(2284); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,250,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -14203,20 +13789,12 @@ public class Java8Parser extends Parser { public ExpressionNameContext expressionName() { return getRuleContext(ExpressionNameContext.class,0); } - public List LBRACK() { return getTokens(Java8Parser.LBRACK); } - public TerminalNode LBRACK(int i) { - return getToken(Java8Parser.LBRACK, i); - } public List expression() { return getRuleContexts(ExpressionContext.class); } public ExpressionContext expression(int i) { return getRuleContext(ExpressionContext.class,i); } - public List RBRACK() { return getTokens(Java8Parser.RBRACK); } - public TerminalNode RBRACK(int i) { - return getToken(Java8Parser.RBRACK, i); - } public PrimaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primaryContext primaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primary() { return getRuleContext(PrimaryNoNewArray_lfno_primary_lfno_arrayAccess_lfno_primaryContext.class,0); } @@ -14278,7 +13856,7 @@ public class Java8Parser extends Parser { setState(2306); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,252,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -14314,18 +13892,12 @@ public class Java8Parser extends Parser { public MethodNameContext methodName() { return getRuleContext(MethodNameContext.class,0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public ArgumentListContext argumentList() { return getRuleContext(ArgumentListContext.class,0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public List DOT() { return getTokens(Java8Parser.DOT); } - public TerminalNode DOT(int i) { - return getToken(Java8Parser.DOT, i); - } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); @@ -14336,7 +13908,6 @@ public class Java8Parser extends Parser { public PrimaryContext primary() { return getRuleContext(PrimaryContext.class,0); } - public TerminalNode SUPER() { return getToken(Java8Parser.SUPER, 0); } public MethodInvocationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -14573,10 +14144,7 @@ public class Java8Parser extends Parser { } public static class MethodInvocation_lf_primaryContext extends ParserRuleContext { - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); } @@ -14649,18 +14217,12 @@ public class Java8Parser extends Parser { public MethodNameContext methodName() { return getRuleContext(MethodNameContext.class,0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public ArgumentListContext argumentList() { return getRuleContext(ArgumentListContext.class,0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public List DOT() { return getTokens(Java8Parser.DOT); } - public TerminalNode DOT(int i) { - return getToken(Java8Parser.DOT, i); - } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); @@ -14668,7 +14230,6 @@ public class Java8Parser extends Parser { public ExpressionNameContext expressionName() { return getRuleContext(ExpressionNameContext.class,0); } - public TerminalNode SUPER() { return getToken(Java8Parser.SUPER, 0); } public MethodInvocation_lfno_primaryContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -14876,10 +14437,6 @@ public class Java8Parser extends Parser { public ExpressionContext expression(int i) { return getRuleContext(ExpressionContext.class,i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public ArgumentListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -14936,7 +14493,6 @@ public class Java8Parser extends Parser { public ExpressionNameContext expressionName() { return getRuleContext(ExpressionNameContext.class,0); } - public TerminalNode COLONCOLON() { return getToken(Java8Parser.COLONCOLON, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); @@ -14947,15 +14503,12 @@ public class Java8Parser extends Parser { public PrimaryContext primary() { return getRuleContext(PrimaryContext.class,0); } - public TerminalNode SUPER() { return getToken(Java8Parser.SUPER, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public ClassTypeContext classType() { return getRuleContext(ClassTypeContext.class,0); } - public TerminalNode NEW() { return getToken(Java8Parser.NEW, 0); } public ArrayTypeContext arrayType() { return getRuleContext(ArrayTypeContext.class,0); } @@ -15136,7 +14689,6 @@ public class Java8Parser extends Parser { } public static class MethodReference_lf_primaryContext extends ParserRuleContext { - public TerminalNode COLONCOLON() { return getToken(Java8Parser.COLONCOLON, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); @@ -15193,7 +14745,6 @@ public class Java8Parser extends Parser { public ExpressionNameContext expressionName() { return getRuleContext(ExpressionNameContext.class,0); } - public TerminalNode COLONCOLON() { return getToken(Java8Parser.COLONCOLON, 0); } public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } public TypeArgumentsContext typeArguments() { return getRuleContext(TypeArgumentsContext.class,0); @@ -15201,15 +14752,12 @@ public class Java8Parser extends Parser { public ReferenceTypeContext referenceType() { return getRuleContext(ReferenceTypeContext.class,0); } - public TerminalNode SUPER() { return getToken(Java8Parser.SUPER, 0); } public TypeNameContext typeName() { return getRuleContext(TypeNameContext.class,0); } - public TerminalNode DOT() { return getToken(Java8Parser.DOT, 0); } public ClassTypeContext classType() { return getRuleContext(ClassTypeContext.class,0); } - public TerminalNode NEW() { return getToken(Java8Parser.NEW, 0); } public ArrayTypeContext arrayType() { return getRuleContext(ArrayTypeContext.class,0); } @@ -15369,7 +14917,6 @@ public class Java8Parser extends Parser { } public static class ArrayCreationExpressionContext extends ParserRuleContext { - public TerminalNode NEW() { return getToken(Java8Parser.NEW, 0); } public PrimitiveTypeContext primitiveType() { return getRuleContext(PrimitiveTypeContext.class,0); } @@ -15520,7 +15067,7 @@ public class Java8Parser extends Parser { setState(2581); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,295,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { { @@ -15547,11 +15094,9 @@ public class Java8Parser extends Parser { } public static class DimExprContext extends ParserRuleContext { - public TerminalNode LBRACK() { return getToken(Java8Parser.LBRACK, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode RBRACK() { return getToken(Java8Parser.RBRACK, 0); } public List annotation() { return getRuleContexts(AnnotationContext.class); } @@ -15710,7 +15255,6 @@ public class Java8Parser extends Parser { public LambdaParametersContext lambdaParameters() { return getRuleContext(LambdaParametersContext.class,0); } - public TerminalNode ARROW() { return getToken(Java8Parser.ARROW, 0); } public LambdaBodyContext lambdaBody() { return getRuleContext(LambdaBodyContext.class,0); } @@ -15755,8 +15299,6 @@ public class Java8Parser extends Parser { public static class LambdaParametersContext extends ParserRuleContext { public TerminalNode Identifier() { return getToken(Java8Parser.Identifier, 0); } - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public FormalParameterListContext formalParameterList() { return getRuleContext(FormalParameterListContext.class,0); } @@ -15828,10 +15370,6 @@ public class Java8Parser extends Parser { public TerminalNode Identifier(int i) { return getToken(Java8Parser.Identifier, i); } - public List COMMA() { return getTokens(Java8Parser.COMMA); } - public TerminalNode COMMA(int i) { - return getToken(Java8Parser.COMMA, i); - } public InferredFormalParameterListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16137,18 +15675,6 @@ public class Java8Parser extends Parser { } public static class AssignmentOperatorContext extends ParserRuleContext { - public TerminalNode ASSIGN() { return getToken(Java8Parser.ASSIGN, 0); } - public TerminalNode MUL_ASSIGN() { return getToken(Java8Parser.MUL_ASSIGN, 0); } - public TerminalNode DIV_ASSIGN() { return getToken(Java8Parser.DIV_ASSIGN, 0); } - public TerminalNode MOD_ASSIGN() { return getToken(Java8Parser.MOD_ASSIGN, 0); } - public TerminalNode ADD_ASSIGN() { return getToken(Java8Parser.ADD_ASSIGN, 0); } - public TerminalNode SUB_ASSIGN() { return getToken(Java8Parser.SUB_ASSIGN, 0); } - public TerminalNode LSHIFT_ASSIGN() { return getToken(Java8Parser.LSHIFT_ASSIGN, 0); } - public TerminalNode RSHIFT_ASSIGN() { return getToken(Java8Parser.RSHIFT_ASSIGN, 0); } - public TerminalNode URSHIFT_ASSIGN() { return getToken(Java8Parser.URSHIFT_ASSIGN, 0); } - public TerminalNode AND_ASSIGN() { return getToken(Java8Parser.AND_ASSIGN, 0); } - public TerminalNode XOR_ASSIGN() { return getToken(Java8Parser.XOR_ASSIGN, 0); } - public TerminalNode OR_ASSIGN() { return getToken(Java8Parser.OR_ASSIGN, 0); } public AssignmentOperatorContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16197,11 +15723,9 @@ public class Java8Parser extends Parser { public ConditionalOrExpressionContext conditionalOrExpression() { return getRuleContext(ConditionalOrExpressionContext.class,0); } - public TerminalNode QUESTION() { return getToken(Java8Parser.QUESTION, 0); } public ExpressionContext expression() { return getRuleContext(ExpressionContext.class,0); } - public TerminalNode COLON() { return getToken(Java8Parser.COLON, 0); } public ConditionalExpressionContext conditionalExpression() { return getRuleContext(ConditionalExpressionContext.class,0); } @@ -16268,7 +15792,6 @@ public class Java8Parser extends Parser { public ConditionalOrExpressionContext conditionalOrExpression() { return getRuleContext(ConditionalOrExpressionContext.class,0); } - public TerminalNode OR() { return getToken(Java8Parser.OR, 0); } public ConditionalOrExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16306,7 +15829,7 @@ public class Java8Parser extends Parser { setState(2656); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,305,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -16347,7 +15870,6 @@ public class Java8Parser extends Parser { public ConditionalAndExpressionContext conditionalAndExpression() { return getRuleContext(ConditionalAndExpressionContext.class,0); } - public TerminalNode AND() { return getToken(Java8Parser.AND, 0); } public ConditionalAndExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16385,7 +15907,7 @@ public class Java8Parser extends Parser { setState(2667); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,306,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -16426,7 +15948,6 @@ public class Java8Parser extends Parser { public InclusiveOrExpressionContext inclusiveOrExpression() { return getRuleContext(InclusiveOrExpressionContext.class,0); } - public TerminalNode BITOR() { return getToken(Java8Parser.BITOR, 0); } public InclusiveOrExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16464,7 +15985,7 @@ public class Java8Parser extends Parser { setState(2678); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,307,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -16505,7 +16026,6 @@ public class Java8Parser extends Parser { public ExclusiveOrExpressionContext exclusiveOrExpression() { return getRuleContext(ExclusiveOrExpressionContext.class,0); } - public TerminalNode CARET() { return getToken(Java8Parser.CARET, 0); } public ExclusiveOrExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16543,7 +16063,7 @@ public class Java8Parser extends Parser { setState(2689); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,308,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -16584,7 +16104,6 @@ public class Java8Parser extends Parser { public AndExpressionContext andExpression() { return getRuleContext(AndExpressionContext.class,0); } - public TerminalNode BITAND() { return getToken(Java8Parser.BITAND, 0); } public AndExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16622,7 +16141,7 @@ public class Java8Parser extends Parser { setState(2700); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,309,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -16663,8 +16182,6 @@ public class Java8Parser extends Parser { public EqualityExpressionContext equalityExpression() { return getRuleContext(EqualityExpressionContext.class,0); } - public TerminalNode EQUAL() { return getToken(Java8Parser.EQUAL, 0); } - public TerminalNode NOTEQUAL() { return getToken(Java8Parser.NOTEQUAL, 0); } public EqualityExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16702,7 +16219,7 @@ public class Java8Parser extends Parser { setState(2714); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,311,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -16761,11 +16278,6 @@ public class Java8Parser extends Parser { public RelationalExpressionContext relationalExpression() { return getRuleContext(RelationalExpressionContext.class,0); } - public TerminalNode LT() { return getToken(Java8Parser.LT, 0); } - public TerminalNode GT() { return getToken(Java8Parser.GT, 0); } - public TerminalNode LE() { return getToken(Java8Parser.LE, 0); } - public TerminalNode GE() { return getToken(Java8Parser.GE, 0); } - public TerminalNode INSTANCEOF() { return getToken(Java8Parser.INSTANCEOF, 0); } public ReferenceTypeContext referenceType() { return getRuleContext(ReferenceTypeContext.class,0); } @@ -16806,7 +16318,7 @@ public class Java8Parser extends Parser { setState(2737); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,313,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -16901,14 +16413,6 @@ public class Java8Parser extends Parser { public ShiftExpressionContext shiftExpression() { return getRuleContext(ShiftExpressionContext.class,0); } - public List LT() { return getTokens(Java8Parser.LT); } - public TerminalNode LT(int i) { - return getToken(Java8Parser.LT, i); - } - public List GT() { return getTokens(Java8Parser.GT); } - public TerminalNode GT(int i) { - return getToken(Java8Parser.GT, i); - } public ShiftExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -16946,7 +16450,7 @@ public class Java8Parser extends Parser { setState(2758); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,315,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -17025,8 +16529,6 @@ public class Java8Parser extends Parser { public AdditiveExpressionContext additiveExpression() { return getRuleContext(AdditiveExpressionContext.class,0); } - public TerminalNode ADD() { return getToken(Java8Parser.ADD, 0); } - public TerminalNode SUB() { return getToken(Java8Parser.SUB, 0); } public AdditiveExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -17064,7 +16566,7 @@ public class Java8Parser extends Parser { setState(2772); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,317,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -17123,9 +16625,6 @@ public class Java8Parser extends Parser { public MultiplicativeExpressionContext multiplicativeExpression() { return getRuleContext(MultiplicativeExpressionContext.class,0); } - public TerminalNode MUL() { return getToken(Java8Parser.MUL, 0); } - public TerminalNode DIV() { return getToken(Java8Parser.DIV, 0); } - public TerminalNode MOD() { return getToken(Java8Parser.MOD, 0); } public MultiplicativeExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -17163,7 +16662,7 @@ public class Java8Parser extends Parser { setState(2789); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,319,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { if ( _parseListeners!=null ) triggerExitRuleEvent(); _prevctx = _localctx; @@ -17234,11 +16733,9 @@ public class Java8Parser extends Parser { public PreDecrementExpressionContext preDecrementExpression() { return getRuleContext(PreDecrementExpressionContext.class,0); } - public TerminalNode ADD() { return getToken(Java8Parser.ADD, 0); } public UnaryExpressionContext unaryExpression() { return getRuleContext(UnaryExpressionContext.class,0); } - public TerminalNode SUB() { return getToken(Java8Parser.SUB, 0); } public UnaryExpressionNotPlusMinusContext unaryExpressionNotPlusMinus() { return getRuleContext(UnaryExpressionNotPlusMinusContext.class,0); } @@ -17340,7 +16837,6 @@ public class Java8Parser extends Parser { } public static class PreIncrementExpressionContext extends ParserRuleContext { - public TerminalNode INC() { return getToken(Java8Parser.INC, 0); } public UnaryExpressionContext unaryExpression() { return getRuleContext(UnaryExpressionContext.class,0); } @@ -17382,7 +16878,6 @@ public class Java8Parser extends Parser { } public static class PreDecrementExpressionContext extends ParserRuleContext { - public TerminalNode DEC() { return getToken(Java8Parser.DEC, 0); } public UnaryExpressionContext unaryExpression() { return getRuleContext(UnaryExpressionContext.class,0); } @@ -17427,11 +16922,9 @@ public class Java8Parser extends Parser { public PostfixExpressionContext postfixExpression() { return getRuleContext(PostfixExpressionContext.class,0); } - public TerminalNode TILDE() { return getToken(Java8Parser.TILDE, 0); } public UnaryExpressionContext unaryExpression() { return getRuleContext(UnaryExpressionContext.class,0); } - public TerminalNode BANG() { return getToken(Java8Parser.BANG, 0); } public CastExpressionContext castExpression() { return getRuleContext(CastExpressionContext.class,0); } @@ -17560,7 +17053,7 @@ public class Java8Parser extends Parser { setState(2823); _errHandler.sync(this); _alt = getInterpreter().adaptivePredict(_input,324,_ctx); - while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + while ( _alt!=2 && _alt!= ATN.INVALID_ALT_NUMBER ) { if ( _alt==1 ) { { setState(2821); @@ -17604,7 +17097,6 @@ public class Java8Parser extends Parser { public PostfixExpressionContext postfixExpression() { return getRuleContext(PostfixExpressionContext.class,0); } - public TerminalNode INC() { return getToken(Java8Parser.INC, 0); } public PostIncrementExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -17643,7 +17135,6 @@ public class Java8Parser extends Parser { } public static class PostIncrementExpression_lf_postfixExpressionContext extends ParserRuleContext { - public TerminalNode INC() { return getToken(Java8Parser.INC, 0); } public PostIncrementExpression_lf_postfixExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -17683,7 +17174,6 @@ public class Java8Parser extends Parser { public PostfixExpressionContext postfixExpression() { return getRuleContext(PostfixExpressionContext.class,0); } - public TerminalNode DEC() { return getToken(Java8Parser.DEC, 0); } public PostDecrementExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -17722,7 +17212,6 @@ public class Java8Parser extends Parser { } public static class PostDecrementExpression_lf_postfixExpressionContext extends ParserRuleContext { - public TerminalNode DEC() { return getToken(Java8Parser.DEC, 0); } public PostDecrementExpression_lf_postfixExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } @@ -17759,11 +17248,9 @@ public class Java8Parser extends Parser { } public static class CastExpressionContext extends ParserRuleContext { - public TerminalNode LPAREN() { return getToken(Java8Parser.LPAREN, 0); } public PrimitiveTypeContext primitiveType() { return getRuleContext(PrimitiveTypeContext.class,0); } - public TerminalNode RPAREN() { return getToken(Java8Parser.RPAREN, 0); } public UnaryExpressionContext unaryExpression() { return getRuleContext(UnaryExpressionContext.class,0); } diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/AbstractASTWalker.java b/src/main/java/de/dhbwstuttgart/syntaxtree/AbstractASTWalker.java index 6fd83f3b..0cbad897 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/AbstractASTWalker.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/AbstractASTWalker.java @@ -126,6 +126,7 @@ public abstract class AbstractASTWalker implements ASTVisitor{ public void visit(Assign assign) { assign.lefSide.accept(this); assign.rightSide.accept(this); + assign.rightSide.getType().accept((ASTVisitor) this); } @Override @@ -186,8 +187,10 @@ public abstract class AbstractASTWalker implements ASTVisitor{ public void visit(MethodCall methodCall) { methodCall.receiver.accept(this); methodCall.getArgumentList().accept(this); + methodCall.getArgumentList().getArguments().forEach(a -> a.getType().accept((ASTVisitor) this)); } + @Override public void visit(NewClass methodCall) { visit((MethodCall) methodCall); @@ -211,6 +214,7 @@ public abstract class AbstractASTWalker implements ASTVisitor{ @Override public void visit(Return aReturn) { aReturn.retexpr.accept(this); + aReturn.getType().accept((ASTVisitor) this); } @Override diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/Method.java b/src/main/java/de/dhbwstuttgart/syntaxtree/Method.java index 13e36b7b..9eda85e4 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/Method.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/Method.java @@ -31,8 +31,14 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope private ExceptionList exceptionlist; private GenericDeclarationList generics; private final RefTypeOrTPHOrWildcardOrGeneric returnType; - public final Boolean isInherited; - + public final Boolean isInherited; + + /* + * its Constraints + * eingefuegt PL 2021-02-15 + */ + public final ConstraintSet constraints = new ConstraintSet(); + public Method(int modifier, String name, RefTypeOrTPHOrWildcardOrGeneric returnType, ParameterList parameterList, Block block, GenericDeclarationList gtvDeclarations, Token offset) { super(offset); @@ -70,6 +76,10 @@ public class Method extends SyntaxTreeNode implements IItemWithOffset, TypeScope return this.returnType; } + public ConstraintSet getConstraints() { + return this.constraints; + } + @Override public void accept(ASTVisitor visitor) { visitor.visit(this); diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/SourceFile.java b/src/main/java/de/dhbwstuttgart/syntaxtree/SourceFile.java index 4a22147b..f9ec340b 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/SourceFile.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/SourceFile.java @@ -45,6 +45,12 @@ public class SourceFile extends SyntaxTreeNode{ public List getClasses() { return KlassenVektor; } + + public List getAllMethods() { + List ret = new ArrayList<>(); + getClasses().forEach(cl -> ret.addAll(cl.getMethods())); + return ret; + } @Override public void accept(ASTVisitor visitor) { diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/NameGenerator.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/NameGenerator.java index f20ea0cd..06414b98 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/NameGenerator.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/NameGenerator.java @@ -4,6 +4,16 @@ public class NameGenerator { private static String strNextName = "A"; + /** + * Setzt den zu Beginn der Typinferenz auf "A" zurueck. + * Dies ist bei JUnit-Test noetig + * TypePlaceholder.
Author: Martin Pluemicke + * @return void + */ + public static void reset() { + strNextName = "A"; + } + /** * Berechnet einen neuen, eindeutigen Namen f�r eine neue * TypePlaceholder.
Author: J�rg B�uerle diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java index b60270b3..468f9647 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/factory/UnifyTypeFactory.java @@ -18,6 +18,7 @@ import de.dhbwstuttgart.syntaxtree.type.WildcardType; import de.dhbwstuttgart.typeinference.constraints.Constraint; import de.dhbwstuttgart.typeinference.constraints.ConstraintSet; import de.dhbwstuttgart.typeinference.constraints.Pair; +import de.dhbwstuttgart.typeinference.result.PairNoResult; import de.dhbwstuttgart.typeinference.result.PairTPHEqualTPH; import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType; import de.dhbwstuttgart.typeinference.result.PairTPHsmallerTPH; @@ -208,6 +209,7 @@ public class UnifyTypeFactory { } public static ResultPair convert(UnifyPair mp, Map tphs) { + if (mp == null) { return null;} //kann bei basePairs passieren RefTypeOrTPHOrWildcardOrGeneric tl = UnifyTypeFactory.convert(mp.getLhsType(), tphs); RefTypeOrTPHOrWildcardOrGeneric tr = UnifyTypeFactory.convert(mp.getRhsType(), tphs); if(tl instanceof TypePlaceholder){ @@ -218,7 +220,7 @@ public class UnifyTypeFactory { //Einfach ignorieren TODO: Das hier muss ausgebessert werden: //return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, ASTFactory.createObjectType()); }else{ - return new PairTPHsmallerTPH((TypePlaceholder)tl, (TypePlaceholder)tr); + return new PairTPHsmallerTPH((TypePlaceholder)tl, (TypePlaceholder)tr, convert(mp.getBasePair(), tphs)); } }else if(tr instanceof RefType){ return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (RefType) tr); @@ -227,7 +229,7 @@ public class UnifyTypeFactory { }else if(tr instanceof GenericRefType){ return new PairTPHequalRefTypeOrWildcardType((TypePlaceholder)tl, (GenericRefType) tr); }else throw new NotImplementedException(); - }else throw new NotImplementedException(); + }else return new PairNoResult(tl, tr);//throw new NotImplementedException(); } public static RefTypeOrTPHOrWildcardOrGeneric convert(ReferenceType t, Map tphs) { @@ -258,6 +260,7 @@ public class UnifyTypeFactory { ret = TypePlaceholder.fresh(new NullToken()); tphs.put(t.getName(), ret); } + ret.setVariance(t.getVariance()); return ret; } diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java b/src/main/java/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java index 75267619..4ef09d86 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/statement/MethodCall.java @@ -24,13 +24,9 @@ public class MethodCall extends Statement public final ArgumentList arglist; - /* - * noetig fuer Bytecodegenerierung - */ public RefTypeOrTPHOrWildcardOrGeneric receiverType; public final ArrayList argTypes; - public MethodCall(RefTypeOrTPHOrWildcardOrGeneric retType, Receiver receiver, String methodName, ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType, ArrayList argTypes, Token offset){ super(retType,offset); @@ -40,6 +36,7 @@ public class MethodCall extends Statement this.receiverType = receiverType; this.argTypes = argTypes; } + @Override public void accept(StatementVisitor visitor) { diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/statement/Statement.java b/src/main/java/de/dhbwstuttgart/syntaxtree/statement/Statement.java index fc13cda1..aad50736 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/statement/Statement.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/statement/Statement.java @@ -6,11 +6,20 @@ import org.antlr.v4.runtime.Token; public abstract class Statement extends Expression { - + /* zeigt an, dass eine StatementExpression als Statement benutzt wird + */ + private boolean isStatement = false; public Statement(RefTypeOrTPHOrWildcardOrGeneric type, Token offset) { super(type, offset); } + public void setStatement() { + isStatement=true; + } + + public boolean getStatement() { + return isStatement; + } } \ No newline at end of file diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java b/src/main/java/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java index 5f282e46..663bc9dc 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/type/ExtendsWildcardType.java @@ -53,4 +53,10 @@ public class ExtendsWildcardType extends WildcardType{ public void accept(ResultSetVisitor visitor) { visitor.visit(this); } + + @Override + public boolean equals(Object o) { + // TODO Auto-generated method stub + return false; + } } diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java b/src/main/java/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java index a14813e7..4ca2ebd6 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/type/GenericRefType.java @@ -32,5 +32,11 @@ public class GenericRefType extends RefTypeOrTPHOrWildcardOrGeneric public void accept(ResultSetVisitor visitor) { visitor.visit(this); } + + @Override + public boolean equals(Object o) { + // TODO Auto-generated method stub + return false; + } } diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/type/RefType.java b/src/main/java/de/dhbwstuttgart/syntaxtree/type/RefType.java index 3e86275a..26f25fcf 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/type/RefType.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/type/RefType.java @@ -77,8 +77,8 @@ public class RefType extends RefTypeOrTPHOrWildcardOrGeneric if(obj instanceof RefType){ boolean ret = true; - if(!super.equals(obj)) - return false; + //if(!(super.equals(obj))) PL 2020-03-12 muss vll. einkommentiert werden + // return false; if(parameter==null || parameter.size()==0){ ret &= (((RefType)obj).getParaList()==null || ((RefType)obj).getParaList().size()==0); diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java b/src/main/java/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java index d20d451d..22c8ab4b 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/type/RefTypeOrTPHOrWildcardOrGeneric.java @@ -16,4 +16,7 @@ public abstract class RefTypeOrTPHOrWildcardOrGeneric extends SyntaxTreeNode{ public abstract A acceptTV(TypeVisitor visitor); public abstract void accept(ResultSetVisitor visitor); + @Override + public abstract boolean equals(Object o); + } diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java b/src/main/java/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java index 625fb01b..6a61b9cb 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/type/SuperWildcardType.java @@ -64,4 +64,10 @@ public class SuperWildcardType extends WildcardType{ public void accept(ResultSetVisitor visitor) { visitor.visit(this); } + + @Override + public boolean equals(Object o) { + // TODO Auto-generated method stub + return false; + } } diff --git a/src/main/java/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java b/src/main/java/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java index 66435b68..38932247 100644 --- a/src/main/java/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java +++ b/src/main/java/de/dhbwstuttgart/syntaxtree/type/TypePlaceholder.java @@ -20,10 +20,9 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric private final String name; /** - * wird bisher nicht genutzt - * setVariance muss ggf. auskommentiert werden. + * wird im Generate Generics Teil nach der Rueckumwandlung nach dem Unify genutzt */ - int variance = 0; + private int variance = 0; /** @@ -78,11 +77,9 @@ public class TypePlaceholder extends RefTypeOrTPHOrWildcardOrGeneric return name; } - /* wird bisher nicht genutzt public void setVariance(int variance) { this.variance= variance; } - */ public int getVariance() { return this.variance; diff --git a/src/main/java/de/dhbwstuttgart/typeinference/constraints/Constraint.java b/src/main/java/de/dhbwstuttgart/typeinference/constraints/Constraint.java index 8715fe55..6ebb9404 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/constraints/Constraint.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/constraints/Constraint.java @@ -9,6 +9,12 @@ import java.util.Set; public class Constraint extends HashSet { private static final long serialVersionUID = 1L; private Boolean isInherited = false;//wird nur für die Method-Constraints benoetigt + + /* es darf kein Constraint für den Return-Type erstellt werden, sonst gibt + * es Probleme beim Generated Generics + */ + public boolean isStatement = false; + private Constraint extendConstraint = null; public Constraint() { @@ -41,7 +47,7 @@ public class Constraint extends HashSet { } public String toString() { - return super.toString() + " isInherited = " + isInherited + return super.toString() + "\nisInherited = " + isInherited + "\nisStatement = " + isStatement //" + extendsContraint: " + (extendConstraint != null ? extendConstraint.toStringBase() : "null" ) + "\n" ; } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java b/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java index 31a466dd..1c7b7439 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/constraints/ConstraintSet.java @@ -23,9 +23,17 @@ public class ConstraintSet { oderConstraints.add(methodConstraints); } + public void addAllUndConstraint(Constraint allUndConstraints){ + undConstraints.addAll(allUndConstraints); + } + + public void addAllOderConstraint(List>> allOderConstraints){ + this.oderConstraints.addAll(allOderConstraints); + } + public void addAll(ConstraintSet constraints) { - this.undConstraints.addAll(constraints.undConstraints); - this.oderConstraints.addAll(constraints.oderConstraints); + this.addAllUndConstraint(constraints.undConstraints); + this.addAllOderConstraint(constraints.oderConstraints); } @Override diff --git a/src/main/java/de/dhbwstuttgart/typeinference/result/PairNoResult.java b/src/main/java/de/dhbwstuttgart/typeinference/result/PairNoResult.java new file mode 100644 index 00000000..63b3137c --- /dev/null +++ b/src/main/java/de/dhbwstuttgart/typeinference/result/PairNoResult.java @@ -0,0 +1,32 @@ +package de.dhbwstuttgart.typeinference.result; + +import de.dhbwstuttgart.exceptions.NotImplementedException; +import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric; +import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; + +/** + * enthaelt alle Paare, die in einem Ergebnis nicht vorkommen koennen + * sie sind noetig fuer origPairs in PairTPHsmallerTPH, da hier auch + * Paare vorkommen koennen die keine Result sind (z.B. bei FunN$$) + */ +public class PairNoResult extends ResultPair{ + //public final TypePlaceholder left; + //public final TypePlaceholder right; + + /* + * urspruengliches Paar aus diesem dieses Resultpair erzeugt wurde + * wichtig fuer generated Generics + */ + ResultPair origPair; + + public PairNoResult(RefTypeOrTPHOrWildcardOrGeneric left, RefTypeOrTPHOrWildcardOrGeneric right){ + super(left, right); + } + + /* noch nicht implementiert. */ + @Override + public void accept(ResultPairVisitor visitor) { + throw new NotImplementedException(); + //visitor.visit(this); + } +} diff --git a/src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java b/src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java index 8d586f4b..1df94e6b 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/result/PairTPHsmallerTPH.java @@ -9,6 +9,12 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; public class PairTPHsmallerTPH extends ResultPair{ public final TypePlaceholder left; public final TypePlaceholder right; + + /* + * urspruengliches Paar aus diesem dieses Resultpair erzeugt wurde + * wichtig fuer generated Generics + */ + ResultPair origPair; public PairTPHsmallerTPH(TypePlaceholder left, TypePlaceholder right){ super(left, right); @@ -16,6 +22,11 @@ public class PairTPHsmallerTPH extends ResultPair{ this.right = right; } + public PairTPHsmallerTPH(TypePlaceholder left, TypePlaceholder right, ResultPair origPair){ + this(left, right); + this.origPair = origPair; + } + @Override public void accept(ResultPairVisitor visitor) { visitor.visit(this); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java b/src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java index 18427731..e1372336 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/result/ResultPairVisitor.java @@ -4,4 +4,7 @@ public interface ResultPairVisitor { void visit(PairTPHsmallerTPH p); void visit(PairTPHequalRefTypeOrWildcardType p); void visit(PairTPHEqualTPH p); + + //bisher nicht umgesetzt + //void visit(PairNoResult p); } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java index c84fa143..685ac9f6 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPE.java @@ -32,8 +32,10 @@ public class TYPE { private ConstraintSet getConstraintsClass(ClassOrInterface cl, TypeInferenceInformation info) { ConstraintSet ret = new ConstraintSet(); + ConstraintSet methConstrains; for(Method m : cl.getMethods()){ - ret.addAll(getConstraintsMethod(m,info, cl)); + ret.addAll(methConstrains = getConstraintsMethod(m,info, cl)); + m.constraints.addAll(methConstrains); } for(Constructor m : cl.getConstructors()){ ret.addAll(getConstraintsConstructor(m,info, cl)); diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index c3c23079..2860e71b 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -11,6 +11,7 @@ import de.dhbwstuttgart.syntaxtree.factory.ASTFactory; import de.dhbwstuttgart.syntaxtree.factory.NameGenerator; import de.dhbwstuttgart.syntaxtree.statement.*; import de.dhbwstuttgart.syntaxtree.type.*; +import de.dhbwstuttgart.syntaxtree.type.Void; import de.dhbwstuttgart.typeinference.assumptions.FieldAssumption; import de.dhbwstuttgart.typeinference.assumptions.FunNClass; import de.dhbwstuttgart.typeinference.assumptions.MethodAssumption; @@ -180,6 +181,7 @@ public class TYPEStmt implements StatementVisitor{ ? new Pair(x.TA1, new ExtendsWildcardType(x.TA2, x.TA2.getOffset()), PairOperator.EQUALSDOT) : x) .collect(Collectors.toCollection(() -> new Constraint(oneMethodConstraint.isInherited()))); + extendsOneMethodConstraint.isStatement = oneMethodConstraint.isStatement; oneMethodConstraint.setExtendConstraint(extendsOneMethodConstraint); extendsOneMethodConstraint.setExtendConstraint(oneMethodConstraint); methodConstraints.add(extendsOneMethodConstraint); @@ -490,7 +492,7 @@ public class TYPEStmt implements StatementVisitor{ @Override public void visit(Return returnExpr) { returnExpr.retexpr.accept(this); - constraintsSet.addUndConstraint(new Pair(returnExpr.getType(),info.getCurrentTypeScope().getReturnType(), PairOperator.SMALLERDOT)); + constraintsSet.addUndConstraint(new Pair(returnExpr.getType(),info.getCurrentTypeScope().getReturnType(), PairOperator.EQUALSDOT)); } @Override @@ -587,12 +589,18 @@ public class TYPEStmt implements StatementVisitor{ */ RefTypeOrTPHOrWildcardOrGeneric retType = assumption.getReceiverType(resolver); - methodConstraint.add(forMethod.name.equals("apply") ? //PL 2019-11-29: Tenaerer Operator eingefügt, weil bei Lambda-Ausdrücken keine Suntype FunN$$ existiert - new Pair(forMethod.receiver.getType(), retType, PairOperator.EQUALSDOT) - : new Pair(forMethod.receiver.getType(), retType, PairOperator.SMALLERDOT)); - + methodConstraint.add(new Pair(forMethod.receiver.getType(), retType, + PairOperator.EQUALSDOT));//PL 2020-03-17 SMALLERDOT in EQUALSDOT umgewandelt, weil alle geerbten Methoden in den jeweilen Klassen enthalten sind. + + //Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ANFANG + //methodConstraint.add(new Pair(forMethod.receiverType, retType, + // PairOperator.EQUALSDOT)); + //Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE + + + methodConstraint.isStatement = forMethod.getStatement(); methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), - PairOperator.EQUALSDOT)); + PairOperator.EQUALSDOT)); methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver)); return methodConstraint; } diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java index 93f33d08..50ea9a2e 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java @@ -655,7 +655,6 @@ public class RuleSet implements IRuleSet{ else t1.getTypeParams().forEach(x -> occuringTypes.push(x)); } - Queue result1 = new LinkedList(pairs); ArrayList result = new ArrayList(); boolean applied = false; @@ -669,6 +668,7 @@ public class RuleSet implements IRuleSet{ && pair.getLhsType() instanceof PlaceholderType) lhsType = (PlaceholderType) pair.getLhsType(); rhsType = pair.getRhsType(); //PL eingefuegt 2017-09-29 statt !((rhsType = pair.getRhsType()) instanceof PlaceholderType) + if(lhsType != null //&& !((rhsType = pair.getRhsType()) instanceof PlaceholderType) //PL geloescht am 2017-09-29 Begründung: auch Typvariablen muessen ersetzt werden. && typeMap.get(lhsType) > 1 // The type occurs in more pairs in the set than just the recent pair. diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java index 798c6f05..317f3660 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify2Task.java @@ -34,7 +34,7 @@ public class TypeUnify2Task extends TypeUnifyTask { System.out.println("two"); } one = true; - Set> res = unify2(setToFlatten, eq, oderConstraintsField, fc, parallel, rekTiefeField, true); + Set> res = unify2(setToFlatten, eq, oderConstraintsField, fc, parallel, rekTiefeField); /*if (isUndefinedPairSetSet(res)) { return new HashSet<>(); } else diff --git a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java index 6de6b9de..5abacf70 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java @@ -110,6 +110,9 @@ public class TypeUnifyTask extends RecursiveTask>> { protected boolean parallel; + //Gives if unify is not called from checkA + private boolean finalresult = true; + int rekTiefeField; Integer nOfUnify = 0; @@ -257,7 +260,7 @@ public class TypeUnifyTask extends RecursiveTask>> { ArrayList>> remainingOderconstraints = oderConstraintsField.stream() .filter(x -> x.size()>1) .collect(Collectors.toCollection(ArrayList::new)); - Set> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField, true); + Set> res = unify(neweq, remainingOderconstraints, fc, parallel, rekTiefeField); noOfThread--; try { logFile.close(); @@ -299,7 +302,7 @@ public class TypeUnifyTask extends RecursiveTask>> { * @param fc The finite closure * @return The set of all principal type unifiers */ - protected Set> unify(final Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) { + protected Set> unify(final Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { //Set aas = eq.stream().filter(x -> x.getLhsType().getName().equals("AA") //&& x.getPairOp().equals(PairOperator.SMALLERDOT) // ).collect(Collectors.toCollection(HashSet::new)); //writeLog(nOfUnify.toString() + " AA: " + aas.toString()); @@ -308,9 +311,7 @@ public class TypeUnifyTask extends RecursiveTask>> { //} //.collect(Collectors.toCollection(HashSet::new))); - /* - * Step 1: Repeated application of reduce, adapt, erase, swap - */ + synchronized (usedTasks) { if (this.myIsCancelled()) { return new HashSet<>(); @@ -339,6 +340,29 @@ public class TypeUnifyTask extends RecursiveTask>> { return ret; } + /* + * Occurs-Check durchfuehren + */ + + Set ocurrPairs = eq.stream().filter(x -> { + UnifyType lhs, rhs; + return (lhs = x.getLhsType()) instanceof PlaceholderType + && !((rhs = x.getRhsType()) instanceof PlaceholderType) + && rhs.getTypeParams().occurs((PlaceholderType)lhs);}) + .map(x -> { x.setUndefinedPair(); return x;}) + .collect(Collectors.toCollection(HashSet::new)); + writeLog("ocurrPairs: " + ocurrPairs); + if (ocurrPairs.size() > 0) { + Set> ret = new HashSet<>(); + ret.add(ocurrPairs); + return ret; + } + + + + /* + * Step 1: Repeated application of reduce, adapt, erase, swap + */ Set eq0; Set eq0Prime; Optional> eqSubst = Optional.of(eq); @@ -457,12 +481,12 @@ public class TypeUnifyTask extends RecursiveTask>> { //Aufruf von computeCartesianRecursive ANFANG //writeLog("topLevelSets: " + topLevelSets.toString()); - return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe, finalresult); + return computeCartesianRecursive(new ArrayList<>(topLevelSets), eq, oderConstraintsOutput, fc, parallel, rekTiefe); } - Set> unify2(Set> setToFlatten, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) { + Set> unify2(Set> setToFlatten, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { //Aufruf von computeCartesianRecursive ENDE //keine Ahnung woher das kommt @@ -551,12 +575,12 @@ public class TypeUnifyTask extends RecursiveTask>> { } } else if(eqPrimePrime.isPresent()) { - Set> unifyres = unifyres1 = unify(eqPrimePrime.get(), newOderConstraints, fc, parallel, rekTiefe, finalresult); + Set> unifyres = unifyres1 = unify(eqPrimePrime.get(), newOderConstraints, fc, parallel, rekTiefe); eqPrimePrimeSet.addAll(unifyres); } else { - Set> unifyres = unifyres2 = unify(eqPrime, newOderConstraints, fc, parallel, rekTiefe, finalresult); + Set> unifyres = unifyres2 = unify(eqPrime, newOderConstraints, fc, parallel, rekTiefe); eqPrimePrimeSet.addAll(unifyres); @@ -587,22 +611,36 @@ public class TypeUnifyTask extends RecursiveTask>> { } - - Set> computeCartesianRecursive(Set> fstElems, ArrayList>> topLevelSets, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe, Boolean finalresult) { - //ArrayList>> remainingSets = new ArrayList<>(topLevelSets); + /** + * Computes the cartesian product of topLevelSets step by step. + * @param topLevelSets List of Sets of Sets, where a cartesian product have to be built + * Ex.: [{{a =. Integer}, {a = Object}}, {{a = Vector, b =. Integer}, {a = Vector, b =. Object}}] + * @param eq Original set of equations which should be unified + * @param oderConstraints Remaining or-constraints + * @param fc The finite closure + * @param parallel If the algorithm should be parallelized run + * @param rekTiefe Deep of recursive calls + * @return The set of all principal type unifiers + */ + Set> computeCartesianRecursive(ArrayList>> topLevelSets, Set eq, List>> oderConstraints, IFiniteClosure fc, boolean parallel, int rekTiefe) { - fstElems.addAll(topLevelSets.stream() + //oneElems: Alle 1-elementigen Mengen, die nur ein Paar + //a <. theta, theta <. a oder a =. theta enthalten + Set> oneElems = new HashSet<>(); + oneElems.addAll(topLevelSets.stream() .filter(x -> x.size()==1) .map(y -> y.stream().findFirst().get()) .collect(Collectors.toCollection(HashSet::new))); - ArrayList>> remainingSets = topLevelSets.stream() - .filter(x -> x.size()>1) - .collect(Collectors.toCollection(ArrayList::new)); - if (remainingSets.isEmpty()) {//Alle Elemente sind 1-elementig - Set> result = unify2(fstElems, eq, oderConstraints, fc, parallel, rekTiefe, finalresult); + + //optNextSet: Eine mehrelementige Menge, wenn vorhanden + Optional>> optNextSet = topLevelSets.stream().filter(x -> x.size()>1).findAny(); + + if (!optNextSet.isPresent()) {//Alle Elemente sind 1-elementig + Set> result = unify2(oneElems, eq, oderConstraints, fc, parallel, rekTiefe); return result; } - Set> nextSet = remainingSets.remove(0); + + Set> nextSet = optNextSet.get(); //writeLog("nextSet: " + nextSet.toString()); List> nextSetasList =new ArrayList<>(nextSet); /* @@ -617,6 +655,12 @@ public class TypeUnifyTask extends RecursiveTask>> { Set> result = new HashSet<>(); int variance = 0; + /* Varianzbestimmung Anfang + * Oderconstraint, wenn entweder kein Basepair oder unterschiedliche Basepairs => oderConstraint = true; + * Varianz = 1 => Argumentvariable + * Varianz = -1 => Rückgabevariable + * Varianz = 0 => unklar + * Varianz = 2 => Operatoren oderConstraints */ ArrayList zeroNextElem = new ArrayList<>(nextSetasList.get(0)); UnifyPair fstBasePair = zeroNextElem.remove(0).getBasePair(); Boolean oderConstraint = false; @@ -639,16 +683,15 @@ public class TypeUnifyTask extends RecursiveTask>> { } } else { - //variance = 2; oderConstraint = true; } } else { - //variance = 2; oderConstraint = true; } - if (oderConstraint) {//Varianz-Bestimmung Oder-Constraints + //Varianz-Bestimmung Oder-Constraints + if (oderConstraint) { if (printtag) System.out.println("nextSetasList " + nextSetasList); Optional optVariance = nextSetasList.iterator() @@ -661,23 +704,22 @@ public class TypeUnifyTask extends RecursiveTask>> { ((PlaceholderType)x.getGroundBasePair().getLhsType()).getVariance()) .findAny(); //Fuer Operatorenaufrufe wird variance auf 2 gesetzt. - //da kein Receiver existiert also keon x.getGroundBasePair().getLhsType() instanceof PlaceholderType - //Es werden alle Elemente des Kartesischen Produkts abgearbeitet + //da kein Receiver existiert also kein x.getGroundBasePair().getLhsType() instanceof PlaceholderType + //Bei Varianz = 2 werden alle Elemente des Kartesischen Produkts abgearbeitet variance = optVariance.isPresent() ? optVariance.get() : 2; } + /* Varianzbestimmung Ende */ - if (!nextSetasList.iterator().hasNext()) - System.out.print(""); - if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1) - System.out.print(""); //writeLog("nextSetasList: " + nextSetasList.toString()); Set nextSetElem = nextSetasList.get(0); //writeLog("BasePair1: " + nextSetElem + " " + nextSetElem.iterator().next().getBasePair()); - /* sameEqSet-Bestimmung: Wenn a = ty \in nextSet dann enthaelt sameEqSet alle Paare a < ty1 oder ty2 < a aus fstElems */ + /* sameEqSet-Bestimmung: Wenn a = ty \in nextSet dann enthaelt sameEqSet + * alle Paare a < ty1 oder ty2 < a aus oneElems */ Set sameEqSet = new HashSet<>(); + + //optOrigPair enthaelt ggf. das Paar a = ty \in nextSet Optional optOrigPair = null; - //if (variance != 2) { if (!oderConstraint) { optOrigPair = nextSetElem.stream().filter(x -> ( //x.getBasePair() != null && ist gegeben wenn variance != 2 @@ -701,7 +743,7 @@ public class TypeUnifyTask extends RecursiveTask>> { tyVar = origPair.getRhsType(); } UnifyType tyVarEF = tyVar; - sameEqSet = fstElems.stream().map(xx -> xx.iterator().next()) + sameEqSet = oneElems.stream().map(xx -> xx.iterator().next()) .filter(x -> (((x.getLhsType().equals(tyVarEF) && !(x.getRhsType() instanceof PlaceholderType)) || (x.getRhsType().equals(tyVarEF) && !(x.getLhsType() instanceof PlaceholderType))))) .collect(Collectors.toCollection(HashSet::new)); @@ -710,14 +752,21 @@ public class TypeUnifyTask extends RecursiveTask>> { /* sameEqSet-Bestimmung Ende */ Set a = null; - while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) { + while (nextSetasList.size() > 0) { Set a_last = a; - //Liste der Faelle für die parallele Verarbeitung + /* Liste der Faelle für die parallele Verarbeitung + * Enthaelt Elemente, die nicht in Relation zu aktuellem Fall in der + * Variablen a stehen. Diese muesse auf alle Faelle bearbeitet werden, + * Deshalb wird ihre Berechnung parallel angestossen. + */ List> nextSetasListRest = new ArrayList<>(); - //Liste der Faelle, bei dem Receiver jeweils "? extends" enthaelt bzw. nicht enthaelt - //In der Regel ein Element + /* Liste der Faelle, bei dem Receiver jeweils "? extends" enthaelt bzw. nicht enthaelt + * In der Regel ist dies genau ein Element + * Dieses Element wird später aus nextSetasList geloescht, wenn das jeweils andere Element zum Erfolg + * gefuehrt hat. + */ List> nextSetasListOderConstraints = new ArrayList<>(); writeLog("nextSet: " + nextSet.toString()); @@ -740,6 +789,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } //Alle maximale Elemente in nextSetasListRest bestimmen + //nur für diese wird parallele Berechnung angestossen. nextSetasListRest = oup.maxElements(nextSetasListRest); } else if (variance == -1) { @@ -760,10 +810,13 @@ public class TypeUnifyTask extends RecursiveTask>> { } } //Alle minimalen Elemente in nextSetasListRest bestimmen + //nur für diese wird parallele Berechnung angestossen. nextSetasListRest = oup.minElements(nextSetasListRest); } else if (variance == 2) { a = nextSetasList.remove(0); + + //Fuer alle Elemente wird parallele Berechnung angestossen. nextSetasListRest = new ArrayList<>(nextSetasList); } else if (variance == 0) { @@ -789,54 +842,32 @@ public class TypeUnifyTask extends RecursiveTask>> { } } } - //writeLog("nextSet: " + nextSetasList.toString()+ "\n"); - //nextSetasList.remove(a); - //PL 2018-03-01 - //TODO: 1. Maximum und Minimum unterscheiden - //TODO: 2. compare noch für alle Elmemente die nicht X =. ty sind erweitern - //for(Set a : newSet) { i++; - Set> elems = new HashSet>(fstElems); + Set> elems = new HashSet>(oneElems); writeLog("a1: " + rekTiefe + " "+ "variance: "+ variance + " " + a.toString()+ "\n"); - //elems.add(a); PL 2019-01-20 Muss weg, weil das in jeweiligen Thread erfolgen muss. Fuer den sequentiellen Fall - //im else-Zweig - //if (remainingSets.isEmpty()) {//muss immer gegeben sein, weil nur 1 Element der topLevelSets mehr als ein Elemet enthaelt - //writeLog("Vor unify2 Aufruf: " + elems.toString()); + + //Ergebnisvariable für den aktuelle Thread Set> res = new HashSet<>(); + + //Menge der Ergebnisse der geforkten Threads Set>> add_res = new HashSet<>(); + + Set> aParDef = new HashSet<>(); - /* PL 2019-03-11 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */ - if (!oderConstraint && !sameEqSet.isEmpty()) { - Optional optAPair = a.stream().filter(x -> ( - //x.getBasePair() != null && ist gegeben wenn variance != 2 - //x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT) && - (x.getPairOp().equals(PairOperator.EQUALSDOT) - /* - (x.getBasePair().getLhsType() instanceof PlaceholderType - && x.getLhsType().equals(x.getBasePair().getLhsType())) - || (x.getBasePair().getRhsType() instanceof PlaceholderType - && x.getLhsType().equals(x.getBasePair().getRhsType()) - */ - ))).filter(x -> //Sicherstellen, dass bei a = ty a auch wirklich die gesuchte Typvariable ist - x.getLhsType().equals(x.getBasePair().getLhsType()) || - x.getLhsType().equals(x.getBasePair().getRhsType()) - ).findFirst(); - - if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a - UnifyPair aPair = optAPair.get(); - //writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair()); - writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet); - if (!checkA(aPair, sameEqSet, elems, result)) { - a = null; - noShortendElements++; - continue; - } - } + /* Wenn bei (a \in theta) \in a zu Widerspruch in oneElems wird + * a verworfen und zu nächstem Element von nextSetasList gegangen + */ + if (!oderConstraint && !sameEqSet.isEmpty() && !checkNoContradiction(a, sameEqSet, result)) { + a = null; + noShortendElements++; + continue; } - /* PL 2019-03-11 Ende eingefuegt Vergleich mit anderen Paaren ggf. loeschen */ + /* Wenn parallel gearbeitet wird, wird je nach Varianz ein neuer Thread + * gestartet, der parallel weiterarbeitet. + */ if(parallel && (variance == 1) && noOfThread <= MaxNoOfThreads) { Set forks = new HashSet<>(); Set newEqOrig = new HashSet<>(eq); @@ -865,35 +896,14 @@ public class TypeUnifyTask extends RecursiveTask>> { writeLog("1 RM" + nSaL.toString()); } - /* PL 2019-03-13 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */ - if (!oderConstraint) {//weiss nicht ob das wirklich stimmt - Optional optAPair = nSaL.stream().filter(x -> ( - //x.getBasePair() != null && ist gegeben wenn variance != 2 - //x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT) && - (x.getPairOp().equals(PairOperator.EQUALSDOT) - /* - (x.getBasePair().getLhsType() instanceof PlaceholderType - && x.getLhsType().equals(x.getBasePair().getLhsType())) - || (x.getBasePair().getRhsType() instanceof PlaceholderType - && x.getLhsType().equals(x.getBasePair().getRhsType()) - */ - ))).filter(x -> //Sicherstellen, dass bei a = ty a auch wirklich die gesuchte Typvariable ist - x.getLhsType().equals(x.getBasePair().getLhsType()) || - x.getLhsType().equals(x.getBasePair().getRhsType()) - ).findFirst(); - - if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a - UnifyPair aPair = optAPair.get(); - //writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair()); - writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet); - if (!sameEqSet.isEmpty() && !checkA(aPair, sameEqSet, elems, result)) { - nSaL = null; - noShortendElements++; - continue; - } + if (!oderConstraint) { + //ueberpruefung ob zu a =. ty \in nSaL in sameEqSet ein Widerspruch besteht + if (!sameEqSet.isEmpty() && !checkNoContradiction(nSaL, sameEqSet, result)) { + nSaL = null; + noShortendElements++; + continue; } } - /* PL 2019-03-13 Ende eingefuegt Vergleich mit anderen Paaren ggf. loeschen */ else { nextSetasListOderConstraints.add(((Constraint)nSaL).getExtendConstraint()); } @@ -985,35 +995,14 @@ public class TypeUnifyTask extends RecursiveTask>> { writeLog("-1 RM" + nSaL.toString()); } - if (!oderConstraint) {//weiss nicht ob das wirklich stimmt - /* PL 2019-03-13 Anfang eingefuegt Vergleich mit anderen Paaren ggf. loeschen */ - Optional optAPair = nSaL.stream().filter(x -> ( - //x.getBasePair() != null && ist gegeben wenn variance != 2 - //x.getBasePair().getPairOp().equals(PairOperator.SMALLERDOT) && - (x.getPairOp().equals(PairOperator.EQUALSDOT) - /* - (x.getBasePair().getLhsType() instanceof PlaceholderType - && x.getLhsType().equals(x.getBasePair().getLhsType())) - || (x.getBasePair().getRhsType() instanceof PlaceholderType - && x.getLhsType().equals(x.getBasePair().getRhsType()) - */ - ))).filter(x -> //Sicherstellen, dass bei a = ty a auch wirklich die gesuchte Typvariable ist - x.getLhsType().equals(x.getBasePair().getLhsType()) || - x.getLhsType().equals(x.getBasePair().getRhsType()) - ).findFirst(); - - if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a - UnifyPair aPair = optAPair.get(); - //writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair()); - writeLog("variance: " + new Integer(variance).toString() + "sameEqSet:" + sameEqSet); - if (!sameEqSet.isEmpty() && !checkA(aPair, sameEqSet, elems, result)) { - nSaL = null; - noShortendElements++; - continue; - } + if (!oderConstraint) { + //ueberpruefung ob zu a =. ty \in nSaL in sameEqSet ein Widerspruch besteht + if (!sameEqSet.isEmpty() && !checkNoContradiction(nSaL, sameEqSet, result)) { + nSaL = null; + noShortendElements++; + continue; } } - /* PL 2019-03-13 Ende eingefuegt Vergleich mit anderen Paaren ggf. loeschen */ else { nextSetasListOderConstraints.add(((Constraint)nSaL).getExtendConstraint()); } @@ -1156,11 +1145,12 @@ public class TypeUnifyTask extends RecursiveTask>> { }; } //noOfThread++; - } else { - //parallel = false; //Wenn MaxNoOfThreads erreicht ist, sequentiell weiterarbeiten + } else {//parallel = false oder MaxNoOfThreads ist erreicht, sequentiell weiterarbeiten elems.add(a); //PL 2019-01-16 muss das wirklich hin steht schon in Zeile 859 ja braucht man siehe Zeile 859 - res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe, finalresult); + res = unify2(elems, eq, oderConstraints, fc, parallel, rekTiefe); }}} + + //Ab hier alle parallele Berechnungen wieder zusammengeführt. if (!isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result)) { //wenn korrektes Ergebnis gefunden alle Fehlerfaelle loeschen result = res; @@ -1247,7 +1237,7 @@ public class TypeUnifyTask extends RecursiveTask>> { } else { //alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden - writeLog("RES Fst: reuslt: " + result.toString() + " res: " + res.toString()); + writeLog("RES Fst: result: " + result.toString() + " res: " + res.toString()); result.addAll(res); } } @@ -1259,10 +1249,6 @@ public class TypeUnifyTask extends RecursiveTask>> { //} } - //} - //else {//duerfte gar nicht mehr vorkommen PL 2018-04-03 - //result.addAll(computeCartesianRecursive(elems, remainingSets, eq, fc, parallel)); - //} if (parallel) { for (Set> par_res : add_res) { if (!isUndefinedPairSetSet(par_res) && isUndefinedPairSetSet(result)) { @@ -1499,7 +1485,29 @@ public class TypeUnifyTask extends RecursiveTask>> { return result; } - protected Boolean checkA (UnifyPair aPair, Set sameEqSet, Set> elems, Set> result) { + /** + * checks if there is for (a = ty) \in a in sameEqSet a constradiction + * @param a Set of actual element of constraints with a =. ty \in a + * @param sameEqSet Set of constraints where a <. ty' and ty' <. a + * @param result set of results which contains correct solution s and the + * the error constraints. Error constraints are added + * @result contradiction of (a = ty) in sameEqSet + */ + protected Boolean checkNoContradiction(Set a, Set sameEqSet, Set> result) { + + //optAPair enthaelt ggf. das Paar a = ty' \in a + //unterscheidet sich von optOrigPair, da dort a = ty + Optional optAPair = + a.stream().filter(x -> (x.getPairOp().equals(PairOperator.EQUALSDOT))) + .filter(x -> //Sicherstellen, dass bei a = ty a auch wirklich die gesuchte Typvariable ist + x.getLhsType().equals(x.getBasePair().getLhsType()) || + x.getLhsType().equals(x.getBasePair().getRhsType())) + .findFirst(); + + if (optAPair.isPresent()) {//basepair ist entweder a <. Ty oder ty <. a + UnifyPair aPair = optAPair.get(); + //writeLog("optOrigPair: " + optOrigPair + " " + "aPair: " + aPair+ " " + "aPair.basePair(): " + aPair.getBasePair()); + writeLog("checkA: " + aPair + "sameEqSet: " + sameEqSet); for (UnifyPair sameEq : sameEqSet) { if (sameEq.getLhsType() instanceof PlaceholderType) { @@ -1509,12 +1517,14 @@ public class TypeUnifyTask extends RecursiveTask>> { unitedSubst.addAll(sameEq.getAllSubstitutions()); unitedSubst.addAll(sameEq.getAllBases()); localEq.add(new UnifyPair(aPair.getRhsType(), sameEq.getRhsType(), sameEq.getPairOp(), unitedSubst, null)); - Set> localRes = unify(localEq, new ArrayList<>(), fc, false, 0, false); + finalresult = false; + Set> localRes = unify(localEq, new ArrayList<>(), fc, false, 0); + finalresult = true; if (isUndefinedPairSetSet(localRes)) { if (result.isEmpty() || isUndefinedPairSetSet(result)) { result.addAll(localRes); } - //writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet); + writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet); return false; } } @@ -1525,20 +1535,25 @@ public class TypeUnifyTask extends RecursiveTask>> { unitedSubst.addAll(sameEq.getAllSubstitutions()); unitedSubst.addAll(sameEq.getAllBases()); localEq.add(new UnifyPair(sameEq.getLhsType(), aPair.getRhsType(), sameEq.getPairOp(), unitedSubst, null)); - Set> localRes = unify(localEq, new ArrayList<>(), fc, false, 0, false); + finalresult = false; + Set> localRes = unify(localEq, new ArrayList<>(), fc, false, 0); + finalresult = true; if (isUndefinedPairSetSet(localRes)) { if (result.isEmpty() || isUndefinedPairSetSet(result)) { result.addAll(localRes); } - //writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet); + writeLog("FALSE: " + aPair + "sameEqSet: " + sameEqSet); return false; } } } - //writeLog("TRUE: " + aPair + "sameEqSet: " + sameEqSet); + writeLog("TRUE: " + aPair + "sameEqSet: " + sameEqSet); + return true; + } return true; } + protected boolean couldBecorrect(Set, UnifyPair>> reducedUndefResSubstGroundedBasePair, Set nextElem) { return reducedUndefResSubstGroundedBasePair.stream() .map(pair -> { @@ -2505,7 +2520,7 @@ public class TypeUnifyTask extends RecursiveTask>> { void writeLog(String str) { synchronized ( this ) { - if (log) { + if (log && finalresult) { try { logFile.write("Thread no.:" + thNo + "\n"); logFile.write("noOfThread:" + noOfThread + "\n"); diff --git a/src/main/java/de/dhbwstuttgart/unify2/model/Result.java b/src/main/java/de/dhbwstuttgart/unify2/model/Result.java new file mode 100644 index 00000000..9bae2867 --- /dev/null +++ b/src/main/java/de/dhbwstuttgart/unify2/model/Result.java @@ -0,0 +1,17 @@ +package de.dhbwstuttgart.unify2.model; + +public class Result { + private final A v; + + private Result(A a, UnifyError e){ + this.v = a; + } + + public static Result of(A a){ + return new Result(a, null); + } + + public static Result error(UnifyError error){ + return new Result(null, error); + } +} diff --git a/src/main/java/de/dhbwstuttgart/unify2/model/UnifyError.java b/src/main/java/de/dhbwstuttgart/unify2/model/UnifyError.java new file mode 100644 index 00000000..cecafd2e --- /dev/null +++ b/src/main/java/de/dhbwstuttgart/unify2/model/UnifyError.java @@ -0,0 +1,5 @@ +package de.dhbwstuttgart.unify2.model; + +public class UnifyError { + +} diff --git a/src/test/java/AllgemeinTest.java b/src/test/java/AllgemeinTest.java index c937035e..50a67b38 100644 --- a/src/test/java/AllgemeinTest.java +++ b/src/test/java/AllgemeinTest.java @@ -40,7 +40,8 @@ public class AllgemeinTest { //String className = "FCTest3"; //String className = "Var"; //String className = "Put"; - String className = "Twice"; + //String className = "Twice"; + String className = "TestSubTypless"; //PL 2019-10-24: genutzt fuer unterschiedliche Tests path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/" + className + ".jav"; //path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav"; diff --git a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java index 1f5f00c3..53122862 100644 --- a/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java +++ b/src/test/java/insertGenerics/FamilyOfGeneratedGenericsTest.java @@ -1,3 +1,4 @@ +/* package insertGenerics; import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; @@ -12,11 +13,13 @@ import java.util.List; public class FamilyOfGeneratedGenericsTest extends TestCase { public void testIdentityMethod(){ - /* + */ +/* Example method: A id(B i) return i; gives constraint: B <. A and A <. Object, which are method constraints - */ + *//* + List inputConstraints = new ArrayList<>(); inputConstraints.add(new TPHConstraint("B", "A", TPHConstraint.Relation.EXTENDS)); @@ -29,10 +32,20 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); assertTrue(classConstraints.isEmpty()); + */ +/* + MethodConstraints should be the same as the input constraint + *//* + +// List methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, new ArrayList(), tphPositions); +// assertTrue(methodConstraints.size() == 2); +// assertTrue(methodConstraints.get(0).getLeft().equals("B")); +// assertTrue(methodConstraints.get(0).getRight().equals("A")); } public void testClassField(){ - /* + */ +/* class Example{ A f; B fReturn(){ @@ -40,7 +53,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } } gives constraint: A <. B and B <. Object which are class constraints - */ + *//* + List inputConstraints = new ArrayList<>(); inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS)); @@ -51,18 +65,22 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { PairTphMethod posOfB = new PairTphMethod<>(PositionFinder.Position.METHOD, "fReturn"); tphPositions.put("B", posOfB); - /* + */ +/* ClassConstraints should not be the same as the input constraint - */ + *//* + List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); System.out.println(classConstraints); assertTrue(classConstraints.size() == 2); //assertTrue(classConstraints.get(0).getLeft().equals("A")); //assertTrue(classConstraints.get(0).getRight().equals("B")); +// HashMap> methodConstraintsWithPosition = FamilyOfGeneratedGenerics.getMethodConstraintsWithPosition(inputConstraints,classConstraints,tphPositions,) } public void testSecondLineOfClassConstraints() { - /* + */ +/* class Example() { A a; B b = a; @@ -76,7 +94,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { return e; } } - */ + *//* + List inputConstraints = new ArrayList<>(); inputConstraints.add(new TPHConstraint("A", "B", TPHConstraint.Relation.EXTENDS)); @@ -102,13 +121,18 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); System.out.println(classConstraints); +// List methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, classConstraints, tphPositions); +// System.out.println(methodConstraints); assertFalse(classConstraints.isEmpty()); assertTrue(classConstraints.size() == 6); +// assertFalse(methodConstraints.isEmpty()); +// assertTrue(methodConstraints.size() == 2); } public void testTPHsAndGenerics() { - /* + */ +/* class TPHsAndGenerics { Fun1 id = x -> x; C id2 (D x) { @@ -122,7 +146,8 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { return b; } } - */ + *//* + List inputConstraints = new ArrayList<>(); inputConstraints.add(new TPHConstraint("A","B", TPHConstraint.Relation.EXTENDS)); @@ -158,6 +183,13 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(inputConstraints, tphPositions); System.out.println(classConstraints); +// List methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(inputConstraints, classConstraints, tphPositions); +// System.out.println(methodConstraints); + + assertFalse(classConstraints.isEmpty()); + assertTrue(classConstraints.size() == 3); +// assertFalse(methodConstraints.isEmpty()); +// assertTrue(methodConstraints.size()==9); } @@ -177,7 +209,7 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { - HashMap> allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld, listOfMethodsAndTphs); + HashMap>> allTphsNew = FamilyOfGeneratedGenerics.positionConverter(allTphsOld, listOfMethodsAndTphs); System.out.println(allTphsNew); //was tun wenn zwei (oder mehr) Methoden gleiches TPH enthalten? //ist dies möglich oder werden die TPHs immer verschieden initialisiert und dann erst am Ende gemappt? @@ -193,4 +225,4 @@ public class FamilyOfGeneratedGenericsTest extends TestCase { } -} \ No newline at end of file +}*/ diff --git a/src/test/java/insertGenerics/MethodsTest.java b/src/test/java/insertGenerics/MethodsTest.java deleted file mode 100644 index 91e67a1d..00000000 --- a/src/test/java/insertGenerics/MethodsTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package insertGenerics; - -import de.dhbwstuttgart.bytecode.genericsGenerator.GeneratedGenericsFinder; -import de.dhbwstuttgart.core.JavaTXCompiler; -import de.dhbwstuttgart.syntaxtree.ClassOrInterface; -import de.dhbwstuttgart.syntaxtree.SourceFile; -import de.dhbwstuttgart.typeinference.result.ResultSet; -import junit.framework.TestResult; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -public class MethodsTest { - public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; - public static final String fileDirectory = rootDirectory + "TestGGFinder.jav"; - - @Test - public void testVisit(ClassOrInterface coi) throws IOException, ClassNotFoundException { - JavaTXCompiler compiler = new JavaTXCompiler(new File(fileDirectory)); - SourceFile sf = compiler.sourceFiles.get(compiler.sourceFiles.keySet()); - List results = compiler.typeInference(); - - GeneratedGenericsFinder ggf = new GeneratedGenericsFinder(sf, results); - ClassOrInterface coiHere = coi; - ggf.visit(coiHere); - //assert results.size()>0; - } -} diff --git a/src/test/java/insertGenerics/TestAny.java b/src/test/java/insertGenerics/TestAny.java new file mode 100644 index 00000000..e5614515 --- /dev/null +++ b/src/test/java/insertGenerics/TestAny.java @@ -0,0 +1,112 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestAny { + + public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException { + execute(new File(rootDirectory+"TestAny.jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + } + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + classConstraintsTest.add(new ClassConstraint("N", "O", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("N", "U", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("U", "O", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("O", "java/lang/Object", Relation.EXTENDS)); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH RanyMethod()", lmc); + lmc = new HashSet<>(); + methodConstraintsWithPositionTest.put("TPH UotherMethod(TPH U)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + //compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + System.out.println(ASTTypePrinter.print(sf)); + System.out.println(ASTPrinter.print(sf)); + //List results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen + assert results.size()>0; + Set insertedTypes = new HashSet<>(); + for(ResultSet resultSet : results){ + Set result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles); + assert result.size()>0; + String content = readFile(f.getPath(), StandardCharsets.UTF_8); + for(TypeInsert tip : result){ + insertedTypes.add(tip.insert(content)); + } + } + for(String s : insertedTypes){ + System.out.println(s); + } + } + return new TestResultSet(); + } + + static String readFile(String path, Charset encoding) + throws IOException + { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding); + } +} diff --git a/src/test/java/insertGenerics/TryTest.java b/src/test/java/insertGenerics/TestClassField.java similarity index 66% rename from src/test/java/insertGenerics/TryTest.java rename to src/test/java/insertGenerics/TestClassField.java index d0b1ae2f..a8070976 100644 --- a/src/test/java/insertGenerics/TryTest.java +++ b/src/test/java/insertGenerics/TestClassField.java @@ -8,6 +8,8 @@ import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; import de.dhbwstuttgart.typedeployment.TypeInsert; import de.dhbwstuttgart.typedeployment.TypeInsertFactory; import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; import org.junit.Test; import java.io.File; @@ -20,13 +22,18 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -public class TryTest { +public class TestClassField { public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + @Test public void ggFinder() throws IOException, ClassNotFoundException { - execute(new File(rootDirectory+"TestGGFinder.jav")); + execute(new File(rootDirectory+"TestClassField.jav")); } private static class TestResultSet{ @@ -34,25 +41,9 @@ public class TryTest { } public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException { - //filesToTest.add(new File(rootDirectory+"fc.jav")); - //filesToTest.add(new File(rootDirectory+"Lambda.jav")); - //filesToTest.add(new File(rootDirectory+"Lambda2.jav")); - //filesToTest.add(new File(rootDirectory+"Lambda3.jav")); - //filesToTest.add(new File(rootDirectory+"Vector.jav")); - //filesToTest.add(new File(rootDirectory+"Generics.jav")); - //filesToTest.add(new File(rootDirectory+"MethodsEasy.jav")); - //filesToTest.add(new File(rootDirectory+"Matrix.jav")); - //filesToTest.add(new File(rootDirectory+"Import.jav")); - // //filesToTest.add(new File(rootDirectory+"Faculty.jav")); - // //filesToTest.add(new File(rootDirectory+"mathStruc.jav")); - // //filesToTest.add(new File(rootDirectory+"test.jav")); JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); for(File f : compiler.sourceFiles.keySet()){ SourceFile sf = compiler.sourceFiles.get(f); -// System.out.println(ASTTypePrinter.print(sf)); -// System.out.println("---------------------------1"); -// System.out.println(ASTPrinter.print(sf)); -// System.out.println("---------------------------2"); } List results = compiler.typeInference(); List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); @@ -60,9 +51,7 @@ public class TryTest { for(File f : compiler.sourceFiles.keySet()){ SourceFile sf = compiler.sourceFiles.get(f); System.out.println(ASTTypePrinter.print(sf)); -// System.out.println("---------------------------3"); System.out.println(ASTPrinter.print(sf)); -// System.out.println("---------------------------4"); //List results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen assert results.size()>0; Set insertedTypes = new HashSet<>(); @@ -75,9 +64,7 @@ public class TryTest { } } for(String s : insertedTypes){ - System.out.println("---------------------------51"); System.out.println(s); - System.out.println("---------------------------52"); } } return new TestResultSet(); diff --git a/src/test/java/insertGenerics/TestContraVariant.java b/src/test/java/insertGenerics/TestContraVariant.java new file mode 100644 index 00000000..744f18f5 --- /dev/null +++ b/src/test/java/insertGenerics/TestContraVariant.java @@ -0,0 +1,112 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestContraVariant { + + public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException { + execute(new File(rootDirectory+"TestContraVariant.jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + } + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("R", "O", Relation.EXTENDS)); + 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("S", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH Rmain(TPH S)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + //compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + System.out.println(ASTTypePrinter.print(sf)); + System.out.println(ASTPrinter.print(sf)); + //List results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen + assert results.size()>0; + Set insertedTypes = new HashSet<>(); + for(ResultSet resultSet : results){ + Set result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles); + assert result.size()>0; + String content = readFile(f.getPath(), StandardCharsets.UTF_8); + for(TypeInsert tip : result){ + insertedTypes.add(tip.insert(content)); + } + } + for(String s : insertedTypes){ + System.out.println(s); + } + } + return new TestResultSet(); + } + + static String readFile(String path, Charset encoding) + throws IOException + { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding); + } +} diff --git a/src/test/java/insertGenerics/TestExample42.java b/src/test/java/insertGenerics/TestExample42.java index e3e800e3..a052bacf 100644 --- a/src/test/java/insertGenerics/TestExample42.java +++ b/src/test/java/insertGenerics/TestExample42.java @@ -52,8 +52,10 @@ public class TestExample42 { @Test public void genericTest() { - List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs()); - System.out.println("ClassConstraints: " + classConstraints); +// List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs()); +// System.out.println("ClassConstraints: " + classConstraints); +// List methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(fillConstraintsList(),classConstraints,fillPosOfTphs()); +// System.out.println("MethodConstraints: " + methodConstraints); List testCons; } diff --git a/src/test/java/insertGenerics/TestExample42_allInOneMethod.java b/src/test/java/insertGenerics/TestExample42_allInOneMethod.java index 11c76f78..f3fe7213 100644 --- a/src/test/java/insertGenerics/TestExample42_allInOneMethod.java +++ b/src/test/java/insertGenerics/TestExample42_allInOneMethod.java @@ -51,8 +51,10 @@ public class TestExample42_allInOneMethod { @Test public void genericTest() { - List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs()); - System.out.println("ClassConstraints: " + classConstraints); +// List classConstraints = FamilyOfGeneratedGenerics.getClassConstraints(fillConstraintsList(),fillPosOfTphs()); +// System.out.println("ClassConstraints: " + classConstraints); +// List methodConstraints = FamilyOfGeneratedGenerics.getMethodConstraints(fillConstraintsList(),classConstraints,fillPosOfTphs(),); +// System.out.println("MethodConstraints: " + methodConstraints); List testCons; } diff --git a/src/test/java/insertGenerics/TestGGFinder.java b/src/test/java/insertGenerics/TestGGFinder.java new file mode 100644 index 00000000..49ca4297 --- /dev/null +++ b/src/test/java/insertGenerics/TestGGFinder.java @@ -0,0 +1,99 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestGGFinder { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestGGFinder"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + classConstraintsTest.add(new ClassConstraint("S", "java/lang/Object", Relation.EXTENDS)); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("P", "AC", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AC", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ACid(TPH P)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("T", "S", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH SsetA(TPH T)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AC", "Y", Relation.EXTENDS)); + lmc.add(new MethodConstraint("Z", "P", Relation.EXTENDS)); + lmc.add(new MethodConstraint("P", "AC", Relation.EXTENDS)); + lmc.add(new MethodConstraint("Y", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("voidm(TPH YTPH Z)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestLocalVarLambda.java b/src/test/java/insertGenerics/TestLocalVarLambda.java new file mode 100644 index 00000000..a3592a24 --- /dev/null +++ b/src/test/java/insertGenerics/TestLocalVarLambda.java @@ -0,0 +1,112 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestLocalVarLambda { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestLocalVarLambda"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + + Set lmc; + lmc = new HashSet<>(); + + if (fogg.allConstraints.contains((new MethodConstraint("O", "ALU", Relation.EXTENDS)))) { + lmc.add(new MethodConstraint("O", "ALU", Relation.EXTENDS)); + lmc.add(new MethodConstraint("DIU", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("ALU", "DIU", Relation.EXTENDS)); + lmc.add(new MethodConstraint("SY", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH DIUm(TPH O)", lmc); + } + else if (fogg.allConstraints.contains((new MethodConstraint("O", "DIV", Relation.EXTENDS)))) { + lmc.add(new MethodConstraint("O", "DIV", Relation.EXTENDS)); + lmc.add(new MethodConstraint("N", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("DIV", "N", Relation.EXTENDS)); + lmc.add(new MethodConstraint("SY", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH Nm(TPH O)", lmc); + } + else + { + lmc.add(new MethodConstraint("O", "DIU", Relation.EXTENDS)); + lmc.add(new MethodConstraint("N", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("DIU", "N", Relation.EXTENDS)); + lmc.add(new MethodConstraint("SY", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH Nm(TPH O)", lmc); + } + + + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestMutualRecursion.java b/src/test/java/insertGenerics/TestMutualRecursion.java new file mode 100644 index 00000000..82385060 --- /dev/null +++ b/src/test/java/insertGenerics/TestMutualRecursion.java @@ -0,0 +1,126 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestMutualRecursion { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void TestMutualRecursion1() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + className = "TestMutualRecursion"; + JavaTXCompiler compiler = new JavaTXCompiler(new File(rootDirectory+className+".jav")); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + + List classConstraintsTest = new ArrayList<>(); + classConstraintsTest.add(new ClassConstraint("N", "java/lang/Object", Relation.EXTENDS)); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("P", "Q", Relation.EXTENDS)); + lmc.add(new MethodConstraint("Q", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AL", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ALid(TPH P)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AL", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("Z", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ALm(TPH ALTPH Z)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AG", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AH", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AL", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ALmain(TPH AGTPH AH)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + } + + @Test + public void TestMutualRecursionWithField() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + className = "TestMutualRecursionWithField"; + execute(new File(rootDirectory+className+".jav")); + } + + @Test + public void TestMutualRecursionWithField2() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + className = "TestMutualRecursionWithField2"; + execute(new File(rootDirectory+className+".jav")); + } + + @Test + public void TestMutualRecursionWithField3() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + className = "TestMutualRecursionWithField3"; + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestReturnVar.java b/src/test/java/insertGenerics/TestReturnVar.java new file mode 100644 index 00000000..d4b98474 --- /dev/null +++ b/src/test/java/insertGenerics/TestReturnVar.java @@ -0,0 +1,79 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestReturnVar { + + public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException { + execute(new File(rootDirectory+"TestReturnVar.jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + } + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + //compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + System.out.println(ASTTypePrinter.print(sf)); + System.out.println(ASTPrinter.print(sf)); + //List results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen + assert results.size()>0; + Set insertedTypes = new HashSet<>(); + for(ResultSet resultSet : results){ + Set result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles); + assert result.size()>0; + String content = readFile(f.getPath(), StandardCharsets.UTF_8); + for(TypeInsert tip : result){ + insertedTypes.add(tip.insert(content)); + } + } + for(String s : insertedTypes){ + System.out.println(s); + } + } + return new TestResultSet(); + } + + static String readFile(String path, Charset encoding) + throws IOException + { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding); + } +} diff --git a/src/test/java/insertGenerics/TestSecondLineOfClassConstraints.java b/src/test/java/insertGenerics/TestSecondLineOfClassConstraints.java new file mode 100644 index 00000000..97cd468f --- /dev/null +++ b/src/test/java/insertGenerics/TestSecondLineOfClassConstraints.java @@ -0,0 +1,79 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestSecondLineOfClassConstraints { + + public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException { + execute(new File(rootDirectory+"TestSecondLineOfClassConstraints.jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + } + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + //compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + System.out.println(ASTTypePrinter.print(sf)); + System.out.println(ASTPrinter.print(sf)); + //List results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen + assert results.size()>0; + Set insertedTypes = new HashSet<>(); + for(ResultSet resultSet : results){ + Set result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles); + assert result.size()>0; + String content = readFile(f.getPath(), StandardCharsets.UTF_8); + for(TypeInsert tip : result){ + insertedTypes.add(tip.insert(content)); + } + } + for(String s : insertedTypes){ + System.out.println(s); + } + } + return new TestResultSet(); + } + + static String readFile(String path, Charset encoding) + throws IOException + { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding); + } +} diff --git a/src/test/java/insertGenerics/TestTPHsAndGenerics.java b/src/test/java/insertGenerics/TestTPHsAndGenerics.java new file mode 100644 index 00000000..d065151b --- /dev/null +++ b/src/test/java/insertGenerics/TestTPHsAndGenerics.java @@ -0,0 +1,154 @@ +package insertGenerics; + + import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; + import de.dhbwstuttgart.syntaxtree.SourceFile; + import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; + import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; + import de.dhbwstuttgart.typedeployment.TypeInsert; + import de.dhbwstuttgart.typedeployment.TypeInsertFactory; + import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; + import java.io.IOException; + import java.lang.reflect.InvocationTargetException; + import java.net.URL; + import java.net.URLClassLoader; + import java.nio.charset.Charset; + import java.nio.charset.StandardCharsets; + import java.nio.file.Files; + import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; + import java.util.List; + import java.util.Set; + + +public class TestTPHsAndGenerics { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestTPHsAndGenerics"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + + Set lmc; + lmc = new HashSet<>(); + + if (fogg.allConstraints.contains((new MethodConstraint("DZP", "ETW", Relation.EXTENDS)))) { + classConstraintsTest.add(new ClassConstraint("UD", "DZP", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("DZP", "ETW", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("ETW", "java/lang/Object", Relation.EXTENDS)); + + 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("AE", "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)); + methodConstraintsWithPositionTest.put("TPH ETWid2(TPH V)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AI", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc); + } else { + if (fogg.allConstraints.contains((new MethodConstraint("DZP", "U", Relation.EXTENDS)))) { + classConstraintsTest.add(new ClassConstraint("ETW", "DZP", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("DZP", "U", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("U", "java/lang/Object", Relation.EXTENDS)); + + 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("AE", "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)); + methodConstraintsWithPositionTest.put("TPH Uid2(TPH V)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AI", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc); + } else { + if (fogg.allConstraints.contains((new MethodConstraint("EIM", "FEA", Relation.EXTENDS)))) { + classConstraintsTest.add(new ClassConstraint("VK", "EIM", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("EIM", "FEA", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("FEA", "java/lang/Object", Relation.EXTENDS)); + + 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("AE", "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)); + methodConstraintsWithPositionTest.put("TPH FEAid2(TPH V)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AM", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AI", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AIm2(TPH AMTPH AI)", lmc); + } + } + + } + + + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + /* + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + */ + return new TestResultSet(); + + } + } diff --git a/src/test/java/insertGenerics/TestTPHsAndGenerics2.java b/src/test/java/insertGenerics/TestTPHsAndGenerics2.java new file mode 100644 index 00000000..ebf0d9df --- /dev/null +++ b/src/test/java/insertGenerics/TestTPHsAndGenerics2.java @@ -0,0 +1,79 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestTPHsAndGenerics2 { + + public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException { + execute(new File(rootDirectory+"TestTPHSAndGenerics2.jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + } + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + //compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + System.out.println(ASTTypePrinter.print(sf)); + System.out.println(ASTPrinter.print(sf)); + //List results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen + assert results.size()>0; + Set insertedTypes = new HashSet<>(); + for(ResultSet resultSet : results){ + Set result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles); + assert result.size()>0; + String content = readFile(f.getPath(), StandardCharsets.UTF_8); + for(TypeInsert tip : result){ + insertedTypes.add(tip.insert(content)); + } + } + for(String s : insertedTypes){ + System.out.println(s); + } + } + return new TestResultSet(); + } + + static String readFile(String path, Charset encoding) + throws IOException + { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding); + } +} diff --git a/src/test/java/insertGenerics/TestThreeArgs.java b/src/test/java/insertGenerics/TestThreeArgs.java new file mode 100644 index 00000000..ff7951f6 --- /dev/null +++ b/src/test/java/insertGenerics/TestThreeArgs.java @@ -0,0 +1,99 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestThreeArgs { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestThreeArgs"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + classConstraintsTest.add(new ClassConstraint("N", "java/lang/Object", Relation.EXTENDS)); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + 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)); + lmc.add(new MethodConstraint("AB", "P", Relation.EXTENDS)); + lmc.add(new MethodConstraint("P", "AF", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AC", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("W", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH Wm(TPH WTPH ABTPH AC)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + //liefert Fehler, da Variable "a" nicht initialisiert ist. + //instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestTransitiveClosure.java b/src/test/java/insertGenerics/TestTransitiveClosure.java index 95c6a0e2..4eaf0527 100644 --- a/src/test/java/insertGenerics/TestTransitiveClosure.java +++ b/src/test/java/insertGenerics/TestTransitiveClosure.java @@ -21,8 +21,8 @@ public class TestTransitiveClosure { @Test public void genericTest() { - List testCons = FamilyOfGeneratedGenerics.buildTransitiveClosure(fillList()); - System.out.println(testCons); + //List testCons = FamilyOfGeneratedGenerics.buildTransitiveClosure(fillList()); + //System.out.println(testCons); } } diff --git a/src/test/java/insertGenerics/TestTwoArgs.java b/src/test/java/insertGenerics/TestTwoArgs.java new file mode 100644 index 00000000..16fbd062 --- /dev/null +++ b/src/test/java/insertGenerics/TestTwoArgs.java @@ -0,0 +1,111 @@ +package insertGenerics; + +import static org.junit.Assert.*; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint; +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestTwoArgs { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestTwoArgs"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + classConstraintsTest.add(new ClassConstraint("AP", "Z", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("Z", "P", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("P", "AL", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("AL", "AF", Relation.EXTENDS)); + classConstraintsTest.add(new ClassConstraint("AF", "java/lang/Object", Relation.EXTENDS)); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AL", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH ALid(TPH P)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AL", "AF", Relation.EXTENDS)); + lmc.add(new MethodConstraint("Z", "P", Relation.EXTENDS)); + lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AF", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AFm(TPH AFTPH Z)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("T", "AP", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH APsetA(TPH T)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AG", "P", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AH", "T", Relation.EXTENDS)); + lmc.add(new MethodConstraint("T", "AP", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AL", "AF", Relation.EXTENDS)); + lmc.add(new MethodConstraint("P", "AL", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AFmain(TPH AGTPH AH)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestTwoArgs2.java b/src/test/java/insertGenerics/TestTwoArgs2.java new file mode 100644 index 00000000..467cac40 --- /dev/null +++ b/src/test/java/insertGenerics/TestTwoArgs2.java @@ -0,0 +1,105 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestTwoArgs2 { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestTwoArgs2"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + classConstraintsTest.add(new ClassConstraint("N", "java/lang/Object", Relation.EXTENDS)); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AG", "AA", Relation.EXTENDS)); + lmc.add(new MethodConstraint("U", "P", Relation.EXTENDS)); + lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AA", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AAm(TPH AATPH U)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("AB", "P", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AC", "U", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AB", "AA", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AA", "U", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AG", "AA", Relation.EXTENDS)); + lmc.add(new MethodConstraint("U", "AA", Relation.EXTENDS)); + lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AAmain(TPH ABTPH AC)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("P", "AG", Relation.EXTENDS)); + lmc.add(new MethodConstraint("AG", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH AGid(TPH P)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestTwoCalls.java b/src/test/java/insertGenerics/TestTwoCalls.java new file mode 100644 index 00000000..adc3bbac --- /dev/null +++ b/src/test/java/insertGenerics/TestTwoCalls.java @@ -0,0 +1,95 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestTwoCalls { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestTwoCalls"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("O", "R", Relation.EXTENDS)); + lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH Rid(TPH O)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("T", "O", Relation.EXTENDS)); + lmc.add(new MethodConstraint("O", "R", Relation.EXTENDS)); + lmc.add(new MethodConstraint("R", "java/lang/Object", Relation.EXTENDS)); + lmc.add(new MethodConstraint("S", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH Rmain(TPH STPH T)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestVector.java b/src/test/java/insertGenerics/TestVector.java new file mode 100644 index 00000000..6a30a456 --- /dev/null +++ b/src/test/java/insertGenerics/TestVector.java @@ -0,0 +1,92 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestVector { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestVector"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("T", "W", Relation.EXTENDS)); + lmc.add(new MethodConstraint("W", "ZU", Relation.EXTENDS)); + lmc.add(new MethodConstraint("ZU", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("voidm(java/util/Vectorjava/util/Vector)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("W", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH Wid(TPH W)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestVectorArg.java b/src/test/java/insertGenerics/TestVectorArg.java new file mode 100644 index 00000000..45509288 --- /dev/null +++ b/src/test/java/insertGenerics/TestVectorArg.java @@ -0,0 +1,92 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation; +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.bytecode.insertGenerics.ClassConstraint; +import de.dhbwstuttgart.bytecode.insertGenerics.FamilyOfGeneratedGenerics; +import de.dhbwstuttgart.bytecode.insertGenerics.MethodConstraint; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestVectorArg { + + private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + private String pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/"; + private static ClassLoader loader; + private static Class classToTest; + private static Object instanceOfClass; + private static String className = "TestVectorArg"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + execute(new File(rootDirectory+className+".jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + + List classConstraintsTest = new ArrayList<>(); + HashMap> methodConstraintsWithPositionTest = new HashMap<>(); + Set lmc; + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("T", "W", Relation.EXTENDS)); + lmc.add(new MethodConstraint("W", "ZU", Relation.EXTENDS)); + lmc.add(new MethodConstraint("ZU", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("voidm(java/util/Vectorjava/util/Vector)", lmc); + lmc = new HashSet<>(); + lmc.add(new MethodConstraint("W", "java/lang/Object", Relation.EXTENDS)); + methodConstraintsWithPositionTest.put("TPH Wid(TPH W)", lmc); + + FamilyOfGeneratedGenerics fogg = compiler.fogg; + Set computedClassCons = new HashSet<>(fogg.classConstraints); + Set expectedClassCons = new HashSet<>(classConstraintsTest); + + //assertEquals(expectedClassCons, computedClassCons); + + HashMap> methodConstraintsWithPositionComputed = new HashMap<>(); + fogg.methodConstraintsWithPosition.forEach((s, l) -> methodConstraintsWithPositionComputed.put(s,new HashSet<>(l))); + + //assertEquals(methodConstraintsWithPositionTest, methodConstraintsWithPositionComputed); + compiler.generateBytecode(new File(pathToClassFile), results, simplifyResultsForAllSourceFiles); + loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)}); + classToTest = loader.loadClass(className); + instanceOfClass = classToTest.getDeclaredConstructor().newInstance(); + return new TestResultSet(); + } +} diff --git a/src/test/java/insertGenerics/TestVoidMeth.java b/src/test/java/insertGenerics/TestVoidMeth.java new file mode 100644 index 00000000..9dc8f99b --- /dev/null +++ b/src/test/java/insertGenerics/TestVoidMeth.java @@ -0,0 +1,79 @@ +package insertGenerics; + +import de.dhbwstuttgart.bytecode.genericsGeneratorTypes.GenericGenratorResultForSourceFile; +import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.syntaxtree.SourceFile; +import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; +import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; +import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; +import de.dhbwstuttgart.typeinference.result.ResultSet; + +import org.junit.BeforeClass; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class TestVoidMeth { + + public static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/insertGenericsJav/"; + + @BeforeClass + public static void resetNamesOfTypePlaceholder() { + de.dhbwstuttgart.syntaxtree.factory.NameGenerator.reset(); + } + + @Test + public void ggFinder() throws IOException, ClassNotFoundException { + execute(new File(rootDirectory+"TestVoidMeth.jav")); + } + + private static class TestResultSet{ + + } + + public TestResultSet execute(File fileToTest) throws IOException, ClassNotFoundException { + JavaTXCompiler compiler = new JavaTXCompiler(fileToTest); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + } + List results = compiler.typeInference(); + List simplifyResultsForAllSourceFiles = compiler.getGeneratedGenericResultsForAllSourceFiles(results); + //compiler.generateBytecode(rootDirectory+"xxx.class", results, simplifyResultsForAllSourceFiles); + for(File f : compiler.sourceFiles.keySet()){ + SourceFile sf = compiler.sourceFiles.get(f); + System.out.println(ASTTypePrinter.print(sf)); + System.out.println(ASTPrinter.print(sf)); + //List results = compiler.typeInference(); PL 2017-10-03 vor die For-Schleife gezogen + assert results.size()>0; + Set insertedTypes = new HashSet<>(); + for(ResultSet resultSet : results){ + Set result = TypeInsertFactory.createTypeInsertPoints(sf, resultSet, results, simplifyResultsForAllSourceFiles); + assert result.size()>0; + String content = readFile(f.getPath(), StandardCharsets.UTF_8); + for(TypeInsert tip : result){ + insertedTypes.add(tip.insert(content)); + } + } + for(String s : insertedTypes){ + System.out.println(s); + } + } + return new TestResultSet(); + } + + static String readFile(String path, Charset encoding) + throws IOException + { + byte[] encoded = Files.readAllBytes(Paths.get(path)); + return new String(encoded, encoding); + } +} diff --git a/src/test/resources/bytecode/javFiles/Fac.jav b/src/test/resources/bytecode/javFiles/Fac.jav index bde593d4..28650b45 100644 --- a/src/test/resources/bytecode/javFiles/Fac.jav +++ b/src/test/resources/bytecode/javFiles/Fac.jav @@ -3,7 +3,7 @@ import java.lang.Integer; public class Fac { - getFac(java.lang.Integer n){ + getFac(n){ var res = 1; var i = 1; while(i<=n) { diff --git a/src/test/resources/insertGenericsJav/TestAny.jav b/src/test/resources/insertGenericsJav/TestAny.jav new file mode 100644 index 00000000..86c0ceb1 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestAny.jav @@ -0,0 +1,13 @@ +class TestAny { + a; + b = a; + anyMethod() { + var f; + return f; + } + otherMethod(e) { + b = e; + e = a; + return e; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestClassField.jav b/src/test/resources/insertGenericsJav/TestClassField.jav new file mode 100644 index 00000000..f3d24e51 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestClassField.jav @@ -0,0 +1,6 @@ +class Example{ + f; + fReturn(){ + return f; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestContraVariant.jav b/src/test/resources/insertGenericsJav/TestContraVariant.jav new file mode 100644 index 00000000..9349e620 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestContraVariant.jav @@ -0,0 +1,12 @@ +public class TestContraVariant { + + m(x) { + var y; + x = y; + return y; + } + + main(x) { + return m(x); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestGGFinder.jav b/src/test/resources/insertGenericsJav/TestGGFinder.jav index d9309646..cc94cad5 100644 --- a/src/test/resources/insertGenericsJav/TestGGFinder.jav +++ b/src/test/resources/insertGenericsJav/TestGGFinder.jav @@ -1,4 +1,4 @@ -class Generics{ +public class TestGGFinder { a; id(b) { diff --git a/src/test/resources/insertGenericsJav/TestLocalVarLambda.jav b/src/test/resources/insertGenericsJav/TestLocalVarLambda.jav new file mode 100644 index 00000000..ab4455c7 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestLocalVarLambda.jav @@ -0,0 +1,7 @@ +public class TestLocalVarLambda { + +m(x) { + var id = z -> z; + return id.apply(x); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestMutualRecursion.jav b/src/test/resources/insertGenericsJav/TestMutualRecursion.jav new file mode 100644 index 00000000..60ce72ca --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestMutualRecursion.jav @@ -0,0 +1,17 @@ +public class TestMutualRecursion { + a; + + id(b) { + var c = b; + return main(b,c); + } + + m(x,y) { + x = id(y); + return x; + } + + main(x,y) { + return m(id(x),y); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestMutualRecursionWithField.jav b/src/test/resources/insertGenericsJav/TestMutualRecursionWithField.jav new file mode 100644 index 00000000..82dc42d2 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestMutualRecursionWithField.jav @@ -0,0 +1,22 @@ +public class TestMutualRecursionWithField { + a; + + id(b) { + var c = b; + return main(b,c); + } + + setA(x) { + a = x; + return a; + } + + m(x,y) { + x = id(y); + return x; + } + + main(x,y) { + return m(id(x),setA(y)); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestMutualRecursionWithField2.jav b/src/test/resources/insertGenericsJav/TestMutualRecursionWithField2.jav new file mode 100644 index 00000000..727e6031 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestMutualRecursionWithField2.jav @@ -0,0 +1,22 @@ +public class TestMutualRecursionWithField2 { + a; + + id(b) { + var c = b; + return main(b,c); + } + + setA(x) { + a = x; + return a; + } + + m(x,y) { + x = id(y); + return x; + } + + main(x,y) { + return m(setA(x),id(y)); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestMutualRecursionWithField3.jav b/src/test/resources/insertGenericsJav/TestMutualRecursionWithField3.jav new file mode 100644 index 00000000..24e09890 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestMutualRecursionWithField3.jav @@ -0,0 +1,23 @@ +public class TestMutualRecursionWithField3 { + a; + + id(b) { + var c = b; + return main(b,c); + } + + setA(x) { + a = x; + return a; + } + + m(x,y) { + x = id(y); + return x; + } + + main(x,y) { + var z = m(setA(x),id(y)); + return z; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestReturnVar.jav b/src/test/resources/insertGenericsJav/TestReturnVar.jav new file mode 100644 index 00000000..0688e5b8 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestReturnVar.jav @@ -0,0 +1,6 @@ +class VarReturn { + anyMethod() { + var f; + return f; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestSecondLineOfClassConstraints.jav b/src/test/resources/insertGenericsJav/TestSecondLineOfClassConstraints.jav new file mode 100644 index 00000000..16275a50 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestSecondLineOfClassConstraints.jav @@ -0,0 +1,12 @@ +class Example { + a; + b = a; + anyMethod() { + var f; + return f; + } + otherMethod(e) { + e = a; + return e; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestTPHsAndGenerics.jav b/src/test/resources/insertGenericsJav/TestTPHsAndGenerics.jav new file mode 100644 index 00000000..33a79e51 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestTPHsAndGenerics.jav @@ -0,0 +1,13 @@ +class TPHsAndGenerics { + id = x -> x; + id2 (x) { + return id.apply(x); + } + m(a, b){ + var c = m2(a,b); + return a; + } + m2(a, b){ + return b; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestTPHsAndGenerics2.jav b/src/test/resources/insertGenericsJav/TestTPHsAndGenerics2.jav new file mode 100644 index 00000000..9cdc21f7 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestTPHsAndGenerics2.jav @@ -0,0 +1,13 @@ +class TPHsAndGenerics2 { + id = x -> x; + id2 (x) { + return id.apply(x); + } + m(a, b){ + var c = m2(a,b); + return a; + } + m2(a, b){ + return b; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestThreeArgs.jav b/src/test/resources/insertGenericsJav/TestThreeArgs.jav new file mode 100644 index 00000000..fe22dd3c --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestThreeArgs.jav @@ -0,0 +1,15 @@ +public class TestThreeArgs { + a; + + id(b) { + var a /* = null */; + var c = b; + m(a,a,b); + return c; + } + + m(x,y, z) { + x = id(y); + return x; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestTwoArgs.jav b/src/test/resources/insertGenericsJav/TestTwoArgs.jav new file mode 100644 index 00000000..84631151 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestTwoArgs.jav @@ -0,0 +1,22 @@ +public class TestTwoArgs { + a; + + id(b) { + var c = b; + return c; + } + + setA(x) { + a = x; + return a; + } + + m(x,y) { + x = id(y); + return x; + } + + main(x,y) { + return m(id(x),setA(y)); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestTwoArgs2.jav b/src/test/resources/insertGenericsJav/TestTwoArgs2.jav new file mode 100644 index 00000000..f8c270a7 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestTwoArgs2.jav @@ -0,0 +1,17 @@ +public class TestTwoArgs2 { + a; + + id(b) { + var c = b; + return c; + } + + m(x,y) { + x = id(y); + return x; + } + + main(x,y) { + return m(id(x),m(x,y)); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestTwoCalls.jav b/src/test/resources/insertGenericsJav/TestTwoCalls.jav new file mode 100644 index 00000000..be3137f0 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestTwoCalls.jav @@ -0,0 +1,12 @@ +public class TestTwoCalls { + + id(b) { + var c = b; + return c; + } + + main(x,y) { + id(x); + return id(y); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestVector.jav b/src/test/resources/insertGenericsJav/TestVector.jav new file mode 100644 index 00000000..1519afb7 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestVector.jav @@ -0,0 +1,12 @@ +import java.util.Vector; + +public class TestVector { + + m(v, w) { + w.addElement(id(v.elementAt(0))); + } + + id(x) { + return x; + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestVectorArg.jav b/src/test/resources/insertGenericsJav/TestVectorArg.jav new file mode 100644 index 00000000..ca29f820 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestVectorArg.jav @@ -0,0 +1,12 @@ +import java.util.Vector; + +public class TestVectorArg { + + add(v, e) { + v.addElement(e); + } + + main(v, e) { + add(v, e); + } +} \ No newline at end of file diff --git a/src/test/resources/insertGenericsJav/TestVoidMeth.jav b/src/test/resources/insertGenericsJav/TestVoidMeth.jav new file mode 100644 index 00000000..50ee7206 --- /dev/null +++ b/src/test/resources/insertGenericsJav/TestVoidMeth.jav @@ -0,0 +1,4 @@ +class VoidMeth { + anyMethod() { + } +} \ No newline at end of file