Skip to content

Commit

Permalink
[ change ] Deprecate Belt & Js modules from all modules
Browse files Browse the repository at this point in the history
  • Loading branch information
banacorn committed Nov 20, 2024
1 parent 054cbcc commit 10df67f
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 75 deletions.
12 changes: 4 additions & 8 deletions lib/js/src/Agda.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions lib/js/src/InputMethod/Buffer.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions lib/js/test/tests/Parser/Test__Parser__Emacs2.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions lib/js/test/tests/Parser/Test__Parser__SExpression.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions lib/js/test/tests/Parser/Test__Parser__SourceFile.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions lib/js/test/tests/Test__Util.bs.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions src/Agda.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module Expr = {
type t = array<Term.t>
let parse = raw =>
raw
->Js.String.trim
->String.trim
/* 1 2 */
->(Js.String.splitByRe(%re("/(\?\d+)|(\_\d+[^\}\)\s]*)/"), _))
->String.splitByRegExp(%re("/(\?\d+)|(\_\d+[^\}\)\s]*)/"))
->// RegEx updated to v10.1.4
Array.mapWithIndex((token, i) =>
switch mod(i, 3) {
Expand Down Expand Up @@ -119,7 +119,7 @@ module Output = {
, ...))
let parse = raw => {
let locRe = %re("/\[ at (\S+\:(?:\d+\,\d+\-\d+\,\d+|\d+\,\d+\-\d+|\d+\,\d+)) \]$/")
let hasLocation = Js.Re.test_(locRe, raw)
let hasLocation = RegExp.test(locRe, raw)
if hasLocation {
parseOutputWithLocation(raw)
} else {
Expand Down Expand Up @@ -193,8 +193,7 @@ module Indices: Indices = {
})

// 6003
let lastInterval =
intervals[Array.length(intervals) - 1]->Option.mapOr(0, ((_, x)) => x + 1)
let lastInterval = intervals[Array.length(intervals) - 1]->Option.mapOr(0, ((_, x)) => x + 1)

{
intervals,
Expand Down Expand Up @@ -271,16 +270,16 @@ module OffsetConverter: OffsetConverter = {
// iterate through the text to find surrogate pairs
let i = ref(0)
while i.contents < lengthInCodeUnits {
let charCode = Js.String.charCodeAt(i.contents, text)->int_of_float
let charCode = text->String.charCodeAt(i.contents)->int_of_float
let notFinal = i.contents + 1 < lengthInCodeUnits

// check if this is a part of a surrogate pair
if charCode >= 0xD800 && (charCode <= 0xDBFF && notFinal) {
// found the high surrogate, proceed to check the low surrogate
let nextCharCode = Js.String.charCodeAt(i.contents + 1, text)->int_of_float
let nextCharCode = text->String.charCodeAt(i.contents + 1)->int_of_float
if nextCharCode >= 0xDC00 && charCode <= 0xDFFF {
// store the index of this surrogate pair
Js.Array.push(i.contents, surrogatePairs)->ignore
surrogatePairs->Array.push(i.contents)
}
// increment by 2 because we have checked the presumably low surrogate char
i := i.contents + 2
Expand Down
8 changes: 4 additions & 4 deletions src/InputMethod/Buffer.res
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ let update = (self, start, change: change): (t, option<string>) => {
}
let insertEnd = insertStart + change.replacedTextLength

let beforeInsertedText = Js.String.substring(~from=0, ~to_=insertStart, sequence)
let afterInsertedText = Js.String.substringToEnd(~from=insertEnd, sequence)
let beforeInsertedText = String.substring(~start=0, ~end=insertStart, sequence)
let afterInsertedText = String.substringToEnd(~start=insertEnd, sequence)
beforeInsertedText ++ (change.insertedText ++ afterInsertedText)
}

let translation = Translator.translate(newSequence, Some({lastTranslation: self.translation, candidateIndex: self.candidateIndex}))
switch translation.symbol {
| None =>
if translation.further {
if Js.String.includes(sequence, newSequence) {
if newSequence->String.includes(sequence) {
// special case of INSERTION
// reduce unnecessary rewriting
let diff = Js.String.substringToEnd(~from=String.length(sequence), newSequence)
let diff = String.substringToEnd(~start=String.length(sequence), newSequence)
let buffer = {...self, tail: self.tail ++ diff, translation: translation}
(buffer, None)
} else {
Expand Down
Loading

0 comments on commit 10df67f

Please sign in to comment.