Package com.intellij.codeInsight.template

Examples of com.intellij.codeInsight.template.TemplateManager


      if (!ApplicationManager.getApplication().isUnitTestMode()) {
        HintManager.getInstance().showErrorHint(editor, getNothingFoundMessage());
      }
      return;
    }
    final TemplateManager templateManager = TemplateManager.getInstance(project);
    for (T e : elementsToProcess) {
      anchor = doAddMethodsForOne(editor, templateManager, buildFunctionsText(templateManager, e), anchor);
    }
  }
View Full Code Here


    super(dartClass);
  }

  @Override
  protected void processElements(@NotNull Project project, @NotNull Editor editor, Set<DartComponent> elementsToProcess) {
    final TemplateManager templateManager = TemplateManager.getInstance(project);
    anchor = doAddMethodsForOne(editor, templateManager, buildFunctionsText(templateManager, elementsToProcess), anchor);
  }
View Full Code Here

    return anchor != null && !DartWritingAccessProvider.isInDartSdkOrDartPackagesFolder(anchor.getContainingFile());
  }

  @Override
  protected void applyFix(Project project, @NotNull PsiElement psiElement, Editor editor) {
    final TemplateManager templateManager = TemplateManager.getInstance(project);
    Template template = templateManager.createTemplate("", "");
    template.setToReformat(true);

    if (!buildTemplate(template, psiElement)) {
      return;
    }

    PsiElement anchor = findAnchor(psiElement);

    if (anchor == null) {
      CommonRefactoringUtil.showErrorHint(
        project,
        editor,
        DartBundle.message("dart.create.function.intention.family"),
        DartBundle.message("dart.cannot.find.place.to.create"),
        null
      );
      return;
    }

    final Editor openedEditor = navigate(project, anchor.getTextOffset(), anchor.getContainingFile().getVirtualFile());
    if (openedEditor != null) {
      templateManager.startTemplate(openedEditor, template);
    }
  }
View Full Code Here

    PsiElement anchor = findAnchor(psiElement);
    if (anchor == null) {
      return;
    }

    final TemplateManager templateManager = TemplateManager.getInstance(project);
    Template template = templateManager.createTemplate("", "");
    template.setToReformat(true);

    template.addTextSegment("class ");
    template.addVariable(DartPresentableUtil.getExpression(myClassName), false);
    template.addTextSegment("{\n");
    template.addEndVariable();
    template.addTextSegment("\n}\n");

    final Editor openedEditor = navigate(project, anchor.getTextOffset(), anchor.getContainingFile().getVirtualFile());
    if (openedEditor != null) {
      templateManager.startTemplate(openedEditor, template);
    }
  }
View Full Code Here

    return containingFile != null && !DartWritingAccessProvider.isInDartSdkOrDartPackagesFolder(containingFile);
  }

  @Override
  protected void applyFix(Project project, @NotNull PsiElement psiElement, Editor editor) {
    final TemplateManager templateManager = TemplateManager.getInstance(project);
    Template template = templateManager.createTemplate("", "");
    template.setToReformat(true);

    buildTemplate(template, psiElement);

    PsiElement anchor = findAnchor(psiElement);

    if (anchor == null) {
      CommonRefactoringUtil.showErrorHint(
        project,
        editor,
        DartBundle.message("dart.create.function.intention.family"),
        DartBundle.message("dart.cannot.find.place.to.create"),
        null
      );
      return;
    }

    final Editor openedEditor = navigate(project, anchor.getTextOffset(), anchor.getContainingFile().getVirtualFile());
    if (openedEditor != null) {
      templateManager.startTemplate(openedEditor, template);
    }
  }
View Full Code Here

    FileEditorManager.getInstance(project).getAllEditors(vFile);
    FileEditorManager.getInstance(project).openTextEditor(descriptor, true);
    final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();

    assert editor != null;
    final TemplateManager templateManager = TemplateManager.getInstance(file.getProject());
    final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
    final Template template = templateManager.getActiveTemplate(editor);
    if (templateState != null && template != null) {
      templateState.gotoEnd(false);
    }
  }
View Full Code Here

          Editor editor = PsiUtilBase.findEditor(anchor);
          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

              return ErlangRefactoringUtil.shorten(erlangExpression);
            }
          });
        }

        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

    return null == elementBefore ? -1 : elementBefore.getTextRange().getStartOffset();
  }

  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(").");
View Full Code Here

TOP

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

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.