default to forceUpdateLocation

This commit is contained in:
Julian Rosse
2018-09-17 10:58:54 -04:00
parent b18e91f936
commit e679cbccf7
5 changed files with 227 additions and 227 deletions

View File

@@ -48,7 +48,7 @@
// is added to the first parameter passed in, and the parameter is returned.
// If the parameter is not a node, it will just be passed through unaffected.
getAddDataToNodeFunctionString = function(first, last) {
return `yy.addDataToNode(yy, @${first}, ${last ? `@${last}` : 'null'}, {forceUpdateLocation: true})`;
return `yy.addDataToNode(yy, {first: @${first}, ${last ? `last: @${last}, ` : ''}})`;
};
action = action.replace(/LOC\(([0-9]*)\)/g, getAddDataToNodeFunctionString('$1'));
action = action.replace(/LOC\(([0-9]*),\s*([0-9]*)\)/g, getAddDataToNodeFunctionString('$1', '$2'));

View File

@@ -199,7 +199,7 @@
// This returns a function which takes an object as a parameter, and if that
// object is an AST node, updates that object's locationData.
// The object is returned either way.
exports.addDataToNode = function(parserState, first, last, {forceUpdateLocation} = {}) {
exports.addDataToNode = function(parserState, {first, last, forceUpdateLocation = true}) {
return function(obj) {
var objHash, ref1;
// Add location data.

File diff suppressed because it is too large Load Diff

View File

@@ -45,7 +45,7 @@ o = (patternString, action, options) ->
# is added to the first parameter passed in, and the parameter is returned.
# If the parameter is not a node, it will just be passed through unaffected.
getAddDataToNodeFunctionString = (first, last) ->
"yy.addDataToNode(yy, @#{first}, #{if last then "@#{last}" else 'null'}, {forceUpdateLocation: true})"
"yy.addDataToNode(yy, {first: @#{first}, #{if last then "last: @#{last}, " else ''}})"
action = action.replace /LOC\(([0-9]*)\)/g, getAddDataToNodeFunctionString('$1')
action = action.replace /LOC\(([0-9]*),\s*([0-9]*)\)/g, getAddDataToNodeFunctionString('$1', '$2')

View File

@@ -136,7 +136,7 @@ buildTokenDataDictionary = (parserState) ->
# This returns a function which takes an object as a parameter, and if that
# object is an AST node, updates that object's locationData.
# The object is returned either way.
exports.addDataToNode = (parserState, first, last, {forceUpdateLocation} = {}) ->
exports.addDataToNode = (parserState, {first, last, forceUpdateLocation = yes}) ->
(obj) ->
# Add location data.
if obj?.updateLocationDataIfMissing? and first?