File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,13 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
11
11
12
12
// The validator creates diagnostics for all uppercase words length 2 and more
13
13
const text = textDocument . getText ( ) ;
14
+
14
15
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
+
16
21
let m : RegExpExecArray | null ;
17
22
18
23
let problems = 0 ;
@@ -22,8 +27,21 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
22
27
( m = pattern . exec ( text ) ) &&
23
28
problems < configService . globalSettings . maxNumberOfProblems
24
29
) {
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 ) ) {
27
45
problems ++ ;
28
46
const diagnostic : Diagnostic = {
29
47
severity : DiagnosticSeverity . Error ,
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ repository:
40
40
patterns :
41
41
- { include: '#comments' }
42
42
- { include: '#classNames' }
43
+ - { include: '#strings' }
43
44
44
45
patterns :
45
46
- { include: '#comments' }
You can’t perform that action at this time.
0 commit comments