22// actions available in the extension, but they are derived via the analysis
33// OCaml binary.
44import * as p from "vscode-languageserver-protocol" ;
5- import { TextDocument } from "vscode-languageserver-textdocument" ;
65import * as utils from "./utils" ;
76import { fileURLToPath } from "url" ;
87
@@ -17,7 +16,6 @@ interface findCodeActionsConfig {
1716 diagnosticMessage : string [ ] ;
1817 file : string ;
1918 range : p . Range ;
20- fileContentCache : Map < string , string > ;
2119 addFoundActionsHere : filesCodeActions ;
2220}
2321
@@ -148,7 +146,6 @@ export let findCodeActionsInDiagnosticsMessage = ({
148146 diagnosticMessage,
149147 file,
150148 range,
151- fileContentCache,
152149 addFoundActionsHere : codeActions ,
153150} : findCodeActionsConfig ) => {
154151 diagnosticMessage . forEach ( ( line , index , array ) => {
@@ -177,7 +174,6 @@ export let findCodeActionsInDiagnosticsMessage = ({
177174 index,
178175 line,
179176 range,
180- fileContentCache,
181177 } ) ;
182178 } catch ( e ) {
183179 console . error ( e ) ;
@@ -198,7 +194,6 @@ interface codeActionExtractorConfig {
198194 range : p . Range ;
199195 diagnostic : p . Diagnostic ;
200196 codeActions : filesCodeActions ;
201- fileContentCache : Map < string , string > ;
202197}
203198
204199type codeActionExtractor = ( config : codeActionExtractorConfig ) => boolean ;
@@ -324,14 +319,12 @@ let handleUndefinedRecordFieldsAction = ({
324319 file,
325320 range,
326321 diagnostic,
327- fileContentCache
328322} : {
329323 recordFieldNames : string [ ] ;
330324 codeActions : filesCodeActions ;
331325 file : string ;
332326 range : p . Range ;
333327 diagnostic : p . Diagnostic ;
334- fileContentCache : Map < string , string > ;
335328} ) => {
336329 if ( recordFieldNames != null ) {
337330 codeActions [ file ] = codeActions [ file ] || [ ] ;
@@ -386,19 +379,8 @@ let handleUndefinedRecordFieldsAction = ({
386379 // Let's put the end brace back where it was (we still have it to the direct right of us).
387380 newText += `${ paddingContentEndBrace } ` ;
388381 } else {
389- let insertLeadingComma = true
390- const fileContent = fileContentCache . get ( file . replace ( "file://" , "" ) )
391- if ( fileContent ) {
392- const textDocument = TextDocument . create ( file , "text" , 0 , fileContent )
393- if ( textDocument . getText ( range ) == "{}" ) {
394- insertLeadingComma = false
395- }
396- }
397-
398382 // A single line record definition body is a bit easier - we'll just add the new fields on the same line.
399- if ( insertLeadingComma ) {
400- newText += ", " ;
401- }
383+ newText += ", " ;
402384 newText += recordFieldNames
403385 . map ( ( fieldName ) => `${ fieldName } : failwith("TODO")` )
404386 . join ( ", " ) ;
@@ -439,7 +421,6 @@ let addUndefinedRecordFieldsV10: codeActionExtractor = ({
439421 index,
440422 line,
441423 range,
442- fileContentCache,
443424} ) => {
444425 if ( line . startsWith ( "Some record fields are undefined:" ) ) {
445426 let recordFieldNames = line
@@ -459,7 +440,6 @@ let addUndefinedRecordFieldsV10: codeActionExtractor = ({
459440 diagnostic,
460441 file,
461442 range,
462- fileContentCache,
463443 } ) ;
464444 }
465445
@@ -474,7 +454,6 @@ let addUndefinedRecordFieldsV11: codeActionExtractor = ({
474454 index,
475455 line,
476456 range,
477- fileContentCache
478457} ) => {
479458 if ( line . startsWith ( "Some required record fields are missing:" ) ) {
480459 let theLine = line ;
@@ -507,7 +486,6 @@ let addUndefinedRecordFieldsV11: codeActionExtractor = ({
507486 diagnostic,
508487 file,
509488 range,
510- fileContentCache,
511489 } ) ;
512490 }
513491
0 commit comments