示例#1
0
 public CSharpCodeCleanUpFixer(
     IThreadingContext threadingContext,
     VisualStudioWorkspaceImpl workspace,
     IVsHierarchyItemManager vsHierarchyItemManager
     ) : base(threadingContext, workspace, vsHierarchyItemManager)
 {
 }
        public VisualStudioSuppressionFixService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl workspace,
            IDiagnosticAnalyzerService diagnosticService,
            ExternalErrorDiagnosticUpdateSource buildErrorDiagnosticService,
            ICodeFixService codeFixService,
            ICodeActionEditHandlerService editHandlerService,
            IVisualStudioDiagnosticListSuppressionStateService suppressionStateService,
            IWaitIndicator waitIndicator,
            IVsHierarchyItemManager vsHierarchyItemManager)
        {
            _workspace                    = workspace;
            _diagnosticService            = diagnosticService;
            _buildErrorDiagnosticService  = buildErrorDiagnosticService;
            _codeFixService               = codeFixService;
            _suppressionStateService      = (VisualStudioDiagnosticListSuppressionStateService)suppressionStateService;
            _editHandlerService           = editHandlerService;
            _waitIndicator                = waitIndicator;
            _vsHierarchyItemManager       = vsHierarchyItemManager;
            _fixMultipleOccurencesService = workspace.Services.GetService <IFixMultipleOccurrencesService>();
            _projectMap                   = workspace.Services.GetService <IHierarchyItemToProjectIdMap>();

            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            _tableControl = errorList?.TableControl;
        }
        private static Func <Project, bool> GetShouldFixInProjectDelegate(
            IVsHierarchyItemManager vsHierarchyItemManager,
            IHierarchyItemToProjectIdMap projectMap,
            IVsHierarchy projectHierarchyOpt
            )
        {
            ProjectId projectIdToMatch = null;

            if (projectHierarchyOpt != null)
            {
                var projectHierarchyItem = vsHierarchyItemManager.GetHierarchyItem(
                    projectHierarchyOpt,
                    VSConstants.VSITEMID_ROOT
                    );
                if (
                    projectMap.TryGetProjectId(
                        projectHierarchyItem,
                        targetFrameworkMoniker: null,
                        out var projectId
                        )
                    )
                {
                    projectIdToMatch = projectId;
                }
            }

            return(p => projectHierarchyOpt == null || p.Id == projectIdToMatch);
        }
示例#4
0
        public VisualStudioSuppressionFixService(
            SVsServiceProvider serviceProvider,
            VisualStudioWorkspaceImpl workspace,
            IDiagnosticAnalyzerService diagnosticService,
            ICodeFixService codeFixService,
            ICodeActionEditHandlerService editHandlerService,
            IVisualStudioDiagnosticListSuppressionStateService suppressionStateService,
            IUIThreadOperationExecutor uiThreadOperationExecutor,
            IVsHierarchyItemManager vsHierarchyItemManager,
            IAsynchronousOperationListenerProvider listenerProvider,
            IGlobalOptionService globalOptions)
        {
            _workspace                    = workspace;
            _diagnosticService            = diagnosticService;
            _buildErrorDiagnosticService  = workspace.ExternalErrorDiagnosticUpdateSource;
            _codeFixService               = codeFixService;
            _suppressionStateService      = (VisualStudioDiagnosticListSuppressionStateService)suppressionStateService;
            _editHandlerService           = editHandlerService;
            _uiThreadOperationExecutor    = uiThreadOperationExecutor;
            _vsHierarchyItemManager       = vsHierarchyItemManager;
            _fixMultipleOccurencesService = workspace.Services.GetRequiredService <IFixMultipleOccurrencesService>();
            _projectMap                   = workspace.Services.GetRequiredService <IHierarchyItemToProjectIdMap>();

            var errorList = serviceProvider.GetService(typeof(SVsErrorList)) as IErrorList;

            _tableControl  = errorList?.TableControl;
            _listener      = listenerProvider.GetListener(FeatureAttribute.ErrorList);
            _globalOptions = globalOptions;
        }
示例#5
0
 public DteToVsAdapter(
     [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider,
     [Import(ContractNames.Interop.IVsHierarchyItemManager)] IVsHierarchyItemManager hierarchyManager)
 {
     this.serviceProvider  = serviceProvider;
     this.hierarchyManager = hierarchyManager;
 }
示例#6
0
 public VsSolutionSelection(
     [Import(ContractNames.Interop.SolutionExplorerWindow)] IVsUIHierarchyWindow hierarchyWindow,
     IVsHierarchyItemManager hierarchyManager,
     JoinableTaskContext context)
 {
     this.hierarchyWindow  = hierarchyWindow;
     this.hierarchyManager = hierarchyManager;
     jtf = context.Factory;
 }
示例#7
0
 public VsSolutionSelection(
     [Import(ContractNames.Interop.SolutionExplorerWindow)] IVsUIHierarchyWindow hierarchyWindow,
     IVsHierarchyItemManager hierarchyManager,
     IAsyncManager asyncManager)
 {
     this.hierarchyWindow  = hierarchyWindow;
     this.hierarchyManager = hierarchyManager;
     this.asyncManager     = asyncManager;
 }
示例#8
0
		public VsSolutionSelection (
			[Import (ContractNames.Interop.SolutionExplorerWindow)] IVsUIHierarchyWindow hierarchyWindow,
			IVsHierarchyItemManager hierarchyManager,
			IAsyncManager asyncManager)
		{
			this.hierarchyWindow = hierarchyWindow;
			this.hierarchyManager = hierarchyManager;
			this.asyncManager = asyncManager;
		}
示例#9
0
        /// <summary>
        /// Converts a <see cref="IVsHierarchy"/> to a <see cref="IVsHierarchyItem"/>.
        /// </summary>
        public static async Task <IVsHierarchyItem> ToHierarchyItemAsync(this IVsHierarchy hierarchy, uint itemId)
        {
            if (hierarchy == null)
            {
                throw new ArgumentNullException(nameof(hierarchy));
            }

            IVsHierarchyItemManager manager = await VS.GetMefServiceAsync <IVsHierarchyItemManager>();

            return(manager.GetHierarchyItem(hierarchy, itemId));
        }
示例#10
0
        /// <summary>
        /// Converts a <see cref="IVsHierarchy"/> to a <see cref="IVsHierarchyItem"/>.
        /// </summary>
        public static IVsHierarchyItem ToHierarchyItem(this IVsHierarchy hierarchy, uint itemId)
        {
            if (hierarchy == null)
            {
                throw new ArgumentNullException(nameof(hierarchy));
            }

            IVsHierarchyItemManager manager = VS.GetMefService <IVsHierarchyItemManager>();

            return(manager.GetHierarchyItem(hierarchy, itemId));
        }
        public RemoveUnusedReferencesCommandHandler(
            RemoveUnusedReferencesDialogProvider unusedReferenceDialogProvider,
            IVsHierarchyItemManager vsHierarchyItemManager,
            IUIThreadOperationExecutor threadOperationExecutor,
            VisualStudioWorkspace workspace)
        {
            _unusedReferenceDialogProvider = unusedReferenceDialogProvider;
            _vsHierarchyItemManager        = vsHierarchyItemManager;
            _threadOperationExecutor       = threadOperationExecutor;
            _workspace = workspace;

            _lazyReferenceCleanupService = new(() => workspace.Services.GetRequiredService <IReferenceCleanupService>());
        }
 public VisualStudioDiagnosticAnalyzerService(
     VisualStudioWorkspace workspace,
     IDiagnosticAnalyzerService diagnosticService,
     IThreadingContext threadingContext,
     IVsHierarchyItemManager vsHierarchyItemManager,
     IAsynchronousOperationListenerProvider listenerProvider)
 {
     _workspace              = workspace;
     _diagnosticService      = diagnosticService;
     _threadingContext       = threadingContext;
     _vsHierarchyItemManager = vsHierarchyItemManager;
     _listener = listenerProvider.GetListener(FeatureAttribute.DiagnosticService);
 }
示例#13
0
 public DependenciesTreeConfiguredProjectSearchContext(
     DependenciesTreeSearchContext inner,
     IProjectTree targetRootNode,
     IVsHierarchyItemManager hierarchyItemManager,
     IUnconfiguredProjectVsServices projectVsServices,
     IRelationProvider relationProvider)
 {
     _inner = inner;
     _hierarchyItemManager = hierarchyItemManager;
     _projectVsServices    = projectVsServices;
     _relationProvider     = relationProvider;
     _targetRootNode       = targetRootNode;
 }
示例#14
0
 public ProjectNodeFactory(
     [Import(typeof(SVsServiceProvider))] IServiceProvider services,
     IVsHierarchyItemManager hierarchyManager,
     Lazy <ISolutionExplorerNodeFactory> childNodeFactory,
     IAdapterService adapter,
     [Import(ContractNames.Interop.SolutionExplorerWindow)] Lazy <IVsUIHierarchyWindow> solutionExplorer)
 {
     solution = new Lazy <IVsSolution> (() => services.GetService <SVsSolution, IVsSolution> ());
     this.hierarchyManager = hierarchyManager;
     this.childNodeFactory = childNodeFactory;
     this.adapter          = adapter;
     this.solutionExplorer = solutionExplorer;
 }
 public DependenciesTreeSearchProvider(
     [ImportMany] IEnumerable <IDependenciesTreeSearchProvider> providers,
     JoinableTaskContext joinableTaskContext,
     IVsHierarchyItemManager hierarchyItemManager,
     IProjectServiceAccessor projectServiceAccessor,
     IRelationProvider relationProvider)
 {
     _providers              = providers.ToImmutableArray();
     _joinableTaskContext    = joinableTaskContext;
     _hierarchyItemManager   = hierarchyItemManager;
     _projectServiceAccessor = projectServiceAccessor;
     _relationProvider       = relationProvider;
 }
示例#16
0
 public DependenciesTreeProjectSearchContext(
     DependenciesTreeSearchContext outer,
     UnconfiguredProject unconfiguredProject,
     IProjectTree dependenciesNode,
     IVsHierarchyItemManager hierarchyItemManager,
     IUnconfiguredProjectVsServices projectVsServices,
     IRelationProvider relationProvider)
 {
     _inner = outer;
     UnconfiguredProject   = unconfiguredProject;
     _dependenciesNode     = dependenciesNode;
     _hierarchyItemManager = hierarchyItemManager;
     _projectVsServices    = projectVsServices;
     _relationProvider     = relationProvider;
 }
示例#17
0
		public ProjectNodeFactory (
			[Import(typeof(SVsServiceProvider))] IServiceProvider services, 
			IVsHierarchyItemManager hierarchyManager,
			Lazy<ISolutionExplorerNodeFactory> childNodeFactory,
			IAdapterService adapter,
			[Import (ContractNames.Interop.SolutionExplorerWindow)] Lazy<IVsUIHierarchyWindow> solutionExplorer,
			[Import(Clide.ContractNames.Interop.IVsBooleanSymbolExpressionEvaluator)] Lazy<IVsBooleanSymbolExpressionEvaluator> expressionEvaluator)
		{
			solution = new Lazy<IVsSolution> (() => services.GetService<SVsSolution, IVsSolution> ());
			this.hierarchyManager = hierarchyManager;
            this.childNodeFactory = childNodeFactory;
			this.adapter = adapter;
			this.solutionExplorer = solutionExplorer;
			this.expressionEvaluator = expressionEvaluator;
		}
示例#18
0
 public ProjectNodeFactory(
     [Import(typeof(SVsServiceProvider))] IServiceProvider services,
     IVsHierarchyItemManager hierarchyManager,
     Lazy <ISolutionExplorerNodeFactory> childNodeFactory,
     IAdapterService adapter,
     JoinableLazy <IVsUIHierarchyWindow> solutionExplorer,
     JoinableTaskContext jtc,
     [Import(Clide.ContractNames.Interop.IVsBooleanSymbolExpressionEvaluator)] JoinableLazy <IVsBooleanSymbolExpressionEvaluator> expressionEvaluator)
 {
     solution = new JoinableLazy <IVsSolution>(() => services.GetService <SVsSolution, IVsSolution>(), jtc.Factory, true);
     this.hierarchyManager    = hierarchyManager;
     this.childNodeFactory    = childNodeFactory;
     this.adapter             = adapter;
     this.solutionExplorer    = solutionExplorer;
     this.expressionEvaluator = expressionEvaluator;
     this.asyncManager        = jtc.Factory;
 }
 public VisualStudioDiagnosticAnalyzerService(
     VisualStudioWorkspace workspace,
     IDiagnosticAnalyzerService diagnosticService,
     IThreadingContext threadingContext,
     IVsHierarchyItemManager vsHierarchyItemManager,
     IAsynchronousOperationListenerProvider listenerProvider,
     HostDiagnosticUpdateSource hostDiagnosticUpdateSource,
     IGlobalOptionService globalOptions)
 {
     _workspace                  = workspace;
     _diagnosticService          = diagnosticService;
     _threadingContext           = threadingContext;
     _vsHierarchyItemManager     = vsHierarchyItemManager;
     _hostDiagnosticUpdateSource = hostDiagnosticUpdateSource;
     _listener      = listenerProvider.GetListener(FeatureAttribute.DiagnosticService);
     _globalOptions = globalOptions;
 }
示例#20
0
        public SolutionExplorer(
            [Import(typeof(SVsServiceProvider))] IServiceProvider services,
            // Get the IVsHierarchyItemManager from our provider, so that it's a singleton
            // and provided always from a UI thread. The default exported one from VS doesn't
            // have the PartCreationPolicy.Shared attribute and is newed up in whatever context
            // you're requesting it from.
            [Import(ContractNames.Interop.IVsHierarchyItemManager)] IVsHierarchyItemManager hierarchy,
            ISolutionExplorerNodeFactory factory)
        {
            Guard.NotNull(nameof(services), services);
            Guard.NotNull(nameof(hierarchy), hierarchy);
            Guard.NotNull(nameof(factory), factory);

            this.services  = services;
            this.hierarchy = hierarchy;
            this.factory   = factory;
            toolWindow     = new Lazy <VsToolWindow> (() => new VsToolWindow(services, StandardToolWindows.ProjectExplorer));
        }
示例#21
0
		public SolutionExplorer (
			[Import (typeof (SVsServiceProvider))] IServiceProvider services,
			// Get the IVsHierarchyItemManager from our provider, so that it's a singleton 
			// and provided always from a UI thread. The default exported one from VS doesn't 
			// have the PartCreationPolicy.Shared attribute and is newed up in whatever context 
			// you're requesting it from.
			[Import (ContractNames.Interop.IVsHierarchyItemManager)] IVsHierarchyItemManager hierarchy,
			ISolutionExplorerNodeFactory factory)
		{
			Guard.NotNull (nameof (services), services);
			Guard.NotNull (nameof (hierarchy), hierarchy);
			Guard.NotNull (nameof (factory), factory);

			this.services = services;
			this.hierarchy = hierarchy;
			this.factory = factory;
			toolWindow = new Lazy<VsToolWindow> (() => new VsToolWindow (services, StandardToolWindows.ProjectExplorer));
		}
示例#22
0
 public CSharpCodeCleanUpFixer(IThreadingContext threadingContext, VisualStudioWorkspaceImpl workspace, IVsHierarchyItemManager vsHierarchyItemManager, IGlobalOptionService globalOptions)
     : base(threadingContext, workspace, vsHierarchyItemManager, globalOptions)
 {
 }
    private static HierarchyNode CreateNode(IVsHierarchy hierarchy, Guid identifier, IVsImageService2 imageService, IVsHierarchyItemManager hierarchyItemManager)
    {
        ThreadHelper.ThrowIfNotOnUIThread();

        ImageMoniker collapsedIcon;
        ImageMoniker expandedIcon;
        string       name;
        bool         isFolder;


        name = HierarchyUtilities.GetHierarchyProperty <string>(
            hierarchy,
            VSConstants.VSITEMID_ROOT,
            (int)__VSHPROPID.VSHPROPID_Name
            );

        isFolder = HierarchyUtilities.IsSolutionFolder(
            hierarchyItemManager.GetHierarchyItem(hierarchy, VSConstants.VSITEMID_ROOT).HierarchyIdentity
            );

        collapsedIcon = imageService.GetImageMonikerForHierarchyItem(
            hierarchy,
            VSConstants.VSITEMID_ROOT,
            (int)__VSHIERARCHYIMAGEASPECT.HIA_Icon
            );

        expandedIcon = imageService.GetImageMonikerForHierarchyItem(
            hierarchy,
            VSConstants.VSITEMID_ROOT,
            (int)__VSHIERARCHYIMAGEASPECT.HIA_OpenFolderIcon
            );

        // Sometimes the icons can be blank.
        // In those cases, use some default icons.
        if (collapsedIcon.Id == 0 && collapsedIcon.Guid == default)
        {
            collapsedIcon = isFolder ? KnownMonikers.FolderClosed : KnownMonikers.DocumentCollection;
        }

        if (expandedIcon.Id == 0 && expandedIcon.Guid == default)
        {
            expandedIcon = isFolder ? KnownMonikers.FolderOpened : KnownMonikers.DocumentCollection;
        }

        return(new HierarchyNode(identifier, name, collapsedIcon, expandedIcon)
        {
            IsLoaded = !HierarchyUtilities.IsStubHierarchy(hierarchy),
            IsFolder = isFolder
        });
    }