Revert "Improve conflict diagnostics (#503)" (#525)
This reverts commit ddfaea21cc5feca1bbf71ddb36645a61f01daea3.
diff --git a/packages/tailwindcss-language-service/src/util/find.ts b/packages/tailwindcss-language-service/src/util/find.ts
index d0ad26681d864cb45c0d893a556e2bd88cc44497..d9a23c461e9c490c4d9708b6768822329c04c25d 100644
--- a/packages/tailwindcss-language-service/src/util/find.ts
+++ b/packages/tailwindcss-language-service/src/util/find.ts
@@ -77,17 +77,9 @@ mode?: 'html' | 'css',
includeCustom: boolean = true
): Promise<DocumentClassName[]> {
const classLists = await findClassListsInRange(state, doc, range, mode, includeCustom)
- return flatten(
- classLists.flatMap((classList) => {
-import { isJsxContext } from './js'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
- return classList.map(getClassNamesInClassList)
- } else {
- return [getClassNamesInClassList(classList)]
-import { isJsxContext } from './js'
+import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
import { isWithinRange } from './isWithinRange'
- })
- )
}
export async function findClassNamesInDocument(
@@ -95,17 +87,9 @@ state: State,
doc: TextDocument
): Promise<DocumentClassName[]> {
const classLists = await findClassListsInDocument(state, doc)
- return flatten(
- classLists.flatMap((classList) => {
-import { isJsxContext } from './js'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
- return classList.map(getClassNamesInClassList)
- } else {
- return [getClassNamesInClassList(classList)]
-import { isJsxContext } from './js'
+import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
import { isWithinRange } from './isWithinRange'
- })
- )
}
export function findClassListsInCssRange(doc: TextDocument, range?: Range): DocumentClassList[] {
@@ -203,7 +187,7 @@ state: State,
doc: TextDocument,
range?: Range
import type { TextDocument, Range, Position } from 'vscode-languageserver'
- end,
+import { isHtmlContext } from './html'
const text = doc.getText(range)
const matches = matchClassAttributes(
@@ -212,7 +196,7 @@ (await state.editor.getConfiguration(doc.uri)).tailwindCSS.classAttributes
)
import type { TextDocument, Range, Position } from 'vscode-languageserver'
- character: (end.line === 0 ? range.start.character : 0) + start.character,
+import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
matches.forEach((match) => {
const subtext = text.substr(match.index + match[0].length - 1)
@@ -223,12 +207,10 @@ ? getComputedClassAttributeLexer()
: getClassAttributeLexer()
lexer.reset(subtext)
- let classLists: Array<{ value: string; offset: number } | { value: string; offset: number }[]> =
- let match: RegExpMatchArray
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+ character: (end.line === 0 ? globalStart.character : 0) + start.character,
- let rootClassList: { value: string; offset: number }[] = []
+ let token: moo.Token
let currentClassList: { value: string; offset: number }
- let depth = 0
try {
for (let token of lexer) {
@@ -243,145 +225,107 @@ }
}
} else {
if (currentClassList) {
- if (depth === 0) {
- rootClassList.push({
- value: currentClassList.value,
- offset: currentClassList.offset,
- let matches: RegExpMatchArray[] = []
+ classList,
import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
- while ((match = re.exec(str)) !== null) {
+ range,
- while ((match = re.exec(str)) !== null) {
+ range,
import type { TextDocument, Range, Position } from 'vscode-languageserver'
import type { TextDocument, Range, Position } from 'vscode-languageserver'
- })
+import lineColumn from 'line-column'
import type { TextDocument, Range, Position } from 'vscode-languageserver'
- )
- })
- }
}
currentClassList = undefined
}
- if (token.type === 'lbrace') {
- depth += 1
- } else if (token.type === 'rbrace') {
- depth -= 1
- }
}
} catch (_) {}
if (currentClassList) {
- if (depth === 0) {
- rootClassList.push({
- matches.push({ ...match })
+import lineColumn from 'line-column'
- offset: currentClassList.offset,
- matches.push({ ...match })
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
- } else {
- matches.push({ ...match })
import lineColumn from 'line-column'
- matches.push({ ...match })
- offset: currentClassList.offset,
+import lineColumn from 'line-column'
- })
- }
+ offset: currentClassList.offset,
import { isHtmlContext } from './html'
-import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
-
+import { flatten } from './array'
-import type { TextDocument, Range, Position } from 'vscode-languageserver'
+import { isHtmlContext } from './html'
import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
-import { isCssContext, isCssDoc } from './css'
result.push(
...classLists
- .map((classList) => {
- if (Array.isArray(classList)) {
- return classList
- .map((classList) => resolveClassList(classList, text, match, range))
- .filter((x) => x !== null)
- } else {
- return resolveClassList(classList, text, match, range)
-import type { TextDocument, Range, Position } from 'vscode-languageserver'
import lineColumn from 'line-column'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
- })
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-import lineColumn from 'line-column'
+import { isHtmlContext } from './html'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
-import { isCssContext, isCssDoc } from './css'
+import { isWithinRange } from './isWithinRange'
-import type { TextDocument, Range, Position } from 'vscode-languageserver'
+import lineColumn from 'line-column'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-
+import { isJsxContext } from './js'
import type { TextDocument, Range, Position } from 'vscode-languageserver'
-import { isCssContext, isCssDoc } from './css'
import lineColumn from 'line-column'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-function resolveClassList(
- classList: { value: string; offset: number },
- text: string,
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
import { flatten } from './array'
- range?: Range
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
import { getClassAttributeLexer, getComputedClassAttributeLexer } from './lexers'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
import { getLanguageBoundaries } from './getLanguageBoundaries'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
import { resolveRange } from './resolveRange'
- return null
- }
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
import dlv from 'dlv'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+ } else {
+import lineColumn from 'line-column'
import { createMultiRegexp } from './createMultiRegexp'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
export function findAll(re: RegExp, str: string): RegExpMatchArray[] {
-import type { TextDocument, Range, Position } from 'vscode-languageserver'
+ return matches[matches.length - 1]
import { isCssContext, isCssDoc } from './css'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
let match: RegExpMatchArray
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
import type { TextDocument, Range, Position } from 'vscode-languageserver'
-import { isJsxContext } from './js'
+import { isCssContext, isCssDoc } from './css'
import type { TextDocument, Range, Position } from 'vscode-languageserver'
-import { isHtmlContext } from './html'
+import { isCssContext, isCssDoc } from './css'
+import lineColumn from 'line-column'
import type { TextDocument, Range, Position } from 'vscode-languageserver'
+import { isJsxContext } from './js'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
while ((match = re.exec(str)) !== null) {
- )
import type { TextDocument, Range, Position } from 'vscode-languageserver'
-import { isCssContext, isCssDoc } from './css'
+ for (let i = 0; i < parts.length; i++) {
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
matches.push({ ...match })
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
}
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
return matches
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+ },
+import lineColumn from 'line-column'
}
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
export function findLast(re: RegExp, str: string): RegExpMatchArray {
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
const matches = findAll(re, str)
import type { TextDocument, Range, Position } from 'vscode-languageserver'
+import lineColumn from 'line-column'
import type { TextDocument, Range, Position } from 'vscode-languageserver'
+ const end = indexToPosition(classList, index + parts[i].length)
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import { createMultiRegexp } from './createMultiRegexp'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-import { isHtmlContext } from './html'
-import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+ matches.push({ ...match })
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-import { isWithinRange } from './isWithinRange'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
+import lineColumn from 'line-column'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-import { isJsxContext } from './js'
+import { isCssContext, isCssDoc } from './css'
import { getLanguageBoundaries } from './getLanguageBoundaries'
-import type { TextDocument, Range, Position } from 'vscode-languageserver'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
-export function getClassNamesInClassList({
- }
+
+ return result
}
export async function findClassListsInRange(
@@ -391,9 +334,10 @@ range?: Range,
mode?: 'html' | 'css',
includeCustom: boolean = true
import type { TextDocument, Range, Position } from 'vscode-languageserver'
- end,
+import { isHtmlContext } from './html'
+import lineColumn from 'line-column'
import { DocumentClassName, DocumentClassList, State, DocumentHelperFunction } from './state'
- range,
+import { isHtmlContext } from './html'
if (mode === 'css') {
classLists = findClassListsInCssRange(doc, range)
} else {
@@ -406,7 +350,7 @@ export async function findClassListsInDocument(
state: State,
doc: TextDocument
import type { TextDocument, Range, Position } from 'vscode-languageserver'
- end,
+import { isHtmlContext } from './html'
if (isCssDoc(state, doc)) {
return findClassListsInCssRange(doc)
}