@@ -85,48 +85,71 @@ Options:
8585|}
8686
8787let main () =
88- match Array. to_list Sys. argv with
88+ let args = Array. to_list Sys. argv in
89+ let debugLevel, args =
90+ match args with
91+ | _ :: "debug-dump" :: logLevel :: rest ->
92+ ( (match logLevel with
93+ | "verbose" -> Debug. Verbose
94+ | "regular" -> Regular
95+ | _ -> Off ),
96+ " dummy" :: rest )
97+ | args -> (Off , args)
98+ in
99+ Debug. debugLevel := debugLevel;
100+ let debug = debugLevel <> Debug. Off in
101+ let printHeaderInfo path line col =
102+ if debug then
103+ Printf. printf " Debug level: %s\n %s:%s-%s\n\n "
104+ (match debugLevel with
105+ | Debug. Verbose -> " verbose"
106+ | Regular -> " regular"
107+ | Off -> " off" )
108+ path line col
109+ in
110+ match args with
89111 | [_; " completion" ; path; line; col; currentFile; supportsSnippets] ->
112+ printHeaderInfo path line col;
90113 (Cfg. supportsSnippets :=
91114 match supportsSnippets with
92115 | "true" -> true
93116 | _ -> false );
94- Commands. completion ~debug: false ~path
117+ Commands. completion ~debug ~path
95118 ~pos: (int_of_string line, int_of_string col)
96119 ~current File
97120 | [_; " definition" ; path; line; col] ->
98121 Commands. definition ~path
99122 ~pos: (int_of_string line, int_of_string col)
100- ~debug: false
123+ ~debug
101124 | [_; " typeDefinition" ; path; line; col] ->
102125 Commands. typeDefinition ~path
103126 ~pos: (int_of_string line, int_of_string col)
104- ~debug: false
127+ ~debug
105128 | [_; " documentSymbol" ; path] -> DocumentSymbol. command ~path
106129 | [_; " hover" ; path; line; col; currentFile; supportsMarkdownLinks] ->
107130 Commands. hover ~path
108131 ~pos: (int_of_string line, int_of_string col)
109- ~current File ~debug: false
132+ ~current File ~debug
110133 ~supports MarkdownLinks:
111134 (match supportsMarkdownLinks with
112135 | "true" -> true
113136 | _ -> false )
114137 | [_; " signatureHelp" ; path; line; col; currentFile] ->
115138 Commands. signatureHelp ~path
116139 ~pos: (int_of_string line, int_of_string col)
117- ~current File ~debug: false
140+ ~current File ~debug
118141 | [_; " inlayHint" ; path; line_start; line_end; maxLength] ->
119142 Commands. inlayhint ~path
120143 ~pos: (int_of_string line_start, int_of_string line_end)
121- ~max Length ~debug: false
122- | [_; " codeLens" ; path] -> Commands. codeLens ~path ~debug: false
123- | [_; " extractDocs" ; path] -> DocExtraction. extractDocs ~path ~debug: false
144+ ~max Length ~debug
145+ | [_; " codeLens" ; path] -> Commands. codeLens ~path ~debug
146+ | [_; " extractDocs" ; path] -> DocExtraction. extractDocs ~path ~debug
124147 | [_; " codeAction" ; path; startLine; startCol; endLine; endCol; currentFile]
125148 ->
126149 Commands. codeAction ~path
127150 ~start Pos:(int_of_string startLine, int_of_string startCol)
128151 ~end Pos:(int_of_string endLine, int_of_string endCol)
129- ~current File ~debug: false
152+ ~current File ~debug
130153 | [_; " codemod" ; path; line; col; typ; hint] ->
131154 let typ =
132155 match typ with
@@ -136,7 +159,7 @@ let main () =
136159 let res =
137160 Codemod. transform ~path
138161 ~pos: (int_of_string line, int_of_string col)
139- ~debug: false ~typ ~hint
162+ ~debug ~typ ~hint
140163 |> Json. escape
141164 in
142165 Printf. printf " \" %s\" " res
@@ -151,11 +174,11 @@ let main () =
151174 | [_; " references" ; path; line; col] ->
152175 Commands. references ~path
153176 ~pos: (int_of_string line, int_of_string col)
154- ~debug: false
177+ ~debug
155178 | [_; " rename" ; path; line; col; newName] ->
156179 Commands. rename ~path
157180 ~pos: (int_of_string line, int_of_string col)
158- ~new Name ~debug: false
181+ ~new Name ~debug
159182 | [_; " semanticTokens" ; currentFile] ->
160183 SemanticTokens. semanticTokens ~current File
161184 | [_; " createInterface" ; path; cmiFile] ->
0 commit comments