Esempio n. 1
0
        public override void VisitVariableDeclarationStatement(VariableDeclarationStatementSyntax node)
        {
            var variables = node.Declaration.Variables.ToList();

            var lastDeclarator  = variables.Last();
            var firstDeclarator = variables.First();

            if (!node.GetFirstToken().Span.IsInRootFile)
            {
                return;
            }

            var declarationRootSpan     = node.Declaration.GetTextSpanRoot();
            var firstDeclaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, declarationRootSpan.Start, firstDeclarator.GetTextSpanRoot().End);

            if (firstDeclarator == lastDeclarator)
            {
                firstDeclaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, firstDeclaratorTextSpan.Start, node.GetTextSpanRoot().End);
            }

            ProcessItem(firstDeclarator.Identifier, firstDeclarator.Identifier.Text, firstDeclaratorTextSpan, NavigateToItemKind.Field, node.Parent, Glyph.Variable);

            foreach (var declarator in variables.Skip(1))
            {
                var declaratorTextSpan = declarator.GetTextSpanRoot();
                if (declarator == lastDeclarator)
                {
                    declaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, declaratorTextSpan.Start, node.GetTextSpanRoot().End);
                }
                ProcessItem(declarator.Identifier, declarator.Identifier.Text, declaratorTextSpan, NavigateToItemKind.Field, node.Parent, Glyph.Variable);
            }
        }
        public override IEnumerable <EditorNavigationTarget> VisitVariableDeclarationStatement(VariableDeclarationStatementSyntax node)
        {
            // The first declarator span includes the initial declaration.
            // The last declarator span includes the semicolon.

            var variables = node.Declaration.Variables.ToList();

            var lastDeclarator  = variables.Last();
            var firstDeclarator = variables.First();

            if (!node.GetFirstToken().Span.IsInRootFile)
            {
                yield break;
            }

            var declarationRootSpan     = node.Declaration.GetTextSpanRoot();
            var firstDeclaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, declarationRootSpan.Start, firstDeclarator.GetTextSpanRoot().End);

            if (firstDeclarator == lastDeclarator)
            {
                firstDeclaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, firstDeclaratorTextSpan.Start, node.GetTextSpanRoot().End);
            }

            yield return(CreateTarget(firstDeclarator.Identifier, firstDeclarator.Identifier.Text, firstDeclaratorTextSpan, Glyph.Variable));

            foreach (var declarator in variables.Skip(1))
            {
                var declaratorTextSpan = declarator.GetTextSpanRoot();
                if (declarator == lastDeclarator)
                {
                    declaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, declaratorTextSpan.Start, node.GetTextSpanRoot().End);
                }
                yield return(CreateTarget(declarator.Identifier, declarator.Identifier.Text, declaratorTextSpan, Glyph.Variable));
            }
        }
        public override void VisitVariableDeclarationStatement(VariableDeclarationStatementSyntax node)
        {
            var variables = node.Declaration.Variables.ToList();

            var lastDeclarator = variables.Last();
            var firstDeclarator = variables.First();

            if (!node.GetFirstToken().Span.IsInRootFile)
                return;

            var declarationRootSpan = node.Declaration.GetTextSpanRoot();
            var firstDeclaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, declarationRootSpan.Start, firstDeclarator.GetTextSpanRoot().End);

            if (firstDeclarator == lastDeclarator)
                firstDeclaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, firstDeclaratorTextSpan.Start, node.GetTextSpanRoot().End);

            ProcessItem(firstDeclarator.Identifier, firstDeclarator.Identifier.Text, firstDeclaratorTextSpan, NavigateToItemKind.Field, node.Parent, Glyph.Variable);

            foreach (var declarator in variables.Skip(1))
            {
                var declaratorTextSpan = declarator.GetTextSpanRoot();
                if (declarator == lastDeclarator)
                    declaratorTextSpan = TextSpan.FromBounds(declarationRootSpan.SourceText, declaratorTextSpan.Start, node.GetTextSpanRoot().End);
                ProcessItem(declarator.Identifier, declarator.Identifier.Text, declaratorTextSpan, NavigateToItemKind.Field, node.Parent, Glyph.Variable);
            }
        }