hoschi / yode

Yode - Focused Code Editing
https://hoschi.github.io/yode/
MIT License
30 stars 1 forks source link

add support for non parsable FunctionExpression node type #8

Open hoschi opened 6 years ago

hoschi commented 6 years ago

Some examples:

let assignedFunction = function (a, b) {
        if (a) {
            return 'a';
        } else {
            return 'b';
        }
    };

[].map(function (a, i) {
        return i
    });

// FunctionExpression inside an ObjectExpression
let myInstance = {
    myMethod() {
        return 'foo'
    }
}

Code like this can't be parsed by Recast, because it is not valid JavaScript syntax:

function (a, i) {
    return i
}

Also other parts in the ecosystem can't handle this, like 'eslint' which would mark the first line as error and doesn't show other errors. The language server used in Oni today can handle this code btw, you still get completions.

By adding a name the code is parsable again, e.g.:

function thisIsNotPartOfYourCode (a, i) {
    return i
}

ideas:

hoschi commented 6 years ago

never saw 'read only' mode on a per character basis

@bryphe or is it?