Don't change style of functions defined with sequential arguments vs options argument; keep the focus of this PR on the AST work, not on unnecessary style changes

This commit is contained in:
Geoffrey Booth 2018-09-22 22:29:02 -07:00
parent e1625a0d31
commit 617a2d5b65
7 changed files with 232 additions and 234 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: @${first}, ${last ? `last: @${last}, ` : ''}})`;
return `yy.addDataToNode(yy, @${first}${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,14 +199,12 @@
// 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 = true}) {
exports.addDataToNode = function(parserState, first, last, forceUpdateLocation = true) {
return function(obj) {
var objHash, ref1;
// Add location data.
if (((obj != null ? obj.updateLocationDataIfMissing : void 0) != null) && (first != null)) {
obj.updateLocationDataIfMissing(buildLocationData(first, last), {
force: forceUpdateLocation
});
obj.updateLocationDataIfMissing(buildLocationData(first, last), forceUpdateLocation);
}
// Add comments, building the dictionary of token data if it hasnt been
// built yet.

View File

@ -491,7 +491,7 @@
// For this node and all descendents, set the location data to `locationData`
// if the location data is not already set.
updateLocationDataIfMissing(locationData, {force} = {}) {
updateLocationDataIfMissing(locationData, force) {
if (force) {
this.forceUpdateLocation = true;
}

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: @#{first}, #{if last then "last: @#{last}, " else ''}})"
"yy.addDataToNode(yy, @#{first}#{if last then ", @#{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,11 +136,11 @@ 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 = yes}) ->
exports.addDataToNode = (parserState, first, last, forceUpdateLocation = yes) ->
(obj) ->
# Add location data.
if obj?.updateLocationDataIfMissing? and first?
obj.updateLocationDataIfMissing buildLocationData(first, last), force: forceUpdateLocation
obj.updateLocationDataIfMissing buildLocationData(first, last), forceUpdateLocation
# Add comments, building the dictionary of token data if it hasnt been
# built yet.

View File

@ -398,7 +398,7 @@ exports.Base = class Base
# For this node and all descendents, set the location data to `locationData`
# if the location data is not already set.
updateLocationDataIfMissing: (locationData, {force} = {}) ->
updateLocationDataIfMissing: (locationData, force) ->
@forceUpdateLocation = yes if force
return this if @locationData and not @forceUpdateLocation
delete @forceUpdateLocation