Package com.intellij.codeInsight.template

Examples of com.intellij.codeInsight.template.Template


          if (editor == null) return;

          editor.getCaretModel().moveToOffset(anchor.getTextRange().getStartOffset());

          TemplateManager manager = TemplateManager.getInstance(project);
          Template template = manager.createTemplate("", "");

          template.addTextSegment(((ErlangQVar) psiElement).getName());
          template.addTextSegment(" = ");
          template.addVariable(new ConstantNode("unbound"), true);
          template.addTextSegment("");
          template.addEndVariable();
          template.addTextSegment(",\n");

          manager.startTemplate(editor, template);

        }
      }
View Full Code Here


            }
          });
        }

        TemplateManager templateManager = TemplateManager.getInstance(project);
        Template template = templateManager.createTemplate("", "");
        template.setToReformat(true);
        template.addTextSegment("\n\n");
        template.addTextSegment(myName + "(");
        int size = placeHolders.size();
        for (int i = 0; i < placeHolders.size(); i++) {
          String name = placeHolders.get(i);
          template.addVariable("param" + i, new ConstantNode(name), true);
          if (i != size - 1) template.addTextSegment(", ");
        }
        template.addTextSegment(") ->\n");
        template.addEndVariable();
        template.addTextSegment("error(not_implemented).");

        editor.getCaretModel().moveToOffset(topmost.getTextRange().getEndOffset());
        templateManager.startTemplate(editor, template);
      }
    }
View Full Code Here

    if (offset == -1 || topLevelOffset < offset) {
      offset = topLevelOffset;
      editor.getDocument().insertString(offset, "\n");
    }

    Template template = createMacroDefinitionTemplate(project, macroName);
    editor.getCaretModel().moveToOffset(offset);
    TemplateManager.getInstance(project).startTemplate(editor, template);
  }
View Full Code Here

  }

  private static Template createMacroDefinitionTemplate(Project project, String macroName) {
    TemplateManager templateManager = TemplateManager.getInstance(project);

    Template template = templateManager.createTemplate("", "");

    template.setToReformat(true);
    template.addTextSegment("-define(" + macroName + ", ");
    template.addVariable("macro_body", new ConstantNode("macro_body"), true);
    template.addTextSegment(").");
    template.addEndVariable();
    template.addTextSegment("\n");

    return template;
  }
View Full Code Here

TOP

Related Classes of com.intellij.codeInsight.template.Template

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.