Interface InvertIfElseProvider<T>

A provider that can be registered to handle the inversion of if-else statements.

interface InvertIfElseProvider<T> {
    provideIfStatements(
        context: DocumentContext,
        range?: Range,
    ): ProviderResult<IfStatementRefNode<T>[]>;
    replaceIfStatement(
        context: DocumentContext,
        edit: TextEditorEdit,
        original: IfStatementRefNode<T>,
        replace: IfStatementUpdatedNode<T>,
    ): void;
    resolveIfStatement(
        context: DocumentContext,
        statement: IfStatementRefNode<T>,
    ): ProviderResult<IfStatementRefNode<T>>;
}

Type Parameters

  • T

Methods

  • Provide if-else statements for the given document and range.

    Parameters

    • context: DocumentContext

      The context of the document for which to provide if-else statements

    • Optionalrange: Range

      The range for which to provide if-else statements (the range may refer to a range inside an embedded section

    Returns ProviderResult<IfStatementRefNode<T>[]>

    A list of if-else statements with references to the original syntax nodes

    // Given the following code:
    if (a) {
    b();
    } else if(c){
    d();
    if (e) f();
    }

    // The following if-else statements should be returned:
    if (a) b() {...}
    if (e) f() {...}

    DocumentContext)