File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,8 +11,13 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
1111
1212 // The validator creates diagnostics for all uppercase words length 2 and more
1313 const text = textDocument . getText ( ) ;
14+
1415 const pattern =
15- / ( \t * (?: S c r i p t P a t h | I n c l u d e F i l e | L o g o F i l e | F i l e P a t h | S k i n F i l e ) \s * = \s * ) ( .* ) / dg;
16+ / (?: \/ \* .* ?(? = \* \/ ) ) | ( \t * (?: S c r i p t P a t h | I n c l u d e F i l e | L o g o F i l e | F i l e P a t h | S k i n F i l e ) \s * = \s * ) ( .* ?) (? = (?: $ | \/ \/ | \/ \* | (?: \s + (?: \/ \/ .* | \/ \* .* ) ) ) ) / dgms;
17+
18+ const commentPattern = / ( \/ \/ [ ^ \n ] * \n ) | ( \/ \* .* ?\* \/ ) / dgms;
19+ const commentRanges = text . matchAll ( commentPattern ) ;
20+
1621 let m : RegExpExecArray | null ;
1722
1823 let problems = 0 ;
@@ -22,8 +27,21 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
2227 ( m = pattern . exec ( text ) ) &&
2328 problems < configService . globalSettings . maxNumberOfProblems
2429 ) {
25- const normalizedPath = normalize ( m [ 2 ] ) ;
26- if ( ! checkIfPathExists ( normalizedPath ) ) {
30+ let skip = false ;
31+ for ( const comment of commentRanges ) {
32+ if ( ! ( comment . index && comment . length ) ) {
33+ continue ;
34+ }
35+ skip =
36+ ( comment . index < m . index && comment . index + comment . length > m . index ) ||
37+ ( comment . index > m . index && comment . index < m . index + m . length ) ;
38+ }
39+
40+ if ( skip ) {
41+ continue ;
42+ }
43+ const normalizedPath = m [ 2 ] ? normalize ( m [ 2 ] . trim ( ) ) : null ;
44+ if ( normalizedPath && ! checkIfPathExists ( normalizedPath ) ) {
2745 problems ++ ;
2846 const diagnostic : Diagnostic = {
2947 severity : DiagnosticSeverity . Error ,
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ repository:
4040 patterns :
4141 - { include: '#comments' }
4242 - { include: '#classNames' }
43+ - { include: '#strings' }
4344
4445 patterns :
4546 - { include: '#comments' }
You can’t perform that action at this time.
0 commit comments