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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 public IEnumerable <IColorElement> GetColorTable()
 {
     return(UnityNamedColors.GetColorTable());
 }