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:
- wrap code temporarily around before parsing it check
builder example for adding AST nodes. This would not fix problems like eslint errors.
- wrap code around in a function buffer
- buffer now parsable by everything
- added code should be read only (never saw 'read only' mode on a per character basis), because user should not change this
- Yode could probably track that a change to the added name occurred and restore it, as Yode can change through the
editorApi and the editor plugin can than react to to this also like make a tooltip "you should not edit this, here are dragons"
- a bit bad look and feel as users sees code which is not in the file, can be solved by highlighting?!
Some examples:
Code like this can't be parsed by Recast, because it is not valid JavaScript syntax:
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.:
ideas:
builderexample for adding AST nodes. This would not fix problems like eslint errors.editorApiand the editor plugin can than react to to this also like make a tooltip "you should not edit this, here are dragons"