本文整理汇总了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;
}
示例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()
);
}
}
}
示例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);
}
}
示例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);
}
};
}
示例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()));
}
示例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());
}