Package com.intellij.openapi.editor

Examples of com.intellij.openapi.editor.Document.insertString()


  public static int insertChar(final Editor editor, final int tailOffset, final char c) {
    Document document = editor.getDocument();
    int textLength = document.getTextLength();
    CharSequence chars = document.getCharsSequence();
    if (tailOffset == textLength || chars.charAt(tailOffset) != c){
      document.insertString(tailOffset, String.valueOf(c));
    }
    return moveCaret(editor, tailOffset, 1);
  }

  protected static int moveCaret(final Editor editor, final int tailOffset, final int delta) {
View Full Code Here


      }
      leaf = leaf.getPrevSibling();
    }

    final int offset = rootTag != null ? rootTag.getTextRange().getStartOffset() : 0;
    doc.insertString(offset, suppressComment);
    CodeStyleManager.getInstance(project).adjustLineIndent(doc, offset + suppressComment.length());
    UndoManager.getInstance(file.getProject()).markDocumentForUndo(file);
  }

  public class SuppressTag implements IntentionAction {
View Full Code Here

                    }
                }


                // @TODO: check is last array line on contains eol and indent and move above this line
                document.insertString(goToPsi.getYamlKeyValue().getTextRange().getEndOffset(), insertString);
                manager.doPostponedOperationsAndUnblockDocument(document);
                manager.commitDocument(document);

                // navigate to new psi element
                // @TODO: jump into quote value
View Full Code Here

                final String finalInsertString = insertString;
                new WriteCommandAction(yamlFile.getProject()) {
                    @Override
                    protected void run(Result result) throws Throwable {
                        document.insertString(goToPsi.getYamlKeyValue().getTextRange().getEndOffset(), finalInsertString);
                        manager.doPostponedOperationsAndUnblockDocument(document);
                        manager.commitDocument(document);
                    }

                    @Override
View Full Code Here

          }
          if (intNode != null && intNode.getElementType() == ErlangTypes.ERL_INTEGER) {
            intNode.getPsi().delete();
          }
          PsiDocumentManager.getInstance(context.getProject()).doPostponedOperationsAndUnblockDocument(document);
          document.insertString(context.getTailOffset(), "/" + arity);
          editor.getCaretModel().moveToOffset(context.getTailOffset());
        }

        @Nullable
        private PsiElement findNextToken(@NotNull InsertionContext context) {
View Full Code Here

        int textOffset = lastChild == null ? 0 : lastChild.getTextRange().getEndOffset();

        if (document == null) return;
        String join = StringUtil.join(vars, ", ");
        String newFunction = "\n" + name + "(" + join + ") ->\n erlang:error(not_implemented).\n";
        document.insertString(textOffset, newFunction);
        manager.commitDocument(document);
        CodeStyleManager.getInstance(project).reformatText(file, textOffset, textOffset + newFunction.length());
      }
    }
View Full Code Here

      super.handleInsert(context, item);
      Editor editor = context.getEditor();

      Document document = editor.getDocument();
      if (!document.getText().substring(context.getTailOffset()).startsWith(".")) {
        document.insertString(context.getTailOffset(), ".");
      }

      if (insertQuotas()) doInsert(editor, document, "\"", "\"");
      if (insertBrackets()) doInsert(editor, document, "[", "]");
    }
View Full Code Here

      Document document = editor.getDocument();
      context.commitDocument();
      int tailOffset = context.getTailOffset();
      int startOffset = context.getStartOffset();

      document.insertString(startOffset, QUOTA);
      document.insertString(tailOffset + 1, QUOTA);
      editor.getCaretModel().moveToOffset(tailOffset + 2);
      context.setTailOffset(tailOffset + 2);
    }
    if (myWithColon) {
View Full Code Here

      context.commitDocument();
      int tailOffset = context.getTailOffset();
      int startOffset = context.getStartOffset();

      document.insertString(startOffset, QUOTA);
      document.insertString(tailOffset + 1, QUOTA);
      editor.getCaretModel().moveToOffset(tailOffset + 2);
      context.setTailOffset(tailOffset + 2);
    }
    if (myWithColon) {
      AutoPopupController.getInstance(context.getProject()).autoPopupMemberLookup(context.getEditor(), null);
View Full Code Here

      Document document = editor.getDocument();
      context.commitDocument();
      int tailOffset = context.getTailOffset();
      String base = String.valueOf(myChar);
      String toInsert = mySurroundWithSpaces ? " " + base + " " : base;
      document.insertString(tailOffset, toInsert);
      editor.getCaretModel().moveToOffset(tailOffset + toInsert.length());
    }
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.