internal VsVimHost( IVsAdapter adapter, ITextBufferFactoryService textBufferFactoryService, ITextEditorFactoryService textEditorFactoryService, ITextDocumentFactoryService textDocumentFactoryService, ITextBufferUndoManagerProvider undoManagerProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOperationsFactoryService editorOperationsFactoryService, IWordUtilFactory wordUtilFactory, ITextManager textManager, ISharedServiceFactory sharedServiceFactory, SVsServiceProvider serviceProvider) : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService) { _vsAdapter = adapter; _editorAdaptersFactoryService = editorAdaptersFactoryService; _wordUtilFactory = wordUtilFactory; _dte = (_DTE)serviceProvider.GetService(typeof(_DTE)); _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility)); _textManager = textManager; _sharedService = sharedServiceFactory.Create(); _vsMonitorSelection = serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>(); uint cookie; _vsMonitorSelection.AdviseSelectionEvents(this, out cookie); }
internal VsVimHost( IVsAdapter adapter, ITextBufferFactoryService textBufferFactoryService, ITextEditorFactoryService textEditorFactoryService, ITextDocumentFactoryService textDocumentFactoryService, ITextBufferUndoManagerProvider undoManagerProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOperationsFactoryService editorOperationsFactoryService, ISmartIndentationService smartIndentationService, ITextManager textManager, ISharedServiceFactory sharedServiceFactory, IVimApplicationSettings vimApplicationSettings, SVsServiceProvider serviceProvider) : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService) { _vsAdapter = adapter; _editorAdaptersFactoryService = editorAdaptersFactoryService; _dte = (_DTE)serviceProvider.GetService(typeof(_DTE)); _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility)); _textManager = textManager; _sharedService = sharedServiceFactory.Create(); _vsMonitorSelection = serviceProvider.GetService<SVsShellMonitorSelection, IVsMonitorSelection>(); _fontProperties = new TextEditorFontProperties(serviceProvider); _vimApplicationSettings = vimApplicationSettings; _smartIndentationService = smartIndentationService; uint cookie; _vsMonitorSelection.AdviseSelectionEvents(this, out cookie); }
internal KeyBindingService(SVsServiceProvider serviceProvider, IOptionsDialogService service, [EditorUtilsImport] IProtectedOperations protectedOperations, IVimApplicationSettings vimApplicationSettings) { _dte = serviceProvider.GetService<SDTE, _DTE>(); _vsShell = serviceProvider.GetService<SVsShell, IVsShell>(); _optionsDialogService = service; _protectedOperations = protectedOperations; _vimApplicationSettings = vimApplicationSettings; _importantScopeSet = new Lazy<HashSet<string>>(CreateImportantScopeSet); }
internal KeyBindingService(SVsServiceProvider serviceProvider, IOptionsDialogService service, IProtectedOperations protectedOperations, ILegacySettings legacySettings) { _dte = serviceProvider.GetService<SDTE, _DTE>(); _vsShell = serviceProvider.GetService<SVsShell, IVsShell>(); _optionsDialogService = service; _protectedOperations = protectedOperations; _legacySettings = legacySettings; _importantScopeSet = new Lazy<HashSet<string>>(CreateImportantScopeSet); }
internal VsVimHost( ITextBufferUndoManagerProvider undoManagerProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, SVsServiceProvider serviceProvider) { _undoManagerProvider = undoManagerProvider; _editorAdaptersFactoryService = editorAdaptersFactoryService; _dte = (_DTE)serviceProvider.GetService(typeof(_DTE)); _textManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager)); }
public SaveEventsService( IVsEditorAdaptersFactoryService editorAdaptersFactoryService, ICommandHandlerServiceFactory commandHandlerServiceFactory, SVsServiceProvider serviceProvider) { _editorAdaptersFactoryService = editorAdaptersFactoryService; _commandHandlerServiceFactory = commandHandlerServiceFactory; _runningDocumentTable = (IVsRunningDocumentTable)serviceProvider.GetService(typeof(SVsRunningDocumentTable)); _textManager = (IVsTextManager)serviceProvider.GetService(typeof(SVsTextManager)); }
internal FallbackKeyProcessorProvider(SVsServiceProvider serviceProvider, IKeyUtil keyUtil, IVimApplicationSettings vimApplicationSettings, IVim vim) { _dte = (_DTE)serviceProvider.GetService(typeof(_DTE)); _keyUtil = keyUtil; _vimApplicationSettings = vimApplicationSettings; _vim = vim; var vsShell = (IVsShell)serviceProvider.GetService(typeof(SVsShell)); _scopeData = new ScopeData(vsShell); }
public VisualStudioDiagnosticListSuppressionStateService( SVsServiceProvider serviceProvider, VisualStudioWorkspace workspace) { _workspace = workspace; _shellService = (IVsUIShell)serviceProvider.GetService(typeof(SVsUIShell)); var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList; _tableControl = errorList?.TableControl; ClearState(); InitializeFromTableControlIfNeeded(); }
internal DocumentMonitorService(SVsServiceProvider vsServiceProvider, ICompletionBroker completionBroker) { _vsServiceProvider = vsServiceProvider; _runningDocumentTable = new RunningDocumentTable(vsServiceProvider); _runningDocumentTable.Advise(this); _completionBroker = completionBroker; _dte = (DTE)vsServiceProvider.GetService(typeof(_DTE)); // NB: Resharper somehow f***s with this event, we need to do as // little as possible in the event handler itself var documentChanged = _changed .ObserveOn(RxApp.TaskpoolScheduler) .Throttle(TimeSpan.FromSeconds(2.0), RxApp.TaskpoolScheduler) .Where(_ => !isCompletionActive()) .Select(_ => Unit.Default) .ObserveOn(RxApp.MainThreadScheduler); documentChanged.Subscribe(_ => SaveAll()); // NB: We use the message bus here, because we want to effectively // merge all of the text change notifications from any document MessageBus.Current.RegisterMessageSource(documentChanged, "AnyDocumentChanged"); checkAlreadyOpenDocuments(vsServiceProvider); _dte.Events.WindowEvents.WindowActivated += (o,e) => _changed.OnNext(Unit.Default); }
public CommentTaskTokenSerializer(SVsServiceProvider serviceProvider) { var tokenInfo = serviceProvider.GetService(typeof(SVsTaskList)) as IVsCommentTaskInfo; // The SVsTaskList may not be available (e.g. during "devenv /build") _taskTokenList = tokenInfo != null ? GetTaskTokenList(tokenInfo) : string.Empty; }
public ClousotOptions(SVsServiceProvider serviceProvider) { var shell = (IVsShell)serviceProvider.GetService(typeof(SVsShell)); IVsPackage package; Marshal.ThrowExceptionForHR(shell.LoadPackage(GuidList.guidOptionsPagePackagePkg, out package)); this.page = ((OptionsPagePackage)package).GetOptionsPage(); }
public VmsViewportAdornment(IWpfTextView view, SVsServiceProvider serviceProvider) { var service = (DTE)serviceProvider.GetService(typeof(DTE)); var properties = service.Properties["Visual Method Separators", "Global"]; var colorProperty = properties.Item("Color"); var color = UIntToColor(colorProperty.Value); var dashStyleProperty = properties.Item("PenDashStyle"); var dashStyle = DashStyleFromInt(dashStyleProperty.Value); var thicknessProperty = properties.Item("Thickness"); var thickness = (double) thicknessProperty.Value; _view = view; _view.LayoutChanged += OnLayoutChanged; _layer = view.GetAdornmentLayer("VmsViewportAdornment"); _pen = new Pen(new SolidColorBrush(color), thickness) { DashStyle = dashStyle, DashCap = PenLineCap.Flat, }; _pen.Freeze(); }
private void RegisterSolutionEvents(SVsServiceProvider serviceProvider) { var dte = serviceProvider.GetService(typeof(SApplicationObject)) as DTE2; var solutionEvents = dte.Events.SolutionEvents; solutionEvents.Opened += solutionEvents_Opened; }
public SettingsFileUserNotifier(SVsServiceProvider sp, INotificationService notifier, SettingsPersister persister, SettingsLocator locator) { this.locator = locator; this.notifier = notifier; this.persister = persister; dte = (DTE)sp.GetService(typeof(DTE)); }
public VisualStudioMetadataAsSourceFileSupportService(SVsServiceProvider serviceProvider, IMetadataAsSourceFileService metadataAsSourceFileService) { _metadataAsSourceFileService = metadataAsSourceFileService; var solution = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution)); ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out _eventCookie)); }
internal SettingsMigrator(SVsServiceProvider serviceProvider, IVimApplicationSettings vimApplicationSettings, ILegacySettings legacySettings, [EditorUtilsImport] IProtectedOperations protectedOperations) { _dte = serviceProvider.GetService<SDTE, _DTE>(); _vimApplicationSettings = vimApplicationSettings; _legacySettings = legacySettings; _protectedOperations = protectedOperations; }
internal PowerToolsUtil(SVsServiceProvider serviceProvider) { var vsShell = serviceProvider.GetService<SVsShell, IVsShell>(); _isQuickFindInstalled = vsShell.IsPackageInstalled(QuickFindGuid); _searchModel = new Lazy<object>(GetSearchModel); _isActivePropertyInfo = new Lazy<PropertyInfo>(GetIsActivePropertyInfo); }
internal ReSharperUtil(IVim vim, IVimBufferCoordinatorFactory vimBufferCoordinatorFactory, SVsServiceProvider serviceProvider) { var vsShell = serviceProvider.GetService<SVsShell, IVsShell>(); _isResharperInstalled = vsShell.IsPackageInstalled(Resharper5Guid); _vim = vim; _vimBufferCoordinatorFactory = vimBufferCoordinatorFactory; }
public ClousotOptions(SVsServiceProvider serviceProvider) { var shell = (IVsShell)serviceProvider.GetService(typeof(SVsShell)); IVsPackage package; Marshal.ThrowExceptionForHR(shell.LoadPackage(Microsoft.Research.AskCodeContracts.Guids.guidOptionsPagePackagePkg, out package)); this.page = ((OptionsPagePackage)package).GetOptionsPage(); }
public VisualStudioDiagnosticListTable( SVsServiceProvider serviceProvider, VisualStudioWorkspace workspace, IDiagnosticService diagnosticService, ExternalErrorDiagnosticUpdateSource errorSource, ITableManagerProvider provider) : this(serviceProvider, (Workspace)workspace, diagnosticService, errorSource, provider) { ConnectWorkspaceEvents(); _errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList; if (_errorList == null) { AddInitialTableSource(workspace.CurrentSolution, _liveTableSource); return; } _errorList.PropertyChanged += OnErrorListPropertyChanged; AddInitialTableSource(workspace.CurrentSolution, GetCurrentDataSource()); SuppressionStateColumnDefinition.SetDefaultFilter(_errorList.TableControl); if (ErrorListHasFullSolutionAnalysisButton()) { SetupErrorListFullSolutionAnalysis(workspace); } }
private ReferencedSymbolsPresenter(SVsServiceProvider serviceProvider) : base(assertIsForeground: true) { _serviceProvider = serviceProvider; // VS service should only be used in UI thread. _manager = (LibraryManager)serviceProvider.GetService(typeof(LibraryManager)); }
public AnalyzerFileWatcherService( VisualStudioWorkspaceImpl workspace, HostDiagnosticUpdateSource hostDiagnosticUpdateSource, SVsServiceProvider serviceProvider) { _workspace = workspace; _updateSource = hostDiagnosticUpdateSource; _fileChangeService = (IVsFileChangeEx)serviceProvider.GetService(typeof(SVsFileChangeEx)); }
public VisualStudioWaitIndicator(SVsServiceProvider serviceProvider) { _serviceProvider = serviceProvider; var shell = serviceProvider.GetService(typeof(SVsShell)) as IVsShell; shell.GetProperty((int)__VSSPROPID5.VSSPROPID_ReleaseVersion, out var property); _isUpdate1 = Equals(property, "14.0.24720.0 D14REL"); }
internal ReSharperUtil(SVsServiceProvider serviceProvider, IWordCompletionSessionFactoryService wordCompletionSessionFactory) { var vsShell = serviceProvider.GetService<SVsShell, IVsShell>(); _isResharperInstalled = vsShell.IsPackageInstalled(s_resharper5Guid); if (_isResharperInstalled) { wordCompletionSessionFactory.Created += OnWordCompletionSessionCreated; } }
internal VimApplicationSettings( SVsServiceProvider vsServiceProvider, ILegacySettings legacySettings, [EditorUtilsImport] IProtectedOperations protectedOperations) : this(vsServiceProvider.GetVisualStudioVersion(), vsServiceProvider.GetWritableSettingsStore(), protectedOperations) { var dte = vsServiceProvider.GetService<SDTE, _DTE>(); MigrateLegacySettings(dte, legacySettings); }
public VsImmediateWindowProvider( SVsServiceProvider serviceProvider, IVsInteractiveWindowFactory interactiveWindowFactory, IViewClassifierAggregatorService classifierAggregator, IContentTypeRegistryService contentTypeRegistry, VisualStudioWorkspace workspace) { _vsInteractiveWindowFactory = interactiveWindowFactory; _vsDebugger = (IVsDebugger)serviceProvider.GetService(typeof(IVsDebugger)); }
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 AutoWrapper(SVsServiceProvider serviceProvider, IClassifierAggregatorService aggregatorService, IWpfTextView textView) { var service = serviceProvider.GetService<CommentatorService>(); this.options = service.GetOptions(); this.view = textView; this.classifier = aggregatorService.GetClassifier(this.view.TextBuffer); this.view.TextBuffer.Changed += this.TextBuffer_Changed; this.view.Closed += this.View_Closed; }
internal ColorColumnAdornmentFactory(IEditorFormatMapService formatMapService, SVsServiceProvider serviceProvider) { this.formatMapService = formatMapService; IVsPackage package; var shell = (IVsShell)serviceProvider.GetService(typeof(SVsShell)); Marshal.ThrowExceptionForHR(shell.LoadPackage(new Guid(GuidList.colorColumnPkgString), out package)); this.settings = ((ColorColumnPackage)package).Settings; }
internal VsVimHost( IVsAdapter adapter, ITextBufferFactoryService textBufferFactoryService, ITextEditorFactoryService textEditorFactoryService, ITextDocumentFactoryService textDocumentFactoryService, ITextBufferUndoManagerProvider undoManagerProvider, IVsEditorAdaptersFactoryService editorAdaptersFactoryService, IEditorOperationsFactoryService editorOperationsFactoryService, IWordUtilFactory wordUtilFactory, ITextManager textManager, SVsServiceProvider serviceProvider) : base(textBufferFactoryService, textEditorFactoryService, textDocumentFactoryService, editorOperationsFactoryService) { _vsAdapter = adapter; _editorAdaptersFactoryService = editorAdaptersFactoryService; _wordUtilFactory = wordUtilFactory; _dte = (_DTE)serviceProvider.GetService(typeof(_DTE)); _vsExtensibility = (IVsExtensibility)serviceProvider.GetService(typeof(IVsExtensibility)); _textManager = textManager; }
private async Task <string?> GetCompilerRootAsync(SVsServiceProvider?serviceProvider) { await _threadingService.SwitchToUIThread(); // https://github.com/dotnet/roslyn-sdk/issues/729 : don't hardcode net fx compiler var shell = (IVsShell?)serviceProvider?.GetService(typeof(SVsShell)); if (shell is object && shell.GetProperty((int)__VSSPROPID2.VSSPROPID_InstallRootDir, out var rootDirObj) == VSConstants.S_OK && rootDirObj is string rootDir) { return(Path.Combine(rootDir, "MSBuild", "Current", "Bin", "Roslyn")); } return(null); }
public PreviewPaneService(IThreadingContext threadingContext, SVsServiceProvider serviceProvider) : base(threadingContext) { _uiShell = serviceProvider.GetService(typeof(SVsUIShell)) as IVsUIShell; }
public static DTE GetDte(SVsServiceProvider serviceProvider) { return((DTE)serviceProvider.GetService(typeof(DTE))); }
public bool CanClassifyViews(IEnumerable <ITextView> views) { var vsTextViews = views.Select(view => _editorAdaptersFactoryService.GetViewAdapter(view)).WhereNotNull(); return(!vsTextViews.ContainsImmediateWindow((IVsUIShell)_serviceProvider.GetService(typeof(SVsUIShell)), _editorAdaptersFactoryService)); }
/// <summary> /// Get the SUIHostCommandDispatcher from the global service provider. /// </summary> private IOleCommandTarget GetShellCommandDispatcher() { return(globalServiceProvider.GetService(typeof(SUIHostCommandDispatcher)) as IOleCommandTarget); }
public void VsTextViewCreated(IVsTextView text_view) { if (ALanguageUtility.s_service_provider == null) { ALanguageUtility.s_service_provider = m_service_provider; } if (m_factory == null) { return; } SaveAdapterFactory(); m_factory.Init(m_service_provider, m_adapters_factory); // 获取系统单例,用于打开文件 if (m_open_document == null) { m_open_document = m_service_provider.GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument; } // 获取视窗 IWpfTextView view = m_adapters_factory.GetWpfTextView(text_view); if (view == null) { return; } // 添加关闭监听 view.Closed += OnViewClosed; // 创建ABnf if (m_abnf == null) { m_abnf = ALanguageUtility.CreateABnf(m_factory); } if (m_abnf == null) { return; } if (m_abnf_ui == null) { m_abnf_ui = ALanguageUtility.CreateABnf(m_factory); } if (m_abnf_ui == null) { return; } // 获取高亮tag if (m_highlight_tag == null) { m_highlight_tag = m_factory.CreateTextMarkerTag(); } if (m_highlight_tag != null) { view.Properties.AddProperty(nameof(TextMarkerTag), m_highlight_tag); } // 获取全路径 string full_path = ALanguageUtility.GetFilePath(view); if (full_path == null) { return; } var solution = m_factory.GetSolution(); if (solution == null) { return; } var server = solution.GetServer(); if (server != null) { view.Properties.AddProperty(nameof(ALanguageServer), server); view.TextBuffer.Properties.AddProperty(nameof(ALanguageServer), server); } view.Properties.AddProperty(nameof(IVsTextView), text_view); // 获取所在的工程 m_open_document.IsDocumentInAProject(full_path, out IVsUIHierarchy project, out uint item_id, out Microsoft.VisualStudio.OLE.Interop.IServiceProvider _ppSP, out int _pDocInProj); UIProjectInfo project_info = null; if (project != null) { solution.GetProjects().TryGetValue(project, out project_info); } // 创建信息,并作为属性给view var info = new UIViewItem(m_abnf, m_abnf_ui, view, m_service_provider, m_adapters_factory, project_info, item_id, full_path, m_factory, m_factory.GetLineCommentBegin()); view.Properties.AddProperty(nameof(UIViewItem), info); view.TextBuffer.Properties.AddProperty(nameof(UIViewItem), info); // 提前添加各种source { if (!view.TextBuffer.Properties.TryGetProperty(nameof(ALanguageCompletionSource), out ALanguageCompletionSource source)) { source = new ALanguageCompletionSource(view.TextBuffer); view.TextBuffer.Properties.AddProperty(nameof(ALanguageCompletionSource), source); } } { if (!view.TextBuffer.Properties.TryGetProperty(nameof(ALanguageQuickInfoSource), out ALanguageQuickInfoSource source)) { source = new ALanguageQuickInfoSource(view.TextBuffer); view.TextBuffer.Properties.AddProperty(nameof(ALanguageQuickInfoSource), source); } } { if (!view.TextBuffer.Properties.TryGetProperty(nameof(ALanguageSignatureHelpSource), out ALanguageSignatureHelpSource source)) { source = new ALanguageSignatureHelpSource(view.TextBuffer); view.TextBuffer.Properties.AddProperty(nameof(ALanguageSignatureHelpSource), source); } } { if (!view.Properties.TryGetProperty(nameof(ALanguageErrorTagger), out ALanguageErrorTagger tagger)) { tagger = new ALanguageErrorTagger(view); view.Properties.AddProperty(nameof(ALanguageErrorTagger), tagger); } } { if (!view.Properties.TryGetProperty(nameof(ALanguageReferenceTagger), out ALanguageReferenceTagger tagger)) { tagger = new ALanguageReferenceTagger(view); view.Properties.AddProperty(nameof(ALanguageReferenceTagger), tagger); } } { if (!view.Properties.TryGetProperty(nameof(ALanguageHighlightWordTagger), out ALanguageHighlightWordTagger tagger)) { tagger = new ALanguageHighlightWordTagger(view); view.Properties.AddProperty(nameof(ALanguageHighlightWordTagger), tagger); } } // 添加命令 { ALanguageGotoDefinitionCommand filter = new ALanguageGotoDefinitionCommand(view); text_view.AddCommandFilter(filter, out IOleCommandTarget next); filter.Next = next; view.Properties.AddProperty(nameof(ALanguageGotoDefinitionCommand) + "Target", next); } { ALanguageCompletionCommand filter = new ALanguageCompletionCommand(view, m_completion_broker); text_view.AddCommandFilter(filter, out IOleCommandTarget next); filter.Next = next; view.Properties.AddProperty(nameof(ALanguageCompletionCommand) + "Target", next); view.Properties.AddProperty(nameof(ALanguageCompletionCommand), filter); } }
internal KeyBindingService(SVsServiceProvider sp, IOptionsDialogService service) { _dte = sp.GetService <SDTE, _DTE>(); _optionsDialogService = service; }
internal KeyBindingService(SVsServiceProvider serviceProvider, IKeyboardOptionsProvider keyboardOptionsProvider, IVimProtectedOperations protectedOperations, IVimApplicationSettings vimApplicationSettings) : this(serviceProvider.GetService <SDTE, _DTE>(), keyboardOptionsProvider, protectedOperations, vimApplicationSettings, new ScopeData(serviceProvider.GetService <SVsShell, IVsShell>())) { }
internal SharedServiceVersionFactory(SVsServiceProvider vsServiceProvider) { _vsRunningDocumentTable = (IVsRunningDocumentTable)vsServiceProvider.GetService(typeof(SVsRunningDocumentTable)); }
public void StartExternalDiff(ITextDocument textDocument, string originalPath) { if (textDocument == null || string.IsNullOrEmpty(textDocument.FilePath)) { return; } var filename = textDocument.FilePath; var repositoryPath = GetGitRepository(Path.GetFullPath(filename), ref originalPath); if (repositoryPath == null) { return; } using (var repo = new Repository(repositoryPath)) { string workingDirectory = repo.Info.WorkingDirectory; string relativePath = originalPath; if (relativePath.StartsWith(workingDirectory, StringComparison.OrdinalIgnoreCase)) { relativePath = relativePath.Substring(workingDirectory.Length); } // the name of the object in the database string objectName = Path.GetFileName(filename); Blob oldBlob = null; var indexEntry = repo.Index[relativePath]; if (indexEntry != null) { objectName = Path.GetFileName(indexEntry.Path); oldBlob = repo.Lookup <Blob>(indexEntry.Id); } var tempFileName = Path.GetTempFileName(); if (oldBlob != null) { File.WriteAllText(tempFileName, oldBlob.GetContentText(new FilteringOptions(relativePath)), GetEncoding(filename)); } IVsDifferenceService differenceService = _serviceProvider.GetService(typeof(SVsDifferenceService)) as IVsDifferenceService; string leftFileMoniker = tempFileName; // The difference service will automatically load the text from the file open in the editor, even if // it has changed. Don't use the original path here. string rightFileMoniker = filename; string actualFilename = objectName; string tempPrefix = Path.GetRandomFileName().Substring(0, 5); string caption = string.Format("{0}_{1} vs. {1}", tempPrefix, actualFilename); string tooltip = null; string leftLabel; if (indexEntry != null) { // determine if the file has been staged string revision; var stagedMask = FileStatus.NewInIndex | FileStatus.ModifiedInIndex; if ((repo.RetrieveStatus(relativePath) & stagedMask) != 0) { revision = "index"; } else { revision = repo.Head.Tip.Sha.Substring(0, 7); } leftLabel = string.Format("{0}@{1}", objectName, revision); } else if (oldBlob != null) { // file was added leftLabel = null; } else { // we just compared to head leftLabel = string.Format("{0}@{1}", objectName, repo.Head.Tip.Sha.Substring(0, 7)); } string rightLabel = originalPath; string inlineLabel = null; string roles = null; __VSDIFFSERVICEOPTIONS grfDiffOptions = __VSDIFFSERVICEOPTIONS.VSDIFFOPT_LeftFileIsTemporary; differenceService.OpenComparisonWindow2(leftFileMoniker, rightFileMoniker, caption, tooltip, leftLabel, rightLabel, inlineLabel, roles, (uint)grfDiffOptions); // Since the file is marked as temporary, we can delete it now File.Delete(tempFileName); } }
public string SetVariables(string str, string cmdsDir) { if (str == null) { return(str); } var dte = (DTE)_serviceProvider.GetService(typeof(DTE)); Solution sln = dte.Solution; IList <Project> projs = GetProjects(dte); SolutionBuild build = sln.SolutionBuild; var slnCfg = (SolutionConfiguration2)build.ActiveConfiguration; Project proj = projs.Cast <Project>().FirstOrDefault(x => x.FileName.Contains(cmdsDir)); ApplyVariable("$(ConfigurationName)", slnCfg.Name, ref str); ApplyVariable("$(DevEnvDir)", Path.GetDirectoryName(dte.FileName), ref str); ApplyVariable("$(PlatformName)", slnCfg.PlatformName, ref str); ApplyVariable("$(SolutionDir)", Path.GetDirectoryName(sln.FileName), ref str); ApplyVariable("$(SolutionExt)", Path.GetExtension(sln.FileName), ref str); ApplyVariable("$(SolutionFileName)", Path.GetFileName(sln.FileName), ref str); ApplyVariable("$(SolutionName)", Path.GetFileNameWithoutExtension(sln.FileName), ref str); ApplyVariable("$(SolutionPath)", sln.FileName, ref str); if (proj != null && proj.ConfigurationManager != null) // some types of projects (TwinCat) can have null ConfigurationManager { Configuration projCfg = proj.ConfigurationManager.ActiveConfiguration; if (projCfg.Properties != null) // website folder projects (File -> Add -> Existing Web Site) have null properties { string outDir = (string)projCfg.Properties.Item("OutputPath").Value; string projectDir = Path.GetDirectoryName(proj.FileName); string targetFilename = (string)proj.Properties.Item("OutputFileName").Value; string targetPath = Path.Combine(projectDir, outDir, targetFilename); string targetDir = Path.Combine(projectDir, outDir); ApplyVariable("$(OutDir)", outDir, ref str); ApplyVariable("$(ProjectDir)", projectDir, ref str); ApplyVariable("$(ProjectExt)", Path.GetExtension(proj.FileName), ref str); ApplyVariable("$(ProjectFileName)", Path.GetFileName(proj.FileName), ref str); ApplyVariable("$(ProjectName)", proj.Name, ref str); ApplyVariable("$(ProjectPath)", proj.FileName, ref str); ApplyVariable("$(TargetDir)", targetDir, ref str); ApplyVariable("$(TargetExt)", Path.GetExtension(targetFilename), ref str); ApplyVariable("$(TargetFileName)", targetFilename, ref str); ApplyVariable("$(TargetName)", proj.Name, ref str); ApplyVariable("$(TargetPath)", targetPath, ref str); } } if (proj != null) { MSBuildProject.SetVariables(proj.FileName, ref str); } return(str); }
/// <summary> /// Get the SUIHostCommandDispatcher from the global service provider. /// </summary> IOleCommandTarget GetShellCommandDispatcher(ITextView view) { return(GlobalServiceProvider.GetService(typeof(SUIHostCommandDispatcher)) as IOleCommandTarget); }
public void StartExternalDiff(ITextDocument textDocument) { if (textDocument == null || string.IsNullOrEmpty(textDocument.FilePath)) { return; } var filename = textDocument.FilePath; var repositoryPath = GetGitRepository(Path.GetFullPath(filename)); if (repositoryPath == null) { return; } using (var repo = new Repository(repositoryPath)) { string workingDirectory = repo.Info.WorkingDirectory; string relativePath = Path.GetFullPath(filename); if (relativePath.StartsWith(workingDirectory, StringComparison.OrdinalIgnoreCase)) { relativePath = relativePath.Substring(workingDirectory.Length); } // the name of the object in the database string objectName = Path.GetFileName(filename); Blob oldBlob = null; var indexEntry = repo.Index[relativePath]; if (indexEntry != null) { objectName = Path.GetFileName(indexEntry.Path); oldBlob = repo.Lookup <Blob>(indexEntry.Id); } var tempFileName = Path.GetTempFileName(); if (oldBlob != null) { File.WriteAllText(tempFileName, oldBlob.GetContentText(new FilteringOptions(relativePath))); } IVsDifferenceService differenceService = _serviceProvider.GetService(typeof(SVsDifferenceService)) as IVsDifferenceService; if (differenceService != null) { string leftFileMoniker = tempFileName; // The difference service will automatically load the text from the file open in the editor, even if // it has changed. string rightFileMoniker = filename; string actualFilename = objectName; string tempPrefix = Path.GetRandomFileName().Substring(0, 5); string caption = string.Format("{0}_{1} vs. {1}", tempPrefix, actualFilename); string tooltip = null; string leftLabel; if (indexEntry != null) { // determine if the file has been staged string revision; var stagedMask = FileStatus.NewInIndex | FileStatus.ModifiedInIndex; if ((repo.RetrieveStatus(relativePath) & stagedMask) != 0) { revision = "index"; } else { revision = repo.Head.Tip.Sha.Substring(0, 7); } leftLabel = string.Format("{0}@{1}", objectName, revision); } else if (oldBlob != null) { // file was added leftLabel = null; } else { // we just compared to head leftLabel = string.Format("{0}@{1}", objectName, repo.Head.Tip.Sha.Substring(0, 7)); } string rightLabel = filename; string inlineLabel = null; string roles = null; __VSDIFFSERVICEOPTIONS grfDiffOptions = __VSDIFFSERVICEOPTIONS.VSDIFFOPT_LeftFileIsTemporary; differenceService.OpenComparisonWindow2(leftFileMoniker, rightFileMoniker, caption, tooltip, leftLabel, rightLabel, inlineLabel, roles, (uint)grfDiffOptions); // Since the file is marked as temporary, we can delete it now File.Delete(tempFileName); } else { // Can't use __VSDIFFSERVICEOPTIONS, so mark the temporary file(s) read only on disk File.SetAttributes(tempFileName, File.GetAttributes(tempFileName) | FileAttributes.ReadOnly); string remoteFile; if (textDocument.IsDirty) { remoteFile = Path.GetTempFileName(); File.WriteAllBytes(remoteFile, GetCompleteContent(textDocument, textDocument.TextBuffer.CurrentSnapshot)); File.SetAttributes(remoteFile, File.GetAttributes(remoteFile) | FileAttributes.ReadOnly); } else { remoteFile = filename; } var diffGuiTool = repo.Config.Get <string>("diff.guitool"); if (diffGuiTool == null) { diffGuiTool = repo.Config.Get <string>("diff.tool"); if (diffGuiTool == null) { return; } } var diffCmd = repo.Config.Get <string>("difftool." + diffGuiTool.Value + ".cmd"); if (diffCmd == null || diffCmd.Value == null) { return; } var cmd = diffCmd.Value.Replace("$LOCAL", tempFileName).Replace("$REMOTE", remoteFile); string fileName = Regex.Match(cmd, ParameterPattern).Value; string arguments = cmd.Substring(fileName.Length); ProcessStartInfo startInfo = new ProcessStartInfo(fileName, arguments); Process.Start(startInfo); } } }
internal AnalyzerReferenceManager(SVsServiceProvider serviceProvider) { _referenceManager = serviceProvider.GetService(typeof(SVsReferenceManager)) as IVsReferenceManager; }