Skip to content

Commit c36e79f

Browse files
committed
cleanup
1 parent da2cbd8 commit c36e79f

File tree

1 file changed

+1
-63
lines changed

1 file changed

+1
-63
lines changed

Diff for: server/src/codeActions.ts

+1-63
Original file line numberDiff line numberDiff line change
@@ -449,52 +449,8 @@ let applyUncurried: codeActionExtractor = ({
449449
return false;
450450
};
451451

452-
// Untransformed is typically OCaml, and looks like these examples:
453-
//
454-
// `SomeVariantName
455-
//
456-
// SomeVariantWithPayload _
457-
//
458-
// ...and we'll need to transform this into proper ReScript. In the future, the
459-
// compiler itself should of course output real ReScript. But it currently does
460-
// not.
461-
//
462-
// Note that we're trying to not be too clever here, so we'll only try to
463-
// convert the very simplest cases - single variant/polyvariant, with single
464-
// payloads. No records, tuples etc yet. We can add those when the compiler
465-
// outputs them in proper ReScript.
466-
let transformMatchPattern = (matchPattern: string): string | null => {
467-
let text = matchPattern.replace(/`/g, "#");
468-
469-
let payloadRegexp = / /g;
470-
let matched = text.match(payloadRegexp);
471-
472-
// Constructors are preceded by a single space. Bail if there's more than 1.
473-
if (matched != null && matched.length > 2) {
474-
return null;
475-
}
476-
477-
// Fix payloads if they can be fixed. If not, bail.
478-
if (text.includes(" ")) {
479-
let [variantText, payloadText] = text.split(" ");
480-
481-
let transformedPayloadText = transformMatchPattern(payloadText);
482-
if (transformedPayloadText == null) {
483-
return null;
484-
}
485-
486-
text = `${variantText}(${payloadText})`;
487-
}
488-
489-
return text;
490-
};
491-
492452
// This action detects missing cases for exhaustive pattern matches, and offers
493-
// to insert dummy branches (using `assert false`) for those branches. Right now
494-
// it works on single variants/polyvariants with and without payloads. In the
495-
// future it could be made to work on anything the compiler tell us about, but
496-
// the compiler needs to emit proper ReScript in the error messages for that to
497-
// work.
453+
// to insert dummy branches (using `failwith("TODO")`) for those branches.
498454
let simpleAddMissingCases: codeActionExtractor = ({
499455
line,
500456
codeActions,
@@ -504,24 +460,6 @@ let simpleAddMissingCases: codeActionExtractor = ({
504460
array,
505461
index,
506462
}) => {
507-
// Examples:
508-
//
509-
// You forgot to handle a possible case here, for example:
510-
// (AnotherValue|Third|Fourth)
511-
//
512-
// You forgot to handle a possible case here, for example:
513-
// (`AnotherValue|`Third|`Fourth)
514-
//
515-
// You forgot to handle a possible case here, for example:
516-
// `AnotherValue
517-
//
518-
// You forgot to handle a possible case here, for example:
519-
// AnotherValue
520-
//
521-
// You forgot to handle a possible case here, for example:
522-
// (`One _|`Two _|
523-
// `Three _)
524-
525463
if (
526464
line.startsWith("You forgot to handle a possible case here, for example:")
527465
) {

0 commit comments

Comments
 (0)