@@ -20,11 +20,6 @@ import {
2020 workspace
2121} from "vscode" ;
2222
23- type Validation = {
24- id : boolean ;
25- class : boolean ;
26- } ;
27-
2823export class SelectorCompletionItemProvider implements CompletionItemProvider , Disposable {
2924
3025 readonly none = "__!NONE!__" ;
@@ -68,8 +63,12 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
6863 return workspace . getConfiguration ( "css" , uri ) . get < string [ ] > ( "styleSheets" , [ ] ) ;
6964 }
7065
71- getValidation ( uri : Uri ) : Validation {
72- return workspace . getConfiguration ( "css" , uri ) . get < Validation > ( "validation" , { id : false , class : true } ) ;
66+ isValidateId ( uri : Uri ) : boolean {
67+ return workspace . getConfiguration ( "css" , uri ) . get < boolean > ( "validation.id" , false ) ;
68+ }
69+
70+ isValidateClass ( uri : Uri ) : boolean {
71+ return workspace . getConfiguration ( "css" , uri ) . get < boolean > ( "validation.class" , true ) ;
7372 }
7473
7574 getRelativePath ( uri : Uri , spec : string , ext ?: string ) : string {
@@ -302,7 +301,8 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
302301 this . findAll ( uri , text ) . then ( sets => {
303302 const ids = new Set < string > ( ) ;
304303 const classes = new Set < string > ( ) ;
305- const validation = this . getValidation ( uri ) ;
304+ const isValidateId = this . isValidateId ( uri ) ;
305+ const isValidateClass = this . isValidateClass ( uri ) ;
306306
307307 sets . forEach ( set => set . forEach ( key => this . getItems ( key ) ?. forEach ( ( v , k ) => {
308308 if ( v . kind === CompletionItemKind . Value ) {
@@ -332,13 +332,13 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
332332 const start = document . positionAt ( anchor - value [ 1 ] . length ) ;
333333
334334 if ( attribute [ 1 ] === "id" ) {
335- if ( validation . id && ! ids . has ( value [ 1 ] ) ) {
335+ if ( isValidateId && ! ids . has ( value [ 1 ] ) ) {
336336 diagnostics . push ( new Diagnostic ( new Range ( start , end ) ,
337337 `CSS id selector '${ value [ 1 ] } ' not found.` ,
338338 DiagnosticSeverity . Information ) ) ;
339339 }
340340 } else {
341- if ( validation . class && ! classes . has ( value [ 1 ] ) ) {
341+ if ( isValidateClass && ! classes . has ( value [ 1 ] ) ) {
342342 diagnostics . push ( new Diagnostic ( new Range ( start , end ) ,
343343 `CSS class selector '${ value [ 1 ] } ' not found.` ,
344344 DiagnosticSeverity . Warning ) ) ;
0 commit comments