-
Notifications
You must be signed in to change notification settings - Fork 464
/
check_nesting.hpp
70 lines (55 loc) · 1.89 KB
/
check_nesting.hpp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef SASS_CHECK_NESTING_H
#define SASS_CHECK_NESTING_H
// sass.hpp must go before all system headers to get the
// __EXTENSIONS__ fix on Solaris.
#include "sass.hpp"
#include "ast.hpp"
#include "operation.hpp"
#include <vector>
namespace Sass {
class CheckNesting : public Operation_CRTP<Statement*, CheckNesting> {
std::vector<Statement*> parents;
Backtraces traces;
Statement* parent;
Definition* current_mixin_definition;
Statement* before(Statement*);
Statement* visit_children(Statement*);
public:
CheckNesting();
~CheckNesting() { }
Statement* operator()(Block*);
Statement* operator()(Definition*);
Statement* operator()(If*);
template <typename U>
Statement* fallback(U x) {
Statement* s = Cast<Statement>(x);
if (s && this->should_visit(s)) {
Block* b1 = Cast<Block>(s);
Has_Block* b2 = Cast<Has_Block>(s);
if (b1 || b2) return visit_children(s);
}
return s;
}
private:
void invalid_content_parent(Statement*, AST_Node*);
void invalid_charset_parent(Statement*, AST_Node*);
void invalid_extend_parent(Statement*, AST_Node*);
// void invalid_import_parent(Statement*);
void invalid_mixin_definition_parent(Statement*, AST_Node*);
void invalid_function_parent(Statement*, AST_Node*);
void invalid_function_child(Statement*);
void invalid_prop_child(Statement*);
void invalid_prop_parent(Statement*, AST_Node*);
void invalid_return_parent(Statement*, AST_Node*);
void invalid_value_child(AST_Node*);
bool is_transparent_parent(Statement*, Statement*);
bool should_visit(Statement*);
bool is_charset(Statement*);
bool is_mixin(Statement*);
bool is_function(Statement*);
bool is_root_node(Statement*);
bool is_at_root_node(Statement*);
bool is_directive_node(Statement*);
};
}
#endif