You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when grasp is using flow parser , the AST returns ranges and getRaw returns incorrect match.
See test case. This is eather bug in flow-parser or bad interpretation of range in grasp implementation of getRaw. Any hints ? Thanx
const grasp = require("grasp");
var raw;
var replacer = grasp.replace('equery', 'var INPUT=$x;', function(getRaw, node, query, named) {
raw = getRaw(node);
return "";
});
replacer("var INPUT={test:'aa'};var UNEXPECTED;");
console.assert(raw==="var INPUT={test:'aa'};");
replacer("var INPUT={test:'až'};var UNEXPECTED;");
console.log(raw); //contains extra char, range from AST is wrong
console.assert(raw==="var INPUT={test:'až'};"); //FAILS
The text was updated successfully, but these errors were encountered:
Just a note: On the other hand, it seems that -o option works , because formatResult function does not work with node.range but works with node.loc.
Please can you explain also parser options range:true and false ? I tried to switch it to false for flow-parser but it seems to have no effect and node.rage is still calculated (and incorrectly) interpreted in replaceFunction (getRaw)
when grasp is using flow parser , the AST returns ranges and getRaw returns incorrect match.
See test case. This is eather bug in flow-parser or bad interpretation of range in grasp implementation of getRaw. Any hints ? Thanx
const grasp = require("grasp");
var raw;
var replacer = grasp.replace('equery', 'var INPUT=$x;', function(getRaw, node, query, named) {
raw = getRaw(node);
return "";
});
replacer("var INPUT={test:'aa'};var UNEXPECTED;");
console.assert(raw==="var INPUT={test:'aa'};");
replacer("var INPUT={test:'až'};var UNEXPECTED;");
console.log(raw); //contains extra char, range from AST is wrong
console.assert(raw==="var INPUT={test:'až'};"); //FAILS
The text was updated successfully, but these errors were encountered: