decaffeinate-parser
Advanced tools
Comparing version 18.1.0 to 19.0.0
@@ -18,3 +18,3 @@ "use strict"; | ||
var value = mapValue_1["default"](context, property); | ||
members.push(new nodes_2.ObjectInitialiserMember(line_1, column_1, start_1, end_1, raw_1, value, value)); | ||
members.push(new nodes_2.ObjectInitialiserMember(line_1, column_1, start_1, end_1, raw_1, value, null)); | ||
} | ||
@@ -21,0 +21,0 @@ else if (property instanceof nodes_1.Assign && property.context === 'object') { |
@@ -11,3 +11,3 @@ import SourceToken from 'coffee-lex/dist/SourceToken'; | ||
readonly raw: string; | ||
readonly range: [number, number]; | ||
parentNode: Node | null; | ||
constructor(type: string, line: number, column: number, start: number, end: number, raw: string); | ||
@@ -95,4 +95,4 @@ getChildren(): Array<Node>; | ||
readonly key: Node; | ||
readonly expression: Node; | ||
constructor(line: number, column: number, start: number, end: number, raw: string, key: Node, expression: Node); | ||
readonly expression: Node | null; | ||
constructor(line: number, column: number, start: number, end: number, raw: string, key: Node, expression: Node | null); | ||
getChildFields(): Array<ChildField>; | ||
@@ -99,0 +99,0 @@ } |
@@ -21,4 +21,3 @@ "use strict"; | ||
this.raw = raw; | ||
this.range = [start, end]; | ||
this.raw = raw; | ||
this.parentNode = null; | ||
} | ||
@@ -241,3 +240,5 @@ Node.prototype.getChildren = function () { | ||
__extends(ObjectInitialiserMember, _super); | ||
function ObjectInitialiserMember(line, column, start, end, raw, key, expression) { | ||
function ObjectInitialiserMember(line, column, start, end, raw, key, | ||
// If null, this is a shorthand initializer and the key and value are the same. | ||
expression) { | ||
var _this = _super.call(this, 'ObjectInitialiserMember', line, column, start, end, raw) || this; | ||
@@ -244,0 +245,0 @@ _this.key = key; |
@@ -1,2 +0,3 @@ | ||
import { Program } from './nodes'; | ||
import { Node, Program } from './nodes'; | ||
export declare function parse(source: string): Program; | ||
export declare function traverse(node: Node, callback: (node: Node, parent: Node | null) => boolean | void): void; |
@@ -13,4 +13,21 @@ "use strict"; | ||
fixLocations_1["default"](context, context.ast); | ||
return mapProgram_1["default"](context); | ||
var program = mapProgram_1["default"](context); | ||
traverse(program, function (node, parent) { | ||
node.parentNode = parent; | ||
}); | ||
return program; | ||
} | ||
exports.parse = parse; | ||
function traverse(node, callback) { | ||
function traverseRec(currentNode, currentParent) { | ||
var shouldDescend = callback(currentNode, currentParent); | ||
if (shouldDescend !== false) { | ||
for (var _i = 0, _a = currentNode.getChildren(); _i < _a.length; _i++) { | ||
var child = _a[_i]; | ||
traverseRec(child, currentNode); | ||
} | ||
} | ||
} | ||
traverseRec(node, null); | ||
} | ||
exports.traverse = traverse; |
{ | ||
"name": "decaffeinate-parser", | ||
"description": "A better AST for CoffeeScript, inspired by CoffeeScriptRedux.", | ||
"version": "19.0.0", | ||
"main": "dist/parser.js", | ||
@@ -35,3 +36,3 @@ "module": "dist/parser.mjs", | ||
"@types/mocha": "^2.2.35", | ||
"@types/node": "8.0.14", | ||
"@types/node": "8.0.15", | ||
"babel": "^6.5.2", | ||
@@ -62,4 +63,3 @@ "babel-eslint": "^7.1.1", | ||
"url": "https://github.com/decaffeinate/decaffeinate-parser.git" | ||
}, | ||
"version": "18.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
327958
7500