Skip to content

Surround with refactoring #18458

Description

@mjbvz

Proposal
Add a refactoring that can surround a statement with a try/catch block or potentially other blocks

For example:

class Ranger {
    rick(count: number, precision: number) {
        let result = 'r'
        for (let i = 0; i < count; ++i) 
            result += i.toPrecision(precision)
        return result
    }
}
new Ranger().rick(2, -1)

if a user selects the for block and did a surround with try/catch refactoring, the result would be:

class Ranger {
    rick(count: number, precision: number) {
        let result = 'r'
        try {
            for (let i = 0; i < count; ++i)
                result += i.toPrecision(precision)
        } catch (e) {

        }
        return result
    }
}
new Ranger().rick(2, -1)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: LS: Refactoringse.g. extract to constant or function, rename symbolExternalRelates to another program, environment, or user action which we cannot control.VS Code TrackedThere is a VS Code equivalent to this issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions