BVB Source Codes

prettier Show jsAst.js Source code

Return Download prettier: download jsAst.js Source code - Download prettier Source code - Type:.js
  1. /**
  2.  * @flow
  3.  */
  4. export type Comment = {
  5.   loc: ?SourceLocation,
  6.   value: string,
  7.   leading: boolean,
  8.   trailing: boolean,
  9. };
  10.  
  11. export type SourceLocation = {
  12.   start: SourcePosition,
  13.   end: SourcePosition,
  14.   source: ?string,
  15. };
  16.  
  17. export type SourcePosition = {
  18.   line: number,
  19.   column: number,
  20. };
  21.  
  22. export type File = {
  23.   source: ?string,
  24.   start: SourcePosition,
  25.   end: SourcePosition,
  26.   comments: ?Array<Comment>,
  27.   type: 'File',
  28.   program: Program,
  29. }
  30.  
  31. export type Program = {
  32.   source: ?string,
  33.   start: SourcePosition,
  34.   end: SourcePosition,
  35.   comments: ?Array<Comment>,
  36.   type: 'Program',
  37.   body: Statement[],
  38. }
  39.  
  40. export type BinaryOperator =
  41.   |'=='
  42.   | '!='
  43.   | '==='
  44.   | '!=='
  45.   | '<'
  46.   | '<='
  47.   | '>'
  48.   | '>='
  49.   | '<<'
  50.   | '>>'
  51.   | '>>>'
  52.   | '+'
  53.   | '-'
  54.   | '*'
  55.   | '/'
  56.   | '%'
  57.   | '&' // TODO Missing from the Parser API.
  58.   | '|'
  59.   | '^'
  60.   | 'in'
  61.   | 'instanceof'
  62.   | '..'
  63. ;
  64.  
  65. export type UnaryOperator =
  66.   | '-'
  67.   | '+'
  68.   | '!'
  69.   | '~'
  70.   | 'typeof'
  71.   | 'void'
  72.   | 'delete'
  73. ;
  74.  
  75. export type AssignmentOperator =
  76.   | '='
  77.   | '+='
  78.   | '-='
  79.   | '*='
  80.   | '/='
  81.   | '%='
  82.   | '<<='
  83.   | '>>='
  84.   | '>>>='
  85.   | '|='
  86.   | '^='
  87.   | '&='
  88. ;
  89.  
  90. export type UpdateOperator =
  91.   | '++'
  92.   | '--'
  93. ;
  94.  
  95. export type LogicalOperator =
  96.   | '&&'
  97.   | '||'
  98. ;
  99.  
  100. export type Node =
  101.   | EmptyStatement
  102.   | BlockStatement
  103.   | ExpressionStatement
  104.   | IfStatement
  105.   | BreakStatement
  106.   | ContinueStatement
  107.   | ReturnStatement
  108.   | ThrowStatement
  109.   | WhileStatement
  110.   | ForStatement
  111.   | ForInStatement
  112.   | TryStatement
  113.   | CatchClause
  114.   | Identifier
  115.   | Literal
  116.   | ThisExpression
  117.   | ArrayExpression
  118.   | ObjectExpreession
  119.   | Property
  120.   | FunctionExpression
  121.   | BinaryExpression
  122.   | UnaryExpression
  123.   | AssignmentExpression
  124.   | UpdateExpression
  125.   | LogicalExpression
  126.   | ConditionalExpression
  127.   | NewExpression
  128.   | CallExpression
  129.   | MemberExpression
  130.   | VariableDeclaration
  131.   | FunctionDeclaration
  132.   | VariableDeclarator
  133. ;
  134.  
  135. export type Statement =
  136.   | BlockStatement
  137.   | EmptyStatement
  138.   | ExpressionStatement
  139.   | IfStatement
  140.   | BreakStatement
  141.   | ContinueStatement
  142.   | ReturnStatement
  143.   | ThrowStatement
  144.   | WhileStatement
  145.   | ForStatement
  146.   | ForInStatement
  147.   | TryStatement
  148.   | Declaration
  149. ;
  150.  
  151. export type EmptyStatement = {
  152.   source: ?string,
  153.   start: SourcePosition,
  154.   end: SourcePosition,
  155.   comments: ?Array<Comment>,
  156.   type: 'EmptyStatement',
  157. }
  158.  
  159. export type BlockStatement = {
  160.   source: ?string,
  161.   start: SourcePosition,
  162.   end: SourcePosition,
  163.   comments: ?Array<Comment>,
  164.   type: 'BlockStatement',
  165.   body: Statement[],
  166. }
  167.  
  168. export type ExpressionStatement = {
  169.   source: ?string,
  170.   start: SourcePosition,
  171.   end: SourcePosition,
  172.   comments: ?Array<Comment>,
  173.   type: 'ExpressionStatement',
  174.   expression: Expression,
  175. }
  176.  
  177. export type IfStatement = {
  178.   source: ?string,
  179.   start: SourcePosition,
  180.   end: SourcePosition,
  181.   comments: ?Array<Comment>,
  182.   type: 'IfStatement',
  183.   test: Expression,
  184.   consequent: Statement,
  185.   alternate: ?Statement,
  186. }
  187.  
  188. export type BreakStatement = {
  189.   source: ?string,
  190.   start: SourcePosition,
  191.   end: SourcePosition,
  192.   comments: ?Array<Comment>,
  193.   type: 'BreakStatement',
  194.   label: ?Identifier,
  195. }
  196.  
  197. export type ContinueStatement = {
  198.   source: ?string,
  199.   start: SourcePosition,
  200.   end: SourcePosition,
  201.   comments: ?Array<Comment>,
  202.   type: 'ContinueStatement',
  203.   label: ?Identifier,
  204. }
  205.  
  206. export type ReturnStatement = {
  207.   source: ?string,
  208.   start: SourcePosition,
  209.   end: SourcePosition,
  210.   comments: ?Array<Comment>,
  211.   type: 'ReturnStatement',
  212.   argument: ?Expression,
  213. }
  214.  
  215. export type ThrowStatement = {
  216.   source: ?string,
  217.   start: SourcePosition,
  218.   end: SourcePosition,
  219.   comments: ?Array<Comment>,
  220.   type: 'ThrowStatement',
  221.   argument: ?Expression,
  222. }
  223.  
  224. export type WhileStatement = {
  225.   source: ?string,
  226.   start: SourcePosition,
  227.   end: SourcePosition,
  228.   comments: ?Array<Comment>,
  229.   type: 'WhileStatement',
  230.   test: Expression,
  231.   body: Statement,
  232. }
  233.  
  234. export type ForStatement = {
  235.   source: ?string,
  236.   start: SourcePosition,
  237.   end: SourcePosition,
  238.   comments: ?Array<Comment>,
  239.   type: 'ForStatement',
  240.   init: ?(VariableDeclaration | Expression),
  241.   test: ?Expression,
  242.   update: ?Expression,
  243.   body: Statement,
  244. }
  245.  
  246. export type ForInStatement = {
  247.   source: ?string,
  248.   start: SourcePosition,
  249.   end: SourcePosition,
  250.   comments: ?Array<Comment>,
  251.   type: 'ForInStatement',
  252.   left: VariableDeclaration | Expression,
  253.   right: Expression,
  254.   body: Statement,
  255. }
  256.  
  257. export type TryStatement = {
  258.   source: ?string,
  259.   start: SourcePosition,
  260.   end: SourcePosition,
  261.   comments: ?Array<Comment>,
  262.   type: 'TryStatement',
  263.   block: BlockStatement,
  264.   handler: ?CatchClause,
  265.   handlers: CatchClause[],
  266.   finalizer: ?BlockStatement,
  267. };
  268.  
  269. export type CatchClause = {
  270.   source: ?string,
  271.   start: SourcePosition,
  272.   end: SourcePosition,
  273.   comments: ?Array<Comment>,
  274.   type: 'CatchClause',
  275.   param: Pattern,
  276.   guard: ?Expression,
  277.   body: BlockStatement,
  278. };
  279.  
  280. export type Expression =
  281.   | Identifier
  282.   | ThisExpression
  283.   | Literal
  284.   | FunctionExpression
  285.   | BinaryExpression
  286.   | UnaryExpression
  287.   | AssignmentExpression
  288.   | UpdateExpression
  289.   | LogicalExpression
  290.   | ConditionalExpression
  291.   | NewExpression
  292.   | CallExpression
  293.   | MemberExpression
  294.   | ArrayExpression
  295.   | ObjectExpreession
  296. ;
  297.  
  298. export type Identifier = {
  299.   source: ?string,
  300.   start: SourcePosition,
  301.   end: SourcePosition,
  302.   comments: ?Array<Comment>,
  303.   type: 'Identifier',
  304.   name: string,
  305. }
  306.  
  307. export type Literal = {
  308.   source: ?string,
  309.   start: SourcePosition,
  310.   end: SourcePosition,
  311.   comments: ?Array<Comment>,
  312.   type: 'Literal',
  313.   value: ?(string | boolean | number | RegExp),
  314.   regex: ?{ pattern: string, flags: string },
  315. }
  316.  
  317. export type ThisExpression = {
  318.   source: ?string,
  319.   start: SourcePosition,
  320.   end: SourcePosition,
  321.   comments: ?Array<Comment>,
  322.   type: 'ThisExpression',
  323. }
  324.  
  325. export type ArrayExpression = {
  326.   source: ?string,
  327.   start: SourcePosition,
  328.   end: SourcePosition,
  329.   comments: ?Array<Comment>,
  330.   type: 'ArrayExpression',
  331.   elements: Expression[],
  332. }
  333.  
  334. export type ObjectExpreession = {
  335.   source: ?string,
  336.   start: SourcePosition,
  337.   end: SourcePosition,
  338.   comments: ?Array<Comment>,
  339.   type: 'ObjectExpression',
  340.   properties: Property[],
  341. }
  342.  
  343. export type Property = {
  344.   source: ?string,
  345.   start: SourcePosition,
  346.   end: SourcePosition,
  347.   comments: ?Array<Comment>,
  348.   type: 'Property',
  349.   kind: 'init' | 'get' | 'set',
  350.   key: Literal | Identifier,
  351.   value: Expression,
  352. };
  353.  
  354. export type FunctionExpression = {
  355.   source: ?string,
  356.   start: SourcePosition,
  357.   end: SourcePosition,
  358.   comments: ?Array<Comment>,
  359.   type: 'FunctionExpression',
  360.   id: ?Identifier,
  361.   params: Pattern[],
  362.   body: BlockStatement,
  363. }
  364.  
  365. export type BinaryExpression = {
  366.   source: ?string,
  367.   start: SourcePosition,
  368.   end: SourcePosition,
  369.   comments: ?Array<Comment>,
  370.   type: 'BinaryExpression',
  371.   operator: BinaryOperator,
  372.   left: Expression,
  373.   right: Expression,
  374. }
  375.  
  376. export type UnaryExpression = {
  377.   source: ?string,
  378.   start: SourcePosition,
  379.   end: SourcePosition,
  380.   comments: ?Array<Comment>,
  381.   type: 'UnaryExpression',
  382.   operator: UnaryOperator,
  383.   argument: Expression,
  384.   prefix: boolean,
  385. };
  386.  
  387. export type AssignmentExpression = {
  388.   source: ?string,
  389.   start: SourcePosition,
  390.   end: SourcePosition,
  391.   comments: ?Array<Comment>,
  392.   type: 'AssignmentExpression',
  393.   operator: AssignmentOperator,
  394.   left: Pattern,
  395.   right: Expression,
  396. };
  397.  
  398. export type UpdateExpression = {
  399.   source: ?string,
  400.   start: SourcePosition,
  401.   end: SourcePosition,
  402.   comments: ?Array<Comment>,
  403.   type: 'UpdateExpression',
  404.   operator: UpdateOperator,
  405.   argument: Expression,
  406.   prefix: boolean,
  407. };
  408.  
  409. export type LogicalExpression = {
  410.   source: ?string,
  411.   start: SourcePosition,
  412.   end: SourcePosition,
  413.   comments: ?Array<Comment>,
  414.   type: 'LogicalExpression',
  415.   operator: LogicalOperator,
  416.   left: Expression,
  417.   right: Expression,
  418. };
  419.  
  420. export type ConditionalExpression = {
  421.   source: ?string,
  422.   start: SourcePosition,
  423.   end: SourcePosition,
  424.   comments: ?Array<Comment>,
  425.   type: 'ConditionalExpression',
  426.   test: Expression,
  427.   consequent: Expression,
  428.   alternate: Expression,
  429. };
  430.  
  431. export type NewExpression = {
  432.   source: ?string,
  433.   start: SourcePosition,
  434.   end: SourcePosition,
  435.   comments: ?Array<Comment>,
  436.   type: 'NewExpression',
  437.   callee: Expression,
  438.   arguments: Expression[],
  439. };
  440.  
  441. export type CallExpression = {
  442.   source: ?string,
  443.   start: SourcePosition,
  444.   end: SourcePosition,
  445.   comments: ?Array<Comment>,
  446.   type: 'CallExpression',
  447.   callee: Expression,
  448.   arguments: Expression[],
  449. };
  450.  
  451. export type MemberExpression = {
  452.   source: ?string,
  453.   start: SourcePosition,
  454.   end: SourcePosition,
  455.   comments: ?Array<Comment>,
  456.   type: 'MemberExpression',
  457.   object: Expression,
  458.   property: Identifier | Expression,
  459.   computed: bool,
  460. }
  461. // ast-types exports all expressions as patterns.
  462. // That seems not like it was intended.
  463. export type Pattern =
  464.   | Identifier
  465. ;
  466.  
  467. export type Declaration =
  468.   | VariableDeclaration
  469.   | FunctionDeclaration
  470. ;
  471.  
  472. export type VariableDeclaration = {
  473.   source: ?string,
  474.   start: SourcePosition,
  475.   end: SourcePosition,
  476.   comments: ?Array<Comment>,
  477.   type: 'VariableDeclaration',
  478.   kind: 'var' | 'let' | 'const',
  479.   declarations: VariableDeclarator[],
  480. }
  481.  
  482. export type FunctionDeclaration = {
  483.   source: ?string,
  484.   start: SourcePosition,
  485.   end: SourcePosition,
  486.   comments: ?Array<Comment>,
  487.   type: 'FunctionDeclaration',
  488.   id: Identifier,
  489.   body: BlockStatement,
  490.   params: Pattern[],
  491. }
  492.  
  493. export type VariableDeclarator = {
  494.   source: ?string,
  495.   start: SourcePosition,
  496.   end: SourcePosition,
  497.   comments: ?Array<Comment>,
  498.   type: 'VariableDeclarator',
  499.   id: Pattern,
  500.   init: ?Expression,
  501. }
  502.  
  503. const a : any = null;
  504.  
  505. export const builders : {
  506.   emptyStatement() : EmptyStatement,
  507.   blockStatement(
  508.     body: Statement[]
  509.   ) : BlockStatement,
  510.   expressionStatement(
  511.     expression: Expression
  512.   ) : ExpressionStatement,
  513.   ifStatement(
  514.     test: Expression,
  515.     consequent: Statement,
  516.     alternate?: Statement
  517.   ) : IfStatement,
  518.   breakStatement(
  519.     label?: Identifier
  520.   ) : BreakStatement,
  521.   continueStatement(
  522.     label?: Identifier
  523.   ) : ContinueStatement,
  524.   returnStatement(
  525.     argument: ?Expression
  526.   ) : ReturnStatement,
  527.   throwStatement(
  528.     argument: ?Expression
  529.   ) : ThrowStatement,
  530.   whileStatement(
  531.     test: Expression,
  532.     body: Statement
  533.   ) : WhileStatement,
  534.   forStatement(
  535.     init: ?(VariableDeclaration | Expression),
  536.     test: ?Expression,
  537.     update: ?Expression,
  538.     body: Statement
  539.   ) : ForStatement,
  540.   forInStatement(
  541.     left: VariableDeclaration | Expression,
  542.     right: Expression,
  543.     body: Statement
  544.   ) : ForInStatement,
  545.   tryStatement(
  546.     block: BlockStatement,
  547.     handler: ?CatchClause,
  548.     handlers: CatchClause[],
  549.     finalizer?: BlockStatement
  550.   ) : TryStatement,
  551.   catchClause(
  552.     param: Pattern,
  553.     guard: ?Expression,
  554.     body: BlockStatement
  555.   ) : CatchClause,
  556.   identifier(
  557.     name: string
  558.   ) : Identifier,
  559.   literal(
  560.     value: ?(string | boolean | number | RegExp),
  561.     regex?: { pattern: string, flags: string }
  562.   ) : Literal,
  563.   thisExpression() : ThisExpression,
  564.   arrayExpression(
  565.     elements: Expression[]
  566.   ) : ArrayExpression,
  567.   objectExpreession(
  568.     properties: Property[]
  569.   ) : ObjectExpreession,
  570.   property(
  571.     kind: 'init' | 'get' | 'set',
  572.     key: Literal | Identifier,
  573.     value: Expression
  574.   ) : Property,
  575.   functionExpression(
  576.     id: ?Identifier,
  577.     params: Pattern[],
  578.     body: BlockStatement
  579.   ) : FunctionExpression,
  580.   binaryExpression(
  581.     operator: BinaryOperator,
  582.     left: Expression,
  583.     right: Expression
  584.   ) : BinaryExpression,
  585.   unaryExpression(
  586.     operator: UnaryOperator,
  587.     argument: Expression,
  588.     prefix: boolean
  589.   ) : UnaryExpression,
  590.   assignmentExpression(
  591.     operator: AssignmentOperator,
  592.     left: Pattern,
  593.     right: Expression
  594.   ) : AssignmentExpression,
  595.   updateExpression(
  596.     operator: UpdateOperator,
  597.     argument: Expression,
  598.     prefix: boolean
  599.   ) : UpdateExpression,
  600.   logicalExpression(
  601.     operator: LogicalOperator,
  602.     left: Expression,
  603.     right: Expression
  604.   ) : LogicalExpression,
  605.   conditionalExpression(
  606.     test: Expression,
  607.     consequent: Expression,
  608.     alternate: Expression
  609.   ) : ConditionalExpression,
  610.   newExpression(
  611.     callee: Expression,
  612.     arguments: Expression[]
  613.   ) : NewExpression,
  614.   callExpression(
  615.     callee: Expression,
  616.     arguments: Expression[]
  617.   ) : CallExpression,
  618.   memberExpression(
  619.     object: Expression,
  620.     property: Identifier | Expression,
  621.     computed: bool
  622.   ) : MemberExpression,
  623.   variableDeclaration(
  624.     kind: 'var' | 'let' | 'const',
  625.     declarations: VariableDeclarator[]
  626.   ) : VariableDeclaration,
  627.   functionDeclaration(
  628.     id: Identifier,
  629.     body: BlockStatement,
  630.     params: Pattern[]
  631.   ) : FunctionDeclaration,
  632.   variableDeclarator(
  633.     id: Pattern,
  634.     init?: Expression
  635.   ) : VariableDeclarator,
  636. } = a;
  637.  
downloadjsAst.js Source code - Download prettier Source code
Related Source Codes/Software:
storybook - 2017-06-07
ionicons - The premium icon font for Ionic ... 2017-06-07
AsyncDisplayKit - Smooth asynchronous user interfaces for iOS apps. ... 2017-06-07
lottie-android - Render After Effects animations natively on Androi... 2017-06-07
parse-server - Parse-compatible API server module for Node/Expres... 2017-06-07
inferno - An extremely fast, React-like JavaScript library f... 2017-06-08
guetzli - Perceptual JPEG encoder 2017-06-08
cs-video-courses - List of Computer Science courses with video lectur... 2017-06-08
interviews - Everything you need to know to get the job. 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top