@@ -20,6 +20,11 @@ import {
2020 workspace
2121} from "vscode" ;
2222
23+ type Validation = {
24+ id : boolean ;
25+ class : boolean ;
26+ } ;
27+
2328export class SelectorCompletionItemProvider implements CompletionItemProvider , Disposable {
2429
2530 readonly none = "__!NONE!__" ;
@@ -63,6 +68,10 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
6368 return workspace . getConfiguration ( "css" , uri ) . get < string [ ] > ( "styleSheets" , [ ] ) ;
6469 }
6570
71+ getValidation ( uri : Uri ) : Validation {
72+ return workspace . getConfiguration ( "css" , uri ) . get < Validation > ( "validation" , { id : false , class : true } ) ;
73+ }
74+
6675 getRelativePath ( uri : Uri , spec : string , ext ?: string ) : string {
6776 const folder = workspace . getWorkspaceFolder ( uri ) ;
6877 const name = ext ? join ( dirname ( spec ) , basename ( spec , ext ) + ext ) : spec ;
@@ -293,6 +302,7 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
293302 this . findAll ( uri , text ) . then ( sets => {
294303 const ids = new Set < string > ( ) ;
295304 const classes = new Set < string > ( ) ;
305+ const validation = this . getValidation ( uri ) ;
296306
297307 sets . forEach ( set => set . forEach ( key => this . getItems ( key ) ?. forEach ( ( v , k ) => {
298308 if ( v . kind === CompletionItemKind . Value ) {
@@ -322,13 +332,13 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
322332 const start = document . positionAt ( anchor - value [ 1 ] . length ) ;
323333
324334 if ( attribute [ 1 ] === "id" ) {
325- if ( ! ids . has ( value [ 1 ] ) ) {
335+ if ( validation . id && ! ids . has ( value [ 1 ] ) ) {
326336 diagnostics . push ( new Diagnostic ( new Range ( start , end ) ,
327337 `CSS id selector '${ value [ 1 ] } ' not found.` ,
328- DiagnosticSeverity . Warning ) ) ;
338+ DiagnosticSeverity . Information ) ) ;
329339 }
330340 } else {
331- if ( ! classes . has ( value [ 1 ] ) ) {
341+ if ( validation . class && ! classes . has ( value [ 1 ] ) ) {
332342 diagnostics . push ( new Diagnostic ( new Range ( start , end ) ,
333343 `CSS class selector '${ value [ 1 ] } ' not found.` ,
334344 DiagnosticSeverity . Warning ) ) ;
0 commit comments