@@ -20,6 +20,11 @@ import {
2020 workspace
2121} from "vscode" ;
2222
23+ export type Validation = {
24+ id : boolean ,
25+ class : boolean
26+ } ;
27+
2328export class SelectorCompletionItemProvider implements CompletionItemProvider , Disposable {
2429
2530 readonly none = "__!NONE!__" ;
@@ -63,12 +68,13 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
6368 return workspace . getConfiguration ( "css" , uri ) . get < string [ ] > ( "styleSheets" , [ ] ) ;
6469 }
6570
66- isValidateId ( uri : Uri ) : boolean {
67- return workspace . getConfiguration ( "css" , uri ) . get < boolean > ( "validation.id" , false ) ;
68- }
71+ getValidation ( uri : Uri ) : Validation {
72+ const config = workspace . getConfiguration ( "css" , uri ) ;
6973
70- isValidateClass ( uri : Uri ) : boolean {
71- return workspace . getConfiguration ( "css" , uri ) . get < boolean > ( "validation.class" , true ) ;
74+ return {
75+ id : config . get < boolean > ( "validation.id" , false ) ,
76+ class : config . get < boolean > ( "validation.class" , true )
77+ } ;
7278 }
7379
7480 getRelativePath ( uri : Uri , spec : string , ext ?: string ) : string {
@@ -301,8 +307,7 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
301307 this . findAll ( uri , text ) . then ( sets => {
302308 const ids = new Set < string > ( ) ;
303309 const classes = new Set < string > ( ) ;
304- const isValidateId = this . isValidateId ( uri ) ;
305- const isValidateClass = this . isValidateClass ( uri ) ;
310+ const validation = this . getValidation ( uri ) ;
306311
307312 sets . forEach ( set => set . forEach ( key => this . getItems ( key ) ?. forEach ( ( v , k ) => {
308313 if ( v . kind === CompletionItemKind . Value ) {
@@ -332,13 +337,13 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
332337 const start = document . positionAt ( anchor - value [ 1 ] . length ) ;
333338
334339 if ( attribute [ 1 ] === "id" ) {
335- if ( isValidateId && ! ids . has ( value [ 1 ] ) ) {
340+ if ( validation . id && ! ids . has ( value [ 1 ] ) ) {
336341 diagnostics . push ( new Diagnostic ( new Range ( start , end ) ,
337342 `CSS id selector '${ value [ 1 ] } ' not found.` ,
338343 DiagnosticSeverity . Information ) ) ;
339344 }
340345 } else {
341- if ( isValidateClass && ! classes . has ( value [ 1 ] ) ) {
346+ if ( validation . class && ! classes . has ( value [ 1 ] ) ) {
342347 diagnostics . push ( new Diagnostic ( new Range ( start , end ) ,
343348 `CSS class selector '${ value [ 1 ] } ' not found.` ,
344349 DiagnosticSeverity . Warning ) ) ;
0 commit comments