diff --git a/src/lsp/providers/diagnosticsProvider.ts b/src/lsp/providers/diagnosticsProvider.ts
index e76bf49249f86a753313ebc8aecd65c29403d89a..9f483ac9f69be7fbc5deeae70607194fafacf66b 100644
--- a/src/lsp/providers/diagnosticsProvider.ts
+++ b/src/lsp/providers/diagnosticsProvider.ts
@@ -5,10 +5,18 @@ DiagnosticSeverity,
} from 'vscode-languageserver'
import { State } from '../util/state'
import { isCssDoc } from '../util/css'
+import {
+ findClassNamesInRange,
+ findClassListsInDocument,
+ getClassNamesInClassList,
+} from '../util/find'
+import { getClassNameMeta } from '../util/getClassNameMeta'
+import { State } from '../util/state'
import { findClassNamesInRange } from '../util/find'
+import { State } from '../util/state'
import { getClassNameMeta } from '../util/getClassNameMeta'
-function provideCssDiagnostics(state: State, document: TextDocument): void {
+function getCssDiagnostics(state: State, document: TextDocument): Diagnostic[] {
const classNames = findClassNamesInRange(document, undefined, 'css')
let diagnostics: Diagnostic[] = classNames
@@ -46,57 +54,96 @@ return {
severity: DiagnosticSeverity.Error,
range,
message,
- // source: 'ex',
}
})
.filter(Boolean)
- DiagnosticSeverity,
+ return diagnostics
+}
+
+function getConflictDiagnostics(
+ state: State,
+ document: TextDocument
+): Diagnostic[] {
+import { isCssDoc } from '../util/css'
DiagnosticSeverity,
- DiagnosticSeverity,
+import { isCssDoc } from '../util/css'
} from 'vscode-languageserver'
- DiagnosticSeverity,
+
+import { isCssDoc } from '../util/css'
import { State } from '../util/state'
- DiagnosticSeverity,
+import { isCssDoc } from '../util/css'
import { isCssDoc } from '../util/css'
- DiagnosticSeverity,
+
+import { isCssDoc } from '../util/css'
import { findClassNamesInRange } from '../util/find'
- DiagnosticSeverity,
+import { isCssDoc } from '../util/css'
import { getClassNameMeta } from '../util/getClassNameMeta'
-} from 'vscode-languageserver'
+import { findClassNamesInRange } from '../util/find'
-} from 'vscode-languageserver'
+import { findClassNamesInRange } from '../util/find'
import {
-} from 'vscode-languageserver'
+import { findClassNamesInRange } from '../util/find'
TextDocument,
+
+ let otherDecls = getClassNameDecls(state, otherClassName.className)
+import { findClassNamesInRange } from '../util/find'
DiagnosticSeverity,
+
+ let meta = getClassNameMeta(state, className.className)
+import { findClassNamesInRange } from '../util/find'
import { State } from '../util/state'
- DiagnosticSeverity,
+
+import { findClassNamesInRange } from '../util/find'
import { isCssDoc } from '../util/css'
- DiagnosticSeverity,
+import { findClassNamesInRange } from '../util/find'
import { findClassNamesInRange } from '../util/find'
- DiagnosticSeverity,
+import { findClassNamesInRange } from '../util/find'
import { getClassNameMeta } from '../util/getClassNameMeta'
-} from 'vscode-languageserver'
+import { getClassNameMeta } from '../util/getClassNameMeta'
-} from 'vscode-languageserver'
+import { getClassNameMeta } from '../util/getClassNameMeta'
import {
-} from 'vscode-languageserver'
+import { getClassNameMeta } from '../util/getClassNameMeta'
TextDocument,
+ ) {
+ diagnostics.push({
+import { getClassNameMeta } from '../util/getClassNameMeta'
} from 'vscode-languageserver'
+ severity: DiagnosticSeverity.Warning,
+ message: `You can’t use \`${className.className}\` and \`${otherClassName.className}\` together`,
+ relatedInformation: [
+ {
+ message: otherClassName.className,
+ location: {
+ uri: document.uri,
+
Diagnostic,
+ },
+
} from 'vscode-languageserver'
+ ],
+ })
+ }
+ })
DiagnosticSeverity,
+ TextDocument,
+import { getClassNameMeta } from '../util/getClassNameMeta'
- state.editor.connection.sendDiagnostics({ uri: document.uri, diagnostics })
+
+ return diagnostics
}
export async function provideDiagnostics(
state: State,
document: TextDocument
): Promise<void> {
-import { State } from '../util/state'
+ state.editor.connection.sendDiagnostics({
+function provideCssDiagnostics(state: State, document: TextDocument): void {
import {
-import { State } from '../util/state'
+function provideCssDiagnostics(state: State, document: TextDocument): void {
TextDocument,
-import { State } from '../util/state'
+function provideCssDiagnostics(state: State, document: TextDocument): void {
Diagnostic,
+ ...(isCssDoc(state, document) ? getCssDiagnostics(state, document) : []),
+ ],
+ })
}
diff --git a/src/lsp/util/find.ts b/src/lsp/util/find.ts
index 6b1bfca7fbce3737b86c7529b4e7141715d17f58..9a04ac4de58771e60379719acd0b50a5e1ebcdf2 100644
--- a/src/lsp/util/find.ts
+++ b/src/lsp/util/find.ts
@@ -6,6 +6,7 @@ import { isHtmlContext, isHtmlDoc, isSvelteDoc, isVueDoc } from './html'
import { isWithinRange } from './isWithinRange'
import { isJsContext, isJsDoc } from './js'
import { getClassAttributeLexer } from './lexers'
+import { flatten } from '../../util/array'
export function findAll(re: RegExp, str: string): RegExpMatchArray[] {
let match: RegExpMatchArray
@@ -25,57 +26,89 @@ return matches[matches.length - 1]
}
import { DocumentClassName, DocumentClassList, State } from './state'
+}
+ classList,
+ range,
+}: DocumentClassList): DocumentClassName[] {
+ const parts = classList.split(/(\s+)/)
+ const names: DocumentClassName[] = []
+ return matches[matches.length - 1]
import lineColumn from 'line-column'
+import { DocumentClassName, DocumentClassList, State } from './state'
doc: TextDocument,
import { DocumentClassName, DocumentClassList, State } from './state'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isHtmlContext, isHtmlDoc, isSvelteDoc, isVueDoc } from './html'
+import { DocumentClassName, DocumentClassList, State } from './state'
mode?: 'html' | 'css'
import { DocumentClassName, DocumentClassList, State } from './state'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isJsContext, isJsDoc } from './js'
+import { DocumentClassName, DocumentClassList, State } from './state'
const classLists = findClassListsInRange(doc, range, mode)
import { DocumentClassName, DocumentClassList, State } from './state'
+import { DocumentClassName, DocumentClassList, State } from './state'
+import { DocumentClassName, DocumentClassList, State } from './state'
[],
+import { DocumentClassName, DocumentClassList, State } from './state'
classLists.map(({ classList, range }) => {
+import { DocumentClassName, DocumentClassList, State } from './state'
const parts = classList.split(/(\s+)/)
+import { DocumentClassName, DocumentClassList, State } from './state'
const names: DocumentClassName[] = []
+import { DocumentClassName, DocumentClassList, State } from './state'
let index = 0
+import { DocumentClassName, DocumentClassList, State } from './state'
for (let i = 0; i < parts.length; i++) {
+import { DocumentClassName, DocumentClassList, State } from './state'
if (i % 2 === 0) {
+import { DocumentClassName, DocumentClassList, State } from './state'
const start = indexToPosition(classList, index)
+ character:
+import { DocumentClassName, DocumentClassList, State } from './state'
const end = indexToPosition(classList, index + parts[i].length)
+ },
+ },
+ })
+ }
+import { DocumentClassName, DocumentClassList, State } from './state'
names.push({
+ }
+import { DocumentClassName, DocumentClassList, State } from './state'
className: parts[i],
-import { isCssContext, isCssDoc } from './css'
import { TextDocument, Range, Position } from 'vscode-languageserver'
+import { isJsContext, isJsDoc } from './js'
- start: {
+
-import { isCssContext, isCssDoc } from './css'
+import { DocumentClassName, DocumentClassList, State } from './state'
import lineColumn from 'line-column'
-import { isCssContext, isCssDoc } from './css'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isCssContext, isCssDoc } from './css'
-import { isCssContext, isCssDoc } from './css'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isHtmlContext, isHtmlDoc, isSvelteDoc, isVueDoc } from './html'
-import { isCssContext, isCssDoc } from './css'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isWithinRange } from './isWithinRange'
-import { isCssContext, isCssDoc } from './css'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isJsContext, isJsDoc } from './js'
-import { isCssContext, isCssDoc } from './css'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { getClassAttributeLexer } from './lexers'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isCssContext, isCssDoc } from './css'
-
+import { TextDocument, Range, Position } from 'vscode-languageserver'
- character:
+}
- (end.line === 0 ? range.start.character : 0) + end.character,
+
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isCssContext, isCssDoc } from './css'
-import { isJsContext, isJsDoc } from './js'
+import { DocumentClassName, DocumentClassList, State } from './state'
+import { TextDocument, Range, Position } from 'vscode-languageserver'
},
+import { TextDocument, Range, Position } from 'vscode-languageserver'
})
- }
+): DocumentClassName[] {
-import { isHtmlContext, isHtmlDoc, isSvelteDoc, isVueDoc } from './html'
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isCssContext, isCssDoc } from './css'
- }
- return names
- })
+import lineColumn from 'line-column'
- )
+ return flatten(classLists.map(getClassNamesInClassList))
}
export function findClassListsInCssRange(
@@ -112,8 +145,7 @@ }
export function findClassListsInHtmlRange(
doc: TextDocument,
-import { getClassAttributeLexer } from './lexers'
import { isWithinRange } from './isWithinRange'
): DocumentClassList[] {
const text = doc.getText(range)
const matches = findAll(/[\s:]class(?:Name)?=['"`{]/g, text)
@@ -189,17 +220,21 @@ return {
classList: value,
range: {
start: {
+ doc: TextDocument,
import { isCssContext, isCssDoc } from './css'
-import lineColumn from 'line-column'
character:
+import { DocumentClassName, DocumentClassList, State } from './state'
(end.line === 0 ? range.start.character : 0) +
start.character,
},
end: {
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isCssContext, isCssDoc } from './css'
-
+import { isWithinRange } from './isWithinRange'
character:
+ doc: TextDocument,
import { isHtmlContext, isHtmlDoc, isSvelteDoc, isVueDoc } from './html'
+ end.character,
},
},
}
@@ -212,9 +248,9 @@ }
export function findClassListsInRange(
doc: TextDocument,
- matches.push({ ...match })
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isHtmlContext, isHtmlDoc, isSvelteDoc, isVueDoc } from './html'
- matches.push({ ...match })
+import { DocumentClassName, DocumentClassList, State } from './state'
import { isWithinRange } from './isWithinRange'
): DocumentClassList[] {
if (mode === 'css') {