Example #1
0
        public static IList <Symbol> CollectSymbols(Core.SemanticModel.SemanticModel model)
        {
            var symbols = new List <Symbol>();
            var visitor = new SymbolCollectorVisitor(symbols);

            visitor.Visit(model.Root);

            return(symbols);
        }
Example #2
0
        public static bool NodeShouldBeBound(ISymbolReference symbolReference, Core.SemanticModel.SemanticModel semanticModel)
        {
            if (!(symbolReference is InstanceFunctionCallSyntax instanceFunctionCallSyntax))
            {
                return(true);
            }

            if (instanceFunctionCallSyntax.BaseExpression is VariableAccessSyntax baseVariableSyntax &&
                semanticModel.Root.ImportedNamespaces.ContainsKey(baseVariableSyntax.Name.IdentifierName))
            {
                // we only expect to have bound InstanceFunctionCallsSnytax if they accessed on a namespace - e.g. sys.concat(..)
                return(true);
            }

            return(false);
        }
Example #3
0
        private static List <SyntaxBase> GetAllBoundSymbolReferences(ProgramSyntax program, Core.SemanticModel.SemanticModel semanticModel)
        {
            return(SyntaxAggregator.Aggregate(
                       program,
                       new List <SyntaxBase>(),
                       (accumulated, current) =>
            {
                if (current is ISymbolReference symbolReference && TestSyntaxHelper.NodeShouldBeBound(symbolReference, semanticModel))
                {
                    accumulated.Add(current);
                }

                return accumulated;
            },