예제 #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();
        }
예제 #2
0
 public void Execute(object parameter)
 {
     CommandStart?.Invoke(this, new EventArgs());
     Task.Run(() =>
     {
         try
         {
             InternalExecute(parameter);
         }
         catch (OperationCanceledException ex)
         {
             CurrrentMessage = "Operation cancelled: " + ex.Message;
         }
         catch (Exception ex)
         {
             CurrrentMessage = "Exception occured: " + ex.Message;
         }
     }).ContinueWith
         (a =>
         CommandEnd?.Invoke(this, new EventArgs())
         );
 }
예제 #3
0
        public int Run()
        {
            Start.Save();

            if (!String.IsNullOrEmpty(Options.Query))
            {
                RunCommandLineSearch();
                return(_lastResult.Count);
            }

            // Capture Trace.WriteLine calls to show as status
            ConsoleProgressTraceListener listener = new ConsoleProgressTraceListener(this);

            Trace.Listeners.Add(listener);

            // Start the index loading
            Thread IndexThread = new Thread(LoadOrIndex);

            IndexThread.SetApartmentState(ApartmentState.STA);
            IndexThread.IsBackground = true;
            IndexThread.Start();

            // Start reading keystrokes
            while (Read())
            {
                RunQuery();
                Draw();
            }

            // Skip to the end of previous output on quit
            End.Restore();
            if (CommandEnd.CompareTo(End) > 0)
            {
                CommandEnd.Restore();
            }

            Console.WriteLine();
            return(_lastResult.Count);
        }