Package com.intellij.openapi.editor

Examples of com.intellij.openapi.editor.Document


        return PomManager.getInstance(pProject).isValid(pFile.getUrl());
    }

    public FileEditor createEditor(final Project pProject, final VirtualFile pPomFile) {
        final FileDocumentManager filedocMgr = FileDocumentManager.getInstance();
        final Document document = filedocMgr.getDocument(pPomFile);
        final XmlFile xmlFile = PsiUtils.findXmlFile(pProject, document);

        return new PomFileEditor(new DefaultPsiProject(xmlFile));
    }
View Full Code Here


        if (desc.canNavigateToSource()) {
            desc.navigate(true);
            final FileEditor fileEditor = fileMgr.getSelectedEditor(script);
            if (fileEditor instanceof TextEditor) {
                final Editor editor = ((TextEditor) fileEditor).getEditor();
                final Document document = editor.getDocument();
                final PsiFile psiFile = psiMgr.getPsiFile(document);
                if (!(psiFile instanceof XmlFile))
                    return;

                final XmlFile xmlFile = (XmlFile) psiFile;
View Full Code Here

    private static final Res RES = Res.getInstance(PsiUtils.class);

    public static XmlFile findXmlFile(final Project pProject,
                                      final VirtualFile pFile) {
        final FileDocumentManager fileDocMgr = FileDocumentManager.getInstance();
        Document doc = fileDocMgr.getCachedDocument(pFile);
        if (doc == null)
            doc = fileDocMgr.getDocument(pFile);

        return findXmlFile(pProject, doc);
    }
View Full Code Here

    Issue issue = new Issue();
    issue.setFile(vFile);
    if (editor != null)
    {
      Document document = editor.getDocument();
      int lineStart = document.getLineNumber(editor.getSelectionModel().getSelectionStart());
      int lineEnd = document.getLineNumber(editor.getSelectionModel().getSelectionEnd());

      issue.setLineStart(lineStart);
      issue.setLineEnd(lineEnd);
      CharSequence fragment = document.getCharsSequence().subSequence(document.getLineStartOffset(lineStart),
        document.getLineEndOffset(lineEnd));
      issue.setHash(fragment.toString().hashCode());
    }
    issue.setStatus(IssueStatus.TO_RESOLVE);

    IssueDialog dialog = new IssueDialog(project, true);
View Full Code Here

    }

    RangeMarker marker = findMarker(issue);
    if ((marker == null) && (checkEvenIfEditorNotAvailable))
    {
      Document document = RevuUtils.getDocument(project, issue);
      if (document != null)
      {
        marker = RevuUtils.createRangeMarker(issue, document);
      }
    }
View Full Code Here

    return fragment.toString().hashCode();
  }

  private boolean hasLocationChanged(Issue issue, RangeMarker marker)
  {
    Document document = marker.getDocument();

    int lineStart = (issue.getLineStart() == -1) ? 0 : issue.getLineStart();
    int lineEnd = (issue.getLineEnd() == -1) ? 0 : issue.getLineEnd();

    return (marker.getStartOffset() != document.getLineStartOffset(lineStart))
      || (marker.getEndOffset() != document.getLineEndOffset(lineEnd));
  }
View Full Code Here

* @author patrick (11/12/13)
*/
public class CompoundExpressionFixer extends SmartEnterProcessorWithFixers.Fixer<MathematicaSmartEnter> {
  @Override
  public void apply(@NotNull Editor editor, @NotNull MathematicaSmartEnter processor, @NotNull PsiElement element) throws IncorrectOperationException {
    Document doc = editor.getDocument();
    if (element instanceof CompoundExpression && element.getTextOffset()+element.getTextLength() == editor.getCaretModel().getOffset()) {
      final PsiElement lastChild = element.getLastChild();
      if (!lastChild.getNode().getElementType().equals(SEMICOLON)) {
        final int offset = lastChild.getTextOffset() + lastChild.getTextLength();
        doc.insertString(offset, ";\n");
        editor.getCaretModel().moveToOffset(offset + 2);
      }
    }
  }
View Full Code Here

  }

  public static PsiElement findNextElement(Editor editor, PsiFile psiFile) {
    int caret = editor.getCaretModel().getOffset();

    final Document doc = editor.getDocument();
    CharSequence chars = doc.getCharsSequence();
    int offset = caret == 0 ? 0 : CharArrayUtil.shiftBackward(chars, caret - 1, " \t");
    if (doc.getLineNumber(offset) < doc.getLineNumber(caret)) {
      offset = CharArrayUtil.shiftForward(chars, caret, " \t");
    }

    PsiElement current = psiFile.findElementAt(offset);
    PsiElement saveOriginal = current;
View Full Code Here

* @author patrick (30/10/13)
*/
public class FunctionCallFixer extends SmartEnterProcessorWithFixers.Fixer<MathematicaSmartEnter> {
  @Override
  public void apply(@NotNull Editor editor, @NotNull MathematicaSmartEnter processor, @NotNull PsiElement element) throws IncorrectOperationException {
    Document doc = editor.getDocument();
    if (element instanceof FunctionCall) {

      final PsiElement lastChild = element.getLastChild();
      if (!lastChild.getNode().getElementType().equals(RIGHT_BRACKET)) {
        PsiElement prevSibling = lastChild.getPrevSibling();
        if (prevSibling != null) {
          final int textOffset = prevSibling.getTextOffset();
          if (prevSibling.getNode().getElementType() == COMMA) {
            doc.replaceString(textOffset, textOffset + 1, "]");
          } else {
            doc.insertString(textOffset + prevSibling.getTextLength(), "]");
          }
        }
        return;
      }
      PsiElement prevSibling = lastChild.getPrevSibling();
      while (prevSibling != null && prevSibling instanceof PsiWhiteSpace) {
        prevSibling = prevSibling.getPrevSibling();
      }
      if (prevSibling != null && prevSibling.getNode().getElementType() == COMMA) {
        doc.insertString(prevSibling.getTextOffset() + 1, "\n\n");
        editor.getCaretModel().moveToOffset(prevSibling.getTextOffset() + 2);
        processor.commit(editor);
//          return;
      }
//      editor.getCaretModel().moveToOffset(lastChild.getTextOffset() + 1, true);
View Full Code Here

  }

  @Override
  public void handleInsert(InsertionContext context, LookupElement item) {
    Editor editor = context.getEditor();
    Document document = editor.getDocument();
    context.commitDocument();

    char completionChar = context.getCompletionChar();
    context.setAddCompletionChar(false);

//        if (completionChar == Lookup.NORMAL_SELECT_CHAR) {
////            editor.getCaretModel().moveToOffset(context.getTailOffset());
//        }

    if (completionChar == Lookup.COMPLETE_STATEMENT_SELECT_CHAR) {
      SymbolInformationProvider.SymbolInformation symbol = SymbolInformationProvider.getSymbolNames().get(item.getLookupString());
      boolean insertBrackets = (symbol != null) && symbol.function;
      if (insertBrackets) {
        document.insertString(context.getTailOffset(), Character.toString(OPEN_BRACKET));
        editor.getCaretModel().moveToOffset(context.getTailOffset());
        document.insertString(context.getTailOffset(), Character.toString(CLOSING_BRACKET));
      } else {
        document.insertString(context.getTailOffset(), " ");
        editor.getCaretModel().moveToOffset(context.getTailOffset());
      }

    }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.editor.Document

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.