From 6f85c2b376d12d8937d1b6dc94ac6cf7c49e57ee Mon Sep 17 00:00:00 2001 From: Aldaron7 Date: Mon, 7 May 2018 19:03:47 +0200 Subject: [PATCH] fixed RuleSetStrucType refl(). --- .../strucTypes/RuleSetStrucType.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/de/dhbwstuttgart/strucTypes/RuleSetStrucType.java b/src/de/dhbwstuttgart/strucTypes/RuleSetStrucType.java index dd56ae82..f470f793 100644 --- a/src/de/dhbwstuttgart/strucTypes/RuleSetStrucType.java +++ b/src/de/dhbwstuttgart/strucTypes/RuleSetStrucType.java @@ -51,25 +51,38 @@ public class RuleSetStrucType extends RuleSet { // Filter SMALLERDOT Pairs final Set pairsSmallerDot = pairs.stream().filter(p -> PairOperator.SMALLERDOT.equals(p.getPairOp())) .collect(Collectors.toSet()); +// System.out.println("Pairs to test: " + pairsSmallerDot); // Filter Tuples of Pairs for a potential Linking (t> tupleOfPotentialLinkings = new ArrayList<>(); for (UnifyPair pair : pairsSmallerDot) { if (!(pair.getRhsType() instanceof PlaceholderType)) { +// System.out.println("Pair not suitable for outerLeftPair: " + pair); continue; } - tupleOfPotentialLinkings = pairsSmallerDot.stream() - .filter(p -> p.getLhsType() instanceof PlaceholderType && p.getRhsType().equals(pair.getLhsType())) - .map(p -> new Pair<>(pair, p)).collect(Collectors.toList()); +// System.out.println("Try to find tuple of potential linkings for pair " + pair); + tupleOfPotentialLinkings.addAll(pairsSmallerDot.stream().filter(p -> { +// System.out.println(" Pair pair: " + pair); +// System.out.println("Pair p: " + p); +// System.out.println("p.lhs instnceof PH: " + (p.getLhsType() instanceof PlaceholderType)); +// System.out.println("p.rhs equals pair.lhs: " + (p.getRhsType().equals(pair.getLhsType()))); + return (p.getLhsType() instanceof PlaceholderType) && (p.getRhsType().equals(pair.getLhsType())); + }).map(p -> { +// System.out.println("Pair to map: " + p); + return new Pair<>(pair, p); + }).collect(Collectors.toList())); +// System.out.println("tuple of potential linkings: " + tupleOfPotentialLinkings); } // Build Linking between the Pairs. Empty if no Linking is possible. for (Pair tuple : tupleOfPotentialLinkings) { UnifyPair outerLeftPair = tuple.getKey(); UnifyPair outerRightPair = tuple.getValue(); +// System.out.println("Try linking pair: " + outerLeftPair + ", " + outerRightPair); Optional> opt = StrucTypeUnifyUtils.linkPairs(outerLeftPair, outerRightPair, pairsSmallerDot); // Remove Pairs of the Linking incl. outerLeft and outerRight, add // EQUALSDOT Pairs instead. if (opt.isPresent()) { +// System.out.println("Linking found: " + opt.get()); pairs.remove(outerLeftPair); pairs.remove(outerRightPair); pairs.removeAll(opt.get()); @@ -86,6 +99,7 @@ public class RuleSetStrucType extends RuleSet { .add(UnifyTypeFactory.generateEqualDotPair(placeholder, outermostUnifyType))); return Optional.of(pairs); } +// System.out.println("No Linking found"); } // No Linking was found. return Optional.empty();