Example #1
0
        private void GoToDefinition()
        {
            Position current = new Position();

            current.Save();
            current.ClearUpTo(CommandEnd);

            Console.WriteLine();

            LocationWithinFile p = VS.GetCurrentLocation(Options.DatabasePath);

            if (p == null)
            {
                Console.WriteLine("Unable to find current cursor position.");
                return;
            }
            else
            {
                Console.WriteLine("Finding Symbol at {0}({1}, {2})", p.FilePath, p.Line, p.CharInLine);
            }

            RoslynDefinitionFinder finder = new RoslynDefinitionFinder(p.FilePath, this.References);
            MemberQuery            query  = finder.BuildQueryForMemberUsedAt(p.Line, p.CharInLine);

            query.IgnoreCase = Options.IgnoreCase;

            if (query == null)
            {
                Console.WriteLine("Unable to identify symbol.");
                return;
            }

            Console.Write("Roslyn identified as {0}", query.SymbolName);
            if (query.Parameters.Length > 0)
            {
                Console.Write("({0})", query.Parameters);
            }
            Console.WriteLine();

            PartialArray <Symbol> results = new PartialArray <Symbol>(1);

            if (query.TryFindMembers(this.Database, ref results))
            {
                OpenSymbol(results[0]);
            }
            else
            {
                Console.WriteLine("NOT FOUND");
            }

            CommandEnd.Save();
        }