diff --git a/editor-extensions/vscode/package.json b/editor-extensions/vscode/package.json index e955571a..909cab83 100644 --- a/editor-extensions/vscode/package.json +++ b/editor-extensions/vscode/package.json @@ -29,10 +29,6 @@ "command": "reason-language-server.restart", "title": "Restart Reason Language Server" }, - { - "command": "reason-language-server.show_ppxed_source", - "title": "Reason: Show the fully ppxed source for this file." - }, { "command": "reason-language-server.show_ast", "title": "Reason: Show the abstract syntax tree (AST) for this file." diff --git a/editor-extensions/vscode/src/index.js b/editor-extensions/vscode/src/index.js index cb8a2338..3a4a6dd0 100644 --- a/editor-extensions/vscode/src/index.js +++ b/editor-extensions/vscode/src/index.js @@ -221,60 +221,19 @@ function activate(context) { } } - class PpxedSourceProvider { - constructor() { - this.privateOnDidChange = new vscode.EventEmitter() - this.onDidChange = this.privateOnDidChange.event; - } - provideTextDocumentContent(uri, token) { - if (!client) { - return Promise.reject("No language client running") - } - - return client.sendRequest("custom:reasonLanguageServer/showPpxedSource", { - "textDocument": { - "uri": uri.with({scheme: 'file'}).toString(), - }, - // unused currently - "position": {character: 0, line: 0}, - }) - } - } - - const provider = new PpxedSourceProvider() const astProvider = new AstSourceProvider() context.subscriptions.push( vscode.workspace.onDidSaveTextDocument((document) => { const uri = document.uri; - provider.privateOnDidChange.fire(uri.with({scheme: 'ppxed-source'})) astProvider.privateOnDidChange.fire(uri.with({scheme: 'ast-source'})) }), ); context.subscriptions.push(configureLanguage()); - vscode.workspace.registerTextDocumentContentProvider("ppxed-source", provider); vscode.workspace.registerTextDocumentContentProvider("ast-source", astProvider); - const showPpxedSource = () => { - if (!client) { - return vscode.window.showInformationMessage('Language server not running'); - } - const editor = vscode.window.activeTextEditor; - if (!editor) { - return vscode.window.showInformationMessage('No active editor'); - } - if (editor.document.languageId !== 'ocaml' && editor.document.languageId !== 'reason') { - return vscode.window.showInformationMessage('Not an OCaml or Reason file'); - } - - const document = TextDocument.create(editor.document.uri.with({scheme: 'ppxed-source'}), editor.document.languageId, 1, ''); - vscode.window.showTextDocument(document); - }; - - vscode.commands.registerCommand('reason-language-server.show_ppxed_source', showPpxedSource); - vscode.commands.registerCommand('reason-language-server.dump_file_data', () => { if (!client) { return vscode.window.showInformationMessage('Language server not running'); diff --git a/src/ppx/Ppx_Monads.re b/src/ppx/Ppx_Monads.re index a520969f..1646d796 100644 --- a/src/ppx/Ppx_Monads.re +++ b/src/ppx/Ppx_Monads.re @@ -91,28 +91,6 @@ Alternatively, if you are just performing a side effect, and want the result of the whole thing to be unit, use `let%consume`. |}; -let opt_wrap_explanation = {| -Optional declaration sugar: -``` -let%opt_wrap name = value; -otherStuff -``` -is transformed into -``` -switch (value) { -| None => None -| Some(name) => Some({ - otherStuff - }) -} -``` -The `wrap` suffix means that the `otherStuff` will be automatically -wrapped in a `Some`. - -If you don't want this wrapping, then use `let%opt`. -Alternatively, if you are just performing a side effect, and want -the result of the whole thing to be unit, use `let%consume`. -|}; let opt_consume_explanation = {| Optional declaration sugar: @@ -143,7 +121,6 @@ let mapper = ) as txt, loc}, PStr([{pstr_desc: Pstr_eval({pexp_desc: Pexp_let(Nonrecursive, bindings, continuation)}, _attributes)}]))) => { let (front, explanation) = switch (txt) { | "opt" => ([%expr Monads.Option.bind], opt_explanation) - | "opt_wrap" => ([%expr Monads.Option.map], opt_wrap_explanation) | "opt_consume" => ([%expr Monads.Option.consume], opt_consume_explanation) | "try" => ([%expr Monads.Result.bind], "Sugar for the Result type") | "try_wrap" => ([%expr Monads.Result.map], "Sugar for the Result type - auto-wraps in `Ok()`") diff --git a/src/rescript-editor-support/EditorSupportCommands.re b/src/rescript-editor-support/EditorSupportCommands.re index 6b4535c7..8f8d1514 100644 --- a/src/rescript-editor-support/EditorSupportCommands.re +++ b/src/rescript-editor-support/EditorSupportCommands.re @@ -1,4 +1,3 @@ -open Infix; module J = JsonShort; let dumpLocations = (state, ~package, ~file, ~extra, ~selectPos, uri) => { @@ -51,10 +50,12 @@ let dumpLocations = (state, ~package, ~file, ~extra, ~selectPos, uri) => { ~markdown=!state.settings.clientNeedsPlainText, ~showPath=state.settings.showModulePathOnHover, loc, - ) - |? ""; + ); let hover = - hoverText == "" ? [] : [("hover", dedupHover(hoverText, i))]; + switch (hoverText) { + | None => [] + | Some(s) => [("hover", dedupHover(s, i))] + }; let uriLocOpt = References.definitionForLoc( @@ -134,7 +135,7 @@ let dump = files => { files |> List.iter(pathWithPos => { let (filePath, selectPos) = pathWithPos |> splitLineChar; - let filePath = maybeConcat(Unix.getcwd(), filePath); + let filePath = Files.maybeConcat(Unix.getcwd(), filePath); let uri = Utils.toUri(filePath); let result = switch (State.getFullFromCmt(uri, state)) { @@ -174,7 +175,7 @@ let complete = (~pathWithPos, ~currentFile) => { }; switch (pathWithPos |> splitLineChar) { | (filePath, Some(pos)) => - let filePath = maybeConcat(Unix.getcwd(), filePath); + let filePath = Files.maybeConcat(Unix.getcwd(), filePath); let uri = Utils.toUri(filePath); let result = switch (State.getFullFromCmt(uri, state)) { diff --git a/src/rescript-editor-support/Files.re b/src/rescript-editor-support/Files.re index 12e7537a..a9724257 100644 --- a/src/rescript-editor-support/Files.re +++ b/src/rescript-editor-support/Files.re @@ -187,3 +187,23 @@ let rec collect = (~checkDir=_ => true, path, test) => } | _ => test(path) ? [path] : [] }; + +let fileConcat = (a, b) => + if (b != "" + && b.[0] == '.' + && String.length(b) >= 2 + && b.[1] == Filename.dir_sep.[0]) { + Filename.concat(a, String.sub(b, 2, String.length(b) - 2)); + } else { + Filename.concat(a, b); + }; + +let isFullPath = b => + b.[0] == '/' || Sys.win32 && String.length(b) > 1 && b.[1] == ':'; + +let maybeConcat = (a, b) => + if (b != "" && isFullPath(b)) { + b; + } else { + fileConcat(a, b); + }; diff --git a/src/rescript-editor-support/FindFiles.re b/src/rescript-editor-support/FindFiles.re index 0068d830..264df763 100644 --- a/src/rescript-editor-support/FindFiles.re +++ b/src/rescript-editor-support/FindFiles.re @@ -147,7 +147,7 @@ let findProjectFiles = (~debug, namespace, root, sourceDirectories, compiledBase) => { let files = sourceDirectories - |> List.map(Infix.fileConcat(root)) + |> List.map(Files.fileConcat(root)) |> ifDebug(debug, "Source directories", String.concat(" - ")) |> List.map(name => Files.collect(name, isSourceFile)) |> List.concat @@ -308,7 +308,7 @@ let findDependencyFiles = (~debug, base, config) => { Log.log("Compiled base: " ++ compiledBase); }; let compiledDirectories = - directories |> List.map(Infix.fileConcat(compiledBase)); + directories |> List.map(Files.fileConcat(compiledBase)); let compiledDirectories = namespace == None ? compiledDirectories diff --git a/src/rescript-editor-support/Infix.re b/src/rescript-editor-support/Infix.re index e9abad35..f71e1a30 100644 --- a/src/rescript-editor-support/Infix.re +++ b/src/rescript-editor-support/Infix.re @@ -52,16 +52,6 @@ let (|?<) = (o, fn) => | Some(v) => fn(v) }; -let fileConcat = (a, b) => - if (b != "" - && b.[0] == '.' - && String.length(b) >= 2 - && b.[1] == Filename.dir_sep.[0]) { - Filename.concat(a, String.sub(b, 2, String.length(b) - 2)); - } else { - Filename.concat(a, b); - }; - let logIfAbsent = (message, x) => switch (x) { | None => @@ -70,14 +60,4 @@ let logIfAbsent = (message, x) => | _ => x }; -let isFullPath = b => - b.[0] == '/' || Sys.win32 && String.length(b) > 1 && b.[1] == ':'; - -let maybeConcat = (a, b) => - if (b != "" && isFullPath(b)) { - b; - } else { - fileConcat(a, b); - }; - -let (/+) = fileConcat; +let (/+) = Files.fileConcat; diff --git a/src/rescript-editor-support/MessageHandlers.re b/src/rescript-editor-support/MessageHandlers.re index 38a0a9b6..e90fc5eb 100644 --- a/src/rescript-editor-support/MessageHandlers.re +++ b/src/rescript-editor-support/MessageHandlers.re @@ -77,29 +77,28 @@ let handlers: let%try (uri, pos) = Protocol.rPositionParams(params); let%try package = getPackage(uri, state); - let res = - { - let pos = Utils.cmtLocFromVscode(pos); - let%opt (file, extra) = - State.fileForUri(state, ~package, uri) |> toOptionAndLog; - - let%opt_wrap refs = References.refsForPos(~file, ~extra, pos); - ( - state, - J.l( - refs - |> List.map(loc => - J.o([ - ("range", Protocol.rangeOfLoc(loc)), - ("kind", J.i(2)), - ]) - ), - ), - ); - } - |? (state, Json.Null); - - Ok(res); + let pos = Utils.cmtLocFromVscode(pos); + let refs = + switch (State.fileForUri(state, ~package, uri) |> toOptionAndLog) { + | None => None + | Some((file, extra)) => References.refsForPos(~file, ~extra, pos) + }; + Ok(( + state, + switch (refs) { + | None => J.null + | Some(refs) => + J.l( + refs + |> List.map(loc => + J.o([ + ("range", Protocol.rangeOfLoc(loc)), + ("kind", J.i(2)), + ]) + ), + ) + }, + )); }, ), ( @@ -749,57 +748,6 @@ let handlers: Ok((state, Json.Null)); }, ), - ( - "custom:reasonLanguageServer/showPpxedSource", - (state, params) => { - let%try (uri, _pos) = Protocol.rPositionParams(params); - let%try package = getPackage(uri, state); - let%try (file, _extra) = State.fileForUri(state, ~package, uri); - let%try parsetree = - AsYouType.getParsetree( - ~uri, - ~moduleName=file.moduleName, - ~cacheLocation=package.tmpPath, - ); - if (State.isMl(uri)) { - switch (parsetree) { - | `Implementation(str) => - Pprintast.structure(Format.str_formatter, str) - | `Interface(int) => Pprintast.signature(Format.str_formatter, int) - }; - } else { - module Convert = - Migrate_parsetree.Convert( - Migrate_parsetree.OCaml_406, - Migrate_parsetree.OCaml_408, - ); - switch (parsetree) { - | `Implementation(str) => - Reason_toolchain.RE.print_implementation_with_comments( - Format.str_formatter, - (Convert.copy_structure(str), []), - ) - | `Interface(int) => - Reason_toolchain.RE.print_interface_with_comments( - Format.str_formatter, - (Convert.copy_signature(int), []), - ) - }; - }; - let source = Format.flush_str_formatter(); - - /* let source = State.isMl(uri) ? source : switch (package.refmtPath) { - | None => source - | Some(refmt) => - let interface = Utils.endsWith(uri, "i"); - switch (AsYouType.convertToRe(~formatWidth=None, ~interface, source, refmt)) { - | RResult.Error(_) => source - | Ok(s) => s - } - }; */ - Ok((state, Json.String(source))); - }, - ), ( "custom:reasonLanguageServer/showAst", (state, params) => { diff --git a/src/rescript-editor-support/Monads.re b/src/rescript-editor-support/Monads.re index f116678f..3daa585c 100644 --- a/src/rescript-editor-support/Monads.re +++ b/src/rescript-editor-support/Monads.re @@ -1,18 +1,5 @@ - -module type MonadThing = { - type t('a); - let map: (t('a), ~f: 'a => 'b) => t('b); - let bind: (t('a), ~f: 'a => t('b)) => t('b); - let consume: (t('a), ~f: 'a => unit) => unit; -}; - module Option = { type t('a) = option('a); - let map = (value, ~f as use) => - switch (value) { - | Some(x) => Some(use(x)) - | None => None - }; let bind = (value, ~f as use) => switch (value) { | Some(x) => use(x) @@ -25,7 +12,7 @@ module Option = { }; }; -module O: MonadThing = Option; +module O = Option; module Result = { let map /*: t 'a 'b => f::('a => 'c) => t 'c 'b*/ = (value, ~f as use) => diff --git a/src/rescript-editor-support/NewCompletions.re b/src/rescript-editor-support/NewCompletions.re index 6d296c49..e0adead7 100644 --- a/src/rescript-editor-support/NewCompletions.re +++ b/src/rescript-editor-support/NewCompletions.re @@ -512,14 +512,13 @@ let getItems = switch (determineCompletion(multiple)) { | `Normal(path) => - { - Log.log("normal " ++ pathToString(path)); - let%opt_wrap (env, suffix) = - getEnvWithOpens(~pos, ~env, ~getModule, ~opens, path); + Log.log("normal " ++ pathToString(path)); + switch (getEnvWithOpens(~pos, ~env, ~getModule, ~opens, path)) { + | Some((env, suffix)) => Log.log("Got the env"); valueCompletions(~env, suffix); - } - |? [] + | None => [] + }; | `Attribute(target, suffix) => { Log.log("suffix :" ++ suffix); @@ -573,16 +572,14 @@ let getItems = } |? [] | `AbsAttribute(path) => - { - let%opt_wrap (env, suffix) = - getEnvWithOpens(~pos, ~env, ~getModule, ~opens, path); - + switch (getEnvWithOpens(~pos, ~env, ~getModule, ~opens, path)) { + | None => [] + | Some((env, suffix)) => attributeCompletions(~env, ~suffix) @ List.concat( opens |> List.map(env => attributeCompletions(~env, ~suffix)), - ); + ) } - |? [] }; }; }; diff --git a/src/rescript-editor-support/Packages.re b/src/rescript-editor-support/Packages.re index d017218f..add617e0 100644 --- a/src/rescript-editor-support/Packages.re +++ b/src/rescript-editor-support/Packages.re @@ -112,7 +112,7 @@ let newBsPackage = (~reportDiagnostics, state, rootPath) => { "Got source directories " ++ String.concat(" - ", localSourceDirs), ); let localCompiledDirs = - localSourceDirs |> List.map(Infix.fileConcat(compiledBase)); + localSourceDirs |> List.map(Files.fileConcat(compiledBase)); let localCompiledDirs = namespace == None ? localCompiledDirs : [compiledBase, ...localCompiledDirs]; diff --git a/src/rescript-editor-support/ProcessExtra.re b/src/rescript-editor-support/ProcessExtra.re index 796c3f82..49bf6ab6 100644 --- a/src/rescript-editor-support/ProcessExtra.re +++ b/src/rescript-editor-support/ProcessExtra.re @@ -62,16 +62,20 @@ let getTypeAtPath = (~env, path) => { | `Exported(env, name) => let res = { let%opt stamp = Hashtbl.find_opt(env.exported.types, name); - let%opt_wrap declaredType = - Hashtbl.find_opt(env.file.stamps.types, stamp); - `Local(declaredType); + let declaredType = Hashtbl.find_opt(env.file.stamps.types, stamp); + switch (declaredType) { + | Some(declaredType) => Some(`Local(declaredType)) + | None => None + }; }; res |? `Not_found; | `Stamp(stamp) => let res = { - let%opt_wrap declaredType = - Hashtbl.find_opt(env.file.stamps.types, stamp); - `Local(declaredType); + let declaredType = Hashtbl.find_opt(env.file.stamps.types, stamp); + switch (declaredType) { + | Some(declaredType) => Some(`Local(declaredType)) + | None => None + }; }; res |? `Not_found; }; @@ -141,12 +145,12 @@ module F = addExternalReference(moduleName, path, tip, identLoc); GlobalReference(moduleName, path, tip); | `Exported(env, name) => - let res = { - let%opt_wrap stamp = Hashtbl.find_opt(env.exported.values, name); + switch (Hashtbl.find_opt(env.exported.values, name)) { + | Some(stamp) => addReference(stamp, identLoc); LocalReference(stamp, tip); - }; - res |? NotFound; + | None => NotFound + } | `GlobalMod(_) => NotFound }; addLocation(loc, Typed(typ, locType)); @@ -166,12 +170,12 @@ module F = addExternalReference(moduleName, path, Module, loc); LModule(GlobalReference(moduleName, path, Module)); | `Exported(env, name) => - let res = { - let%opt_wrap stamp = Hashtbl.find_opt(env.exported.modules, name); + switch (Hashtbl.find_opt(env.exported.modules, name)) { + | Some(stamp) => addReference(stamp, loc); LModule(LocalReference(stamp, Module)); - }; - res |? LModule(NotFound); + | None => LModule(NotFound) + } }; addLocation(loc, locType); }; @@ -189,13 +193,12 @@ module F = let locType = switch (t) { | `Local({stamp, item: {kind: Record(attributes)}}) => - { - let%opt_wrap {stamp: astamp} = - attributes |> List.find_opt(a => a.aname.txt == name); + switch (attributes |> List.find_opt(a => a.aname.txt == name)) { + | Some({stamp: astamp}) => addReference(astamp, nameLoc); LocalReference(stamp, Attribute(name)); + | None => NotFound } - |? NotFound | `Global(moduleName, path) => addExternalReference(moduleName, path, Attribute(name), nameLoc); GlobalReference(moduleName, path, Attribute(name)); @@ -221,13 +224,12 @@ module F = let locType = switch (t) { | `Local({stamp, item: {kind: Record(attributes)}}) => - { - let%opt_wrap {stamp: astamp} = - attributes |> List.find_opt(a => a.aname.txt == name); + switch (attributes |> List.find_opt(a => a.aname.txt == name)) { + | Some({stamp: astamp}) => addReference(astamp, nameLoc); LocalReference(stamp, Attribute(name)); + | None => NotFound } - |? NotFound | `Global(moduleName, path) => addExternalReference( moduleName, @@ -258,13 +260,12 @@ module F = let locType = switch (t) { | `Local({stamp, item: {kind: Variant(constructors)}}) => - { - let%opt_wrap {stamp: cstamp} = - constructors |> List.find_opt(c => c.cname.txt == cstr_name); + switch (constructors |> List.find_opt(c => c.cname.txt == cstr_name)) { + | Some({stamp: cstamp}) => addReference(cstamp, nameLoc); LocalReference(stamp, Constructor(name)); + | None => NotFound } - |? NotFound | `Global(moduleName, path) => addExternalReference(moduleName, path, Constructor(name), nameLoc); GlobalReference(moduleName, path, Constructor(name)); diff --git a/src/rescript-editor-support/Query.re b/src/rescript-editor-support/Query.re index e4541f1c..e5138d6c 100644 --- a/src/rescript-editor-support/Query.re +++ b/src/rescript-editor-support/Query.re @@ -148,16 +148,16 @@ let fromCompilerPath = (~env, path) => { | `Path(0, moduleName, path) => `Global((moduleName, path)) | `GlobalMod(name) => `GlobalMod(name) | `Path(stamp, _moduleName, path) => - let res = { - let%opt {item: kind} = - Hashtbl.find_opt(env.file.stamps.modules, stamp); - let%opt_wrap res = findInModule(~env, kind, path); - switch (res) { - | `Local(env, name) => `Exported((env, name)) - | `Global(moduleName, fullPath) => `Global((moduleName, fullPath)) + let res = + switch (Hashtbl.find_opt(env.file.stamps.modules, stamp)) { + | None => None + | Some({item: kind}) => findInModule(~env, kind, path) }; + switch (res) { + | None => `Not_found + | Some(`Local(env, name)) => `Exported((env, name)) + | Some(`Global(moduleName, fullPath)) => `Global((moduleName, fullPath)) }; - res |? `Not_found; }; }; @@ -188,13 +188,18 @@ let resolveModuleFromCompilerPath = (~env, ~getModule, path) => { let resolveFromCompilerPath = (~env, ~getModule, path) => { switch (fromCompilerPath(~env, path)) { | `Global(moduleName, path) => - let res = { - let%opt file = getModule(moduleName); - let env = {file, exported: file.contents.exported}; - let%opt_wrap (env, name) = resolvePath(~env, ~getModule, ~path); - `Exported((env, name)); + let res = + switch (getModule(moduleName)) { + | None => None + | Some(file) => + let env = {file, exported: file.contents.exported}; + resolvePath(~env, ~getModule, ~path); + }; + switch (res) { + | None => `Not_found + | Some((env, name)) => `Exported((env, name)) }; - res |? `Not_found; + | `Stamp(stamp) => `Stamp(stamp) | `GlobalMod(_) => `Not_found | `Not_found => `Not_found diff --git a/src/rescript-editor-support/References.re b/src/rescript-editor-support/References.re index e5d68e17..59aa41cf 100644 --- a/src/rescript-editor-support/References.re +++ b/src/rescript-editor-support/References.re @@ -70,12 +70,16 @@ let localReferencesForLoc = (~file, ~extra, loc) => Hashtbl.find_opt(extra.internalReferences, localStamp); | LModule(GlobalReference(moduleName, path, tip)) | Typed(_, GlobalReference(moduleName, path, tip)) => - let%opt_wrap refs = - Hashtbl.find_opt(extra.externalReferences, moduleName); - refs - |> Utils.filterMap(((p, t, l)) => - p == path && t == tip ? Some(l) : None - ); + switch (Hashtbl.find_opt(extra.externalReferences, moduleName)) { + | None => None + | Some(refs) => + Some( + refs + |> Utils.filterMap(((p, t, l)) => + p == path && t == tip ? Some(l) : None + ), + ) + } }; let definedForLoc = (~file, ~getModule, loc) => { diff --git a/src/rescript-editor-support/State.re b/src/rescript-editor-support/State.re index 0ac21ad7..a3ea552e 100644 --- a/src/rescript-editor-support/State.re +++ b/src/rescript-editor-support/State.re @@ -299,8 +299,10 @@ let docsForModule = (modname, state, ~package) => let src = SharedTypes.getSrc(paths); Log.log("FINDING docs for module " ++ SharedTypes.showPaths(paths)); Log.log("FINDING " ++ cmt ++ " src " ++ (src |? "")); - let%opt_wrap docs = docsForCmt(~moduleName=modname, cmt, src, state); - (docs, src); + switch (docsForCmt(~moduleName=modname, cmt, src, state)) { + | None => None + | Some(docs) => Some((docs, src)) + }; } else { Log.log("No path for module " ++ modname); None; diff --git a/src/rescript-editor-support/dune b/src/rescript-editor-support/dune index 7041347f..d40b63bc 100644 --- a/src/rescript-editor-support/dune +++ b/src/rescript-editor-support/dune @@ -2,7 +2,7 @@ (executable (name RescriptEditorSupport) (public_name rescript-editor-support.exe) - (libraries str reason ocaml-migrate-parsetree uri bigarray) + (libraries str compiler-libs.common uri unix) (flags "-w" "+26+27+32+33+39") (preprocess (pps Ppx_monads)) ) diff --git a/src/rescript-editor-support/vendor/omd/omd.ml b/src/rescript-editor-support/vendor/omd/omd.ml index 4f694bcf..b5c5dfb7 100644 --- a/src/rescript-editor-support/vendor/omd/omd.ml +++ b/src/rescript-editor-support/vendor/omd/omd.ml @@ -25,7 +25,6 @@ let of_input lex ?extensions:e ?default_lang:d s = Parser.make_paragraphs md let of_string = of_input Omd_lexer.lex -let of_bigarray = of_input Omd_lexer.lex_bigarray let to_html : ?override:(Omd_representation.element -> string option) -> diff --git a/src/rescript-editor-support/vendor/omd/omd.mli b/src/rescript-editor-support/vendor/omd/omd.mli index 26af37e0..0648236b 100644 --- a/src/rescript-editor-support/vendor/omd/omd.mli +++ b/src/rescript-editor-support/vendor/omd/omd.mli @@ -121,12 +121,6 @@ val of_string : ?extensions:Omd_representation.extensions -> If you want to use a custom lexer or parser, use {!Omd_lexer.lex} and {!Omd_parser.parse}. *) -val of_bigarray : ?extensions:Omd_representation.extensions -> - ?default_lang: name -> - Omd_lexer.bigstring -> t -(** As {!of_string}, but read input from a bigarray rather than from a - string. *) - val set_default_lang : name -> t -> t (** [set_default_lang lang md] return a copy of [md] where the language of all [Code] or [Code_block] with an empty language is diff --git a/src/rescript-editor-support/vendor/omd/omd_lexer.ml b/src/rescript-editor-support/vendor/omd/omd_lexer.ml index 8f48c346..3c4e8d53 100644 --- a/src/rescript-editor-support/vendor/omd/omd_lexer.ml +++ b/src/rescript-editor-support/vendor/omd/omd_lexer.ml @@ -326,30 +326,6 @@ end module Lex_string = Lex(StringLabels) let lex = Lex_string.lex - -type bigstring = (char, - Bigarray.int8_unsigned_elt, - Bigarray.c_layout) Bigarray.Array1.t - -module Bigarray_input : Input with type t = bigstring = -struct - module BA = Bigarray - - type t = bigstring - let get = BA.Array1.get - let length = BA.Array1.dim - let sub arr ~pos ~len = - if len < 0 || pos < 0 || pos + len > BA.Array1.dim arr - then invalid_arg "Bigarray_input.sub"; - let s = Bytes.create len in - for i = 0 to len - 1 do - Bytes.unsafe_set s i (BA.Array1.unsafe_get arr (i + pos)) - done; - Bytes.unsafe_to_string s -end -module Lex_bigarray = Lex(Bigarray_input) -let lex_bigarray = Lex_bigarray.lex - let make_space = function | 0 -> invalid_arg "Omd_lexer.make_space" | 1 -> Space diff --git a/src/rescript-editor-support/vendor/omd/omd_lexer.mli b/src/rescript-editor-support/vendor/omd/omd_lexer.mli index 18beed6c..bcebdd36 100644 --- a/src/rescript-editor-support/vendor/omd/omd_lexer.mli +++ b/src/rescript-editor-support/vendor/omd/omd_lexer.mli @@ -12,13 +12,6 @@ val lex : string -> t in highest priority whereas functions in [extensions] are applied with lowest priority. *) -type bigstring = (char, - Bigarray.int8_unsigned_elt, - Bigarray.c_layout) Bigarray.Array1.t - -val lex_bigarray : bigstring -> t -(** As {!lex}, but read input from a bigarray rather than from a string. *) - val string_of_tokens : t -> string (** [string_of_tokens t] return the string corresponding to the token list [t]. *)