forked from OKEAMAH/prettier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathangular.js
More file actions
35 lines (31 loc) · 952 Bytes
/
angular.js
File metadata and controls
35 lines (31 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {
parseAction,
parseBinding,
parseInterpolationExpression,
parseTemplateBindings,
} from "angular-estree-parser";
import { locEnd, locStart } from "../loc.js";
/**
* @param {parseAction | parseBinding | parseInterpolationExpression | parseTemplateBindings} parseMethod
*/
function createParser(parseMethod) {
return {
astFormat: "estree",
parse(text) {
const node = parseMethod(text);
return {
type: "NGRoot",
node:
parseMethod === parseAction && node.type !== "NGChainedExpression"
? { ...node, type: "NGChainedExpression", expressions: [node] }
: node,
};
},
locStart,
locEnd,
};
}
export const __ng_action = createParser(parseAction);
export const __ng_binding = createParser(parseBinding);
export const __ng_interpolation = createParser(parseInterpolationExpression);
export const __ng_directive = createParser(parseTemplateBindings);