Package com.intellij.codeInsight.template.impl

Examples of com.intellij.codeInsight.template.impl.TemplateImpl


            e.printStackTrace();
        }
    }

    protected Template readExternal (Element element, final String templateName) {
        TemplateImpl template = new TemplateImpl(element.getAttributeValue("name"),
                                                 element.getAttributeValue("value"),
                                                 templateName);
        template.setDescription(element.getAttributeValue("description"));
        template.setToReformat(Boolean.valueOf(element.getAttributeValue("toReformat")));
        template.setToShortenLongNames(Boolean.valueOf(element.getAttributeValue("toShortenFQNames")));
        TemplateContext context = template.getTemplateContext();
        for (Object o : element.getChildren("variable")) {
            Element e = (Element) o;
            template.addVariable(e.getAttributeValue("name"),
                                 e.getAttributeValue("expression"),
                                 e.getAttributeValue("defaultValue"),
                                 Boolean.valueOf(e.getAttributeValue("alwaysStopAt")));
        }
        Element contextElement = element.getChild("context");
View Full Code Here


              .deleteString(range.getStartOffset(), range.getEndOffset());

        String text = getTemplateVariableExpression(resultNames.size(), ", ");
        text += " := " + declaration;

        TemplateImpl template = createTemplate(text);
        setTemplateVariableValues(template, resultNames);
        TemplateManager.getInstance(project).startTemplate(editor, template);
        return true;
    }
View Full Code Here

        int count = getFunctionResultCount(function);
        if (count == 0) {
            return;
        }

        TemplateImpl template = createTemplate(" " + getTemplateVariableExpression(count, ", "));
        for (int i = 0; i < count; i++) {
            String defaultValue = String.format("\"v%d\"", i);
            template.addVariable("v" + i, defaultValue, defaultValue, true);
        }

        Editor editor = context.getEditor();
        Project project = context.getProject();
        TemplateManager.getInstance(project).startTemplate(editor, "", template);
View Full Code Here

import java.util.List;

public class TemplateUtil {
    public static TemplateImpl createTemplate(String text) {
        TemplateImpl template = new TemplateImpl("", text, "");
        template.setToReformat(true);
        return template;
    }
View Full Code Here

        if (!defaultValue.matches("\".*\"")) {
            defaultValue = '"' + defaultValue + '"';
        }

        TemplateImpl template = createTemplate(text);
        template.addVariable(variable, defaultValue, defaultValue, true);
        TemplateManager.getInstance(editor.getProject()).startTemplate(editor, "", template);
    }
View Full Code Here


        arguments.add(k);
        arguments.add(v);

        TemplateImpl template = TemplateUtil.createTemplate(String.format("for $v0$,$v1$ := range %s{$END$}", expr.getText()));
        TemplateUtil.runTemplate(editor, textRange, arguments, template);
    }
View Full Code Here

            String packStr = String.format("\npackage %s", startElement.getFirstChild().getText());
            doc.insertString(insertPoint, packStr);
            insertPoint += packStr.length();
        }

        TemplateImpl template = TemplateUtil.createTemplate(String.format("\n\nfunc %s%s { \n$v%d$$END$\n}", e.getText(), fnArguments, arguments.size()));
        arguments.add("//TODO: implements " + e.getText());
        TemplateUtil.runTemplate(editor, insertPoint, arguments, template);
    }
View Full Code Here

        return createTemplateAtPosition(editor, position, decl);
    }

    private static Template createTemplateAtPosition(Editor editor, int position, String decl) {
        editor.getCaretModel().moveToOffset(position);
        TemplateImpl template = TemplateUtil.createTemplate(decl);
        template.setToIndent(true);
        template.setToReformat(true);
        template.addVariable(VARIABLE, "\"value\"", "\"value\"", true);
        return template;
    }
View Full Code Here

            rangeMarker = doc.createRangeMarker(startElement.getTextRange());
        }

        editor.getCaretModel().moveToOffset(doc.getLineStartOffset(line));

        TemplateImpl template = createTemplate(variableName);
        TemplateManager.getInstance(project).startTemplate(editor, template, new TemplateEditingAdapter() {
            @Override
            public void templateFinished(Template template, boolean brokenOff) {
                int offset;
                if (rangeMarker != null) {
View Full Code Here

        });
    }

    private TemplateImpl createTemplate(String variableName) {
        String decl = String.format("%s := $%s$\n", variableName, VARIABLE);
        TemplateImpl template = TemplateUtil.createTemplate(decl);
        template.setToIndent(true);
        template.setToReformat(true);
        template.addVariable(VARIABLE, "\"value\"", "\"value\"", true);
        return template;
    }
View Full Code Here

TOP

Related Classes of com.intellij.codeInsight.template.impl.TemplateImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.