use of il.org.spartan.Leonidas.plugin.leonidas.MatchingResult in project Main by SpartanRefactoring.
the class Method method generalizes.
@Override
public MatchingResult generalizes(Encapsulator e) {
if (super.generalizes(e).notMatches() || !iz.method(e.getInner()))
return new MatchingResult(false);
PsiMethod m = az.method(e.getInner());
Wrapper<Integer> dummy = new Wrapper<>(0);
return matcherReturnType.getMatchingResult(m.getReturnTypeElement(), dummy).combineWith(matcherParameters.getMatchingResult(m.getParameterList(), dummy)).combineWith(matcherCodeBlock.getMatchingResult(m.getBody(), dummy));
}
use of il.org.spartan.Leonidas.plugin.leonidas.MatchingResult in project Main by SpartanRefactoring.
the class Class method matchInnerElements.
private MatchingResult matchInnerElements(PsiElement[] innerElements, List<Matcher> matchers) {
if (matchers.size() == 0)
return new MatchingResult(true);
List<List<MatchingResult>> l = matchers.stream().map(m -> Arrays.stream(innerElements).map(ie -> m.getMatchingResult(ie, new Wrapper<>(0))).filter(mr -> mr.matches()).collect(Collectors.toList())).collect(Collectors.toList());
MatchingResult[] ass = new MatchingResult[matchers.size()];
if (!matchInnerElementAux(l, matchers.size() - 1, new LinkedList<>(), ass)) {
return new MatchingResult(false);
}
MatchingResult mr = new MatchingResult(true);
Arrays.stream(ass).forEach(a -> mr.combineWith(a));
return mr;
}
use of il.org.spartan.Leonidas.plugin.leonidas.MatchingResult in project Main by SpartanRefactoring.
the class Class method matchInnerElementAux.
private boolean matchInnerElementAux(List<List<MatchingResult>> l, int i, List<MatchingResult> used, MatchingResult[] ass) {
if (i < 0)
return true;
for (MatchingResult mr : l.get(i)) {
if (used.contains(mr))
continue;
used.add(mr);
ass[i] = mr;
if (matchInnerElementAux(l, i - 1, used, ass))
return true;
used.remove(mr);
}
return false;
}
use of il.org.spartan.Leonidas.plugin.leonidas.MatchingResult in project Main by SpartanRefactoring.
the class Class method generalizes.
@Override
public MatchingResult generalizes(Encapsulator e) {
if (!iz.classDeclaration(e.inner))
return new MatchingResult(false);
PsiClass c = az.classDeclaration(e.inner);
MatchingResult mr = new MatchingResult(true);
if (!super.generalizes(e).matches())
return new MatchingResult(false);
mr.combineWith(matchInnerElements(c.getFields(), fieldsMatchers));
mr.combineWith(matchInnerElements(c.getMethods(), methodsMatchers));
mr.combineWith(matchInnerElements(c.getInnerClasses(), innerClassesMatchers));
return mr;
}
Aggregations