.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / postcss-less / dist / tokenizer / tokenize-at-rule.js
1 'use strict';
2
3 Object.defineProperty(exports, "__esModule", {
4   value: true
5 });
6 exports.default = tokenizeAtRule;
7
8 var _globals = require('./globals');
9
10 var _unclosed = require('./unclosed');
11
12 var _unclosed2 = _interopRequireDefault(_unclosed);
13
14 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
16 function tokenizeAtRule(state) {
17   // it's an interpolation
18   if (state.css.charCodeAt(state.pos + 1) === _globals.openedCurlyBracket) {
19     state.nextPos = state.css.indexOf('}', state.pos + 2);
20
21     if (state.nextPos === -1) {
22       (0, _unclosed2.default)(state, 'interpolation');
23     }
24
25     state.cssPart = state.css.slice(state.pos, state.nextPos + 1);
26     state.lines = state.cssPart.split('\n');
27     state.lastLine = state.lines.length - 1;
28
29     if (state.lastLine > 0) {
30       state.nextLine = state.line + state.lastLine;
31       state.nextOffset = state.nextPos - state.lines[state.lastLine].length;
32     } else {
33       state.nextLine = state.line;
34       state.nextOffset = state.offset;
35     }
36
37     state.tokens.push(['word', state.cssPart, state.line, state.pos - state.offset, state.nextLine, state.nextPos - state.nextOffset]);
38
39     state.offset = state.nextOffset;
40     state.line = state.nextLine;
41   } else {
42     _globals.atEndPattern.lastIndex = state.pos + 1;
43     _globals.atEndPattern.test(state.css);
44
45     if (_globals.atEndPattern.lastIndex === 0) {
46       state.nextPos = state.css.length - 1;
47     } else {
48       state.nextPos = _globals.atEndPattern.lastIndex - 2;
49     }
50
51     state.cssPart = state.css.slice(state.pos, state.nextPos + 1);
52     state.token = 'at-word';
53
54     // check if it's a variable
55     if (_globals.variablePattern.test(state.cssPart)) {
56       _globals.wordEndPattern.lastIndex = state.pos + 1;
57       _globals.wordEndPattern.test(state.css);
58       if (_globals.wordEndPattern.lastIndex === 0) {
59         state.nextPos = state.css.length - 1;
60       } else {
61         state.nextPos = _globals.wordEndPattern.lastIndex - 2;
62       }
63
64       state.cssPart = state.css.slice(state.pos, state.nextPos + 1);
65       state.token = 'word';
66     }
67
68     state.tokens.push([state.token, state.cssPart, state.line, state.pos - state.offset, state.line, state.nextPos - state.offset]);
69   }
70
71   state.pos = state.nextPos;
72 }
73 module.exports = exports['default'];