Skip to content

Commit 44193d3

Browse files
committed
Remove Symbol functions from String module
1 parent 562b0dc commit 44193d3

File tree

4 files changed

+46
-107
lines changed

4 files changed

+46
-107
lines changed

runtime/Stdlib_String.res

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ external splitByRegExpAtMost: (string, Stdlib_RegExp.t, ~limit: int) => array<op
164164
@send external padStart: (string, int, string) => string = "padStart"
165165
@send external padEnd: (string, int, string) => string = "padEnd"
166166

167-
@get_index external getSymbol: (string, Stdlib_Symbol.t) => option<'a> = ""
168-
@get_index external getSymbolUnsafe: (string, Stdlib_Symbol.t) => 'a = ""
169-
@set_index external setSymbol: (string, Stdlib_Symbol.t, 'a) => unit = ""
170-
171167
@send external localeCompare: (string, string) => float = "localeCompare"
172168

173169
external ignore: string => unit = "%ignore"

runtime/Stdlib_String.resi

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,51 +1112,6 @@ String.padEnd("abc", 1, "") == "abc"
11121112
@send
11131113
external padEnd: (string, int, string) => string = "padEnd"
11141114

1115-
/**
1116-
`getSymbol(str, symbol)` returns the value associated with the given symbol on the string as an `option<'a>`.
1117-
Returns `None` if the symbol property doesn't exist.
1118-
1119-
## Examples
1120-
1121-
```rescript
1122-
let mySymbol = Symbol.make("test")
1123-
let h = String.make("hello")
1124-
String.setSymbol(h, mySymbol, 42)
1125-
String.getSymbol(h, mySymbol) == Some(42)
1126-
```
1127-
*/
1128-
@get_index external getSymbol: (string, Stdlib_Symbol.t) => option<'a> = ""
1129-
1130-
/**
1131-
`getSymbolUnsafe(str, symbol)` returns the value associated with the given symbol on the string.
1132-
1133-
This is _unsafe_, meaning it will return `undefined` if the symbol property doesn't exist.
1134-
1135-
## Examples
1136-
1137-
```rescript
1138-
let mySymbol = Symbol.make("test")
1139-
let h = String.make("hello")
1140-
String.setSymbol(h, mySymbol, 43)
1141-
String.getSymbolUnsafe(h, mySymbol) == 43
1142-
```
1143-
*/
1144-
@get_index external getSymbolUnsafe: (string, Stdlib_Symbol.t) => 'a = ""
1145-
1146-
/**
1147-
`setSymbol(str, symbol, value)` sets the given symbol property on the string to the specified value.
1148-
1149-
## Examples
1150-
1151-
```rescript
1152-
let mySymbol = Symbol.make("test")
1153-
let h = String.make("hello")
1154-
String.setSymbol(h, mySymbol, 42)
1155-
String.getSymbol(h, mySymbol) == Some(42)
1156-
```
1157-
*/
1158-
@set_index external setSymbol: (string, Stdlib_Symbol.t, 'a) => unit = ""
1159-
11601115
/**
11611116
`localeCompare(referenceStr, compareStr)` returns a float than indicatings
11621117
whether a reference string comes before or after, or is the same as the given

tests/analysis_tests/tests/src/expected/CompletionJsx.res.txt

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,30 @@ Path s
785785
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
786786
"newText": ""
787787
}]
788+
}, {
789+
"label": "->String.startsWith",
790+
"kind": 12,
791+
"tags": [],
792+
"detail": "(string, string) => bool",
793+
"documentation": {"kind": "markdown", "value": "\n`startsWith(str, substr)` returns `true` if the `str` starts with `substr`,\n`false` otherwise.\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) on MDN.\n\n## Examples\n\n```rescript\nString.startsWith(\"BuckleScript\", \"Buckle\") == true\nString.startsWith(\"BuckleScript\", \"\") == true\nString.startsWith(\"JavaScript\", \"Buckle\") == false\n```\n"},
794+
"sortText": "startsWith",
795+
"insertText": "->String.startsWith",
796+
"additionalTextEdits": [{
797+
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
798+
"newText": ""
799+
}]
800+
}, {
801+
"label": "->String.splitAtMost",
802+
"kind": 12,
803+
"tags": [],
804+
"detail": "(string, string, ~limit: int) => array<string>",
805+
"documentation": {"kind": "markdown", "value": "\n`splitAtMost(str, delimiter, ~limit)` splits the given `str` at every\noccurrence of `delimiter` and returns an array of the first `limit` resulting\nsubstrings. If `limit` is negative or greater than the number of substrings,\nthe array will contain all the substrings.\n\n## Examples\n\n```rescript\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=3) == [\"ant\", \"bee\", \"cat\"]\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=0) == []\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=9) == [\"ant\", \"bee\", \"cat\", \"dog\", \"elk\"]\n```\n"},
806+
"sortText": "splitAtMost",
807+
"insertText": "->String.splitAtMost",
808+
"additionalTextEdits": [{
809+
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
810+
"newText": ""
811+
}]
788812
}, {
789813
"label": "->String.searchOpt",
790814
"kind": 12,
@@ -821,42 +845,6 @@ Path s
821845
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
822846
"newText": ""
823847
}]
824-
}, {
825-
"label": "->String.substringToEnd",
826-
"kind": 12,
827-
"tags": [],
828-
"detail": "(string, ~start: int) => string",
829-
"documentation": {"kind": "markdown", "value": "\n`substringToEnd(str, ~start)` returns the substring of `str` from position\n`start` to the end.\n- If `start` is less than or equal to zero, the entire string is returned.\n- If `start` is greater than or equal to the length of `str`, the empty string\nis returned.\nSee [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substringToEnd(\"playground\", ~start=4) == \"ground\"\nString.substringToEnd(\"playground\", ~start=-3) == \"playground\"\nString.substringToEnd(\"playground\", ~start=12) == \"\"\n```\n"},
830-
"sortText": "substringToEnd",
831-
"insertText": "->String.substringToEnd",
832-
"additionalTextEdits": [{
833-
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
834-
"newText": ""
835-
}]
836-
}, {
837-
"label": "->String.startsWith",
838-
"kind": 12,
839-
"tags": [],
840-
"detail": "(string, string) => bool",
841-
"documentation": {"kind": "markdown", "value": "\n`startsWith(str, substr)` returns `true` if the `str` starts with `substr`,\n`false` otherwise.\nSee [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) on MDN.\n\n## Examples\n\n```rescript\nString.startsWith(\"BuckleScript\", \"Buckle\") == true\nString.startsWith(\"BuckleScript\", \"\") == true\nString.startsWith(\"JavaScript\", \"Buckle\") == false\n```\n"},
842-
"sortText": "startsWith",
843-
"insertText": "->String.startsWith",
844-
"additionalTextEdits": [{
845-
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
846-
"newText": ""
847-
}]
848-
}, {
849-
"label": "->String.splitAtMost",
850-
"kind": 12,
851-
"tags": [],
852-
"detail": "(string, string, ~limit: int) => array<string>",
853-
"documentation": {"kind": "markdown", "value": "\n`splitAtMost(str, delimiter, ~limit)` splits the given `str` at every\noccurrence of `delimiter` and returns an array of the first `limit` resulting\nsubstrings. If `limit` is negative or greater than the number of substrings,\nthe array will contain all the substrings.\n\n## Examples\n\n```rescript\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=3) == [\"ant\", \"bee\", \"cat\"]\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=0) == []\nString.splitAtMost(\"ant/bee/cat/dog/elk\", \"/\", ~limit=9) == [\"ant\", \"bee\", \"cat\", \"dog\", \"elk\"]\n```\n"},
854-
"sortText": "splitAtMost",
855-
"insertText": "->String.splitAtMost",
856-
"additionalTextEdits": [{
857-
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
858-
"newText": ""
859-
}]
860848
}, {
861849
"label": "->String.sliceToEnd",
862850
"kind": 12,
@@ -869,18 +857,6 @@ Path s
869857
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
870858
"newText": ""
871859
}]
872-
}, {
873-
"label": "->String.setSymbol",
874-
"kind": 12,
875-
"tags": [],
876-
"detail": "(string, Symbol.t, 'a) => unit",
877-
"documentation": {"kind": "markdown", "value": "\n`setSymbol(str, symbol, value)` sets the given symbol property on the string to the specified value.\n\n## Examples\n\n```rescript\nlet mySymbol = Symbol.make(\"test\")\nlet h = String.make(\"hello\")\nString.setSymbol(h, mySymbol, 42)\nString.getSymbol(h, mySymbol) == Some(42)\n```\n"},
878-
"sortText": "setSymbol",
879-
"insertText": "->String.setSymbol",
880-
"additionalTextEdits": [{
881-
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
882-
"newText": ""
883-
}]
884860
}, {
885861
"label": "->String.splitByRegExp",
886862
"kind": 12,
@@ -941,5 +917,17 @@ Path s
941917
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
942918
"newText": ""
943919
}]
920+
}, {
921+
"label": "->String.substringToEnd",
922+
"kind": 12,
923+
"tags": [],
924+
"detail": "(string, ~start: int) => string",
925+
"documentation": {"kind": "markdown", "value": "\n`substringToEnd(str, ~start)` returns the substring of `str` from position\n`start` to the end.\n- If `start` is less than or equal to zero, the entire string is returned.\n- If `start` is greater than or equal to the length of `str`, the empty string\nis returned.\nSee [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN.\n\n## Examples\n\n```rescript\nString.substringToEnd(\"playground\", ~start=4) == \"ground\"\nString.substringToEnd(\"playground\", ~start=-3) == \"playground\"\nString.substringToEnd(\"playground\", ~start=12) == \"\"\n```\n"},
926+
"sortText": "substringToEnd",
927+
"insertText": "->String.substringToEnd",
928+
"additionalTextEdits": [{
929+
"range": {"start": {"line": 93, "character": 17}, "end": {"line": 93, "character": 18}},
930+
"newText": ""
931+
}]
944932
}]
945933

tests/analysis_tests/tests/src/expected/DotPipeCompletionSpec.res.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -418,25 +418,25 @@ Path Array.joinWith
418418
Path Stdlib.String.includ
419419
Path includ
420420
[{
421-
"label": "->String.includes",
421+
"label": "->String.includesFrom",
422422
"kind": 12,
423423
"tags": [],
424-
"detail": "(string, string) => bool",
425-
"documentation": {"kind": "markdown", "value": "\n`includes(str, searchValue)` returns `true` if `searchValue` is found anywhere\nwithin `str`, `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includes(\"programmer\", \"gram\") == true\nString.includes(\"programmer\", \"er\") == true\nString.includes(\"programmer\", \"pro\") == true\nString.includes(\"programmer.dat\", \"xyz\") == false\n```\n"},
426-
"sortText": "includes",
427-
"insertText": "->String.includes",
424+
"detail": "(string, string, int) => bool",
425+
"documentation": {"kind": "markdown", "value": "\n`includesFrom(str, searchValue, start)` returns `true` if `searchValue` is found\nanywhere within `str` starting at character number `start` (where 0 is the\nfirst character), `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includesFrom(\"programmer\", \"gram\", 1) == true\nString.includesFrom(\"programmer\", \"gram\", 4) == false\nString.includesFrom(`대한민국`, `한`, 1) == true\n```\n"},
426+
"sortText": "includesFrom",
427+
"insertText": "->String.includesFrom",
428428
"additionalTextEdits": [{
429429
"range": {"start": {"line": 89, "character": 55}, "end": {"line": 89, "character": 56}},
430430
"newText": ""
431431
}]
432432
}, {
433-
"label": "->String.includesFrom",
433+
"label": "->String.includes",
434434
"kind": 12,
435435
"tags": [],
436-
"detail": "(string, string, int) => bool",
437-
"documentation": {"kind": "markdown", "value": "\n`includesFrom(str, searchValue, start)` returns `true` if `searchValue` is found\nanywhere within `str` starting at character number `start` (where 0 is the\nfirst character), `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includesFrom(\"programmer\", \"gram\", 1) == true\nString.includesFrom(\"programmer\", \"gram\", 4) == false\nString.includesFrom(`대한민국`, `한`, 1) == true\n```\n"},
438-
"sortText": "includesFrom",
439-
"insertText": "->String.includesFrom",
436+
"detail": "(string, string) => bool",
437+
"documentation": {"kind": "markdown", "value": "\n`includes(str, searchValue)` returns `true` if `searchValue` is found anywhere\nwithin `str`, `false` otherwise.\nSee [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) on MDN.\n\n## Examples\n\n```rescript\nString.includes(\"programmer\", \"gram\") == true\nString.includes(\"programmer\", \"er\") == true\nString.includes(\"programmer\", \"pro\") == true\nString.includes(\"programmer.dat\", \"xyz\") == false\n```\n"},
438+
"sortText": "includes",
439+
"insertText": "->String.includes",
440440
"additionalTextEdits": [{
441441
"range": {"start": {"line": 89, "character": 55}, "end": {"line": 89, "character": 56}},
442442
"newText": ""

0 commit comments

Comments
 (0)