MCPcopy
hub / github.com/postcss/postcss / decl

Method decl

lib/parser.js:202–305  ·  view source on GitHub ↗
(tokens, customProperty)

Source from the content-addressed store, hash-verified

200 }
201
202 decl(tokens, customProperty) {
203 let node = new Declaration()
204 this.init(node, tokens[0][2])
205
206 let last = tokens[tokens.length - 1]
207 if (last[0] === ';') {
208 this.semicolon = true
209 tokens.pop()
210 }
211
212 node.source.end = this.getPosition(
213 last[3] || last[2] || findLastWithPosition(tokens)
214 )
215 node.source.end.offset++
216
217 let start = 0
218 while (tokens[start][0] !== 'word') {
219 if (start === tokens.length - 1) this.unknownWord([tokens[start]])
220 start++
221 }
222 node.raws.before += tokensToString(tokens, 0, start)
223 node.source.start = this.getPosition(tokens[start][2])
224
225 let propStart = start
226 while (start < tokens.length) {
227 let type = tokens[start][0]
228 if (type === ':' || type === 'space' || type === 'comment') {
229 break
230 }
231 start++
232 }
233 node.prop = tokensToString(tokens, propStart, start)
234
235 let betweenStart = start
236 let token
237 while (start < tokens.length) {
238 token = tokens[start]
239 start++
240 if (token[0] === ':') break
241 if (token[0] === 'word' && /\w/.test(token[1])) {
242 this.unknownWord([token])
243 }
244 }
245 node.raws.between = tokensToString(tokens, betweenStart, start)
246
247 if (node.prop[0] === '_' || node.prop[0] === '*') {
248 node.raws.before += node.prop[0]
249 node.prop = node.prop.slice(1)
250 }
251
252 let firstSpacesStart = start
253 while (start < tokens.length) {
254 let next = tokens[start][0]
255 if (next !== 'space' && next !== 'comment') break
256 start++
257 }
258 let firstSpaces = tokens.slice(firstSpacesStart, start)
259

Callers 3

otherMethod · 0.95
postcss.test.tsFile · 0.45

Calls 12

initMethod · 0.95
getPositionMethod · 0.95
unknownWordMethod · 0.95
stringFromMethod · 0.95
spacesFromEndMethod · 0.95
rawMethod · 0.95
checkMissedSemicolonMethod · 0.95
findLastWithPositionFunction · 0.85
tokensToStringFunction · 0.85
someMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected