Tabnine Logo
Template.setToReformat
Code IndexAdd Tabnine to your IDE (free)

How to use
setToReformat
method
in
com.intellij.codeInsight.template.Template

Best Java code snippets using com.intellij.codeInsight.template.Template.setToReformat (Showing top 5 results out of 315)

origin: go-lang-plugin-org/go-lang-idea-plugin

 @Override
 public void invoke(@NotNull Project project,
           @NotNull PsiFile file,
           @Nullable("is null when called from inspection") Editor editor,
           @NotNull PsiElement startElement,
           @NotNull PsiElement endElement) {
  if (!(file instanceof GoFile) || editor == null || !(startElement instanceof GoBlock)) return;
  PsiElement brace = ((GoBlock)startElement).getRbrace();
  if (brace == null) return;
  Template template = TemplateSettings.getInstance().getTemplateById("go_lang_add_return");
  if (template == null) return;
  int start = brace.getTextRange().getStartOffset();
  editor.getCaretModel().moveToOffset(start);
  editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
  template.setToReformat(true);
  TemplateManager.getInstance(project).startTemplate(editor, template, true, Collections.emptyMap(), null);
 }
}
origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
public void invoke(@NotNull Project project,
          @NotNull PsiFile file,
          @Nullable("is null when called from inspection") Editor editor,
          @NotNull PsiElement startElement,
          @NotNull PsiElement endElement) {
 if (editor == null) {
  LOG.error("Cannot run quick fix without editor: " + getClass().getSimpleName(),
       AttachmentFactory.createAttachment(file.getVirtualFile()));
  return;
 }
 PsiElement reference = PsiTreeUtil.getNonStrictParentOfType(startElement, GoReferenceExpressionBase.class);
 PsiElement anchor = reference != null ? findAnchor(reference) : null;
 if (anchor == null) {
  LOG.error("Cannot find anchor for " + myWhat + " (GoUnresolvedFixBase), offset: " + editor.getCaretModel().getOffset(),
       AttachmentFactory.createAttachment(file.getVirtualFile()));
  return;
 }
 Template template = TemplateSettings.getInstance().getTemplateById(myTemplateId);
 if (template == null) {
  LOG.error("Cannot find anchor for " + myWhat + " (GoUnresolvedFixBase), offset: " + editor.getCaretModel().getOffset(),
       AttachmentFactory.createAttachment(file.getVirtualFile()));
  return;
 }
 int start = anchor.getTextRange().getStartOffset();
 editor.getCaretModel().moveToOffset(start);
 template.setToReformat(true);
 TemplateManager.getInstance(project).startTemplate(editor, template, true, ContainerUtil.stringMap("NAME", myName), null);
}
origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
public void handleInsert(@NotNull InsertionContext context, LookupElement item) {
 Editor editor = context.getEditor();
 CharSequence documentText = context.getDocument().getImmutableCharSequence();
 int offset = skipWhiteSpaces(editor.getCaretModel().getOffset(), documentText);
 if (documentText.charAt(offset) != '{') {
  Project project = context.getProject();
  Template template = TemplateManager.getInstance(project).createTemplate("braces", "go", myOneLine ? "{$END$}" : " {\n$END$\n}");
  template.setToReformat(true);
  TemplateManager.getInstance(project).startTemplate(editor, template);
 }
 else {
  editor.getCaretModel().moveToOffset(offset);
  ApplicationManager.getApplication().runWriteAction(() -> {
   EditorActionHandler enterAction = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE);
   enterAction.execute(editor, editor.getCaretModel().getCurrentCaret(), ((EditorEx)editor).getDataContext());
  });
 }
}
origin: liias/monkey

template.setToReformat(true);
template.setToShortenLongNames(true);
origin: JetBrains/Grammar-Kit

Template template = builder.buildInlineTemplate();
template.setToShortenLongNames(false);
template.setToReformat(false);
TemplateManager.getInstance(project).startTemplate(editor, template, new TemplateEditingAdapter() {
com.intellij.codeInsight.templateTemplatesetToReformat

Popular methods of Template

  • addVariable
  • addTextSegment
  • setToIndent
  • setToShortenLongNames
  • addEndVariable
  • addVariableSegment
  • getTemplateText

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setContentView (Activity)
  • runOnUiThread (Activity)
  • getSharedPreferences (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now