Share via


CodeRefactoringContext Struct

Definition

Context for code refactorings provided by a CodeRefactoringProvider.

public value class CodeRefactoringContext
public struct CodeRefactoringContext
public readonly struct CodeRefactoringContext
type CodeRefactoringContext = struct
Public Structure CodeRefactoringContext
Inheritance
CodeRefactoringContext

Constructors

CodeRefactoringContext(Document, TextSpan, Action<CodeAction>, CancellationToken)

Creates a code refactoring context to be passed into ComputeRefactoringsAsync(CodeRefactoringContext) method.

CodeRefactoringContext(TextDocument, TextSpan, Action<CodeAction>, CancellationToken)

Creates a code refactoring context to be passed into ComputeRefactoringsAsync(CodeRefactoringContext) method.

Properties

CancellationToken

CancellationToken.

Document

Document corresponding to the Span to refactor. For code refactorings that support non-source documents by providing a non-default value for DocumentKinds, this property will throw an InvalidOperationException. Such refactorings should use the TextDocument property instead.

Span

Text span within the Document or TextDocument to refactor.

TextDocument

TextDocument corresponding to the Span to refactor. This property should be used instead of Document property by code refactorings that support non-source documents by providing a non-default value for DocumentKinds

Methods

RegisterRefactoring(CodeAction)

Add supplied action to the list of refactorings that will be offered to the user.

Applies to