Skip to content

Commit 81a3b5f

Browse files
committed
Add class list parser
1 parent 83640ae commit 81a3b5f

File tree

1 file changed

+22
-0
lines changed
  • packages/tailwindcss-language-service/src/scopes/classes

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ScopeClassList } from '../scope'
2+
3+
export function scanClassList(input: string, scope: ScopeClassList) {
4+
let classList = input.slice(scope.source.scope[0], scope.source.scope[1])
5+
let parts = classList.split(/(\s+)/)
6+
7+
let index = scope.source.scope[0]
8+
9+
for (let i = 0; i < parts.length; i++) {
10+
let length = parts[i].length
11+
12+
if (i % 2 === 0) {
13+
scope.children.push({
14+
kind: 'class.name',
15+
source: { scope: [index, index + length] },
16+
children: [],
17+
})
18+
}
19+
20+
index += length
21+
}
22+
}

0 commit comments

Comments
 (0)