@@ -2,26 +2,36 @@ import type { State, Settings, DocumentClassName } from '../util/state'
22import { type InvalidClassDiagnostic , DiagnosticKind } from './types'
33import { findClassListsInDocument , getClassNamesInClassList } from '../util/find'
44import { visit } from './getCssConflictDiagnostics'
5+ import { getClassNameDecls } from '../util/getClassNameDecls'
6+ import * as jit from '../util/jit'
57import type { TextDocument } from 'vscode-languageserver-textdocument'
68
79function isClassValid ( state : State , className : string ) : boolean {
8- if ( ! state . v4 ) return true // Only check for v4
10+ if ( state . v4 ) {
11+ // V4: Use design system compilation
12+ let roots = state . designSystem . compile ( [ className ] )
13+ let hasDeclarations = false
914
10- let roots = state . designSystem . compile ( [ className ] )
11- let hasDeclarations = false
12-
13- visit ( [ roots [ 0 ] ] , ( node ) => {
14- if ( ( node . type === 'rule' || node . type === 'atrule' ) && node . nodes ) {
15- for ( let child of node . nodes ) {
16- if ( child . type === 'decl' ) {
17- hasDeclarations = true
18- break
15+ visit ( [ roots [ 0 ] ] , ( node ) => {
16+ if ( ( node . type === 'rule' || node . type === 'atrule' ) && node . nodes ) {
17+ for ( let child of node . nodes ) {
18+ if ( child . type === 'decl' ) {
19+ hasDeclarations = true
20+ break
21+ }
1922 }
2023 }
21- }
22- } )
23-
24- return hasDeclarations
24+ } )
25+ return hasDeclarations
26+ } else if ( state . jit ) {
27+ // JIT: Try to generate rules
28+ let { rules } = jit . generateRules ( state , [ className ] )
29+ return rules . length > 0
30+ } else {
31+ // Static: Check if decls exist
32+ let decls = getClassNameDecls ( state , className )
33+ return ! ! decls
34+ }
2535}
2636
2737export async function getInvalidClassDiagnostics (
0 commit comments