diff --git a/src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts b/src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts index bc1be2b..23cdbb5 100644 --- a/src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts +++ b/src/lsp/providers/codeActions/provideInvalidApplyCodeActions.ts @@ -20,8 +20,8 @@ import isObject from '../../../util/isObject' import { cssObjToAst } from '../../util/cssObjToAst' import dset from 'dset' import selectorParser from 'postcss-selector-parser' -import { logFull } from '../../util/logFull' import { flatten } from '../../../util/array' +import { getClassNameMeta } from '../../util/getClassNameMeta' export async function provideInvalidApplyCodeActions( state: State, @@ -180,9 +180,10 @@ function classNameToAst( if (!baseClassName) { return null } - const info = dlv(state.classNames.classNames, classNameParts) - let context = info.__context || [] - let pseudo = info.__pseudo || [] + const meta = getClassNameMeta(state, classNameParts) + if (Array.isArray(meta)) return null + let context = meta.context + let pseudo = meta.pseudo const globalContexts = state.classNames.context let screens = dlv( state.config, diff --git a/src/lsp/util/getClassNameMeta.ts b/src/lsp/util/getClassNameMeta.ts index 9ec86cd..1099a1a 100644 --- a/src/lsp/util/getClassNameMeta.ts +++ b/src/lsp/util/getClassNameMeta.ts @@ -4,9 +4,11 @@ const dlv = require('dlv') export function getClassNameMeta( state: State, - className: string + classNameOrParts: string | string[] ): ClassNameMeta | ClassNameMeta[] { - const parts = getClassNameParts(state, className) + const parts = Array.isArray(classNameOrParts) + ? classNameOrParts + : getClassNameParts(state, classNameOrParts) if (!parts) return null const info = dlv(state.classNames.classNames, parts)