Example #1
0
        public override IDeclaredElement Analyze(IDeclaration node, IHighlightingConsumer consumer, DaemonProcessKind kind)
        {
            if (!(node is IClassLikeDeclaration element))
            {
                return(null);
            }

            var typeElement = element.DeclaredElement;

            if (typeElement != null)
            {
                if (myUnityApi.IsDescendantOfMonoBehaviour(typeElement))
                {
                    AddMonoBehaviourHiglighting(consumer, element, "Script", "Unity script", kind);
                }
                else if (myUnityApi.IsDescendantOf(KnownTypes.Editor, typeElement) ||
                         myUnityApi.IsDescendantOf(KnownTypes.EditorWindow, typeElement))
                {
                    AddEditorHiglighting(consumer, element, "Editor", "Custom Unity Editor", kind);
                }
                else if (myUnityApi.IsUnityType(typeElement))
                {
                    AddUnityTypeHighlighting(consumer, element, "Unity type", "Custom Unity type", kind);
                }
                else if (myUnityApi.IsUnityECSType(typeElement))
                {
                    AddUnityECSHighlighting(consumer, element, "Unity ECS", "Unity entity component system object",
                                            kind);
                }

                return(typeElement);
            }

            return(null);
        }
Example #2
0
        public IDeclaredElement Analyze(IDeclaration node, IHighlightingConsumer consumer, DaemonProcessKind kind)
        {
            if (!(node is IClassLikeDeclaration element))
            {
                return(null);
            }

            var typeElement = element.DeclaredElement;

            if (typeElement != null)
            {
                if (myUnityApi.IsUnityType(typeElement))
                {
                    myContributor.AddUnityImplicitClassUsage(consumer, element,
                                                             "Unity scripting component", "Scripting component", kind);
                }
                else if (myUnityApi.IsUnityECSType(typeElement))
                {
                    myContributor.AddUnityImplicitClassUsage(consumer, element,
                                                             "Unity entity component system object", "Unity ECS", kind);
                }

                return(typeElement);
            }

            return(null);
        }
Example #3
0
        private bool CanHaveAnyUsagesInUnity(IDeclaredElement declaredElement, UnityApi api)
        {
            if (declaredElement == null)
            {
                return(false);
            }
            if (declaredElement is IMethod method && !api.IsEventFunction(method) &&
                !api.IsUnityECSType(method.GetContainingType()))
            {
                return(true);
            }

            if (declaredElement is IClass type && !api.IsUnityECSType(type))
            {
                return(true);
            }

            return(false);
        }
        public override bool AddDeclarationHighlighting(IDeclaration node, IHighlightingConsumer consumer, DaemonProcessKind kind)
        {
            if (!(node is IClassLikeDeclaration element))
            {
                return(false);
            }

            var typeElement = element.DeclaredElement;

            if (typeElement != null)
            {
                if (typeElement.DerivesFromMonoBehaviour())
                {
                    AddMonoBehaviourHiglighting(consumer, element, "Script", "Unity script", kind);
                }
                else if (typeElement.DerivesFrom(KnownTypes.Editor) || typeElement.DerivesFrom(KnownTypes.EditorWindow))
                {
                    AddEditorHiglighting(consumer, element, "Editor", "Custom Unity Editor", kind);
                }
                else if (typeElement.DerivesFromScriptableObject())
                {
                    AddMonoBehaviourHiglighting(consumer, element, "Scriptable object", "Scriptable Object", kind);
                }
                else if (myUnityApi.IsUnityType(typeElement))
                {
                    AddUnityTypeHighlighting(consumer, element, "Unity type", "Custom Unity type", kind);
                }
                else if (myUnityApi.IsUnityECSType(typeElement))
                {
                    AddUnityECSHighlighting(consumer, element, "Unity ECS", "Unity entity component system object",
                                            kind);
                }

                return(true);
            }

            return(false);
        }