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


Java PsiDocumentManager.commitAllDocuments方法代码示例

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


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

示例1: iterateOverCarets

import com.intellij.psi.PsiDocumentManager; //导入方法依赖的package包/类
private static void iterateOverCarets(@NotNull final Project project,
                               @NotNull final Editor hostEditor,
                               @NotNull final MultiCaretCodeInsightActionHandler handler) {
  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
  final PsiFile psiFile = documentManager.getCachedPsiFile(hostEditor.getDocument());
  documentManager.commitAllDocuments();

  hostEditor.getCaretModel().runForEachCaret(new CaretAction() {
    @Override
    public void perform(Caret caret) {
      Editor editor = hostEditor;
      if (psiFile != null) {
        Caret injectedCaret = InjectedLanguageUtil.getCaretForInjectedLanguageNoCommit(caret, psiFile);
        if (injectedCaret != null) {
          caret = injectedCaret;
          editor = caret.getEditor();
        }
      }
      final PsiFile file = PsiUtilBase.getPsiFileInEditor(caret, project);
      if (file != null) {
        handler.invoke(project, editor, caret, file);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MultiCaretCodeInsightAction.java

示例2: indentBlock

import com.intellij.psi.PsiDocumentManager; //导入方法依赖的package包/类
static void indentBlock(Project project, Editor editor, final int startOffset, final int endOffset, int originalCaretCol) {
  final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
  documentManager.commitAllDocuments();
  final Document document = editor.getDocument();
  PsiFile file = documentManager.getPsiFile(document);
  if (file == null) {
    return;
  }

  if (LanguageFormatting.INSTANCE.forContext(file) != null) {
    indentBlockWithFormatter(project, document, startOffset, endOffset, file);
  }
  else {
    indentPlainTextBlock(document, startOffset, endOffset, originalCaretCol);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PasteHandler.java

示例3: testXmlDeclDtd

import com.intellij.psi.PsiDocumentManager; //导入方法依赖的package包/类
public void testXmlDeclDtd() throws Exception {
  PsiFile file = createFile("x.xml", "<!DOCTYPE name [\n" +
                                     "  <!ELEMENT name (" + marker+ "a b c d" + marker+ ")>\n" +
                                     "  <!ELEMENT name2 (" + marker+ "%entity;" + marker+ ")>\n" +
                                     "]>\n" +
                                     "<name></name>");

  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
  Document document = documentManager.getDocument(file);

  removeGarbage(document);

  documentManager.commitAllDocuments();
  String myFullDataPath = getTestDataPath() + "psi/";
  ParsingTestCase.doCheckResult(myFullDataPath, file, true, "testXmlDeclDtd", false, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XmlReparseTest.java

示例4: testUsageViewHandlesDocumentChange

import com.intellij.psi.PsiDocumentManager; //导入方法依赖的package包/类
public void testUsageViewHandlesDocumentChange() throws Exception {
  PsiFile psiFile = myFixture.addFileToProject("X.java", "public class X{ int xxx; } //comment");
  Usage usage = createUsage(psiFile, psiFile.getText().indexOf("xxx"));

  UsageView usageView = UsageViewManager.getInstance(getProject()).createUsageView(UsageTarget.EMPTY_ARRAY, new Usage[]{usage}, new UsageViewPresentation(), null);
  Disposer.register(getTestRootDisposable(), usageView);

  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
  Document document = documentManager.getDocument(psiFile);
  document.insertString(0, "/* sdfsdfsd */");
  documentManager.commitAllDocuments();
  int navigationOffset = ((UsageInfo2UsageAdapter)usage).getUsageInfo().getNavigationOffset();
  assertEquals(psiFile.getText().indexOf("xxx"), navigationOffset);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:UsageViewTest.java

示例5: testTextUsageInfoHandlesDocumentChange

import com.intellij.psi.PsiDocumentManager; //导入方法依赖的package包/类
public void testTextUsageInfoHandlesDocumentChange() throws Exception {
  PsiFile psiFile = myFixture.addFileToProject("X.java", "public class X{ int xxx; } //comment");
  Usage usage = new UsageInfo2UsageAdapter(new UsageInfo(psiFile, psiFile.getText().indexOf("xxx"), StringUtil.indexOfSubstringEnd(psiFile.getText(),"xxx")));

  UsageView usageView = UsageViewManager.getInstance(getProject()).createUsageView(UsageTarget.EMPTY_ARRAY, new Usage[]{usage}, new UsageViewPresentation(), null);
  Disposer.register(getTestRootDisposable(), usageView);

  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(getProject());
  Document document = documentManager.getDocument(psiFile);
  document.insertString(0, "/* sdfsdfsd */");
  documentManager.commitAllDocuments();
  int navigationOffset = ((UsageInfo2UsageAdapter)usage).getUsageInfo().getNavigationOffset();
  assertEquals(psiFile.getText().indexOf("xxx"), navigationOffset);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:UsageViewTest.java

示例6: autoPopupParameterInfo

import com.intellij.psi.PsiDocumentManager; //导入方法依赖的package包/类
public void autoPopupParameterInfo(@NotNull final Editor editor, @Nullable final PsiElement highlightedMethod){
  if (ApplicationManager.getApplication().isUnitTestMode()) return;
  if (DumbService.isDumb(myProject)) return;
  if (PowerSaveMode.isEnabled()) return;

  ApplicationManager.getApplication().assertIsDispatchThread();
  final CodeInsightSettings settings = CodeInsightSettings.getInstance();
  if (settings.AUTO_POPUP_PARAMETER_INFO) {
    final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
    PsiFile file = documentManager.getPsiFile(editor.getDocument());
    if (file == null) return;

    if (!documentManager.isUncommited(editor.getDocument())) {
      file = documentManager.getPsiFile(InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file).getDocument());
      if (file == null) return;
    }

    final PsiFile file1 = file;
    final Runnable request = new Runnable(){
      @Override
      public void run(){
        if (myProject.isDisposed() || DumbService.isDumb(myProject)) return;
        documentManager.commitAllDocuments();
        if (editor.isDisposed() || !editor.getComponent().isShowing()) return;
        int lbraceOffset = editor.getCaretModel().getOffset() - 1;
        try {
          ShowParameterInfoHandler.invoke(myProject, editor, file1, lbraceOffset, highlightedMethod);
        }
        catch (IndexNotReadyException ignored) { //anything can happen on alarm
        }
      }
    };

    addRequest(request, settings.PARAMETER_INFO_DELAY);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:AutoPopupController.java

示例7: getInjectedEditor

import com.intellij.psi.PsiDocumentManager; //导入方法依赖的package包/类
public static Editor getInjectedEditor(@NotNull Project project, final Editor editor, boolean commit) {
  Editor injectedEditor = editor;
  if (editor != null) {
    PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
    PsiFile psiFile = documentManager.getCachedPsiFile(editor.getDocument());
    if (psiFile != null) {
      if (commit) documentManager.commitAllDocuments();
      injectedEditor = InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, psiFile);
    }
  }
  return injectedEditor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:BaseCodeInsightAction.java

示例8: createDomHighlighter

import com.intellij.psi.PsiDocumentManager; //导入方法依赖的package包/类
@Override
public BackgroundEditorHighlighter createDomHighlighter(final Project project, final PerspectiveFileEditor editor, final DomElement element) {
  return new BackgroundEditorHighlighter() {
    @Override
    @NotNull
    public HighlightingPass[] createPassesForEditor() {
      if (!element.isValid()) return HighlightingPass.EMPTY_ARRAY;
      
      final XmlFile psiFile = DomUtil.getFile(element);

      final PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
      final Document document = psiDocumentManager.getDocument(psiFile);
      if (document == null) return HighlightingPass.EMPTY_ARRAY;

      editor.commit();

      psiDocumentManager.commitAllDocuments();

      GeneralHighlightingPass ghp = new GeneralHighlightingPass(project, psiFile, document, 0, document.getTextLength(),
                                                                true, new ProperTextRange(0, document.getTextLength()), null, new DefaultHighlightInfoProcessor());
      LocalInspectionsPass lip = new LocalInspectionsPass(psiFile, document, 0,
                                                          document.getTextLength(), LocalInspectionsPass.EMPTY_PRIORITY_RANGE, true,
                                                          new DefaultHighlightInfoProcessor());
      return new HighlightingPass[]{ghp, lip};
    }

    @Override
    @NotNull
    public HighlightingPass[] createPassesForVisibleArea() {
      return createPassesForEditor();
    }
  };

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:DomUIFactoryImpl.java


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