1
- import { normalize } from 'path' ;
1
+ import { extname , normalize } from 'path' ;
2
2
import { Diagnostic , DiagnosticSeverity } from 'vscode-languageserver' ;
3
3
import { TextDocument } from 'vscode-languageserver-textdocument' ;
4
4
import { configService } from '../services/configuration.service' ;
5
5
import { fileSystemService } from '../services/fs.service' ;
6
+ import { imageFileExtensions } from 'shared' ;
6
7
7
8
export function validateFilePaths ( textDocument : TextDocument ) : Diagnostic [ ] {
8
9
// In this simple example we get the settings for every validate run.
@@ -22,7 +23,7 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
22
23
problems < configService . globalSettings . maxNumberOfProblems
23
24
) {
24
25
const normalizedPath = normalize ( m [ 2 ] ) ;
25
- if ( ! fileSystemService . moduleFileList . includes ( normalizedPath ) ) {
26
+ if ( ! checkIfPathExists ( normalizedPath ) ) {
26
27
problems ++ ;
27
28
const diagnostic : Diagnostic = {
28
29
severity : DiagnosticSeverity . Error ,
@@ -52,3 +53,22 @@ export function validateFilePaths(textDocument: TextDocument): Diagnostic[] {
52
53
// Send the computed diagnostics to VSCode.
53
54
return diagnostics ;
54
55
}
56
+
57
+ function checkIfPathExists ( filePath : string ) : boolean {
58
+ if ( fileSystemService . moduleFileList . includes ( filePath ) ) {
59
+ return true ;
60
+ }
61
+
62
+ if ( imageFileExtensions . includes ( extname ( filePath ) ) ) {
63
+ const index = filePath . lastIndexOf ( '.' ) ;
64
+ if ( index < 0 ) {
65
+ return false ;
66
+ }
67
+
68
+ filePath = filePath . substring ( 0 , index ) + '000' + filePath . substring ( index ) ;
69
+
70
+ return fileSystemService . moduleFileList . includes ( filePath ) ;
71
+ }
72
+
73
+ return false ;
74
+ }
0 commit comments