use of il.org.spartan.Leonidas.plugin.leonidas.Matcher in project Main by SpartanRefactoring.
the class Method method create.
@Override
public GenericEncapsulator create(Encapsulator e, Map<Integer, List<Matcher.Constraint>> map) {
Method m = new Method(e);
Encapsulator returnType = Pruning.prune(Encapsulator.buildTreeFromPsi(az.method(e.getInner()).getReturnTypeElement()), map);
Encapsulator parameters = Pruning.prune(Encapsulator.buildTreeFromPsi(az.method(e.getInner()).getParameterList()), map);
Encapsulator codeBlock = Pruning.prune(Encapsulator.buildTreeFromPsi(az.method(e.getInner()).getBody()), map);
m.matcherReturnType = new Matcher(Utils.wrapWithList(returnType), map);
m.matcherParameters = new Matcher(Utils.wrapWithList(parameters), map);
m.matcherCodeBlock = new Matcher(Utils.wrapWithList(codeBlock), map);
m.replacerReturnType = new Replacer(Utils.wrapWithList(returnType));
m.replacerParameters = new Replacer(Utils.wrapWithList(parameters));
m.replacerCodeBlock = new Replacer(Utils.wrapWithList(codeBlock));
return m;
}
use of il.org.spartan.Leonidas.plugin.leonidas.Matcher in project Main by SpartanRefactoring.
the class Class method create.
@Override
public GenericEncapsulator create(Encapsulator e, Map<Integer, List<Matcher.Constraint>> map) {
Class c = new Class(e);
c.fields = Arrays.stream(az.classDeclaration(e.getInner()).getFields()).map(f -> Pruning.prune(Encapsulator.buildTreeFromPsi(f), map)).collect(Collectors.toList());
c.methods = Arrays.stream(az.classDeclaration(e.getInner()).getMethods()).map(f -> Pruning.prune(Encapsulator.buildTreeFromPsi(f), map)).collect(Collectors.toList());
c.innerClasses = Arrays.stream(az.classDeclaration(e.getInner()).getInnerClasses()).map(f -> Pruning.prune(Encapsulator.buildTreeFromPsi(f), map)).collect(Collectors.toList());
c.fieldsMatchers = c.fields.stream().map(f -> new Matcher(Utils.wrapWithList(f), map)).collect(Collectors.toList());
c.methodsMatchers = c.methods.stream().map(m -> new Matcher(Utils.wrapWithList(m), map)).collect(Collectors.toList());
c.innerClassesMatchers = c.innerClasses.stream().map(ic -> new Matcher(Utils.wrapWithList(ic), map)).collect(Collectors.toList());
return c;
}
use of il.org.spartan.Leonidas.plugin.leonidas.Matcher 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;
}
Aggregations