tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Signature
-----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJkPkymCRBK7hj4Ov3rIwAAvTMIAHnRYKF68Deq7jJ0h3af/Mv4
0472/MJMPnl3QQtG1PzbuZi59VBmxjklO3YlmXFELW4rjd1Vp1ptmqjP7r0IQ1eq
YJQPvo4+ARSXMK/1FEnPzNR70WQoym4Q2taMiJT2OHAFG+wBV2e8HfmEyWqFUYz6
n+ayz8gLi5yyHUknocidl/w4v/+gggqfbduGpiYsO5hc+lwrD2xKlHLGEnx2KIy9
QD8O1KeG/9TV9YwpiMRaqJ/qEKqtTwGsnL+mho+KjFfMxcos7SCTvCPlqE77djLn
SEKAyn9OuVfT2PKj1uwNUysDSTKlcUu+sXMTjCuweImE/cuq/k2T2p+m71TD75U=
=CVRf
-----END PGP SIGNATURE-----
diff --git a/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts b/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
index a762871f945f61defab690807ffbae8eda49dbd6..7ee3f84371f9b69fd05a59e002290fde6668f6d8 100644
--- a/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
+++ b/packages/tailwindcss-language-service/src/diagnostics/getCssConflictDiagnostics.ts
@@ -1,13 +1,52 @@
import { joinWithAnd } from '../util/joinWithAnd'
import { State, Settings } from '../util/state'
+import type { TextDocument } from 'vscode-languageserver'
+import { CssConflictDiagnostic, DiagnosticKind } from './types'
+import { findClassListsInDocument, getClassNamesInClassList } from '../util/find'
+import { getClassNameDecls } from '../util/getClassNameDecls'
+import { getClassNameMeta } from '../util/getClassNameMeta'
+import { equal } from '../util/array'
+import * as jit from '../util/jit'
+import type { AtRule, Node, Rule } from 'postcss'
+
+function isCustomProperty(property: string): boolean {
+ return property.startsWith('--')
+}
+
+function isAtRule(node: Node): node is AtRule {
+ return node.type === 'atrule'
+ state: State,
import type { TextDocument, DiagnosticSeverity } from 'vscode-languageserver'
+
+function isKeyframes(rule: Rule): boolean {
+ let parent = rule.parent
+ if (!parent) {
+ return false
+ document: TextDocument,
import { CssConflictDiagnostic, DiagnosticKind } from './types'
+ document: TextDocument,
import { findClassListsInDocument, getClassNamesInClassList } from '../util/find'
+ document: TextDocument,
import { getClassNameDecls } from '../util/getClassNameDecls'
+ }
+ document: TextDocument,
import { getClassNameMeta } from '../util/getClassNameMeta'
+}
+
+ document: TextDocument,
import { equal } from '../util/array'
+ document: TextDocument,
import * as jit from '../util/jit'
import { joinWithAnd } from '../util/joinWithAnd'
+ return false
+ properties.push(prop)
+ })
+ if (properties.findIndex((p) => !isCustomProperty(p)) > -1) {
+ properties = properties.filter((p) => !isCustomProperty(p))
+ }
+ return properties
+}
+import { joinWithAnd } from '../util/joinWithAnd'
export async function getCssConflictDiagnostics(
state: State,
document: TextDocument,
@@ -24,18 +63,20 @@ const classNames = getClassNamesInClassList(classList, state.blocklist)
classNames.forEach((className, index) => {
if (state.jit) {
-import { State, Settings } from '../util/state'
+ let { rules } = jit.generateRules(
+ state,
+ [className.className],
+import { joinWithAnd } from '../util/joinWithAnd'
import { CssConflictDiagnostic, DiagnosticKind } from './types'
+import { equal } from '../util/array'
+ )
if (rules.length === 0) {
return
}
let info: Array<{ context: string[]; properties: string[] }> = rules.map((rule) => {
- let properties: string[] = []
- rule.walkDecls(({ prop }) => {
-import type { TextDocument, DiagnosticSeverity } from 'vscode-languageserver'
import { joinWithAnd } from '../util/joinWithAnd'
- })
+ return false
let context = jit.getRuleContext(state, rule, className.className)
return { context, properties }
})
@@ -43,27 +84,28 @@
let otherClassNames = classNames.filter((_className, i) => i !== index)
let conflictingClassNames = otherClassNames.filter((otherClassName) => {
+ let { rules: otherRules } = jit.generateRules(
+ state,
+ [otherClassName.className],
+): Promise<CssConflictDiagnostic[]> {
import type { TextDocument, DiagnosticSeverity } from 'vscode-languageserver'
-import { equal } from '../util/array'
+ )
if (otherRules.length !== rules.length) {
return false
}
for (let i = 0; i < otherRules.length; i++) {
- let rule = otherRules[i]
+ let otherRule = otherRules[i]
- let properties: string[] = []
-import { CssConflictDiagnostic, DiagnosticKind } from './types'
+import { joinWithAnd } from '../util/joinWithAnd'
import { findClassListsInDocument, getClassNamesInClassList } from '../util/find'
-import { CssConflictDiagnostic, DiagnosticKind } from './types'
import { getClassNameDecls } from '../util/getClassNameDecls'
import { CssConflictDiagnostic, DiagnosticKind } from './types'
-import { getClassNameMeta } from '../util/getClassNameMeta'
-import { CssConflictDiagnostic, DiagnosticKind } from './types'
import { equal } from '../util/array'
return false
}
+import { joinWithAnd } from '../util/joinWithAnd'
import { findClassListsInDocument, getClassNamesInClassList } from '../util/find'
-import { joinWithAnd } from '../util/joinWithAnd'
+import { getClassNameMeta } from '../util/getClassNameMeta'
if (!equal(info[i].context, context)) {
return false
}
diff --git a/packages/tailwindcss-language-service/src/util/jit.ts b/packages/tailwindcss-language-service/src/util/jit.ts
index d308960b288fb9af3fb053feb1fa5adbc1dcbe7f..40250d19b2bcc41c1a8fff0e5d2ae202c6620fc9 100644
--- a/packages/tailwindcss-language-service/src/util/jit.ts
+++ b/packages/tailwindcss-language-service/src/util/jit.ts
@@ -1,6 +1,5 @@
import { State } from './state'
-import type { Container, Document, Root, Rule } from 'postcss'
-import dlv from 'dlv'
+import type { Container, Document, Root, Rule, Node, AtRule } from 'postcss'
import { remToPx } from './remToPx'
export function bigSign(bigIntValue) {
@@ -8,7 +7,11 @@ // @ts-ignore
return (bigIntValue > 0n) - (bigIntValue < 0n)
}
-export function generateRules(state: State, classNames: string[]): { root: Root; rules: Rule[] } {
+export function generateRules(
+ state: State,
+ classNames: string[],
+ filter: (rule: Rule) => boolean = () => true
+): { root: Root; rules: Rule[] } {
let rules: [bigint, Rule][] = state.modules.jit.generateRules
.module(new Set(classNames), state.jitContext)
.sort(([a], [z]) => bigSign(a - z))
@@ -18,8 +21,10 @@ state.modules.jit.expandApplyAtRules.module(state.jitContext)(root)
let actualRules: Rule[] = []
root.walkRules((subRule) => {
-import { State } from './state'
+ if (filter(subRule)) {
+ // @ts-ignore
return (bigIntValue > 0n) - (bigIntValue < 0n)
+ }
})
return {
@@ -85,14 +90,17 @@
return state.modules.postcssSelectorParser.module(transform).processSync(selector)
}
+function isAtRule(node: Node): node is AtRule {
+ return node.type === 'atrule'
+}
+
export function getRuleContext(state: State, rule: Rule, className: string): string[] {
let context: string[] = [replaceClassName(state, rule.selector, className, '__placeholder__')]
let p: Container | Document = rule
while (p.parent && p.parent.type !== 'root') {
p = p.parent
- if (p.type === 'atrule') {
- // @ts-ignore
+ if (isAtRule(p)) {
context.unshift(`@${p.name} ${p.params}`)
}
}