当前位置: 首页>>代码示例>>Java>>正文


Java FileDocumentManager.saveDocument方法代码示例

本文整理汇总了Java中com.intellij.openapi.fileEditor.FileDocumentManager.saveDocument方法的典型用法代码示例。如果您正苦于以下问题:Java FileDocumentManager.saveDocument方法的具体用法?Java FileDocumentManager.saveDocument怎么用?Java FileDocumentManager.saveDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.fileEditor.FileDocumentManager的用法示例。


在下文中一共展示了FileDocumentManager.saveDocument方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveFiles

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
protected void saveFiles(PhpClass currentTestClass, Project project) {
    FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();

    Document documentTestClass = fileDocumentManager.getDocument(currentTestClass.getContainingFile().getVirtualFile());
    if (documentTestClass != null) {
        fileDocumentManager.saveDocument(documentTestClass);
    }

    PhpClass currentTestedClass = Utils.locateTestedClass(project, currentTestClass);
    if (currentTestedClass != null) {
        Document documentTestedClass = fileDocumentManager.getDocument(currentTestedClass.getContainingFile().getVirtualFile());
        if (documentTestedClass != null) {
            fileDocumentManager.saveDocument(documentTestedClass);
        }
    }
}
 
开发者ID:atoum,项目名称:phpstorm-plugin,代码行数:17,代码来源:Run.java

示例2: save

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
public static void save(VirtualFile file, String content)
{
    FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
    Document document = fileDocumentManager.getDocument(file);
    if (document != null)
    {
        document.setText(content);
        fileDocumentManager.saveDocument(document);
    }
}
 
开发者ID:miche-atucha,项目名称:deps-checker,代码行数:11,代码来源:VirtualFileHelper.java

示例3: changeLineSeparators

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
public static void changeLineSeparators(@NotNull final Project project,
                                        @NotNull final VirtualFile virtualFile,
                                        @NotNull final String newSeparator)
{
  FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
  Document document = fileDocumentManager.getCachedDocument(virtualFile);
  if (document != null) {
    fileDocumentManager.saveDocument(document);
  }

  String currentSeparator = LoadTextUtil.detectLineSeparator(virtualFile, false);
  final String commandText;
  if (StringUtil.isEmpty(currentSeparator)) {
    commandText = "Changed line separators to " + LineSeparator.fromString(newSeparator);
  }
  else {
    commandText = String.format("Changed line separators from %s to %s",
                                LineSeparator.fromString(currentSeparator), LineSeparator.fromString(newSeparator));
  }

  new WriteCommandAction(project, commandText) {
    @Override
    protected void run(@NotNull Result result) throws Throwable {
      try {
        LoadTextUtil.changeLineSeparators(project, virtualFile, newSeparator, this);
      }
      catch (IOException e) {
        LOG.info(e);
      }
    }
  }.execute();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:AbstractConvertLineSeparatorsAction.java

示例4: saveFiles

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
public static void saveFiles(VirtualFile... files) {
  // ensure the validation/conversion runs on the current content
  final FileDocumentManager mgr = FileDocumentManager.getInstance();
  for (VirtualFile f : files) {
    final Document document = mgr.getDocument(f);
    if (document != null) {
      mgr.saveDocument(document);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ValidateAction.java

示例5: saveDocument

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
private static void saveDocument(VirtualFile f) {
  FileDocumentManager dm = FileDocumentManager.getInstance();
  Document document = dm.getDocument(f);
  assertNotNull(f.getPath(), document);
  dm.saveDocument(document);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:ActionsTest.java

示例6: add

import com.intellij.openapi.fileEditor.FileDocumentManager; //导入方法依赖的package包/类
@Override
public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException {
  checkAdd(element);
  if (element instanceof PsiDirectory) {
    LOG.error("not implemented");
    return null;
  }
  else if (element instanceof PsiFile) {
    PsiFile originalFile = (PsiFile)element;

    try {
      VirtualFile newVFile;
      final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(myManager.getProject());
      if (originalFile instanceof PsiFileImpl) {
        newVFile = myFile.createChildData(myManager, originalFile.getName());
        String text = originalFile.getText();
        final PsiFile psiFile = getManager().findFile(newVFile);
        final Document document = psiFile == null ? null : psiDocumentManager.getDocument(psiFile);
        final FileDocumentManager fileDocumentManager = FileDocumentManager.getInstance();
        if (document != null) {
          document.setText(text);
          fileDocumentManager.saveDocument(document);
        }
        else {
          String lineSeparator = fileDocumentManager.getLineSeparator(newVFile, getProject());
          if (!lineSeparator.equals("\n")) {
            text = StringUtil.convertLineSeparators(text, lineSeparator);
          }

          LoadTextUtil.write(getProject(), newVFile, myManager, text, -1);
        }
      }
      else {
        byte[] storedContents = ((PsiBinaryFileImpl)originalFile).getStoredContents();
        if (storedContents != null) {
          newVFile = myFile.createChildData(myManager, originalFile.getName());
          newVFile.setBinaryContent(storedContents);
        }
        else {
          newVFile = VfsUtilCore.copyFile(null, originalFile.getVirtualFile(), myFile);
        }
      }
      psiDocumentManager.commitAllDocuments();

      PsiFile newFile = myManager.findFile(newVFile);
      updateAddedFile(newFile);

      return newFile;
    }
    catch (IOException e) {
      throw new IncorrectOperationException(e);
    }
  }
  else {
    LOG.assertTrue(false);
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:59,代码来源:PsiDirectoryImpl.java


注:本文中的com.intellij.openapi.fileEditor.FileDocumentManager.saveDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。