Skip to content

Commit

Permalink
don't mutate locationData
Browse files Browse the repository at this point in the history
  • Loading branch information
helixbass committed Oct 8, 2018
1 parent b3d5cdb commit 51f566f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
16 changes: 10 additions & 6 deletions lib/coffeescript/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions src/nodes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1305,20 +1305,24 @@ exports.Call = class Call extends Base
# expands the range on the left, but not the right.
updateLocationDataIfMissing: (locationData) ->
if @locationData and @needsUpdatedStartLocation
@locationData.first_line = locationData.first_line
@locationData.first_column = locationData.first_column
@locationData.range = [
locationData.range[0]
@locationData.range[1]
]
base = @variable?.base or @variable
if base.needsUpdatedStartLocation
@variable.locationData.first_line = locationData.first_line
@variable.locationData.first_column = locationData.first_column
@variable.locationData.range = [
@locationData = Object.assign {},
@locationData,
first_line: locationData.first_line
first_column: locationData.first_column
range: [
locationData.range[0]
@variable.locationData.range[1]
@locationData.range[1]
]
base = @variable?.base or @variable
if base.needsUpdatedStartLocation
@variable.locationData = Object.assign {},
@variable.locationData,
first_line: locationData.first_line
first_column: locationData.first_column
range: [
locationData.range[0]
@variable.locationData.range[1]
]
base.updateLocationDataIfMissing locationData
delete @needsUpdatedStartLocation
super locationData
Expand Down

0 comments on commit 51f566f

Please sign in to comment.