mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-207762 cleanup AutoPopupControllerImpl.java
GitOrigin-RevId: 7bdbe3eac2a65fcef59685a574cfdfaa400fe953
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e80d425ea0
commit
074d1f664b
@@ -157,43 +157,45 @@ class AutoPopupControllerImpl extends AutoPopupController {
|
||||
|
||||
ThreadingAssertions.assertEventDispatchThread();
|
||||
CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
if (settings.AUTO_POPUP_PARAMETER_INFO) {
|
||||
AtomicInteger offset = new AtomicInteger(-1);
|
||||
ReadAction.nonBlocking(() -> {
|
||||
offset.set(editor.getCaretModel().getOffset());
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(myProject);
|
||||
PsiFile file = documentManager.getPsiFile(editor.getDocument());
|
||||
if (!settings.AUTO_POPUP_PARAMETER_INFO) {
|
||||
return;
|
||||
}
|
||||
|
||||
AtomicInteger offset = new AtomicInteger(-1);
|
||||
ReadAction.nonBlocking(() -> {
|
||||
offset.set(editor.getCaretModel().getOffset());
|
||||
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;
|
||||
}
|
||||
|
||||
if (!documentManager.isUncommited(editor.getDocument())) {
|
||||
file = documentManager.getPsiFile(InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file).getDocument());
|
||||
if (file == null) return;
|
||||
}
|
||||
|
||||
Runnable request = () -> {
|
||||
if (!myProject.isDisposed() && !editor.isDisposed() && UIUtil.isShowing(editor.getContentComponent())) {
|
||||
int lbraceOffset = offset.get() - 1;
|
||||
try {
|
||||
PsiFile file1 = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
|
||||
if (file1 != null) {
|
||||
ShowParameterInfoHandler.invoke(myProject, editor, file1, lbraceOffset, highlightedMethod, false,
|
||||
true, null);
|
||||
}
|
||||
}
|
||||
catch (IndexNotReadyException ignored) { //anything can happen on alarm
|
||||
Runnable request = () -> {
|
||||
if (!myProject.isDisposed() && !editor.isDisposed() && UIUtil.isShowing(editor.getContentComponent())) {
|
||||
int lbraceOffset = offset.get() - 1;
|
||||
try {
|
||||
PsiFile file1 = PsiDocumentManager.getInstance(myProject).getPsiFile(editor.getDocument());
|
||||
if (file1 != null) {
|
||||
ShowParameterInfoHandler.invoke(myProject, editor, file1, lbraceOffset, highlightedMethod, false,
|
||||
true, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
catch (IndexNotReadyException ignored) { //anything can happen on alarm
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
myAlarm.addRequest(() -> documentManager.performLaterWhenAllCommitted(request), settings.PARAMETER_INFO_DELAY);
|
||||
}).expireWith(myAlarm)
|
||||
.coalesceBy(this, editor)
|
||||
.expireWhen(() -> {
|
||||
int initialOffset = offset.get();
|
||||
return editor.isDisposed() || initialOffset != -1 && editor.getCaretModel().getOffset() != initialOffset;
|
||||
})
|
||||
.submit(AppExecutorUtil.getAppExecutorService());
|
||||
}
|
||||
myAlarm.addRequest(() -> documentManager.performLaterWhenAllCommitted(request), settings.PARAMETER_INFO_DELAY);
|
||||
}).expireWith(myAlarm)
|
||||
.coalesceBy(this, editor)
|
||||
.expireWhen(() -> {
|
||||
int initialOffset = offset.get();
|
||||
return editor.isDisposed() || initialOffset != -1 && editor.getCaretModel().getOffset() != initialOffset;
|
||||
})
|
||||
.submit(AppExecutorUtil.getAppExecutorService());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user