當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiDocumentManager.isUncommited方法代碼示例

本文整理匯總了Java中com.intellij.psi.PsiDocumentManager.isUncommited方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiDocumentManager.isUncommited方法的具體用法?Java PsiDocumentManager.isUncommited怎麽用?Java PsiDocumentManager.isUncommited使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.psi.PsiDocumentManager的用法示例。


在下文中一共展示了PsiDocumentManager.isUncommited方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPsiFileForPsiDependentIndex

import com.intellij.psi.PsiDocumentManager; //導入方法依賴的package包/類
public PsiFile getPsiFileForPsiDependentIndex() {
  Document document = FileDocumentManager.getInstance().getCachedDocument(getFile());
  PsiFile psi = null;
  if (document != null) {
    PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(getProject());
    if (psiDocumentManager.isUncommited(document)) {
      PsiFile existingPsi = psiDocumentManager.getPsiFile(document);
      if(existingPsi != null) {
        psi = existingPsi;
      }
    }
  }
  if (psi == null) {
    psi = getPsiFile();
  }
  return psi;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:FileContentImpl.java

示例2: validateModel

import com.intellij.psi.PsiDocumentManager; //導入方法依賴的package包/類
private static void validateModel(FormattingModel model) throws FormattingModelInconsistencyException {
  FormattingDocumentModel documentModel = model.getDocumentModel();
  Document document = documentModel.getDocument();
  Block rootBlock = model.getRootBlock();
  if (rootBlock instanceof ASTBlock) {
    PsiElement rootElement = ((ASTBlock)rootBlock).getNode().getPsi();
    if (!rootElement.isValid()) {
      throw new FormattingModelInconsistencyException("Invalid root block PSI element");
    }
    PsiFile file = rootElement.getContainingFile();
    Project project = file.getProject();
    PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
    if (documentManager.isUncommited(document)) {
      throw new FormattingModelInconsistencyException("Uncommitted document");
    }
    if (document.getTextLength() != file.getTextLength()) {
      throw new FormattingModelInconsistencyException(
        "Document length " + document.getTextLength() +
        " doesn't match PSI file length " + file.getTextLength() + ", language: " + file.getLanguage()
      );
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:FormatterImpl.java

示例3: 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

示例4: buildInitialFoldings

import com.intellij.psi.PsiDocumentManager; //導入方法依賴的package包/類
@Nullable
@Override
public CodeFoldingState buildInitialFoldings(@NotNull final Document document) {
  if (myProject.isDisposed()) {
    return null;
  }
  ApplicationManager.getApplication().assertReadAccessAllowed();
  PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(myProject);
  if (psiDocumentManager.isUncommited(document)) {
    // skip building foldings for uncommitted document, CodeFoldingPass invoked by daemon will do it later
    return null;
  }
  //Do not save/restore folding for code fragments
  final PsiFile file = psiDocumentManager.getPsiFile(document);
  if (file == null || !file.isValid() || !file.getViewProvider().isPhysical() && !ApplicationManager.getApplication().isUnitTestMode()) {
    return null;
  }


  final FoldingUpdate.FoldingMap foldingMap = FoldingUpdate.getFoldingsFor(file, document, true);

  return new CodeFoldingState() {
    @Override
    public void setToEditor(@NotNull final Editor editor) {
      ApplicationManagerEx.getApplicationEx().assertIsDispatchThread();
      if (myProject.isDisposed() || editor.isDisposed()) return;
      final FoldingModelEx foldingModel = (FoldingModelEx)editor.getFoldingModel();
      if (!foldingModel.isFoldingEnabled()) return;
      if (isFoldingsInitializedInEditor(editor)) return;
      if (DumbService.isDumb(myProject) && !FoldingUpdate.supportsDumbModeFolding(editor)) return;

      foldingModel.runBatchFoldingOperationDoNotCollapseCaret(new UpdateFoldRegionsOperation(myProject, editor, file, foldingMap, YES, false));
      initFolding(editor);
    }
  };
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:37,代碼來源:CodeFoldingManagerImpl.java

示例5: assertCommitSuccessful

import com.intellij.psi.PsiDocumentManager; //導入方法依賴的package包/類
static void assertCommitSuccessful(Editor editor, PsiFile psiFile) {
  Document document = editor.getDocument();
  int docLength = document.getTextLength();
  int psiLength = psiFile.getTextLength();
  PsiDocumentManager manager = PsiDocumentManager.getInstance(psiFile.getProject());
  boolean committed = !manager.isUncommited(document);
  if (docLength == psiLength && committed) {
    return;
  }

  FileViewProvider viewProvider = psiFile.getViewProvider();

  String message = "unsuccessful commit:";
  message += "\nmatching=" + (psiFile == manager.getPsiFile(document));
  message += "\ninjectedEditor=" + (editor instanceof EditorWindow);
  message += "\ninjectedFile=" + InjectedLanguageManager.getInstance(psiFile.getProject()).isInjectedFragment(psiFile);
  message += "\ncommitted=" + committed;
  message += "\nfile=" + psiFile.getName();
  message += "\nfile class=" + psiFile.getClass();
  message += "\nfile.valid=" + psiFile.isValid();
  message += "\nfile.physical=" + psiFile.isPhysical();
  message += "\nfile.eventSystemEnabled=" + viewProvider.isEventSystemEnabled();
  message += "\nlanguage=" + psiFile.getLanguage();
  message += "\ndoc.length=" + docLength;
  message += "\npsiFile.length=" + psiLength;
  String fileText = psiFile.getText();
  if (fileText != null) {
    message += "\npsiFile.text.length=" + fileText.length();
  }
  FileASTNode node = psiFile.getNode();
  if (node != null) {
    message += "\nnode.length=" + node.getTextLength();
    String nodeText = node.getText();
    if (nodeText != null) {
      message += "\nnode.text.length=" + nodeText.length();
    }
  }
  VirtualFile virtualFile = viewProvider.getVirtualFile();
  message += "\nvirtualFile=" + virtualFile;
  message += "\nvirtualFile.class=" + virtualFile.getClass();
  message += "\n" + DebugUtil.currentStackTrace();

  throw new LogEventException("Commit unsuccessful", message,
                                     new Attachment(virtualFile.getPath() + "_file.txt", fileText),
                                     createAstAttachment(psiFile, psiFile),
                                     new Attachment("docText.txt", document.getText()));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:48,代碼來源:CompletionAssertions.java

示例6: canUseDocumentModel

import com.intellij.psi.PsiDocumentManager; //導入方法依賴的package包/類
public static boolean canUseDocumentModel(@NotNull Document document,@NotNull PsiFile file) {
  PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(file.getProject());
  return !psiDocumentManager.isUncommited(document) &&
         !psiDocumentManager.isDocumentBlockedByPsi(document) &&
         file.getText().equals(document.getText());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:FormattingDocumentModelImpl.java


注:本文中的com.intellij.psi.PsiDocumentManager.isUncommited方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。