import {Parser} from "./state" import {SourceLocation} from "./location" // Start an AST node, attaching a start offset. const pp = Parser.prototype export class Node {} pp.startNode = function() { let node = new Node node.start = this.start if (this.options.locations) node.loc = new SourceLocation(this, this.startLoc) if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile if (this.options.ranges) node.range = [this.start, 0] return node } pp.startNodeAt = function(pos, loc) { let node = new Node if (Array.isArray(pos)){ if (this.options.locations && loc === undefined) { // flatten pos loc = pos[1] pos = pos[0] } } node.start = pos if (this.options.locations) node.loc = new SourceLocation(this, loc) if (this.options.directSourceFile) node.sourceFile = this.options.directSourceFile if (this.options.ranges) node.range = [pos, 0] return node } // Finish an AST node, adding `type` and `end` properties. pp.finishNode = function(node, type) { node.type = type node.end = this.lastTokEnd if (this.options.locations) node.loc.end = this.lastTokEndLoc if (this.options.ranges) node.range[1] = this.lastTokEnd return node } // Finish node at given position pp.finishNodeAt = function(node, type, pos, loc) { node.type = type if (Array.isArray(pos)){ if (this.options.locations && loc === undefined) { // flatten pos loc = pos[1] pos = pos[0] } } node.end = pos if (this.options.locations) node.loc.end = loc if (this.options.ranges) node.range[1] = pos return node }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/acorn/src/node.js | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |