Exemplo n.º 1
0
        /// <summary>
        /// Finds a declaration (excluding methods) with the specified name
        /// </summary>
        /// <param name="name">The name of the declaration to search for.</param>
        /// <returns>The declaration with the specified name or null if not found.</returns>
        public IDeclaration GetDeclaration(string name)
        {
            // Project
            if (Project == null)
            {
                return(null);
            }

            IDeclaration superGlobalDeclaration = Project.GetDeclaration(name);

            if (superGlobalDeclaration != null)
            {
                return(superGlobalDeclaration);
            }

            // Sprite
            if (CurrentSprite == null)
            {
                return(null);
            }

            ITypedDeclaration globalDeclaration = CurrentSprite.GetDeclaration(name);

            if (globalDeclaration != null)
            {
                return(globalDeclaration);
            }

            // Methods
            if (CurrentScope == null)
            {
                return(null);
            }

            // Method params
            ParamDeclaration methodParam = (CurrentScope.Method as MethodDeclaration)?.FindParam(name);

            if (methodParam != null)
            {
                return(methodParam);
            }

            // Scoped variables
            return(CurrentScope.Search(name));
        }