@@ -29,11 +29,8 @@ interface SchemaInfo {
29
29
const schemaCache = new Map < string , SchemaInfo > ( ) ;
30
30
31
31
function loadReScriptSchema ( projectRoot : string ) : SchemaInfo | null {
32
- console . log ( `[JSON_CONFIG] Loading schema for project: ${ projectRoot } ` ) ;
33
-
34
32
// Check cache first
35
33
if ( schemaCache . has ( projectRoot ) ) {
36
- console . log ( `[JSON_CONFIG] Schema found in cache` ) ;
37
34
return schemaCache . get ( projectRoot ) ! ;
38
35
}
39
36
@@ -46,18 +43,12 @@ function loadReScriptSchema(projectRoot: string): SchemaInfo | null {
46
43
"build-schema.json" ,
47
44
) ;
48
45
49
- console . log ( `[JSON_CONFIG] Looking for schema at: ${ schemaPath } ` ) ;
50
-
51
46
if ( ! fs . existsSync ( schemaPath ) ) {
52
- console . log ( `[JSON_CONFIG] Schema file does not exist` ) ;
53
47
return null ;
54
48
}
55
49
56
50
try {
57
51
const schemaContent = fs . readFileSync ( schemaPath , "utf8" ) ;
58
- console . log (
59
- `[JSON_CONFIG] Schema content preview: ${ schemaContent . substring ( 0 , 500 ) } ...` ,
60
- ) ;
61
52
const schema = JSON . parse ( schemaContent ) ;
62
53
63
54
const schemaInfo : SchemaInfo = {
@@ -81,43 +72,30 @@ export function isConfigFile(filePath: string): boolean {
81
72
82
73
export function validateConfig ( document : TextDocument ) : Diagnostic [ ] {
83
74
const filePath = document . uri ;
84
- console . log ( `[JSON_CONFIG] Validating config: ${ filePath } ` ) ;
85
75
86
76
// Convert file URI to filesystem path for project root detection
87
77
let fsPath : string ;
88
78
try {
89
79
fsPath = fileURLToPath ( filePath ) ;
90
- console . log ( `[JSON_CONFIG] Converted to filesystem path: ${ fsPath } ` ) ;
91
80
} catch ( error ) {
92
- console . log ( `[JSON_CONFIG] Failed to convert file URI to path: ${ error } ` ) ;
81
+ console . error ( `[JSON_CONFIG] Failed to convert file URI to path: ${ error } ` ) ;
93
82
return [ ] ;
94
83
}
95
84
96
85
const projectRoot = findProjectRootOfFile ( fsPath ) ;
97
- console . log ( `[JSON_CONFIG] Found project root: ${ projectRoot } ` ) ;
98
86
99
87
if ( ! projectRoot ) {
100
- console . log (
101
- `[JSON_CONFIG] No project root found, returning empty diagnostics` ,
102
- ) ;
103
88
return [ ] ;
104
89
}
105
90
106
91
const schemaInfo = loadReScriptSchema ( projectRoot ) ;
107
- console . log (
108
- `[JSON_CONFIG] Schema info: ${ schemaInfo ? "found" : "not found" } ` ,
109
- ) ;
110
92
111
93
if ( ! schemaInfo ) {
112
- console . log ( `[JSON_CONFIG] No schema found, returning empty diagnostics` ) ;
113
94
return [ ] ;
114
95
}
115
96
116
97
try {
117
98
const jsonContent = document . getText ( ) ;
118
- console . log (
119
- `[JSON_CONFIG] JSON content: ${ jsonContent . substring ( 0 , 200 ) } ...` ,
120
- ) ;
121
99
const config = JSON . parse ( jsonContent ) ;
122
100
123
101
let validate ;
@@ -129,17 +107,15 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
129
107
}
130
108
131
109
const valid = validate ( config ) ;
132
- console . log ( `[JSON_CONFIG] Validation result: ${ valid } ` ) ;
133
110
134
111
if ( ! valid && validate . errors ) {
135
- console . log (
112
+ console . error (
136
113
`[JSON_CONFIG] Validation errors:` ,
137
114
JSON . stringify ( validate . errors , null , 2 ) ,
138
115
) ;
139
116
}
140
117
141
118
if ( valid ) {
142
- console . log ( `[JSON_CONFIG] Valid JSON, returning empty diagnostics` ) ;
143
119
return [ ] ;
144
120
}
145
121
@@ -166,9 +142,6 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
166
142
line = i ;
167
143
column = match . index ;
168
144
endColumn = column + match [ 0 ] . length ;
169
- console . log (
170
- `[JSON_CONFIG] Found property "${ propertyName } " at line ${ line } , col ${ column } , match: "${ match [ 0 ] } "` ,
171
- ) ;
172
145
break ;
173
146
}
174
147
}
@@ -179,9 +152,6 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
179
152
) {
180
153
// Handle additionalProperties error - extract the invalid property name
181
154
propertyName = error . params . additionalProperty ;
182
- console . log (
183
- `[JSON_CONFIG] Found additionalProperties error for property: "${ propertyName } "` ,
184
- ) ;
185
155
186
156
// Find the line containing the invalid property
187
157
for ( let i = 0 ; i < lines . length ; i ++ ) {
@@ -192,9 +162,6 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
192
162
line = i ;
193
163
column = match . index ;
194
164
endColumn = column + match [ 0 ] . length ;
195
- console . log (
196
- `[JSON_CONFIG] Found invalid property "${ propertyName } " at line ${ line } , col ${ column } , match: "${ match [ 0 ] } "` ,
197
- ) ;
198
165
break ;
199
166
}
200
167
}
@@ -218,23 +185,9 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
218
185
message,
219
186
source : "rescript-json-config-schema" ,
220
187
} ;
221
- console . log (
222
- `[JSON_CONFIG] Created diagnostic for property "${ propertyName } ":` ,
223
- diagnostic ,
224
- ) ;
225
- console . log (
226
- `[JSON_CONFIG] Diagnostic details - Line: ${ line } , Column: ${ column } , EndColumn: ${ endColumn } , Message: ${ message } ` ,
227
- ) ;
228
188
return diagnostic ;
229
189
} ) ;
230
190
231
- console . log (
232
- `[JSON_CONFIG] Total diagnostics created: ${ diagnostics . length } ` ,
233
- ) ;
234
- if ( diagnostics . length > 0 ) {
235
- console . log ( `[JSON_CONFIG] First diagnostic:` , diagnostics [ 0 ] ) ;
236
- }
237
-
238
191
return diagnostics ;
239
192
} catch ( error ) {
240
193
// Handle JSON parsing errors
@@ -293,9 +246,6 @@ export function getConfigCompletions(document: TextDocument): CompletionItem[] {
293
246
try {
294
247
fsPath = fileURLToPath ( filePath ) ;
295
248
} catch ( error ) {
296
- console . log (
297
- `[JSON_CONFIG] Failed to convert file URI to path for completions: ${ error } ` ,
298
- ) ;
299
249
return [ ] ;
300
250
}
301
251
const projectRoot = findProjectRootOfFile ( fsPath ) ;
@@ -340,9 +290,6 @@ export function getConfigHover(
340
290
try {
341
291
fsPath = fileURLToPath ( filePath ) ;
342
292
} catch ( error ) {
343
- console . log (
344
- `[JSON_CONFIG] Failed to convert file URI to path for hover: ${ error } ` ,
345
- ) ;
346
293
return null ;
347
294
}
348
295
const projectRoot = findProjectRootOfFile ( fsPath ) ;
0 commit comments