public VisualStudioMetadataAsSourceFileSupportService( IThreadingContext threadingContext, IMetadataAsSourceFileService metadataAsSourceFileService) { _threadingContext = threadingContext; _metadataAsSourceFileService = metadataAsSourceFileService; }
public VisualStudioMetadataAsSourceFileSupportService(SVsServiceProvider serviceProvider, IMetadataAsSourceFileService metadataAsSourceFileService) { _metadataAsSourceFileService = metadataAsSourceFileService; var solution = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution)); ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out _eventCookie)); }
public FindAllReferencesHandler( IMetadataAsSourceFileService metadataAsSourceFileService, IAsynchronousOperationListenerProvider asynchronousOperationListenerProvider) { _metadataAsSourceFileService = metadataAsSourceFileService; _asyncListener = asynchronousOperationListenerProvider.GetListener(FeatureAttribute.LanguageServer); }
public TestWorkspace( ExportProvider?exportProvider = null, TestComposition?composition = null, string?workspaceKind = WorkspaceKind.Host, bool disablePartialSolutions = true, bool ignoreUnchangeableDocumentsWhenApplyingChanges = true ) : base(GetHostServices(exportProvider, composition), workspaceKind ?? WorkspaceKind.Host) { Contract.ThrowIfTrue(exportProvider != null && composition != null); this.TestHookPartialSolutionsDisabled = disablePartialSolutions; this.ExportProvider = exportProvider ?? GetComposition(composition).ExportProviderFactory.CreateExportProvider(); _workspaceKind = workspaceKind ?? WorkspaceKind.Host; this.Projects = new List <TestHostProject>(); this.Documents = new List <TestHostDocument>(); this.AdditionalDocuments = new List <TestHostDocument>(); this.AnalyzerConfigDocuments = new List <TestHostDocument>(); this.ProjectionDocuments = new List <TestHostDocument>(); this.CanApplyChangeDocument = true; this.IgnoreUnchangeableDocumentsWhenApplyingChanges = ignoreUnchangeableDocumentsWhenApplyingChanges; if ( Services.GetService <INotificationService>() is INotificationServiceCallback callback ) { // Avoid showing dialogs in tests by default callback.NotificationCallback = (message, title, severity) => { var severityText = severity switch { NotificationSeverity.Information => "💡", NotificationSeverity.Warning => "⚠", _ => "❌" }; var fullMessage = string.IsNullOrEmpty(title) ? message : $"{title}:{Environment.NewLine}{Environment.NewLine}{message}"; throw new InvalidOperationException($"{severityText} {fullMessage}"); }; } _backgroundCompiler = new BackgroundCompiler(this); _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); _metadataAsSourceFileService = ExportProvider .GetExportedValues <IMetadataAsSourceFileService>() .FirstOrDefault(); RegisterDocumentOptionProviders( ExportProvider.GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>() ); }
public VisualStudioLspSolutionProvider( VisualStudioWorkspace visualStudioWorkspace, MiscellaneousFilesWorkspace miscellaneousFilesWorkspace, IMetadataAsSourceFileService metadataAsSourceFileService) { _visualStudioWorkspace = visualStudioWorkspace; _miscellaneousFilesWorkspace = miscellaneousFilesWorkspace; _metadataAsSourceFileService = metadataAsSourceFileService; }
public PeekableItemSourceProvider( IPeekableItemFactory peekableItemFactory, IPeekResultFactory peekResultFactory, IMetadataAsSourceFileService metadataAsSourceService, IWaitIndicator waitIndicator) { _peekableItemFactory = peekableItemFactory; _peekResultFactory = peekResultFactory; _metadataAsSourceService = metadataAsSourceService; _waitIndicator = waitIndicator; }
public VisualStudioSymbolNavigationService( SVsServiceProvider serviceProvider, IThreadingContext threadingContext, IVsEditorAdaptersFactoryService editorAdaptersFactory, IMetadataAsSourceFileService metadataAsSourceFileService) : base(threadingContext) { _serviceProvider = serviceProvider; _editorAdaptersFactory = editorAdaptersFactory; _metadataAsSourceFileService = metadataAsSourceFileService; }
public DefinitionPeekableItem( Workspace workspace, ProjectId projectId, SymbolKey symbolKey, IPeekResultFactory peekResultFactory, IMetadataAsSourceFileService metadataAsSourceService) : base(peekResultFactory) { _workspace = workspace; _projectId = projectId; _symbolKey = symbolKey; _metadataAsSourceFileService = metadataAsSourceService; }
public VisualStudioSymbolNavigationService( SVsServiceProvider serviceProvider, VisualStudio14StructureTaggerProvider outliningTaggerProvider) : base(outliningTaggerProvider.ThreadingContext) { _serviceProvider = serviceProvider; var componentModel = _serviceProvider.GetService <SComponentModel, IComponentModel>(); _editorAdaptersFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>(); _metadataAsSourceFileService = componentModel.GetService <IMetadataAsSourceFileService>(); }
public FindUsagesLSPContext( Document document, int position, IMetadataAsSourceFileService metadataAsSourceFileService, CancellationToken cancellationToken) { _document = document; _position = position; _metadataAsSourceFileService = metadataAsSourceFileService; CancellationToken = cancellationToken; }
public TestContext(string projectLanguage = null, IEnumerable <string> metadataSources = null, bool includeXmlDocComments = false, string sourceWithSymbolReference = null) { projectLanguage = projectLanguage ?? LanguageNames.CSharp; metadataSources = metadataSources ?? SpecializedCollections.EmptyEnumerable <string>(); metadataSources = !metadataSources.Any() ? new[] { AbstractMetadataAsSourceTests.DefaultMetadataSource } : metadataSources; _workspace = CreateWorkspace(projectLanguage, metadataSources, includeXmlDocComments, sourceWithSymbolReference); _metadataAsSourceService = _workspace.GetService <IMetadataAsSourceFileService>(); _textBufferFactoryService = _workspace.GetService <ITextBufferFactoryService>(); }
public TestContext(string projectLanguage = null, IEnumerable<string> metadataSources = null, bool includeXmlDocComments = false, string sourceWithSymbolReference = null) { projectLanguage = projectLanguage ?? LanguageNames.CSharp; metadataSources = metadataSources ?? SpecializedCollections.EmptyEnumerable<string>(); metadataSources = !metadataSources.Any() ? new[] { AbstractMetadataAsSourceTests.DefaultMetadataSource } : metadataSources; _workspace = CreateWorkspace(projectLanguage, metadataSources, includeXmlDocComments, sourceWithSymbolReference); _metadataAsSourceService = _workspace.GetService<IMetadataAsSourceFileService>(); _textBufferFactoryService = _workspace.GetService<ITextBufferFactoryService>(); }
public DefinitionContextTracker( IMetadataAsSourceFileService metadataAsSourceFileService, ICodeDefinitionWindowService codeDefinitionWindowService, IThreadingContext threadingContext, IGlobalOptionService globalOptions, IAsynchronousOperationListenerProvider listenerProvider) { _metadataAsSourceFileService = metadataAsSourceFileService; _codeDefinitionWindowService = codeDefinitionWindowService; _threadingContext = threadingContext; _globalOptions = globalOptions; _asyncListener = listenerProvider.GetListener(FeatureAttribute.CodeDefinitionWindow); }
public PeekableItemSource( ITextBuffer textBuffer, IPeekableItemFactory peekableItemFactory, IPeekResultFactory peekResultFactory, IMetadataAsSourceFileService metadataAsSourceService, IWaitIndicator waitIndicator) { _textBuffer = textBuffer; _peekableItemFactory = peekableItemFactory; _peekResultFactory = peekResultFactory; _metadataAsSourceService = metadataAsSourceService; _waitIndicator = waitIndicator; }
public VisualStudioSymbolNavigationService( SVsServiceProvider serviceProvider, VisualStudio14StructureTaggerProvider outliningTaggerProvider) { _serviceProvider = serviceProvider; _outliningTaggerProvider = outliningTaggerProvider; var componentModel = _serviceProvider.GetService<SComponentModel, IComponentModel>(); _editorAdaptersFactory = componentModel.GetService<IVsEditorAdaptersFactoryService>(); _textEditorFactoryService = componentModel.GetService<ITextEditorFactoryService>(); _textDocumentFactoryService = componentModel.GetService<ITextDocumentFactoryService>(); _metadataAsSourceFileService = componentModel.GetService<IMetadataAsSourceFileService>(); }
public VisualStudioSymbolNavigationService( SVsServiceProvider serviceProvider, OutliningTaggerProvider outliningTaggerProvider) { _serviceProvider = serviceProvider; _outliningTaggerProvider = outliningTaggerProvider; var componentModel = GetService <SComponentModel, IComponentModel>(); _editorAdaptersFactory = componentModel.GetService <IVsEditorAdaptersFactoryService>(); _textEditorFactoryService = componentModel.GetService <ITextEditorFactoryService>(); _textDocumentFactoryService = componentModel.GetService <ITextDocumentFactoryService>(); _metadataAsSourceFileService = componentModel.GetService <IMetadataAsSourceFileService>(); }
private static async Task <LSP.VSReferenceItem?> GenerateVSReferenceItemAsync( int id, int?definitionId, Document document, int position, DocumentSpan documentSpan, ImmutableDictionary <string, string> properties, IMetadataAsSourceFileService metadataAsSourceFileService, string?definitionText, SymbolUsageInfo?symbolUsageInfo, CancellationToken cancellationToken) { var location = await ComputeLocationAsync(document, position, documentSpan, metadataAsSourceFileService, cancellationToken).ConfigureAwait(false); if (location == null) { return(null); } // Getting the text for the Text property. If we somehow can't compute the text, that means we're probably dealing with a metadata // reference, and those don't show up in the results list in Roslyn FAR anyway. var text = await ComputeTextAsync(id, definitionId, documentSpan, definitionText, cancellationToken).ConfigureAwait(false); if (text == null) { return(null); } // TO-DO: The Origin property should be added once Rich-Nav is completed. // https://github.com/dotnet/roslyn/issues/42847 var result = new LSP.VSReferenceItem { ContainingMember = properties.TryGetValue( AbstractReferenceFinder.ContainingMemberInfoPropertyName, out var referenceContainingMember) ? referenceContainingMember : null, ContainingType = properties.TryGetValue( AbstractReferenceFinder.ContainingTypeInfoPropertyName, out var referenceContainingType) ? referenceContainingType : null, DefinitionId = definitionId, DefinitionText = definitionText, // Only definitions should have a non-null DefinitionText DisplayPath = location.Uri.LocalPath, DocumentName = documentSpan == default ? null : documentSpan.Document.Name, Id = id, Kind = symbolUsageInfo.HasValue ? ProtocolConversions.SymbolUsageInfoToReferenceKinds(symbolUsageInfo.Value) : new ReferenceKind[] { }, Location = location, ProjectName = documentSpan == default ? null : documentSpan.Document.Project.Name, ResolutionStatus = ResolutionStatusKind.ConfirmedAsReference, Text = text, }; return(result);
// Local functions static async Task <LSP.Location?> ComputeLocationAsync( Document document, int position, DocumentSpan documentSpan, IMetadataAsSourceFileService metadataAsSourceFileService, CancellationToken cancellationToken) { if (documentSpan != default) { // We do have a document span, so compute location normally. return(await ProtocolConversions.DocumentSpanToLocationAsync(documentSpan, cancellationToken).ConfigureAwait(false)); } // If we have no document span, our location may be in metadata or may be a namespace. var symbol = await SymbolFinder.FindSymbolAtPositionAsync(document, position, cancellationToken).ConfigureAwait(false); if (symbol == null || symbol.Locations.IsEmpty || symbol.Kind == SymbolKind.Namespace) { // Either: // (1) We couldn't find the location in metadata and it's not in any of our known documents. // (2) The symbol is a namespace (and therefore has no location). return(null); } var declarationFile = await metadataAsSourceFileService.GetGeneratedFileAsync( document.Project, symbol, allowDecompilation : false, cancellationToken).ConfigureAwait(false); var linePosSpan = declarationFile.IdentifierLocation.GetLineSpan().Span; if (string.IsNullOrEmpty(declarationFile.FilePath)) { return(null); } try { return(new LSP.Location { Uri = ProtocolConversions.GetUriFromFilePath(declarationFile.FilePath), Range = ProtocolConversions.LinePositionToRange(linePosSpan), }); } catch (UriFormatException e) when(FatalError.ReportAndCatch(e)) { // We might reach this point if the file path is formatted incorrectly. return(null); } }
public FindUsagesLSPContext( IProgress <VSReferenceItem[]> progress, Document document, int position, IMetadataAsSourceFileService metadataAsSourceFileService, CancellationToken cancellationToken) { _progress = progress; _document = document; _position = position; _metadataAsSourceFileService = metadataAsSourceFileService; _workQueue = new AsyncBatchingWorkQueue <VSReferenceItem>( TimeSpan.FromMilliseconds(500), ReportReferencesAsync, cancellationToken); CancellationToken = cancellationToken; }
public TestWorkspace(ExportProvider exportProvider, string workspaceKind = null, bool disablePartialSolutions = true) : base(VisualStudioMefHostServices.Create(exportProvider), workspaceKind ?? WorkspaceKind.Test) { this.TestHookPartialSolutionsDisabled = disablePartialSolutions; this.ExportProvider = exportProvider; this.Projects = new List <TestHostProject>(); this.Documents = new List <TestHostDocument>(); this.AdditionalDocuments = new List <TestHostDocument>(); this.ProjectionDocuments = new List <TestHostDocument>(); this.CanApplyChangeDocument = true; _backgroundCompiler = new BackgroundCompiler(this); _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); _metadataAsSourceFileService = exportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault(); }
public MiscellaneousFilesWorkspace( IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IMetadataAsSourceFileService fileTrackingMetadataAsSourceService, SaveEventsService saveEventsService, VisualStudioWorkspace visualStudioWorkspace, SVsServiceProvider serviceProvider) : base(visualStudioWorkspace.Services.HostServices, WorkspaceKind.MiscellaneousFiles) { _editorAdaptersFactoryService = editorAdaptersFactoryService; _fileTrackingMetadataAsSourceService = fileTrackingMetadataAsSourceService; _runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); _textManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager)); ((IVsRunningDocumentTable)_runningDocumentTable).AdviseRunningDocTableEvents(this, out _runningDocumentTableEventsCookie); _metadataReferences = ImmutableArray.CreateRange(CreateMetadataReferences()); _documentProvider = new RoslynDocumentProvider(this, serviceProvider); saveEventsService.StartSendingSaveEvents(); }
public MiscellaneousFilesWorkspace( IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IMetadataAsSourceFileService fileTrackingMetadataAsSourceService, SaveEventsService saveEventsService, VisualStudioWorkspace visualStudioWorkspace, SVsServiceProvider serviceProvider) : base(visualStudioWorkspace.Services.HostServices, "MiscellaneousFiles") { _editorAdaptersFactoryService = editorAdaptersFactoryService; _fileTrackingMetadataAsSourceService = fileTrackingMetadataAsSourceService; _runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); _textManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager)); ((IVsRunningDocumentTable)_runningDocumentTable).AdviseRunningDocTableEvents(this, out _runningDocumentTableEventsCookie); _metadataReferences = ImmutableArray.CreateRange(CreateMetadataReferences()); _documentProvider = new RoslynDocumentProvider(this, serviceProvider); saveEventsService.StartSendingSaveEvents(); }
public MiscellaneousFilesWorkspace( IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IMetadataAsSourceFileService fileTrackingMetadataAsSourceService, SaveEventsService saveEventsService, VisualStudioWorkspace visualStudioWorkspace, SVsServiceProvider serviceProvider) : base(visualStudioWorkspace.Services.HostServices, WorkspaceKind.MiscellaneousFiles) { _foregroundThreadAffinitization = new ForegroundThreadAffinitizedObject(assertIsForeground: true); _editorAdaptersFactoryService = editorAdaptersFactoryService; _fileTrackingMetadataAsSourceService = fileTrackingMetadataAsSourceService; _runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); _textManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager)); ((IVsRunningDocumentTable)_runningDocumentTable).AdviseRunningDocTableEvents(this, out _runningDocumentTableEventsCookie); _metadataReferences = ImmutableArray.CreateRange(CreateMetadataReferences()); _documentProvider = new DocumentProvider(this, serviceProvider, documentTrackingService: null); saveEventsService.StartSendingSaveEvents(); }
public TestWorkspace(ExportProvider exportProvider, string?workspaceKind = null, bool disablePartialSolutions = true, bool ignoreUnchangeableDocumentsWhenApplyingChanges = true) : base(VisualStudioMefHostServices.Create(exportProvider), workspaceKind ?? WorkspaceKind.Test) { this.TestHookPartialSolutionsDisabled = disablePartialSolutions; this.ExportProvider = exportProvider; this.Projects = new List <TestHostProject>(); this.Documents = new List <TestHostDocument>(); this.AdditionalDocuments = new List <TestHostDocument>(); this.AnalyzerConfigDocuments = new List <TestHostDocument>(); this.ProjectionDocuments = new List <TestHostDocument>(); this.CanApplyChangeDocument = true; this.IgnoreUnchangeableDocumentsWhenApplyingChanges = ignoreUnchangeableDocumentsWhenApplyingChanges; _backgroundCompiler = new BackgroundCompiler(this); _backgroundParser = new BackgroundParser(this); _backgroundParser.Start(); _metadataAsSourceFileService = exportProvider.GetExportedValues <IMetadataAsSourceFileService>().FirstOrDefault(); RegisterDocumentOptionProviders(exportProvider.GetExports <IDocumentOptionsProviderFactory, OrderableMetadata>()); }
public FindAllReferencesHandler(IMetadataAsSourceFileService metadataAsSourceFileService, ILspSolutionProvider solutionProvider) : base(solutionProvider) { _metadataAsSourceFileService = metadataAsSourceFileService; }
private PeekableItemFactory(IMetadataAsSourceFileService metadataAsSourceFileService) { _metadataAsSourceFileService = metadataAsSourceFileService; }
public GoToDefinitionHandler(IMetadataAsSourceFileService metadataAsSourceFileService) { _metadataAsSourceFileService = metadataAsSourceFileService; }
private static async Task <LSP.Location[]> GetSymbolDefinitionLocationsAsync(XamlSymbolDefinition symbolDefinition, RequestContext context, IMetadataAsSourceFileService metadataAsSourceFileService, CancellationToken cancellationToken) { Contract.ThrowIfNull(symbolDefinition.Symbol); using var _ = ArrayBuilder <LSP.Location> .GetInstance(out var locations); var symbol = symbolDefinition.Symbol; var items = NavigableItemFactory.GetItemsFromPreferredSourceLocations(context.Solution, symbol, displayTaggedParts: null, cancellationToken); if (items.Any()) { foreach (var item in items) { var location = await ProtocolConversions.TextSpanToLocationAsync( item.Document, item.SourceSpan, item.IsStale, cancellationToken).ConfigureAwait(false); locations.AddIfNotNull(location); } } else { var metadataLocation = symbol.Locations.Where(loc => loc.IsInMetadata).FirstOrDefault(); if (metadataLocation != null && metadataAsSourceFileService.IsNavigableMetadataSymbol(symbol)) { var project = context.Document?.GetCodeProject(); if (project != null) { var declarationFile = await metadataAsSourceFileService.GetGeneratedFileAsync(project, symbol, allowDecompilation : false, cancellationToken).ConfigureAwait(false); var linePosSpan = declarationFile.IdentifierLocation.GetLineSpan().Span; locations.Add(new LSP.Location { Uri = new Uri(declarationFile.FilePath), Range = ProtocolConversions.LinePositionToRange(linePosSpan), }); } } } return(locations.ToArray()); }
public TestContext(TestWorkspace workspace) { Workspace = workspace; _metadataAsSourceService = Workspace.GetService <IMetadataAsSourceFileService>(); }
public TestContext(TestWorkspace workspace) { _workspace = workspace; _metadataAsSourceService = _workspace.GetService<IMetadataAsSourceFileService>(); _textBufferFactoryService = _workspace.GetService<ITextBufferFactoryService>(); }
public PeekableItemFactory(IMetadataAsSourceFileService metadataAsSourceFileService) => _metadataAsSourceFileService = metadataAsSourceFileService;
public AbstractGoToDefinitionHandler(IMetadataAsSourceFileService metadataAsSourceFileService, ILspSolutionProvider solutionProvider) : base(solutionProvider) => _metadataAsSourceFileService = metadataAsSourceFileService;
public GoToTypeDefinitionHandler(IMetadataAsSourceFileService metadataAsSourceFileService) : base(metadataAsSourceFileService) { }
public FindAllReferencesHandler(IMetadataAsSourceFileService metadataAsSourceFileService) { _metadataAsSourceFileService = metadataAsSourceFileService; }