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