コード例 #1
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 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;
        }
コード例 #2
0
 public PeekableItemSourceProvider(
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IWaitIndicator waitIndicator)
 {
     _peekableItemFactory = peekableItemFactory;
     _peekResultFactory   = peekResultFactory;
     _waitIndicator       = waitIndicator;
 }
コード例 #3
0
 public ExternalFilePeekableItem(
     FileLinePositionSpan span,
     IPeekRelationship relationship,
     IPeekResultFactory peekResultFactory)
     : base(peekResultFactory)
 {
     _span = span;
     _relationship = relationship;
 }
コード例 #4
0
 public PeekableItemSource(
     ITextBuffer textBuffer,
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IUIThreadOperationExecutor uiThreadOperationExecutor)
 {
     _textBuffer                = textBuffer;
     _peekableItemFactory       = peekableItemFactory;
     _peekResultFactory         = peekResultFactory;
     _uiThreadOperationExecutor = uiThreadOperationExecutor;
 }
コード例 #5
0
 public DefinitionPeekableItem(
     Workspace workspace, ProjectId projectId, SymbolKey symbolKey,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService)
     : base(peekResultFactory)
 {
     _workspace = workspace;
     _projectId = projectId;
     _symbolKey = symbolKey;
     _metadataAsSourceFileService = metadataAsSourceService;
 }
コード例 #6
0
 public PeekableItemSourceProvider(
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService,
     IWaitIndicator waitIndicator)
 {
     _peekableItemFactory     = peekableItemFactory;
     _peekResultFactory       = peekResultFactory;
     _metadataAsSourceService = metadataAsSourceService;
     _waitIndicator           = waitIndicator;
 }
コード例 #7
0
 public PeekableItemSourceProvider(
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IThreadingContext threadingContext,
     IUIThreadOperationExecutor uiThreadOperationExecutor)
 {
     _peekableItemFactory       = peekableItemFactory;
     _peekResultFactory         = peekResultFactory;
     _threadingContext          = threadingContext;
     _uiThreadOperationExecutor = uiThreadOperationExecutor;
 }
コード例 #8
0
 public PeekableItemSource(
     ITextBuffer textBuffer,
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IWaitIndicator waitIndicator)
 {
     _textBuffer          = textBuffer;
     _peekableItemFactory = peekableItemFactory;
     _peekResultFactory   = peekResultFactory;
     _waitIndicator       = waitIndicator;
 }
コード例 #9
0
 public PeekableItemSourceProvider(
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService,
     IWaitIndicator waitIndicator)
 {
     _peekableItemFactory = peekableItemFactory;
     _peekResultFactory = peekResultFactory;
     _metadataAsSourceService = metadataAsSourceService;
     _waitIndicator = waitIndicator;
 }
コード例 #10
0
 public DefinitionPeekableItem(
     Workspace workspace, ProjectId projectId, SymbolKey symbolKey,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService)
     : base(peekResultFactory)
 {
     _workspace = workspace;
     _projectId = projectId;
     _symbolKey = symbolKey;
     _metadataAsSourceFileService = metadataAsSourceService;
 }
コード例 #11
0
ファイル: PeekHelpers.cs プロジェクト: CAPCHIK/roslyn
 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);
 }
コード例 #12
0
 public PeekableItemSource(
     ITextBuffer textBuffer,
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService,
     IWaitIndicator waitIndicator)
 {
     _textBuffer = textBuffer;
     _peekableItemFactory = peekableItemFactory;
     _peekResultFactory = peekResultFactory;
     _metadataAsSourceService = metadataAsSourceService;
     _waitIndicator = waitIndicator;
 }
コード例 #13
0
 public PeekableItemSource(
     ITextBuffer textBuffer,
     IPeekableItemFactory peekableItemFactory,
     IPeekResultFactory peekResultFactory,
     IMetadataAsSourceFileService metadataAsSourceService,
     IWaitIndicator waitIndicator)
 {
     _textBuffer              = textBuffer;
     _peekableItemFactory     = peekableItemFactory;
     _peekResultFactory       = peekResultFactory;
     _metadataAsSourceService = metadataAsSourceService;
     _waitIndicator           = waitIndicator;
 }
コード例 #14
0
ファイル: PeekHelpers.cs プロジェクト: CAPCHIK/roslyn
        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);
        }
コード例 #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);
        }
コード例 #16
0
ファイル: PeekableItemFactory.cs プロジェクト: zuvys/roslyn
        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));
            }
コード例 #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
                ));
 }
コード例 #18
0
ファイル: PeekableItemSource.cs プロジェクト: belav/roslyn
        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
                                             ));
                        }
                    }
                }
            }
        }
コード例 #19
0
 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);
 }
コード例 #20
0
 public XSharpDefinitionPeekItem(XSharpModel.XElement gotoElement, IPeekResultFactory peekResultFactory)
 {
     _gotoElement       = gotoElement;
     _peekResultFactory = peekResultFactory;
 }
コード例 #21
0
 public PeekableItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory, IServiceContainer services)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _services          = services;
 }
コード例 #22
0
 public PeekableItemSource(ITextBuffer buffer, IPeekResultFactory peekResultFactory)
 {
     this.buffer = buffer;
     this.peekResultFactory = peekResultFactory;
 }
コード例 #23
0
 public IdDefinitionPeekItem(string id, IPeekResultFactory peekResultFactory, ITextBuffer textbuffer)
 {
     _id = id;
     _peekResultFactory = peekResultFactory;
     _textbuffer = textbuffer;
 }
コード例 #24
0
ファイル: PeekHelpers.cs プロジェクト: khm1600/CJing
        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));
        }
コード例 #25
0
ファイル: PeekableItemSource.cs プロジェクト: nomada2/RTVS
 public PeekableItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
 }
コード例 #26
0
 public ClassPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer = textBuffer;
     _peekResultFactory = peekResultFactory;
 }
コード例 #27
0
 public ClassPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
 }
コード例 #28
0
 public XSharpDefinitionPeekItem(XSourceSymbol gotoElement, IPeekResultFactory peekResultFactory)
 {
     _gotoElement       = gotoElement;
     _peekResultFactory = peekResultFactory;
 }
コード例 #29
0
 public PeekableItemSourceProvider(IPeekResultFactory peekResultFactory, ICoreShell shell) {
     _peekResultFactory = peekResultFactory;
     _shell = shell;
 }
コード例 #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);
                    }
                }
            }
        }
コード例 #31
0
ファイル: PeekableItem.cs プロジェクト: Rickinio/roslyn
 protected PeekableItem(IPeekResultFactory peekResultFactory)
 {
     this.PeekResultFactory = peekResultFactory;
 }
コード例 #32
0
ファイル: UserDefinedPeekItem.cs プロジェクト: Microsoft/RTVS
 public UserDefinedPeekItem(string fileName, IAstNode definitionNode, string name, IPeekResultFactory peekResultFactory, ICoreShell shell) :
     base(name, peekResultFactory, shell) {
     DefinitionNode = definitionNode;
     FileName = fileName;
 }
コード例 #33
0
 public ClassDefinitionPeekItem(string className, IPeekResultFactory peekResultFactory, ITextBuffer textbuffer)
 {
     _className         = className;
     _peekResultFactory = peekResultFactory;
     _textbuffer        = textbuffer;
 }
コード例 #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);
        }
コード例 #35
0
 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);
 }
コード例 #36
0
ファイル: PeekableItemSource.cs プロジェクト: zachwieja/RTVS
 public PeekableItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory, ICoreShell shell)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _shell             = shell;
 }
コード例 #37
0
 public XSharpPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory, XFile file)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _file = file;
 }
コード例 #38
0
ファイル: PeekItemBase.cs プロジェクト: Microsoft/RTVS
 public PeekItemBase(string name, IPeekResultFactory peekResultFactory, ICoreShell shell) {
     PeekResultFactory = peekResultFactory;
     Shell = shell;
     DisplayName = name;
 }
コード例 #39
0
ファイル: PythonPeekResultSource.cs プロジェクト: xyongy/PTVS
 public PythonPeekResultSource(IPeekResultFactory peekResultFactory, IAnalysisVariable[] variables)
 {
     _peekResultFactory = peekResultFactory ?? throw new ArgumentNullException(nameof(peekResultFactory));
     _variables         = variables ?? throw new ArgumentNullException(nameof(variables));
 }
コード例 #40
0
 public ClassDefinitionPeekItem(string className, IPeekResultFactory peekResultFactory, ITextBuffer textbuffer)
 {
     _className = className;
     _peekResultFactory = peekResultFactory;
     _textbuffer = textbuffer;
 }
コード例 #41
0
 public IdDefinitionPeekItem(string id, IPeekResultFactory peekResultFactory, ITextBuffer textbuffer)
 {
     _id = id;
     _peekResultFactory = peekResultFactory;
     _textbuffer        = textbuffer;
 }
コード例 #42
0
 public PeekResultSource(IPeekResultFactory peekResultFactory, INavigationToken navigationToken)
 {
     _peekResultFactory = peekResultFactory;
     _token             = navigationToken;
 }
コード例 #43
0
 public XSharpPeekItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory)
 {
     _textBuffer        = textBuffer;
     _peekResultFactory = peekResultFactory;
     _file = textBuffer.GetFile();
 }
コード例 #44
0
 public PeekableItemSourceProvider(IPeekResultFactory peekResultFactory, ICoreShell shell)
 {
     _peekResultFactory = peekResultFactory;
     _shell             = shell;
 }
コード例 #45
0
 protected PeekableItem(IPeekResultFactory peekResultFactory)
 {
     this.PeekResultFactory = peekResultFactory;
 }
コード例 #46
0
 public MyPeekItem(IPeekResultFactory peekResultFactory)
 {
     this.peekResultFactory = peekResultFactory;
 }
コード例 #47
0
 public PythonPeekResultSource(IPeekResultFactory peekResultFactory, AnalysisLocation[] locations)
 {
     _peekResultFactory = peekResultFactory ?? throw new ArgumentNullException(nameof(peekResultFactory));
     _locations         = locations ?? throw new ArgumentNullException(nameof(locations));
 }
コード例 #48
0
ファイル: PeekableItemSource.cs プロジェクト: Microsoft/RTVS
 public PeekableItemSource(ITextBuffer textBuffer, IPeekResultFactory peekResultFactory, ICoreShell shell) {
     _textBuffer = textBuffer;
     _peekResultFactory = peekResultFactory;
     _shell = shell;
 }