Skip to content

Commit fe38658

Browse files
committed
root ast methods
1 parent 21ea0ee commit fe38658

File tree

3 files changed

+31
-34
lines changed

3 files changed

+31
-34
lines changed

lib/coffeescript/nodes.js

Lines changed: 19 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,13 @@ exports.Root = class Root extends Base
482482
return fragments if o.bare
483483
[].concat @makeCode("(function() {\n"), fragments, @makeCode("\n}).call(this);\n")
484484

485+
astType: -> 'File'
486+
487+
astProperties: ->
488+
return
489+
program: @body.ast()
490+
comments: []
491+
485492
#### Block
486493

487494
# The block is the list of expressions that forms the body of an
@@ -776,26 +783,13 @@ exports.Block = class Block extends Base
776783
bodyToAst: ->
777784
@getExpressionAst(expression) for expression in @expressions
778785

779-
rootToAst: ->
780-
programLocationData = @astLocationData()
786+
astType: -> 'Program'
781787

782-
programAst = Object.assign
783-
type: 'Program'
784-
sourceType: 'module'
788+
astProperties: ->
789+
return
790+
# sourceType: 'module'
785791
body: @bodyToAst()
786792
directives: []
787-
,
788-
programLocationData
789-
790-
Object.assign
791-
type: 'File'
792-
program: programAst
793-
comments: []
794-
,
795-
programLocationData
796-
797-
ast: ->
798-
@rootToAst()
799793

800794
#### Literal
801795

test/abstract_syntax_tree.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ test "AST as expected for Block node", ->
9696
type: 'File'
9797
program:
9898
type: 'Program'
99-
sourceType: 'module' # TODO: should this always be module?
99+
# sourceType: 'module'
100100
body: [
101101
type: 'ExpressionStatement'
102102
expression:

0 commit comments

Comments
 (0)