Search in sources :

Example 11 with ThreeState

use of com.intellij.util.ThreeState in project go-lang-idea-plugin by go-lang-plugin-org.

the class GoTargetSystem method forModule.

@NotNull
public static GoTargetSystem forModule(@NotNull Module module) {
    return CachedValuesManager.getManager(module.getProject()).getCachedValue(module, () -> {
        GoBuildTargetSettings settings = GoModuleSettings.getInstance(module).getBuildTargetSettings();
        String os = realValue(settings.os, GoUtil.systemOS());
        String arch = realValue(settings.arch, GoUtil.systemArch());
        ThreeState cgo = settings.cgo == ThreeState.UNSURE ? GoUtil.systemCgo(os, arch) : settings.cgo;
        String moduleSdkVersion = GoSdkService.getInstance(module.getProject()).getSdkVersion(module);
        String[] customFlags = GoSdkService.getInstance(module.getProject()).isAppEngineSdk(module) ? ArrayUtil.prepend(GAE_BUILD_FLAG, settings.customFlags) : settings.customFlags;
        String compiler = GoBuildTargetSettings.ANY_COMPILER.equals(settings.compiler) ? null : settings.compiler;
        GoTargetSystem result = new GoTargetSystem(os, arch, realValue(settings.goVersion, moduleSdkVersion), compiler, cgo, customFlags);
        return CachedValueProvider.Result.create(result, settings);
    });
}
Also used : ThreeState(com.intellij.util.ThreeState) GoBuildTargetSettings(com.goide.project.GoBuildTargetSettings) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with ThreeState

use of com.intellij.util.ThreeState in project intellij-community by JetBrains.

the class LoginPerformer method checkLoginWorker.

public static ThreeState checkLoginWorker(final CvsLoginWorker worker, final boolean forceCheckParam) throws AuthenticationException {
    boolean forceCheck = forceCheckParam;
    final Ref<Boolean> promptResult = new Ref<>();
    final Runnable prompt = () -> promptResult.set(worker.promptForPassword());
    while (true) {
        final ThreeState state = worker.silentLogin(forceCheck);
        if (ThreeState.YES.equals(state))
            return ThreeState.YES;
        if (ThreeState.NO.equals(state))
            return state;
        try {
            // hack: allow indeterminate progress bar time to appear before displaying login dialog.
            // otherwise progress bar without cancel button appears on top of login dialog, blocking input and hanging IDEA.
            Thread.sleep(1000L);
        } catch (InterruptedException ignore) {
            return ThreeState.NO;
        }
        UIUtil.invokeAndWaitIfNeeded(prompt);
        if (!Boolean.TRUE.equals(promptResult.get())) {
            // canceled
            return ThreeState.UNSURE;
        }
        forceCheck = true;
    }
}
Also used : ThreeState(com.intellij.util.ThreeState) Ref(com.intellij.openapi.util.Ref)

Example 13 with ThreeState

use of com.intellij.util.ThreeState in project intellij-community by JetBrains.

the class VcsContentAnnotationImpl method intervalRecentlyChanged.

@Override
public boolean intervalRecentlyChanged(VirtualFile file, TextRange lineInterval, VcsRevisionNumber currentRevisionNumber) {
    final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
    final AbstractVcs vcs = vcsManager.getVcsFor(file);
    if (vcs == null || vcs.getDiffProvider() == null)
        return false;
    if (currentRevisionNumber == null) {
        currentRevisionNumber = vcs.getDiffProvider().getCurrentRevision(file);
        assert currentRevisionNumber != null;
    }
    final ThreeState isRecent = myContentAnnotationCache.isRecent(file, vcs.getKeyInstanceMethod(), currentRevisionNumber, lineInterval, System.currentTimeMillis() - mySettings.getLimit());
    if (!ThreeState.UNSURE.equals(isRecent))
        return ThreeState.YES.equals(isRecent);
    final FileAnnotation fileAnnotation;
    try {
        fileAnnotation = vcs.getAnnotationProvider().annotate(file);
    } catch (VcsException e) {
        LOG.info(e);
        return false;
    }
    myContentAnnotationCache.register(file, vcs.getKeyInstanceMethod(), currentRevisionNumber, fileAnnotation);
    for (int i = lineInterval.getStartOffset(); i <= lineInterval.getEndOffset(); i++) {
        Date lineDate = fileAnnotation.getLineDate(i);
        if (lineDate != null && isRecent(lineDate))
            return true;
    }
    return false;
}
Also used : ThreeState(com.intellij.util.ThreeState) VcsException(com.intellij.openapi.vcs.VcsException) FileAnnotation(com.intellij.openapi.vcs.annotate.FileAnnotation) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) Date(java.util.Date)

Example 14 with ThreeState

use of com.intellij.util.ThreeState in project intellij-community by JetBrains.

the class CodeCompletionHandlerBase method shouldSkipAutoPopup.

private static boolean shouldSkipAutoPopup(Editor editor, PsiFile psiFile) {
    int offset = editor.getCaretModel().getOffset();
    int psiOffset = Math.max(0, offset - 1);
    PsiElement elementAt = InjectedLanguageUtil.findInjectedElementNoCommit(psiFile, psiOffset);
    if (elementAt == null) {
        elementAt = psiFile.findElementAt(psiOffset);
    }
    if (elementAt == null)
        return true;
    Language language = PsiUtilCore.findLanguageFromElement(elementAt);
    for (CompletionConfidence confidence : CompletionConfidenceEP.forLanguage(language)) {
        final ThreeState result = confidence.shouldSkipAutopopup(elementAt, psiFile, offset);
        if (result != ThreeState.UNSURE) {
            LOG.debug(confidence + " has returned shouldSkipAutopopup=" + result);
            return result == ThreeState.YES;
        }
    }
    return false;
}
Also used : ThreeState(com.intellij.util.ThreeState) Language(com.intellij.lang.Language) PsiElement(com.intellij.psi.PsiElement)

Example 15 with ThreeState

use of com.intellij.util.ThreeState in project intellij-community by JetBrains.

the class ShowIntentionActionsHandler method availableFor.

public static boolean availableFor(@NotNull PsiFile psiFile, @NotNull Editor editor, @NotNull IntentionAction action) {
    if (!psiFile.isValid())
        return false;
    int offset = editor.getCaretModel().getOffset();
    PsiElement psiElement = psiFile.findElementAt(offset);
    boolean inProject = psiFile.getManager().isInProject(psiFile);
    try {
        Project project = psiFile.getProject();
        if (action instanceof SuppressIntentionActionFromFix) {
            final ThreeState shouldBeAppliedToInjectionHost = ((SuppressIntentionActionFromFix) action).isShouldBeAppliedToInjectionHost();
            if (editor instanceof EditorWindow && shouldBeAppliedToInjectionHost == ThreeState.YES) {
                return false;
            }
            if (!(editor instanceof EditorWindow) && shouldBeAppliedToInjectionHost == ThreeState.NO) {
                return false;
            }
        }
        if (action instanceof PsiElementBaseIntentionAction) {
            if (!inProject || psiElement == null || !((PsiElementBaseIntentionAction) action).isAvailable(project, editor, psiElement))
                return false;
        } else if (!action.isAvailable(project, editor, psiFile)) {
            return false;
        }
    } catch (IndexNotReadyException e) {
        return false;
    }
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) SuppressIntentionActionFromFix(com.intellij.codeInspection.SuppressIntentionActionFromFix) ThreeState(com.intellij.util.ThreeState) IndexNotReadyException(com.intellij.openapi.project.IndexNotReadyException) PsiElementBaseIntentionAction(com.intellij.codeInsight.intention.PsiElementBaseIntentionAction) PsiElement(com.intellij.psi.PsiElement) EditorWindow(com.intellij.injected.editor.EditorWindow)

Aggregations

ThreeState (com.intellij.util.ThreeState)21 PsiElement (com.intellij.psi.PsiElement)4 NotNull (org.jetbrains.annotations.NotNull)4 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)3 Project (com.intellij.openapi.project.Project)3 Ref (com.intellij.openapi.util.Ref)3 SourcePosition (com.intellij.debugger.SourcePosition)2 SuspendContextImpl (com.intellij.debugger.engine.SuspendContextImpl)2 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 ExpressionEvaluator (com.intellij.debugger.engine.evaluation.expression.ExpressionEvaluator)2 JavaLanguage (com.intellij.lang.java.JavaLanguage)2 Logger (com.intellij.openapi.diagnostic.Logger)2 Document (com.intellij.openapi.editor.Document)2 TextEditor (com.intellij.openapi.fileEditor.TextEditor)2 TextRange (com.intellij.openapi.util.TextRange)2 Registry (com.intellij.openapi.util.registry.Registry)2 Client (com.android.ddmlib.Client)1 ClientData (com.android.ddmlib.ClientData)1 IDevice (com.android.ddmlib.IDevice)1 GoBuildTargetSettings (com.goide.project.GoBuildTargetSettings)1