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