1 | #ifndef SASS_CHECK_NESTING_H |
---|---|
2 | #define SASS_CHECK_NESTING_H |
3 | |
4 | // sass.hpp must go before all system headers to get the |
5 | // __EXTENSIONS__ fix on Solaris. |
6 | #include "sass.hpp" |
7 | #include "ast.hpp" |
8 | #include "operation.hpp" |
9 | #include <vector> |
10 | |
11 | namespace Sass { |
12 | |
13 | class CheckNesting : public Operation_CRTP<Statement*, CheckNesting> { |
14 | |
15 | sass::vector<Statement*> parents; |
16 | Backtraces traces; |
17 | Statement* parent; |
18 | Definition* current_mixin_definition; |
19 | |
20 | Statement* before(Statement*); |
21 | Statement* visit_children(Statement*); |
22 | |
23 | public: |
24 | CheckNesting(); |
25 | ~CheckNesting() { } |
26 | |
27 | Statement* operator()(Block*); |
28 | Statement* operator()(Definition*); |
29 | Statement* operator()(If*); |
30 | |
31 | template <typename U> |
32 | Statement* fallback(U x) { |
33 | Statement* s = Cast<Statement>(x); |
34 | if (s && this->should_visit(s)) { |
35 | Block* b1 = Cast<Block>(ptr: s); |
36 | ParentStatement* b2 = Cast<ParentStatement>(ptr: s); |
37 | if (b1 || b2) return visit_children(s); |
38 | } |
39 | return s; |
40 | } |
41 | |
42 | private: |
43 | void invalid_content_parent(Statement*, AST_Node*); |
44 | void invalid_charset_parent(Statement*, AST_Node*); |
45 | void invalid_extend_parent(Statement*, AST_Node*); |
46 | // void invalid_import_parent(Statement*); |
47 | void invalid_mixin_definition_parent(Statement*, AST_Node*); |
48 | void invalid_function_parent(Statement*, AST_Node*); |
49 | |
50 | void invalid_function_child(Statement*); |
51 | void invalid_prop_child(Statement*); |
52 | void invalid_prop_parent(Statement*, AST_Node*); |
53 | void invalid_return_parent(Statement*, AST_Node*); |
54 | void invalid_value_child(AST_Node*); |
55 | |
56 | bool is_transparent_parent(Statement*, Statement*); |
57 | |
58 | bool should_visit(Statement*); |
59 | |
60 | bool is_charset(Statement*); |
61 | bool is_mixin(Statement*); |
62 | bool is_function(Statement*); |
63 | bool is_root_node(Statement*); |
64 | bool is_at_root_node(Statement*); |
65 | bool is_directive_node(Statement*); |
66 | }; |
67 | |
68 | } |
69 | |
70 | #endif |
71 |