@@ -29,11 +29,8 @@ interface SchemaInfo {
2929const schemaCache = new Map < string , SchemaInfo > ( ) ;
3030
3131function loadReScriptSchema ( projectRoot : string ) : SchemaInfo | null {
32- console . log ( `[JSON_CONFIG] Loading schema for project: ${ projectRoot } ` ) ;
33-
3432 // Check cache first
3533 if ( schemaCache . has ( projectRoot ) ) {
36- console . log ( `[JSON_CONFIG] Schema found in cache` ) ;
3734 return schemaCache . get ( projectRoot ) ! ;
3835 }
3936
@@ -46,18 +43,12 @@ function loadReScriptSchema(projectRoot: string): SchemaInfo | null {
4643 "build-schema.json" ,
4744 ) ;
4845
49- console . log ( `[JSON_CONFIG] Looking for schema at: ${ schemaPath } ` ) ;
50-
5146 if ( ! fs . existsSync ( schemaPath ) ) {
52- console . log ( `[JSON_CONFIG] Schema file does not exist` ) ;
5347 return null ;
5448 }
5549
5650 try {
5751 const schemaContent = fs . readFileSync ( schemaPath , "utf8" ) ;
58- console . log (
59- `[JSON_CONFIG] Schema content preview: ${ schemaContent . substring ( 0 , 500 ) } ...` ,
60- ) ;
6152 const schema = JSON . parse ( schemaContent ) ;
6253
6354 const schemaInfo : SchemaInfo = {
@@ -81,43 +72,30 @@ export function isConfigFile(filePath: string): boolean {
8172
8273export function validateConfig ( document : TextDocument ) : Diagnostic [ ] {
8374 const filePath = document . uri ;
84- console . log ( `[JSON_CONFIG] Validating config: ${ filePath } ` ) ;
8575
8676 // Convert file URI to filesystem path for project root detection
8777 let fsPath : string ;
8878 try {
8979 fsPath = fileURLToPath ( filePath ) ;
90- console . log ( `[JSON_CONFIG] Converted to filesystem path: ${ fsPath } ` ) ;
9180 } 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 } ` ) ;
9382 return [ ] ;
9483 }
9584
9685 const projectRoot = findProjectRootOfFile ( fsPath ) ;
97- console . log ( `[JSON_CONFIG] Found project root: ${ projectRoot } ` ) ;
9886
9987 if ( ! projectRoot ) {
100- console . log (
101- `[JSON_CONFIG] No project root found, returning empty diagnostics` ,
102- ) ;
10388 return [ ] ;
10489 }
10590
10691 const schemaInfo = loadReScriptSchema ( projectRoot ) ;
107- console . log (
108- `[JSON_CONFIG] Schema info: ${ schemaInfo ? "found" : "not found" } ` ,
109- ) ;
11092
11193 if ( ! schemaInfo ) {
112- console . log ( `[JSON_CONFIG] No schema found, returning empty diagnostics` ) ;
11394 return [ ] ;
11495 }
11596
11697 try {
11798 const jsonContent = document . getText ( ) ;
118- console . log (
119- `[JSON_CONFIG] JSON content: ${ jsonContent . substring ( 0 , 200 ) } ...` ,
120- ) ;
12199 const config = JSON . parse ( jsonContent ) ;
122100
123101 let validate ;
@@ -129,17 +107,15 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
129107 }
130108
131109 const valid = validate ( config ) ;
132- console . log ( `[JSON_CONFIG] Validation result: ${ valid } ` ) ;
133110
134111 if ( ! valid && validate . errors ) {
135- console . log (
112+ console . error (
136113 `[JSON_CONFIG] Validation errors:` ,
137114 JSON . stringify ( validate . errors , null , 2 ) ,
138115 ) ;
139116 }
140117
141118 if ( valid ) {
142- console . log ( `[JSON_CONFIG] Valid JSON, returning empty diagnostics` ) ;
143119 return [ ] ;
144120 }
145121
@@ -166,9 +142,6 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
166142 line = i ;
167143 column = match . index ;
168144 endColumn = column + match [ 0 ] . length ;
169- console . log (
170- `[JSON_CONFIG] Found property "${ propertyName } " at line ${ line } , col ${ column } , match: "${ match [ 0 ] } "` ,
171- ) ;
172145 break ;
173146 }
174147 }
@@ -179,9 +152,6 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
179152 ) {
180153 // Handle additionalProperties error - extract the invalid property name
181154 propertyName = error . params . additionalProperty ;
182- console . log (
183- `[JSON_CONFIG] Found additionalProperties error for property: "${ propertyName } "` ,
184- ) ;
185155
186156 // Find the line containing the invalid property
187157 for ( let i = 0 ; i < lines . length ; i ++ ) {
@@ -192,9 +162,6 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
192162 line = i ;
193163 column = match . index ;
194164 endColumn = column + match [ 0 ] . length ;
195- console . log (
196- `[JSON_CONFIG] Found invalid property "${ propertyName } " at line ${ line } , col ${ column } , match: "${ match [ 0 ] } "` ,
197- ) ;
198165 break ;
199166 }
200167 }
@@ -218,23 +185,9 @@ export function validateConfig(document: TextDocument): Diagnostic[] {
218185 message,
219186 source : "rescript-json-config-schema" ,
220187 } ;
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- ) ;
228188 return diagnostic ;
229189 } ) ;
230190
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-
238191 return diagnostics ;
239192 } catch ( error ) {
240193 // Handle JSON parsing errors
@@ -293,9 +246,6 @@ export function getConfigCompletions(document: TextDocument): CompletionItem[] {
293246 try {
294247 fsPath = fileURLToPath ( filePath ) ;
295248 } catch ( error ) {
296- console . log (
297- `[JSON_CONFIG] Failed to convert file URI to path for completions: ${ error } ` ,
298- ) ;
299249 return [ ] ;
300250 }
301251 const projectRoot = findProjectRootOfFile ( fsPath ) ;
@@ -340,9 +290,6 @@ export function getConfigHover(
340290 try {
341291 fsPath = fileURLToPath ( filePath ) ;
342292 } catch ( error ) {
343- console . log (
344- `[JSON_CONFIG] Failed to convert file URI to path for hover: ${ error } ` ,
345- ) ;
346293 return null ;
347294 }
348295 const projectRoot = findProjectRootOfFile ( fsPath ) ;
0 commit comments