Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Improve error recovery #124

Open
lucaswerkmeister opened this issue Oct 28, 2015 · 0 comments
Open

Improve error recovery #124

lucaswerkmeister opened this issue Oct 28, 2015 · 0 comments
Assignees
Milestone

Comments

@lucaswerkmeister
Copy link
Contributor

The current error recovery of the FormattingWriter doesn’t work very well. I think one approach that might work better would be that FormattingWriter always throws an exception when it encounters an unexpected token, and FormattingVisitor handles it:

    shared actual void visitStatement(Statement that) {
        try {
            value context = fWriter.openContext();
            that.visitChildren(this);
            if (exists mainEndToken = that.mainEndToken) {
                writeSemicolon(fWriter, mainEndToken, context);
            } else {
                // complex statements like loops, ifs, etc. don’t end in a semicolon
                fWriter.closeContext(context);
            }
        } catch (UnexpectedTokenException ute) {
            if (exists mainEndToken = that.mainEndToken) {
                fWriter.writeRecoveryToken {
                    mainEndToken;
                    // other options as in writeToken
                };
            } else {
                throw ute;
            }
        }
    }

where writeRecoveryToken writes out all unexpected tokens until it finds the recovery token (here, the semicolon). This is mostly what FormattingWriter currently does, but I think the fact that it tries to do it for any token makes it unstable.

Needs more investigation though.

CC eclipse-archived/ceylon-ide-eclipse#1536.

@lucaswerkmeister lucaswerkmeister self-assigned this Oct 28, 2015
@lucaswerkmeister lucaswerkmeister added this to the 1.3.0 milestone Oct 28, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant