Search in sources :

Example 6 with ThreeState

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

the class SkipDefaultsSerializationFilter method equal.

boolean equal(@Nullable Binding binding, @Nullable Object currentValue, @Nullable Object defaultValue) {
    if (defaultValue instanceof Element && currentValue instanceof Element) {
        return JDOMUtil.areElementsEqual((Element) currentValue, (Element) defaultValue);
    } else {
        if (currentValue == defaultValue) {
            return true;
        }
        if (currentValue == null || defaultValue == null) {
            return false;
        }
        if (binding instanceof BasePrimitiveBinding) {
            Binding referencedBinding = ((BasePrimitiveBinding) binding).myBinding;
            if (referencedBinding instanceof BeanBinding) {
                BeanBinding classBinding = (BeanBinding) referencedBinding;
                ThreeState compareByFields = classBinding.compareByFields;
                if (compareByFields == ThreeState.UNSURE) {
                    compareByFields = ReflectionUtil.getDeclaredMethod(classBinding.myBeanClass, "equals", Object.class) == null ? ThreeState.YES : ThreeState.NO;
                    classBinding.compareByFields = compareByFields;
                }
                if (compareByFields == ThreeState.YES) {
                    return classBinding.equalByFields(currentValue, defaultValue, this);
                }
            }
        }
        return Comparing.equal(currentValue, defaultValue);
    }
}
Also used : ThreeState(com.intellij.util.ThreeState) Element(org.jdom.Element)

Example 7 with ThreeState

use of com.intellij.util.ThreeState in project android by JetBrains.

the class GpuSampler method sample.

@Override
protected void sample(boolean forced) throws InterruptedException {
    Client client = getClient();
    assert client != null;
    IDevice device = client.getDevice();
    if (device != null) {
        try {
            ClientData data = client.getClientData();
            ThreeState newGpuProfilingState = myCurrentGfxinfoHandler.getIsEnabledOnDevice(device);
            if (newGpuProfilingState != ThreeState.UNSURE) {
                boolean newGpuBooleanState = newGpuProfilingState.toBoolean();
                setGpuProfileSetting(newGpuBooleanState);
            }
            if (myGpuProfileSetting) {
                myCurrentGfxinfoHandler.sample(device, data, getTimelineData());
            }
        } catch (RuntimeException e) {
            throw new InterruptedException("Sample error, interrupting.");
        } catch (Exception ignored) {
        }
    }
}
Also used : ThreeState(com.intellij.util.ThreeState) ClientData(com.android.ddmlib.ClientData) IDevice(com.android.ddmlib.IDevice) Client(com.android.ddmlib.Client)

Example 8 with ThreeState

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

the class PreferByKindWeigher method weigh.

@NotNull
@Override
public MyResult weigh(@NotNull LookupElement item) {
    final Object object = item.getObject();
    if (object instanceof PsiKeyword) {
        ThreeState result = isProbableKeyword(((PsiKeyword) object).getText());
        if (result == ThreeState.YES)
            return MyResult.probableKeyword;
        if (result == ThreeState.NO)
            return MyResult.improbableKeyword;
    }
    if (item.as(CastingLookupElementDecorator.CLASS_CONDITION_KEY) != null) {
        return MyResult.castVariable;
    }
    if (object instanceof PsiLocalVariable || object instanceof PsiParameter || object instanceof PsiThisExpression) {
        return MyResult.localOrParameter;
    }
    if (object instanceof String && item.getUserData(JavaCompletionUtil.SUPER_METHOD_PARAMETERS) == Boolean.TRUE) {
        return MyResult.superMethodParameters;
    }
    if (object instanceof PsiMethod) {
        PsiClass containingClass = ((PsiMethod) object).getContainingClass();
        if (containingClass != null && CommonClassNames.JAVA_UTIL_COLLECTIONS.equals(containingClass.getQualifiedName())) {
            return MyResult.collectionFactory;
        }
    }
    if (object instanceof PsiClass && CommonClassNames.JAVA_LANG_STRING.equals(((PsiClass) object).getQualifiedName()) && JavaSmartCompletionContributor.AFTER_NEW.accepts(myPosition)) {
        return MyResult.unlikelyClass;
    }
    Boolean expectedTypeMember = item.getUserData(MembersGetter.EXPECTED_TYPE_MEMBER);
    if (expectedTypeMember != null) {
        return expectedTypeMember ? (object instanceof PsiField ? MyResult.expectedTypeConstant : MyResult.expectedTypeMethod) : MyResult.classNameOrGlobalStatic;
    }
    if (item instanceof TypeArgumentCompletionProvider.TypeArgsLookupElement) {
        return MyResult.expectedTypeArgument;
    }
    final JavaChainLookupElement chain = item.as(JavaChainLookupElement.CLASS_CONDITION_KEY);
    if (chain != null) {
        Object qualifier = chain.getQualifier().getObject();
        if (qualifier instanceof PsiLocalVariable || qualifier instanceof PsiParameter) {
            return MyResult.localOrParameter;
        }
        if (qualifier instanceof PsiField) {
            return MyResult.qualifiedWithField;
        }
        if (isGetter(qualifier)) {
            return MyResult.qualifiedWithGetter;
        }
    }
    if (myCompletionType == CompletionType.SMART) {
        if (object instanceof PsiField)
            return MyResult.field;
        if (isGetter(object))
            return MyResult.getter;
        return MyResult.normal;
    }
    if (myCompletionType == CompletionType.BASIC) {
        StaticallyImportable callElement = item.as(StaticallyImportable.CLASS_CONDITION_KEY);
        if (callElement != null && callElement.canBeImported() && !callElement.willBeImported()) {
            return MyResult.classNameOrGlobalStatic;
        }
        if (object instanceof PsiMethod && PsiUtil.isAnnotationMethod((PsiElement) object)) {
            return MyResult.annoMethod;
        }
        if (object instanceof PsiClass) {
            if (myRequiredSuper.value((PsiClass) object)) {
                return MyResult.suitableClass;
            }
            return MyResult.classNameOrGlobalStatic;
        }
        if (object instanceof PsiField && myNonInitializedFields.contains(object)) {
            return MyResult.nonInitialized;
        }
    }
    return MyResult.normal;
}
Also used : ThreeState(com.intellij.util.ThreeState) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with ThreeState

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

the class AngularJSAttributeDescriptorsProvider method applicableDirective.

private static PsiElement applicableDirective(Project project, String directiveName, XmlTag tag, final StubIndexKey<String, JSImplicitElementProvider> index) {
    Ref<PsiElement> result = Ref.create(PsiUtilCore.NULL_PSI_ELEMENT);
    AngularIndexUtil.multiResolve(project, index, directiveName, (directive) -> {
        ThreeState applicable = isApplicable(project, tag, directive);
        if (applicable == ThreeState.YES) {
            result.set(directive);
        }
        if (applicable == ThreeState.NO && result.get() == PsiUtilCore.NULL_PSI_ELEMENT) {
            result.set(null);
        }
        return !result.isNull();
    });
    return result.get();
}
Also used : ThreeState(com.intellij.util.ThreeState) PsiElement(com.intellij.psi.PsiElement)

Example 10 with ThreeState

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

the class GoExecutor method in.

@NotNull
public static GoExecutor in(@NotNull Module module) {
    Project project = module.getProject();
    ThreeState vendoringEnabled = GoModuleSettings.getInstance(module).getVendoringEnabled();
    return new GoExecutor(project, module).withGoRoot(GoSdkService.getInstance(project).getSdkHomePath(module)).withGoPath(GoSdkUtil.retrieveGoPath(project, module)).withEnvPath(GoSdkUtil.retrieveEnvironmentPathForGo(project, module)).withVendoring(vendoringEnabled != ThreeState.UNSURE ? vendoringEnabled.toBoolean() : null);
}
Also used : Project(com.intellij.openapi.project.Project) ThreeState(com.intellij.util.ThreeState) NotNull(org.jetbrains.annotations.NotNull)

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