don't provide quick fix for @apply class name which has multiple rules
parent
6add64c19b
commit
743f10ac3d
|
@ -111,22 +111,18 @@ export async function provideCodeActions(
|
||||||
|
|
||||||
function classNameToAst(
|
function classNameToAst(
|
||||||
state: State,
|
state: State,
|
||||||
className: string,
|
classNameParts: string[],
|
||||||
selector: string = `.${className}`,
|
selector: string,
|
||||||
important: boolean = false
|
important: boolean = false
|
||||||
) {
|
) {
|
||||||
const parts = getClassNameParts(state, className)
|
|
||||||
if (!parts) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
const baseClassName = dlv(
|
const baseClassName = dlv(
|
||||||
state.classNames.classNames,
|
state.classNames.classNames,
|
||||||
parts[parts.length - 1]
|
classNameParts[classNameParts.length - 1]
|
||||||
)
|
)
|
||||||
if (!baseClassName) {
|
if (!baseClassName) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const info = dlv(state.classNames.classNames, parts)
|
const info = dlv(state.classNames.classNames, classNameParts)
|
||||||
let context = info.__context || []
|
let context = info.__context || []
|
||||||
let pseudo = info.__pseudo || []
|
let pseudo = info.__pseudo || []
|
||||||
const globalContexts = state.classNames.context
|
const globalContexts = state.classNames.context
|
||||||
|
@ -139,8 +135,8 @@ function classNameToAst(
|
||||||
screens = Object.keys(screens)
|
screens = Object.keys(screens)
|
||||||
const path = []
|
const path = []
|
||||||
|
|
||||||
for (let i = 0; i < parts.length - 1; i++) {
|
for (let i = 0; i < classNameParts.length - 1; i++) {
|
||||||
let part = parts[i]
|
let part = classNameParts[i]
|
||||||
let common = globalContexts[part]
|
let common = globalContexts[part]
|
||||||
if (!common) return null
|
if (!common) return null
|
||||||
if (screens.includes(part)) {
|
if (screens.includes(part)) {
|
||||||
|
@ -158,7 +154,7 @@ function classNameToAst(
|
||||||
let rule = {
|
let rule = {
|
||||||
// TODO: use proper selector parser
|
// TODO: use proper selector parser
|
||||||
[selector + pseudo.join('')]: {
|
[selector + pseudo.join('')]: {
|
||||||
[`@apply ${parts[parts.length - 1]}${
|
[`@apply ${classNameParts[classNameParts.length - 1]}${
|
||||||
important ? ' !important' : ''
|
important ? ' !important' : ''
|
||||||
}`]: '',
|
}`]: '',
|
||||||
},
|
},
|
||||||
|
@ -221,6 +217,14 @@ async function provideInvalidApplyCodeActions(
|
||||||
/\s+/
|
/\s+/
|
||||||
).length
|
).length
|
||||||
|
|
||||||
|
let className = diagnostic.className.className
|
||||||
|
let classNameParts = getClassNameParts(state, className)
|
||||||
|
let classNameInfo = dlv(state.classNames.classNames, classNameParts)
|
||||||
|
|
||||||
|
if (Array.isArray(classNameInfo)) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
if (!isCssDoc(state, document)) {
|
if (!isCssDoc(state, document)) {
|
||||||
let languageBoundaries = getLanguageBoundaries(state, document)
|
let languageBoundaries = getLanguageBoundaries(state, document)
|
||||||
if (!languageBoundaries) return []
|
if (!languageBoundaries) return []
|
||||||
|
@ -259,10 +263,9 @@ async function provideInvalidApplyCodeActions(
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
let className = diagnostic.className.className
|
|
||||||
let ast = classNameToAst(
|
let ast = classNameToAst(
|
||||||
state,
|
state,
|
||||||
className,
|
classNameParts,
|
||||||
rule.selector,
|
rule.selector,
|
||||||
diagnostic.className.classList.important
|
diagnostic.className.classList.important
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue