Package com.intellij.openapi.fileEditor

Examples of com.intellij.openapi.fileEditor.FileDocumentManager.saveDocument()


    private void formatWhenEditorIsClosed(PsiFile psiFile) throws InvalidPathToConfigFileException {
        VirtualFile virtualFile = psiFile.getVirtualFile();
        FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
        Document document = fileDocumentManager.getDocument(virtualFile);
        fileDocumentManager.saveDocument(document); // when file is edited and editor is closed, it is needed to save
        // the text
        document.setText(reformat(document.getText()));
        postProcess(document, true, psiFile);
        fileDocumentManager.saveDocument(document);
    }
View Full Code Here


        Document document = fileDocumentManager.getDocument(virtualFile);
        fileDocumentManager.saveDocument(document); // when file is edited and editor is closed, it is needed to save
        // the text
        document.setText(reformat(document.getText()));
        postProcess(document, true, psiFile);
        fileDocumentManager.saveDocument(document);
    }

    private String reformat(String virtualFile) throws InvalidPathToConfigFileException {
        return codeFormatterFacade.format(virtualFile, Settings.LINE_SEPARATOR);
    }
View Full Code Here

  private void formatWhenEditorIsClosed(PsiFile psiFile) throws FileDoesNotExistsException {
    LOG.debug("#formatWhenEditorIsClosed " + psiFile.getName());
    VirtualFile virtualFile = psiFile.getVirtualFile();
    FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
    Document document = fileDocumentManager.getDocument(virtualFile);
    fileDocumentManager.saveDocument(document); // when file is edited and editor is closed, it is needed to save
    // the text
    String text = document.getText();
    String reformat = reformat(0, text.length(), text);
    document.setText(reformat);
    postProcess(document, psiFile, new Range(-1, -1, true));
View Full Code Here

    // the text
    String text = document.getText();
    String reformat = reformat(0, text.length(), text);
    document.setText(reformat);
    postProcess(document, psiFile, new Range(-1, -1, true));
    fileDocumentManager.saveDocument(document);
  }

  /* when file is being edited, it is important to load text from editor, i think */
  private void formatWhenEditorIsOpen(Range range, PsiFile file) throws FileDoesNotExistsException {
    LOG.debug("#formatWhenEditorIsOpen " + file.getName());
View Full Code Here

        } else {
          FileDocumentManager instance = FileDocumentManager.getInstance();
          String iDocument = codeFormatterFacade.format(ioFile(file), LINE_SEPARATOR);
          Document writeTo = instance.getDocument(file);
          writeTo.setText(iDocument);
          instance.saveDocument(writeTo);
        }
      } else {
        notifyNothingWasFormatted();
        return;
      }
View Full Code Here

            }
          }
        }.execute();
        FileDocumentManager docManager = FileDocumentManager.getInstance();
        com.intellij.openapi.editor.Document doc = docManager.getDocument(psiFile.getVirtualFile());
        docManager.saveDocument(doc);
        PsiDocumentManager.getInstance(project).commitDocument(doc);
        /*
        MavenId mavenid = new MavenId(result.getGroupId(), result.getArtifactId(), result.getVersion());
        Module module = getModuleForFile(problemDescriptor.getPsiElement().getContainingFile());
        MavenModel model = MavenUtil.getMavenModel(project, problemDescriptor.getPsiElement().getContainingFile().getVirtualFile());
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.