mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-25 20:48:27 +00:00
fix numbers
This commit is contained in:
parent
8b0e036ed5
commit
dcebdd6dbc
@ -92,15 +92,16 @@ export default (code) => {
|
|||||||
// add to location to pure(x) calls
|
// add to location to pure(x) calls
|
||||||
if (node.type === 'CallExpression' && node.callee.name === 'pure') {
|
if (node.type === 'CallExpression' && node.callee.name === 'pure') {
|
||||||
const literal = node.arguments[0];
|
const literal = node.arguments[0];
|
||||||
const value = literal[{ LiteralNumericExpression: 'value', LiteralStringExpression: 'name' }[literal.type]];
|
// const value = literal[{ LiteralNumericExpression: 'value', LiteralStringExpression: 'name' }[literal.type]];
|
||||||
return reifyWithLocation(value + '', node.arguments[0], ast.locations, artificialNodes);
|
// console.log('value',value);
|
||||||
|
return reifyWithLocation(literal, node.arguments[0], ast.locations, artificialNodes);
|
||||||
}
|
}
|
||||||
// replace pseudo note variables
|
// replace pseudo note variables
|
||||||
if (node.type === 'IdentifierExpression') {
|
if (node.type === 'IdentifierExpression') {
|
||||||
if (isNote(node.name)) {
|
if (isNote(node.name)) {
|
||||||
const value = node.name[1] === 's' ? node.name.replace('s', '#') : node.name;
|
const value = node.name[1] === 's' ? node.name.replace('s', '#') : node.name;
|
||||||
if (addLocations && isMarkable) {
|
if (addLocations && isMarkable) {
|
||||||
return reifyWithLocation(value, node, ast.locations, artificialNodes);
|
return reifyWithLocation(new LiteralStringExpression({ value }), node, ast.locations, artificialNodes);
|
||||||
}
|
}
|
||||||
return new LiteralStringExpression({ value });
|
return new LiteralStringExpression({ value });
|
||||||
}
|
}
|
||||||
@ -110,7 +111,7 @@ export default (code) => {
|
|||||||
}
|
}
|
||||||
if (addLocations && node.type === 'LiteralStringExpression' && isMarkable) {
|
if (addLocations && node.type === 'LiteralStringExpression' && isMarkable) {
|
||||||
// console.log('add', node);
|
// console.log('add', node);
|
||||||
return reifyWithLocation(node.value, node, ast.locations, artificialNodes);
|
return reifyWithLocation(node, node, ast.locations, artificialNodes);
|
||||||
}
|
}
|
||||||
if (!addMiniLocations) {
|
if (!addMiniLocations) {
|
||||||
return wrapFunction('reify', node);
|
return wrapFunction('reify', node);
|
||||||
@ -219,10 +220,10 @@ function wrapLocationOffset(node, stringNode, locations, artificialNodes) {
|
|||||||
|
|
||||||
// turns node in reify(value).withLocation(location), where location is the node's location in the source code
|
// turns node in reify(value).withLocation(location), where location is the node's location in the source code
|
||||||
// with this, the reified pattern can pass its location to the event, to know where to highlight when it's active
|
// with this, the reified pattern can pass its location to the event, to know where to highlight when it's active
|
||||||
function reifyWithLocation(value, node, locations, artificialNodes) {
|
function reifyWithLocation(literalNode, node, locations, artificialNodes) {
|
||||||
const withLocation = new CallExpression({
|
const withLocation = new CallExpression({
|
||||||
callee: new StaticMemberExpression({
|
callee: new StaticMemberExpression({
|
||||||
object: wrapFunction('reify', new LiteralStringExpression({ value })),
|
object: wrapFunction('reify', literalNode),
|
||||||
property: 'withLocation',
|
property: 'withLocation',
|
||||||
}),
|
}),
|
||||||
arguments: [getLocationObject(node, locations)],
|
arguments: [getLocationObject(node, locations)],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user