public IconId GetImageId(IDeclaredElement declaredElement, PsiLanguageType languageType, out bool canApplyExtensions)
        {
            canApplyExtensions = false;

            var typeMember = declaredElement as ITypeMember;

            if (typeMember == null)
            {
                return(null);
            }

            if (!UnityColorTypes.IsColorProperty(typeMember))
            {
                return(null);
            }

            var color = UnityNamedColors.Get(typeMember.ShortName);

            if (color == null)
            {
                return(null);
            }

            return(new ColorIconId(color.Value));
        }
Exemple #2
0
        public static Pair <ITypeElement, ITypeMember>?PropertyFromColorElement(ITypeElement qualifierType, IColorElement colorElement, IPsiModule module)
        {
            var colorName = UnityNamedColors.GetColorName(colorElement.RGBColor);

            if (string.IsNullOrEmpty(colorName))
            {
                return(null);
            }

            var unityColorType = GetInstance(module).UnityColorType;

            if (unityColorType == null || !unityColorType.Equals(qualifierType))
            {
                return(null);
            }

            var colorProperties    = GetStaticColorProperties(unityColorType);
            var propertyTypeMember = colorProperties.FirstOrDefault(p => p.ShortName == colorName);

            if (propertyTypeMember == null)
            {
                return(null);
            }

            return(Pair.Of(unityColorType, propertyTypeMember));
        }
Exemple #3
0
        public static bool IsColorProperty(ITypeMember typeMember)
        {
            if (typeMember is IProperty && typeMember.IsStatic)
            {
                var unityColorTypes = GetInstance(typeMember.Module);
                return(unityColorTypes.IsUnityColorTypeSupportingProperties(typeMember.GetContainingType()) &&
                       UnityNamedColors.Get(typeMember.ShortName).HasValue);
            }

            return(false);
        }
 public IEnumerable <IColorElement> GetColorTable()
 {
     return(UnityNamedColors.GetColorTable());
 }