public static Guid?GetLanguageServiceID([NotNull] this IVsTextBuffer textBuffer) { Requires.NotNull(textBuffer, nameof(textBuffer)); Guid id; int hr = textBuffer.GetLanguageServiceID(out id); if (hr != VSConstants.S_OK) { return(null); } return(id); }
public static Guid?GetLanguageServiceID(this IVsTextBuffer textBuffer) { Contract.Requires <ArgumentNullException>(textBuffer != null, "textBuffer"); Guid id; int hr = textBuffer.GetLanguageServiceID(out id); if (hr != VSConstants.S_OK) { return(null); } return(id); }
public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer) { /* If a language service is registered for this content type, then the CodeWindowManager will * support the standard editor navigation margin. */ IVsTextBuffer textBufferAdapter = EditorAdaptersFactoryService.GetBufferAdapter(wpfTextViewHost.TextView.TextBuffer); if (textBufferAdapter != null) { Guid?languageService = textBufferAdapter.GetLanguageServiceID(); if (languageService.HasValue) { return(null); } } //var viewAdapter = EditorAdaptersFactoryService.GetViewAdapter(wpfTextViewHost.TextView); //var codeWindow = viewAdapter.GetCodeWindow(); //var dropdownBarManager = codeWindow as IVsDropdownBarManager; //if (dropdownBarManager != null && dropdownBarManager.GetDropdownBarClient() != null) // return null; var providers = NavigationSourceProviders.Where(provider => provider.Metadata.ContentTypes.Any(contentType => wpfTextViewHost.TextView.TextBuffer.ContentType.IsOfType(contentType))); var sources = providers .Select(provider => provider.Value.TryCreateEditorNavigationSource(wpfTextViewHost.TextView.TextBuffer)) .Where(source => source != null) .ToArray(); return(new EditorNavigationMargin(wpfTextViewHost.TextView, sources, EditorNavigationTypeRegistryService)); //var tagAggregator = BufferTagAggregatorFactoryService.CreateTagAggregator<ILanguageElementTag>(wpfTextViewHost.TextView.TextBuffer); ////var manager = LanguageElementManagerService.GetLanguageElementManager(wpfTextViewHost.TextView); ////if (manager == null) //// return null; //return new EditorNavigationMargin(wpfTextViewHost.TextView, tagAggregator, GlyphService); }