Search in sources :

Example 1 with GenericEncapsulator

use of il.org.spartan.Leonidas.plugin.leonidas.BasicBlocks.GenericEncapsulator in project Main by SpartanRefactoring.

the class Replacer method getReplacingForest.

/**
     * @param m the mapping between generic element index to concrete elements of the user.
     * @param r rewrite object
     * @return the template of the replacer with the concrete elements inside it.
     */
private List<PsiElement> getReplacingForest(List<Encapsulator> rootsCopy, Map<Integer, List<PsiElement>> m, PsiRewrite r) {
    List<PsiElement> elements = new LinkedList<>();
    rootsCopy.forEach(rootCopy -> {
        if (rootCopy.isGeneric()) {
            GenericEncapsulator ge = az.generic(rootCopy);
            elements.addAll(ge.replaceByRange(m.get(az.generic(rootCopy).getId()), m, r));
        } else {
            rootCopy.accept(e -> {
                if (!e.isGeneric())
                    return;
                GenericEncapsulator ge = az.generic(e);
                ge.replaceByRange(m.get(ge.getId()), m, r);
            });
            elements.add(rootCopy.getInner());
        }
    });
    return elements;
}
Also used : GenericEncapsulator(il.org.spartan.Leonidas.plugin.leonidas.BasicBlocks.GenericEncapsulator) LinkedList(java.util.LinkedList) PsiElement(com.intellij.psi.PsiElement)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 GenericEncapsulator (il.org.spartan.Leonidas.plugin.leonidas.BasicBlocks.GenericEncapsulator)1 LinkedList (java.util.LinkedList)1