Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Reduce dependencies #40

Merged
merged 4 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reduce dependencies: remove show ppx and the dep on Reason_toolchain.
  • Loading branch information
cristianoc committed Dec 11, 2020
commit 34cb2750b39b062b6f46662171f6a69f58d17ef3
4 changes: 0 additions & 4 deletions editor-extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
41 changes: 0 additions & 41 deletions editor-extensions/vscode/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
51 changes: 0 additions & 51 deletions src/rescript-editor-support/MessageHandlers.re
Original file line number Diff line number Diff line change
Expand Up @@ -749,57 +749,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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/rescript-editor-support/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(executable
(name RescriptEditorSupport)
(public_name rescript-editor-support.exe)
(libraries str reason ocaml-migrate-parsetree uri bigarray)
(libraries str ocaml-migrate-parsetree uri bigarray)
(flags "-w" "+26+27+32+33+39")
(preprocess (pps Ppx_monads))
)