Search in sources :

Example 1 with CompletionPhase

use of com.intellij.codeInsight.completion.CompletionPhase in project intellij-community by JetBrains.

the class LookupTypedHandler method execute.

@Override
public void execute(@NotNull Editor originalEditor, char charTyped, @NotNull DataContext dataContext) {
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    PsiFile file = project == null ? null : PsiUtilBase.getPsiFileInEditor(originalEditor, project);
    if (file == null) {
        if (myOriginalHandler != null) {
            myOriginalHandler.execute(originalEditor, charTyped, dataContext);
        }
        return;
    }
    if (!EditorModificationUtil.checkModificationAllowed(originalEditor)) {
        return;
    }
    CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase();
    if (oldPhase instanceof CompletionPhase.CommittingDocuments && ((CompletionPhase.CommittingDocuments) oldPhase).isRestartingCompletion()) {
        assert oldPhase.indicator != null;
        oldPhase.indicator.scheduleRestart();
    }
    Editor editor = TypedHandler.injectedEditorIfCharTypedIsSignificant(charTyped, originalEditor, file);
    if (editor != originalEditor) {
        file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    }
    if (originalEditor.isInsertMode() && beforeCharTyped(charTyped, project, originalEditor, editor, file)) {
        return;
    }
    if (myOriginalHandler != null) {
        myOriginalHandler.execute(originalEditor, charTyped, dataContext);
    }
}
Also used : Project(com.intellij.openapi.project.Project) CompletionPhase(com.intellij.codeInsight.completion.CompletionPhase) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor)

Aggregations

CompletionPhase (com.intellij.codeInsight.completion.CompletionPhase)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 PsiFile (com.intellij.psi.PsiFile)1