UNPKG

3.05 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
6 * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
7 * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
8 * Google as part of the polymer project is also subject to an additional IP
9 * rights grant found at http://polymer.github.io/PATENTS.txt
10 */
11import { AtRule, Comment, Declaration, Discarded, Expression, Range, Rule, Rulelist, Ruleset, Stylesheet } from './common';
12/**
13 * Class used for generating nodes in a CSS AST. Extend this class to implement
14 * visitors to different nodes while the tree is being generated, and / or
15 * custom node generation.
16 */
17declare class NodeFactory {
18 /**
19 * Creates a Stylesheet node.
20 * @param rules The list of rules that appear at the top
21 * level of the stylesheet.
22 */
23 stylesheet(rules: Rule[], range: Range): Stylesheet;
24 /**
25 * Creates an At Rule node.
26 * @param name The "name" of the At Rule (e.g., `charset`)
27 * @param parameters The "parameters" of the At Rule (e.g., `utf8`)
28 * @param rulelist The Rulelist node (if any) of the At Rule.
29 */
30 atRule(name: string, parameters: string, rulelist: Rulelist | undefined, nameRange: Range, parametersRange: Range | undefined, range: Range): AtRule;
31 /**
32 * Creates a Comment node.
33 * @param value The full text content of the comment, including
34 * opening and closing comment signature.
35 */
36 comment(value: string, range: Range): Comment;
37 /**
38 * Creates a Rulelist node.
39 * @param rules An array of the Rule nodes found within the Ruleset.
40 */
41 rulelist(rules: Rule[], range: Range): Rulelist;
42 /**
43 * Creates a Ruleset node.
44 * @param selector The selector that corresponds to the Selector
45 * (e.g., `#foo > .bar`).
46 * @param rulelist The Rulelist node that corresponds to the Selector.
47 */
48 ruleset(selector: string, rulelist: Rulelist, selectorRange: Range, range: Range): Ruleset;
49 /**
50 * Creates a Declaration node.
51 * @param name The property name of the Declaration (e.g., `color`).
52 * @param value Either an Expression node, or a Rulelist node, that
53 * corresponds to the value of the Declaration.
54 */
55 declaration(name: string, value: Expression | Rulelist | undefined, nameRange: Range, range: Range): Declaration;
56 /**
57 * Creates an Expression node.
58 * @param text The full text content of the expression (e.g.,
59 * `url(img.jpg)`)
60 */
61 expression(text: string, range: Range): Expression;
62 /**
63 * Creates a Discarded node. Discarded nodes contain content that was not
64 * parseable (usually due to typos, or otherwise unrecognized syntax).
65 * @param text The text content that is discarded.
66 */
67 discarded(text: string, range: Range): Discarded;
68}
69export { NodeFactory };