private TypeKindOptions GetTypeKindOption(State state) { var gotPreassignedTypeOptions = GetPredefinedTypeKindOption(state, out var typeKindValue); if (!gotPreassignedTypeOptions) { typeKindValue = state.IsSimpleNameGeneric ? TypeKindOptionsHelper.RemoveOptions(typeKindValue, TypeKindOptions.GenericInCompatibleTypes) : typeKindValue; typeKindValue = state.IsMembersWithModule ? TypeKindOptionsHelper.AddOption(typeKindValue, TypeKindOptions.Module) : typeKindValue; typeKindValue = state.IsInterfaceOrEnumNotAllowedInTypeContext ? TypeKindOptionsHelper.RemoveOptions(typeKindValue, TypeKindOptions.Interface, TypeKindOptions.Enum) : typeKindValue; typeKindValue = state.IsDelegateAllowed ? typeKindValue : TypeKindOptionsHelper.RemoveOptions(typeKindValue, TypeKindOptions.Delegate); typeKindValue = state.IsEnumNotAllowed ? TypeKindOptionsHelper.RemoveOptions(typeKindValue, TypeKindOptions.Enum) : typeKindValue; } return(typeKindValue); }
private bool GetPredefinedTypeKindOption(State state, out TypeKindOptions typeKindValueFinal) { if (state.IsAttribute) { typeKindValueFinal = TypeKindOptions.Attribute; return(true); } TypeKindOptions typeKindValue = TypeKindOptions.None; if (_service.TryGetBaseList(state.NameOrMemberAccessExpression, out typeKindValue) || _service.TryGetBaseList(state.SimpleName, out typeKindValue)) { typeKindValueFinal = typeKindValue; return(true); } if (state.IsClassInterfaceTypes) { typeKindValueFinal = TypeKindOptions.BaseList; return(true); } if (state.IsDelegateOnly) { typeKindValueFinal = TypeKindOptions.Delegate; return(true); } if (state.IsTypeGeneratedIntoNamespaceFromMemberAccess) { typeKindValueFinal = state.IsSimpleNameGeneric ? TypeKindOptionsHelper.RemoveOptions(TypeKindOptions.MemberAccessWithNamespace, TypeKindOptions.GenericInCompatibleTypes) : TypeKindOptions.MemberAccessWithNamespace; typeKindValueFinal = state.IsEnumNotAllowed ? TypeKindOptionsHelper.RemoveOptions(typeKindValueFinal, TypeKindOptions.Enum) : typeKindValueFinal; return(true); } typeKindValueFinal = TypeKindOptions.AllOptions; return(false); }