public async Task<IEnumerable<IPeekableItem>> GetPeekableItemsAsync(ISymbol symbol, Project project, IPeekResultFactory peekResultFactory, CancellationToken cancellationToken)
        {
            if (symbol == null)
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (peekResultFactory == null)
            {
                throw new ArgumentNullException(nameof(peekResultFactory));
            }

            var results = new List<IPeekableItem>();

            var solution = project.Solution;
            var sourceDefinition = await SymbolFinder.FindSourceDefinitionAsync(symbol, solution, cancellationToken).ConfigureAwait(false);

            // And if our definition actually is from source, then let's re-figure out what project it came from
            if (sourceDefinition != null)
            {
                var originatingProject = solution.GetProject(sourceDefinition.ContainingAssembly, cancellationToken);

                project = originatingProject ?? project;
            }

            string filePath;
            int lineNumber;
            int charOffset;

            var symbolNavigationService = solution.Workspace.Services.GetService<ISymbolNavigationService>();

            if (symbolNavigationService.WouldNavigateToSymbol(symbol, solution, out filePath, out lineNumber, out charOffset))
            {
                var position = new LinePosition(lineNumber, charOffset);
                results.Add(new ExternalFilePeekableItem(new FileLinePositionSpan(filePath, position, position), PredefinedPeekRelationships.Definitions, peekResultFactory));
            }
            else
            {
                var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);
                var symbolKey = SymbolKey.Create(symbol, compilation, cancellationToken);

                var firstLocation = symbol.Locations.FirstOrDefault();
                if (firstLocation != null)
                {
                    if (firstLocation.IsInSource || _metadataAsSourceFileService.IsNavigableMetadataSymbol(symbol))
                    {
                        results.Add(new DefinitionPeekableItem(solution.Workspace, project.Id, symbolKey, peekResultFactory, _metadataAsSourceFileService));
                    }
                }
            }

            return results;
        }
Example #2
0
 public PeekableItemSourceProvider(
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IWaitIndicator waitIndicator)
 {
     _peekableItemFactory = peekableItemFactory;
     _peekResultFactory   = peekResultFactory;
     _waitIndicator       = waitIndicator;
 }
 public ExternalFilePeekableItem(
     FileLinePositionSpan span,
     IPeekRelationship relationship,
     IPeekResultFactory peekResultFactory)
     : base(peekResultFactory)
 {
     _span = span;
     _relationship = relationship;
 }
Example #4
0
 public PeekableItemSource(
     ITextBuffer textBuffer,
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IUIThreadOperationExecutor uiThreadOperationExecutor)
 {
     _textBuffer                = textBuffer;
     _peekableItemFactory       = peekableItemFactory;
     _peekResultFactory         = peekResultFactory;
     _uiThreadOperationExecutor = uiThreadOperationExecutor;
 }
 public DefinitionPeekableItem(
     Workspace workspace, ProjectId projectId, SymbolKey symbolKey,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService)
     : base(peekResultFactory)
 {
     _workspace = workspace;
     _projectId = projectId;
     _symbolKey = symbolKey;
     _metadataAsSourceFileService = metadataAsSourceService;
 }
Example #6
0
 public PeekableItemSourceProvider(
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService,
     IWaitIndicator waitIndicator)
 {
     _peekableItemFactory     = peekableItemFactory;
     _peekResultFactory       = peekResultFactory;
     _metadataAsSourceService = metadataAsSourceService;
     _waitIndicator           = waitIndicator;
 }
Example #7
0
 public PeekableItemSourceProvider(
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IThreadingContext threadingContext,
     IUIThreadOperationExecutor uiThreadOperationExecutor)
 {
     _peekableItemFactory       = peekableItemFactory;
     _peekResultFactory         = peekResultFactory;
     _threadingContext          = threadingContext;
     _uiThreadOperationExecutor = uiThreadOperationExecutor;
 }
Example #8
0
 public PeekableItemSource(
     ITextBuffer textBuffer,
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IWaitIndicator waitIndicator)
 {
     _textBuffer          = textBuffer;
     _peekableItemFactory = peekableItemFactory;
     _peekResultFactory   = peekResultFactory;
     _waitIndicator       = waitIndicator;
 }
 public PeekableItemSourceProvider(
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService,
     IWaitIndicator waitIndicator)
 {
     _peekableItemFactory = peekableItemFactory;
     _peekResultFactory = peekResultFactory;
     _metadataAsSourceService = metadataAsSourceService;
     _waitIndicator = waitIndicator;
 }
 public DefinitionPeekableItem(
     Workspace workspace, ProjectId projectId, SymbolKey symbolKey,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService)
     : base(peekResultFactory)
 {
     _workspace = workspace;
     _projectId = projectId;
     _symbolKey = symbolKey;
     _metadataAsSourceFileService = metadataAsSourceService;
 }
Example #11
0
 internal static IDocumentPeekResult CreateDocumentPeekResult(string filePath, LinePositionSpan identifierLocation, LinePositionSpan entityOfInterestSpan, PeekResultDisplayInfo displayInfo, IPeekResultFactory peekResultFactory, bool isReadOnly)
 {
     return peekResultFactory.Create(
         displayInfo,
         filePath: filePath,
         startLine: entityOfInterestSpan.Start.Line,
         startIndex: entityOfInterestSpan.Start.Character,
         endLine: entityOfInterestSpan.End.Line,
         endIndex: entityOfInterestSpan.End.Character,
         idLine: identifierLocation.Start.Line,
         idIndex: identifierLocation.Start.Character,
         isReadOnly: isReadOnly);
 }
Example #12
0
 public PeekableItemSource(
     ITextBuffer textBuffer,
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService,
     IWaitIndicator waitIndicator)
 {
     _textBuffer = textBuffer;
     _peekableItemFactory = peekableItemFactory;
     _peekResultFactory = peekResultFactory;
     _metadataAsSourceService = metadataAsSourceService;
     _waitIndicator = waitIndicator;
 }
Example #13
0
 public PeekableItemSource(
     ITextBuffer textBuffer,
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService,
     IWaitIndicator waitIndicator)
 {
     _textBuffer              = textBuffer;
     _peekableItemFactory     = peekableItemFactory;
     _peekResultFactory       = peekResultFactory;
     _metadataAsSourceService = metadataAsSourceService;
     _waitIndicator           = waitIndicator;
 }
Example #14
0
        internal static IDocumentPeekResult CreateDocumentPeekResult(string filePath, LinePositionSpan identifierLocation, LinePositionSpan entityOfInterestSpan, IPeekResultFactory peekResultFactory)
        {
            var fileName = Path.GetFileName(filePath);
            var label = string.Format("{0} - ({1}, {2})", fileName, identifierLocation.Start.Line + 1, identifierLocation.Start.Character + 1);

            var displayInfo = new PeekResultDisplayInfo(label: label, labelTooltip: filePath, title: fileName, titleTooltip: filePath);

            return CreateDocumentPeekResult(
                filePath,
                identifierLocation,
                entityOfInterestSpan,
                displayInfo,
                peekResultFactory,
                isReadOnly: false);
        }
Example #15
0
        private async Task <IPeekableItem> GetPeekableItemAsync(IPeekResultFactory peekResultFactory, ITextBuffer buffer, SnapshotPoint pt)
        {
            var entry = buffer.TryGetAnalysisEntry();

            if (entry == null)
            {
                return(null);
            }

            var result = await NavigableSymbolSource.GetDefinitionLocationsAsync(entry, pt).ConfigureAwait(false);

            if (result.Length > 0)
            {
                return(new PythonPeekableItem(peekResultFactory, result));
            }

            return(null);
        }
Example #16
0
        public async Task <IEnumerable <IPeekableItem> > GetPeekableItemsAsync(
            ISymbol symbol, Project project,
            IPeekResultFactory peekResultFactory,
            CancellationToken cancellationToken)
        {
            if (symbol == null)
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (peekResultFactory == null)
            {
                throw new ArgumentNullException(nameof(peekResultFactory));
            }

            var results = new List <IPeekableItem>();

            var solution         = project.Solution;
            var sourceDefinition = await SymbolFinder.FindSourceDefinitionAsync(symbol, solution, cancellationToken).ConfigureAwait(false);

            // And if our definition actually is from source, then let's re-figure out what project it came from
            if (sourceDefinition != null)
            {
                var originatingProject = solution.GetProject(sourceDefinition.ContainingAssembly, cancellationToken);

                project = originatingProject ?? project;
            }

            var symbolNavigationService = solution.Workspace.Services.GetService <ISymbolNavigationService>();
            var definitionItem          = symbol.ToNonClassifiedDefinitionItem(project, includeHiddenLocations: true);

            if (symbolNavigationService.WouldNavigateToSymbol(
                    definitionItem, solution, cancellationToken,
                    out var filePath, out var lineNumber, out var charOffset))
            {
                var position = new LinePosition(lineNumber, charOffset);
                results.Add(new ExternalFilePeekableItem(new FileLinePositionSpan(filePath, position, position), PredefinedPeekRelationships.Definitions, peekResultFactory));
            }
Example #17
0
 internal static IDocumentPeekResult CreateDocumentPeekResult(
     string filePath,
     LinePositionSpan identifierLocation,
     LinePositionSpan entityOfInterestSpan,
     PeekResultDisplayInfo displayInfo,
     IPeekResultFactory peekResultFactory,
     bool isReadOnly
     )
 {
     return(peekResultFactory.Create(
                displayInfo,
                filePath: filePath,
                startLine: entityOfInterestSpan.Start.Line,
                startIndex: entityOfInterestSpan.Start.Character,
                endLine: entityOfInterestSpan.End.Line,
                endIndex: entityOfInterestSpan.End.Character,
                idLine: identifierLocation.Start.Line,
                idIndex: identifierLocation.Start.Character,
                isReadOnly: isReadOnly
                ));
 }
Example #18
0
        private static IEnumerable <IPeekableItem> GetPeekableItemsForNavigableItems(
            IEnumerable <INavigableItem>?navigableItems,
            Project project,
            IPeekResultFactory peekResultFactory,
            CancellationToken cancellationToken
            )
        {
            if (navigableItems != null)
            {
                var workspace         = project.Solution.Workspace;
                var navigationService =
                    workspace.Services.GetRequiredService <IDocumentNavigationService>();

                foreach (var item in navigableItems)
                {
                    var document = item.Document;
                    if (
                        navigationService.CanNavigateToPosition(
                            workspace,
                            document.Id,
                            item.SourceSpan.Start,
                            cancellationToken
                            )
                        )
                    {
                        var text             = document.GetTextSynchronously(cancellationToken);
                        var linePositionSpan = text.Lines.GetLinePositionSpan(item.SourceSpan);
                        if (document.FilePath != null)
                        {
                            yield return(new ExternalFilePeekableItem(
                                             new FileLinePositionSpan(document.FilePath, linePositionSpan),
                                             PredefinedPeekRelationships.Definitions,
                                             peekResultFactory
                                             ));
                        }
                    }
                }
            }
        }
 public InternalFunctionPeekItem(string sourceFileName, Span sourceSpan, string functionName, IPeekResultFactory peekResultFactory, ICoreShell shell) :
     base(functionName, peekResultFactory, shell) {
     // Create source right away so it can start asynchronous function fetching
     // so by the time GetOrCreateResultSource is called the task may be already underway.
     _source = new InternalFunctionPeekResultSource(sourceFileName, sourceSpan, functionName, this, shell);
 }
Example #20
0
 public XSharpDefinitionPeekItem(XSharpModel.XElement gotoElement, IPeekResultFactory peekResultFactory)
 {
     _gotoElement       = gotoElement;
     _peekResultFactory = peekResultFactory;
 }
Example #21
0
 public PeekableItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory, IServiceContainer services)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _services          = services;
 }
 public PeekableItemSource(ITextBuffer buffer, IPeekResultFactory peekResultFactory)
 {
     this.buffer = buffer;
     this.peekResultFactory = peekResultFactory;
 }
 public IdDefinitionPeekItem(string id, IPeekResultFactory peekResultFactory, ITextBuffer textbuffer)
 {
     _id = id;
     _peekResultFactory = peekResultFactory;
     _textbuffer = textbuffer;
 }
Example #24
0
        internal static IDocumentPeekResult CreateDocumentPeekResult(string filePath, LinePositionSpan identifierLocation, LinePositionSpan entityOfInterestSpan, IPeekResultFactory peekResultFactory)
        {
            var fileName = Path.GetFileName(filePath);
            var label    = string.Format("{0} - ({1}, {2})", fileName, identifierLocation.Start.Line + 1, identifierLocation.Start.Character + 1);

            var displayInfo = new PeekResultDisplayInfo(label: label, labelTooltip: filePath, title: fileName, titleTooltip: filePath);

            return(CreateDocumentPeekResult(
                       filePath,
                       identifierLocation,
                       entityOfInterestSpan,
                       displayInfo,
                       peekResultFactory,
                       isReadOnly: false));
        }
Example #25
0
 public PeekableItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
 }
 public ClassPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer = textBuffer;
     _peekResultFactory = peekResultFactory;
 }
Example #27
0
 public ClassPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
 }
 public XSharpDefinitionPeekItem(XSourceSymbol gotoElement, IPeekResultFactory peekResultFactory)
 {
     _gotoElement       = gotoElement;
     _peekResultFactory = peekResultFactory;
 }
 public PeekableItemSourceProvider(IPeekResultFactory peekResultFactory, ICoreShell shell) {
     _peekResultFactory = peekResultFactory;
     _shell = shell;
 }
Example #30
0
        private static IEnumerable<IPeekableItem> GetPeekableItemsForNavigableItems(
            IEnumerable<INavigableItem> navigableItems, Project project,
            IPeekResultFactory peekResultFactory,
            CancellationToken cancellationToken)
        {
            if (navigableItems != null)
            {
                var workspace = project.Solution.Workspace;
                var navigationService = workspace.Services.GetService<IDocumentNavigationService>();

                foreach (var item in navigableItems)
                {
                    var document = item.Document;
                    if (navigationService.CanNavigateToPosition(workspace, document.Id, item.SourceSpan.Start))
                    {
                        var text = document.GetTextAsync(cancellationToken).WaitAndGetResult(cancellationToken);
                        var linePositionSpan = text.Lines.GetLinePositionSpan(item.SourceSpan);
                        yield return new ExternalFilePeekableItem(
                            new FileLinePositionSpan(document.FilePath, linePositionSpan),
                            PredefinedPeekRelationships.Definitions, peekResultFactory);
                    }
                }
            }
        }
Example #31
0
 protected PeekableItem(IPeekResultFactory peekResultFactory)
 {
     this.PeekResultFactory = peekResultFactory;
 }
Example #32
0
 public UserDefinedPeekItem(string fileName, IAstNode definitionNode, string name, IPeekResultFactory peekResultFactory, ICoreShell shell) :
     base(name, peekResultFactory, shell) {
     DefinitionNode = definitionNode;
     FileName = fileName;
 }
 public ClassDefinitionPeekItem(string className, IPeekResultFactory peekResultFactory, ITextBuffer textbuffer)
 {
     _className         = className;
     _peekResultFactory = peekResultFactory;
     _textbuffer        = textbuffer;
 }
Example #34
0
        public async Task <IEnumerable <IPeekableItem> > GetPeekableItemsAsync(ISymbol symbol, Project project, IPeekResultFactory peekResultFactory, CancellationToken cancellationToken)
        {
            if (symbol == null)
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            if (peekResultFactory == null)
            {
                throw new ArgumentNullException(nameof(peekResultFactory));
            }

            var results = new List <IPeekableItem>();

            var solution         = project.Solution;
            var sourceDefinition = await SymbolFinder.FindSourceDefinitionAsync(symbol, solution, cancellationToken).ConfigureAwait(false);

            // And if our definition actually is from source, then let's re-figure out what project it came from
            if (sourceDefinition != null)
            {
                var originatingProject = solution.GetProject(sourceDefinition.ContainingAssembly, cancellationToken);

                project = originatingProject ?? project;
            }

            string filePath;
            int    lineNumber;
            int    charOffset;

            var symbolNavigationService = solution.Workspace.Services.GetService <ISymbolNavigationService>();

            if (symbolNavigationService.WouldNavigateToSymbol(symbol, solution, out filePath, out lineNumber, out charOffset))
            {
                var position = new LinePosition(lineNumber, charOffset);
                results.Add(new ExternalFilePeekableItem(new FileLinePositionSpan(filePath, position, position), PredefinedPeekRelationships.Definitions, peekResultFactory));
            }
            else
            {
                var symbolKey = SymbolKey.Create(symbol, cancellationToken);

                var firstLocation = symbol.Locations.FirstOrDefault();
                if (firstLocation != null)
                {
                    if (firstLocation.IsInSource || _metadataAsSourceFileService.IsNavigableMetadataSymbol(symbol))
                    {
                        results.Add(new DefinitionPeekableItem(solution.Workspace, project.Id, symbolKey, peekResultFactory, _metadataAsSourceFileService));
                    }
                }
            }

            return(results);
        }
 public InternalFunctionPeekItem(string sourceFileName, Span sourceSpan, string functionName, IPeekResultFactory peekResultFactory, ICoreShell shell) :
     base(functionName, peekResultFactory, shell)
 {
     // Create source right away so it can start asynchronous function fetching
     // so by the time GetOrCreateResultSource is called the task may be already underway.
     _source = new InternalFunctionPeekResultSource(sourceFileName, sourceSpan, functionName, this, shell);
 }
Example #36
0
 public PeekableItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory, ICoreShell shell)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _shell             = shell;
 }
 public XSharpPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory, XFile file)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _file = file;
 }
Example #38
0
 public PeekItemBase(string name, IPeekResultFactory peekResultFactory, ICoreShell shell) {
     PeekResultFactory = peekResultFactory;
     Shell = shell;
     DisplayName = name;
 }
Example #39
0
 public PythonPeekResultSource(IPeekResultFactory peekResultFactory, IAnalysisVariable[] variables)
 {
     _peekResultFactory = peekResultFactory ?? throw new ArgumentNullException(nameof(peekResultFactory));
     _variables         = variables ?? throw new ArgumentNullException(nameof(variables));
 }
 public ClassDefinitionPeekItem(string className, IPeekResultFactory peekResultFactory, ITextBuffer textbuffer)
 {
     _className = className;
     _peekResultFactory = peekResultFactory;
     _textbuffer = textbuffer;
 }
Example #41
0
 public IdDefinitionPeekItem(string id, IPeekResultFactory peekResultFactory, ITextBuffer textbuffer)
 {
     _id = id;
     _peekResultFactory = peekResultFactory;
     _textbuffer        = textbuffer;
 }
Example #42
0
 public PeekResultSource(IPeekResultFactory peekResultFactory, INavigationToken navigationToken)
 {
     _peekResultFactory = peekResultFactory;
     _token             = navigationToken;
 }
 public XSharpPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _file = textBuffer.GetFile();
 }
 public PeekableItemSourceProvider(IPeekResultFactory peekResultFactory, ICoreShell shell)
 {
     _peekResultFactory = peekResultFactory;
     _shell             = shell;
 }
Example #45
0
 protected PeekableItem(IPeekResultFactory peekResultFactory)
 {
     this.PeekResultFactory = peekResultFactory;
 }
 public MyPeekItem(IPeekResultFactory peekResultFactory)
 {
     this.peekResultFactory = peekResultFactory;
 }
Example #47
0
 public PythonPeekResultSource(IPeekResultFactory peekResultFactory, AnalysisLocation[] locations)
 {
     _peekResultFactory = peekResultFactory ?? throw new ArgumentNullException(nameof(peekResultFactory));
     _locations         = locations ?? throw new ArgumentNullException(nameof(locations));
 }
Example #48
0
 public PeekableItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory, ICoreShell shell) {
     _textBuffer = textBuffer;
     _peekResultFactory = peekResultFactory;
     _shell = shell;
 }