MCPcopy
hub / github.com/postcss/postcss / positionInside

Method positionInside

lib/node.js:234–254  ·  view source on GitHub ↗
(index)

Source from the content-addressed store, hash-verified

232 }
233
234 positionInside(index) {
235 let column = this.source.start.column
236 let line = this.source.start.line
237 let inputString =
238 'document' in this.source.input
239 ? this.source.input.document
240 : this.source.input.css
241 let offset = sourceOffset(inputString, this.source.start)
242 let end = offset + index
243
244 for (let i = offset; i < end; i++) {
245 if (inputString[i] === '\n') {
246 column = 1
247 line += 1
248 } else {
249 column += 1
250 }
251 }
252
253 return { column, line, offset: end }
254 }
255
256 prev() {
257 if (!this.parent) return undefined

Callers 3

positionByMethod · 0.95
rangeByMethod · 0.95
node.test.tsFile · 0.80

Calls 1

sourceOffsetFunction · 0.85

Tested by

no test coverage detected