Example #1
0
        public override void Visit(ExprDotName e)
        {
            MemberSelectExpr mse = null;

            if (e.ResolvedExpression is MemberSelectExpr)
            {
                mse = e.ResolvedExpression as MemberSelectExpr;
            }

            var nav          = new SymbolNavigator();
            var definingItem = nav.TopDown(RootNode, mse?.Member.tok);

            var declaration = FindDeclaration(e.SuffixName, definingItem);

            CreateSymbol(
                name: e.SuffixName,
                kind: null,
                type: e.Type,

                positionAsToken: e.tok,
                bodyStartPosAsToken: null,
                bodyEndPosAsToken: null,

                isDeclaration: false,
                declarationSymbol: declaration,
                addUsageAtDeclaration: true,

                canHaveChildren: false,
                canBeUsed: false
                );
        }
Example #2
0
        public override void Visit(TypeRhs e)
        {
            UserDefinedType t = null;

            if (e.Type is UserDefinedType type)
            {
                t = type;
            }

            if (t == null)
            {
                return;
            }

            var nav         = new SymbolNavigator();
            var declaration = nav.GetSymbolAtPosition(RootNode, t.ResolvedClass.tok);

            CreateSymbol(
                name: t.Name,
                kind: Kind.Class,
                type: e.Type,

                positionAsToken: t.tok,
                bodyStartPosAsToken: e.Tok,  //"new"
                bodyEndPosAsToken: t.tok,    //ClassName

                isDeclaration: false,
                declarationSymbol: declaration,
                addUsageAtDeclaration: true,

                canHaveChildren: false,
                canBeUsed: false
                );
        }
        protected ISymbolInformation FindDeclaration(string target, ISymbolInformation scope, Kind?kind = null)
        {
            ISymbolNavigator navigator = new SymbolNavigator();

            bool filter(ISymbolInformation s) => s.Name == target && s.IsDeclaration && (kind == null || s.Kind == kind);

            return(navigator.BottomUpFirst(scope, filter) ?? new SymbolInformation
            {
                Name = Resources.SymbolTableStrings.declaration_not_found,
                Position = new TokenPosition()
                {
                    Token = new Token(0, 0)
                },
                ChildrenHash = new Dictionary <string, ISymbolInformation>(),
                Usages = new List <ISymbolInformation>()
            });
        }
Example #4
0
        public override void Visit(NameSegment e)
        {
            var nav            = new SymbolNavigator();
            var resolvedSymbol = nav.TopDown(RootNode, e.ResolvedExpression.tok);

            var declaration = FindDeclaration(e.Name, resolvedSymbol);

            CreateSymbol(
                name: e.Name,
                kind: null,
                type: e.Type,

                positionAsToken: e.tok,
                bodyStartPosAsToken: null,
                bodyEndPosAsToken: null,

                isDeclaration: false,
                declarationSymbol: declaration,
                addUsageAtDeclaration: true,

                canHaveChildren: false,
                canBeUsed: false
                );
        }