當前位置: 首頁>>代碼示例>>C#>>正文


C# CodeActions.CodeAction類代碼示例

本文整理匯總了C#中Microsoft.CodeAnalysis.CodeActions.CodeAction的典型用法代碼示例。如果您正苦於以下問題:C# CodeAction類的具體用法?C# CodeAction怎麽用?C# CodeAction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CodeAction類屬於Microsoft.CodeAnalysis.CodeActions命名空間,在下文中一共展示了CodeAction類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CodeFix

 internal CodeFix(Project project, CodeAction action, ImmutableArray<Diagnostic> diagnostics)
 {
     Debug.Assert(!diagnostics.IsDefault);
     this.Project = project;
     this.Action = action;
     this.Diagnostics = diagnostics;
 }
開發者ID:XieShuquan,項目名稱:roslyn,代碼行數:7,代碼來源:CodeFix.cs

示例2: SuggestedActionWithFlavors

 protected SuggestedActionWithFlavors(
     Workspace workspace,
     ITextBuffer subjectBuffer,
     ICodeActionEditHandlerService editHandler,
     CodeAction codeAction,
     object provider) : base(workspace, subjectBuffer, editHandler, codeAction, provider)
 {
 }
開發者ID:noahstein,項目名稱:roslyn,代碼行數:8,代碼來源:SuggestedActionWithFlavors.cs

示例3: SuggestedActionWithPreview

 public SuggestedActionWithPreview(
     Workspace workspace, ITextBuffer subjectBuffer, ICodeActionEditHandlerService editHandler, 
     IWaitIndicator waitIndicator, CodeAction codeAction, object provider, 
     IAsynchronousOperationListener operationListener) 
     : base(workspace, subjectBuffer, editHandler, waitIndicator, codeAction,
           provider, operationListener, actionSets: null)
 {
 }
開發者ID:genlu,項目名稱:roslyn,代碼行數:8,代碼來源:SuggestedActionWithPreview.cs

示例4: SuggestedActionWithNestedActions

 public SuggestedActionWithNestedActions(
     SuggestedActionsSourceProvider sourceProvider, Workspace workspace, 
     ITextBuffer subjectBuffer, object provider, 
     CodeAction codeAction, SuggestedActionSet nestedActionSet) 
     : base(sourceProvider, workspace, subjectBuffer, provider, codeAction)
 {
     NestedActionSet = nestedActionSet;
 }
開發者ID:XieShuquan,項目名稱:roslyn,代碼行數:8,代碼來源:SuggestedActionWithNestedActions.cs

示例5: ExecuteCodeAction

 private async Task ExecuteCodeAction(CodeAction codeAction)
 {
     var operations = await codeAction.GetOperationsAsync(CancellationToken.None).ConfigureAwait(true);
     foreach (var operation in operations)
     {
         operation.Apply(_roslynHost.GetDocument(_documentId).Project.Solution.Workspace, CancellationToken.None);
     }
 }
開發者ID:mjheitland,項目名稱:TableTweaker,代碼行數:8,代碼來源:RoslynContextActionProvider.cs

示例6: CodeRefactoringSuggestedAction

 public CodeRefactoringSuggestedAction(
     SuggestedActionsSourceProvider sourceProvider,
     Workspace workspace,
     ITextBuffer subjectBuffer,
     CodeRefactoringProvider provider,
     CodeAction codeAction)
     : base(sourceProvider, workspace, subjectBuffer, provider, codeAction)
 {
 }
開發者ID:XieShuquan,項目名稱:roslyn,代碼行數:9,代碼來源:CodeRefactoringSuggestedAction.cs

示例7: RegisterRefactoring

        /// <summary>
        /// Add supplied <paramref name="action"/> to the list of refactorings that will be offered to the user.
        /// </summary>
        /// <param name="action">The <see cref="CodeAction"/> that will be invoked to apply the refactoring.</param>
        public void RegisterRefactoring(CodeAction action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            _registerRefactoring(action);
        }
開發者ID:XieShuquan,項目名稱:roslyn,代碼行數:13,代碼來源:CodeRefactoringContext.cs

示例8: CodeRefactoringSuggestedAction

 public CodeRefactoringSuggestedAction(
     Workspace workspace,
     ITextBuffer subjectBuffer,
     ICodeActionEditHandlerService editHandler,
     CodeAction codeAction,
     CodeRefactoringProvider provider)
     : base(workspace, subjectBuffer, editHandler, codeAction, provider)
 {
 }
開發者ID:GloryChou,項目名稱:roslyn,代碼行數:9,代碼來源:CodeRefactoringSuggestedAction.cs

示例9: SuggestedActionWithNestedFlavors

 public SuggestedActionWithNestedFlavors(
     SuggestedActionsSourceProvider sourceProvider,
     Workspace workspace, ITextBuffer subjectBuffer,
     object provider, CodeAction codeAction, 
     SuggestedActionSet additionalFlavors = null) 
     : base(sourceProvider, workspace, subjectBuffer, 
            provider, codeAction)
 {
     _additionalFlavors = additionalFlavors;
 }
開發者ID:XieShuquan,項目名稱:roslyn,代碼行數:10,代碼來源:SuggestedActionWithNestedFlavors.cs

示例10: SuggestedActionWithFlavors

 protected SuggestedActionWithFlavors(
     Workspace workspace,
     ITextBuffer subjectBuffer,
     ICodeActionEditHandlerService editHandler,
     IWaitIndicator waitIndicator,
     CodeAction codeAction,
     object provider,
     IAsynchronousOperationListener operationListener) : base(workspace, subjectBuffer, editHandler, waitIndicator, codeAction, provider, operationListener)
 {
 }
開發者ID:rgani,項目名稱:roslyn,代碼行數:10,代碼來源:SuggestedActionWithFlavors.cs

示例11: CodeRefactoringSuggestedAction

 public CodeRefactoringSuggestedAction(
     Workspace workspace,
     ITextBuffer subjectBuffer,
     ICodeActionEditHandlerService editHandler,
     IWaitIndicator waitIndicator,
     CodeAction codeAction,
     CodeRefactoringProvider provider,
     IAsynchronousOperationListener operationListener)
     : base(workspace, subjectBuffer, editHandler, waitIndicator, codeAction, provider, operationListener)
 {
 }
開發者ID:genlu,項目名稱:roslyn,代碼行數:11,代碼來源:CodeRefactoringSuggestedAction.cs

示例12: GetFixAllOperationsAsync

        private async Task<IEnumerable<CodeActionOperation>> GetFixAllOperationsAsync(CodeAction codeAction, FixAllContext fixAllContext, string fixAllPreviewChangesTitle, bool showPreviewChangesDialog)
        {
            // We have computed the fix all occurrences code fix.
            // Now fetch the new solution with applied fix and bring up the Preview changes dialog.

            var cancellationToken = fixAllContext.CancellationToken;
            var workspace = fixAllContext.Project.Solution.Workspace;

            cancellationToken.ThrowIfCancellationRequested();
            var operations = await codeAction.GetOperationsAsync(cancellationToken).ConfigureAwait(false);
            if (operations == null)
            {
                return null;
            }

            cancellationToken.ThrowIfCancellationRequested();
            var newSolution = await codeAction.GetChangedSolutionInternalAsync(cancellationToken).ConfigureAwait(false);

            if (showPreviewChangesDialog)
            {
                cancellationToken.ThrowIfCancellationRequested();
                using (Logger.LogBlock(FunctionId.CodeFixes_FixAllOccurrencesPreviewChanges, cancellationToken))
                {
                    var previewService = workspace.Services.GetService<IPreviewDialogService>();
                    var glyph = fixAllContext.Project.Language == LanguageNames.CSharp ?
                        Glyph.CSharpProject :
                        Glyph.BasicProject;

                    var changedSolution = previewService.PreviewChanges(
                    string.Format(EditorFeaturesResources.PreviewChangesOf, fixAllPreviewChangesTitle),
                    "vs.codefix.fixall",
                    codeAction.Title,
                    fixAllPreviewChangesTitle,
                    glyph,
                    newSolution,
                    fixAllContext.Project.Solution);

                    if (changedSolution == null)
                    {
                        // User clicked cancel.
                        FixAllLogger.LogPreviewChangesResult(applied: false);
                        return null;
                    }

                    FixAllLogger.LogPreviewChangesResult(applied: true, allChangesApplied: changedSolution == newSolution);
                    newSolution = changedSolution;
                }
            }

            // Get a code action, with apply changes operation replaced with the newSolution.
            return GetNewFixAllOperations(operations, newSolution, cancellationToken);
        }
開發者ID:nemec,項目名稱:roslyn,代碼行數:52,代碼來源:FixAllGetFixesService.cs

示例13: RefactoringPreviewTooltipWindow

		public RefactoringPreviewTooltipWindow (TextEditor editor, DocumentContext documentContext, CodeAction codeAction)
		{
			this.editor = editor;
			this.documentContext = documentContext;
			this.codeAction = codeAction;
			TransientFor = IdeApp.Workbench.RootWindow;

			fontDescription = Pango.FontDescription.FromString (DefaultSourceEditorOptions.Instance.FontName);
			fontDescription.Size = (int)(fontDescription.Size * 0.8f);

			using (var metrics = PangoContext.GetMetrics (fontDescription, PangoContext.Language)) {
				lineHeight = (int)Math.Ceiling (0.5 + (metrics.Ascent + metrics.Descent) / Pango.Scale.PangoScale);
			}
		}
開發者ID:FreeBSD-DotNet,項目名稱:monodevelop,代碼行數:14,代碼來源:RefactoringPreviewTooltipWindow.cs

示例14: CodeAction

        public static void CodeAction(CodeAction codeAction, Document document, string expectedCode)
        {
            var operations = codeAction.GetOperationsAsync(CancellationToken.None).Result;

            Assert.That(operations.Count(), Is.EqualTo(1));

            var operation = operations.Single();
            var workspace = document.Project.Solution.Workspace;
            operation.Apply(workspace, CancellationToken.None);

            var newDocument = workspace.CurrentSolution.GetDocument(document.Id);

            var sourceText = newDocument.GetTextAsync(CancellationToken.None).Result;
            var text = sourceText.ToString();

            Assert.That(text, Is.EqualTo(expectedCode));
        }
開發者ID:sangelov,項目名稱:RoslynNUnitLight,代碼行數:17,代碼來源:Verify.cs

示例15: TryGetRedundantLambdaParameterAction

        private static bool TryGetRedundantLambdaParameterAction(SyntaxNode syntaxNode, SyntaxNode root,
            Document document, out CodeAction action)
        {
            var parameterList = syntaxNode.Parent?.Parent as ParameterListSyntax;
            if (parameterList == null)
            {
                action = null;
                return false;
            }

            action = CodeAction.Create(TitleRedundantLambdaParameterType, c =>
            {
                var newParameterList = parameterList.WithParameters(
                    SyntaxFactory.SeparatedList(parameterList.Parameters.Select(p =>
                        SyntaxFactory.Parameter(p.Identifier).WithTriviaFrom(p))));
                var newRoot = root.ReplaceNode(parameterList, newParameterList);
                return Task.FromResult(document.WithSyntaxRoot(newRoot));
            }, TitleRedundantLambdaParameterType);
            return true;
        }
開發者ID:dbolkensteyn,項目名稱:sonarlint-vs,代碼行數:20,代碼來源:RedundantDeclarationCodeFixProvider.cs


注:本文中的Microsoft.CodeAnalysis.CodeActions.CodeAction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。