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);
});
}
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;
}
}
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;
}
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;
}
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;
}
Aggregations