Java Code Examples for com.intellij.codeInsight.completion.impl.CompletionServiceImpl#assertPhase()
The following examples show how to use
com.intellij.codeInsight.completion.impl.CompletionServiceImpl#assertPhase() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompletionProgressIndicator.java From consulo with Apache License 2.0 | 6 votes |
private void finishCompletionProcess(boolean disposeOffsetMap) { cancel(); ApplicationManager.getApplication().assertIsDispatchThread(); Disposer.dispose(myQueue); LookupManager.getInstance(getProject()).removePropertyChangeListener(myLookupManagerListener); CompletionServiceImpl.assertPhase(CompletionPhase.BgCalculation.class, CompletionPhase.ItemsCalculated.class, CompletionPhase.Synchronous.class, CompletionPhase.CommittingDocuments.class); CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCurrentCompletionProgressIndicator(); LOG.assertTrue(currentCompletion == this, currentCompletion + "!=" + this); CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase(); if (oldPhase instanceof CompletionPhase.CommittingDocuments) { LOG.assertTrue(((CompletionPhase.CommittingDocuments)oldPhase).indicator != null, oldPhase); ((CompletionPhase.CommittingDocuments)oldPhase).replaced = true; } CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion); if (disposeOffsetMap) { disposeIndicator(); } }
Example 2
Source File: CompletionProgressIndicator.java From consulo with Apache License 2.0 | 6 votes |
@TestOnly public static void cleanupForNextTest() { CompletionService completionService = ServiceManager.getService(CompletionService.class); if (!(completionService instanceof CompletionServiceImpl)) { return; } CompletionProgressIndicator currentCompletion = CompletionServiceImpl.getCurrentCompletionProgressIndicator(); if (currentCompletion != null) { currentCompletion.finishCompletionProcess(true); CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass()); } else { CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion); } StatisticsUpdate.cancelLastCompletionStatisticsUpdate(); }
Example 3
Source File: CompletionProgressIndicator.java From consulo with Apache License 2.0 | 5 votes |
public void closeAndFinish(boolean hideLookup) { if (!myLookup.isLookupDisposed()) { Lookup lookup = LookupManager.getActiveLookup(myEditor); LOG.assertTrue(lookup == myLookup, "lookup changed: " + lookup + "; " + this); } myLookup.removeLookupListener(myLookupListener); finishCompletionProcess(true); CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass()); if (hideLookup) { myLookup.hideLookup(true); } }
Example 4
Source File: CompletionPhase.java From consulo with Apache License 2.0 | 4 votes |
@Override public int newCompletionStarted(int time, boolean repeated) { CompletionServiceImpl.assertPhase(NoCompletion.getClass()); // will fail and log valuable info CompletionServiceImpl.setCompletionPhase(NoCompletion); return time; }
Example 5
Source File: CodeCompletionHandlerBase.java From consulo with Apache License 2.0 | 4 votes |
private void invokeCompletion(@Nonnull Project project, @Nonnull Editor editor, int time, boolean hasModifiers, @Nonnull Caret caret) { markCaretAsProcessed(caret); if (invokedExplicitly) { StatisticsUpdate.applyLastCompletionStatisticsUpdate(); } checkNoWriteAccess(); CompletionAssertions.checkEditorValid(editor); int offset = editor.getCaretModel().getOffset(); if (editor.isViewer() || editor.getDocument().getRangeGuard(offset, offset) != null) { editor.getDocument().fireReadOnlyModificationAttempt(); EditorModificationUtil.checkModificationAllowed(editor); return; } if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) { return; } CompletionPhase phase = CompletionServiceImpl.getCompletionPhase(); boolean repeated = phase.indicator != null && phase.indicator.isRepeatedInvocation(completionType, editor); final int newTime = phase.newCompletionStarted(time, repeated); if (invokedExplicitly) { time = newTime; } final int invocationCount = time; if (CompletionServiceImpl.isPhase(CompletionPhase.InsertedSingleItem.class)) { CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion); } CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass(), CompletionPhase.CommittingDocuments.class); if (invocationCount > 1 && completionType == CompletionType.BASIC) { FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.SECOND_BASIC_COMPLETION); } long startingTime = System.currentTimeMillis(); Runnable initCmd = () -> { CompletionInitializationContextImpl context = withTimeout(calcSyncTimeOut(startingTime), () -> CompletionInitializationUtil.createCompletionInitializationContext(project, editor, caret, invocationCount, completionType)); boolean hasValidContext = context != null; if (!hasValidContext) { final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(caret, project); context = new CompletionInitializationContextImpl(editor, caret, psiFile, completionType, invocationCount); } doComplete(context, hasModifiers, hasValidContext, startingTime); }; try { if (autopopup) { CommandProcessor.getInstance().runUndoTransparentAction(initCmd); } else { CommandProcessor.getInstance().executeCommand(project, initCmd, null, null, editor.getDocument()); } } catch (IndexNotReadyException e) { if (invokedExplicitly) { DumbService.getInstance(project).showDumbModeNotification("Code completion is not available here while indices are being built"); } } }