Skip to content

Do not use rewrite to add new imports #1520

Closed
@berberman

Description

@berberman

hideImplicitPreludeSymbol, or newImport which I factored out in #1428, is really weird in my opinion. The goal is simple: to insert an import declaration, but it's a little bit tedious to express this in Rewrite -- we concatenate strings manually, parse it, adjust its annotations, and finally print it with exactPrint, which is kinda going round. Moreover, I don't think it accords with the semantic of rewriting ASTs: it rewrites nothing, but returns a new AST. The true rewriting in this case should be appending the new import declaration into the end of hsmodDecls, a part of HsModule, but it seems less resonable as well, so TextEdit could be the solution. I plan to remove newImport in my next PR.

Originally posted in #1512

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions