Skip to content

Commit

Permalink
feat: add a get document proofs external api
Browse files Browse the repository at this point in the history
Now extensions that depend on vscoq can get all the document proofs.
  • Loading branch information
rtetley committed Dec 9, 2024
1 parent d2e9efc commit 0b05cfb
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
1 change: 0 additions & 1 deletion client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
integer
} from 'vscode-languageclient/node';

import {decorationsManual, decorationsContinuous, decorationsErrorAnimation} from './Decorations';
Expand Down
26 changes: 25 additions & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import GoalPanel from './panels/GoalPanel';
import SearchViewProvider from './panels/SearchViewProvider';
import {
CoqLogMessage,
DocumentProofsRequest,
DocumentProofsResponse,
ErrorAlertNotification,
MoveCursorNotification,
ProofViewNotification,
Expand Down Expand Up @@ -186,6 +188,22 @@ export function activate(context: ExtensionContext) {
});
};

const getDocumentProofs = (editor: TextEditor) => {
const uri = editor.document.uri;
const textDocument = TextDocumentIdentifier.create(uri.toString());
const params: DocumentProofsRequest = {textDocument};
const req = new RequestType<DocumentProofsRequest, DocumentProofsResponse, void>("vscoq/documentProofs");
Client.writeToVscoq2Channel("Getting proofs for: " + uri.toString());
client.sendRequest(req, params).then(
(res) => {
return res;
},
(err) => {
window.showErrorMessage(err);
}
);
};

registerVscoqTextCommand('reset', (editor) => {
const uri = editor.document.uri;
const textDocument = TextDocumentIdentifier.create(uri.toString());
Expand Down Expand Up @@ -368,7 +386,13 @@ Path: \`${coqTM.getVsCoqTopPath()}\`
});

context.subscriptions.push(client);
}

const externalApi = {
getDocumentProofs
};

return externalApi;
}

}

Expand Down
19 changes: 19 additions & 0 deletions client/src/protocol/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,22 @@ export interface ResetCoqRequest {
}

export interface ResetCoqResponse {};

export interface DocumentProofsRequest {
textDocument: TextDocumentIdentifier;
}

type proof_step = {
range: Range;
tactic: string;
};

type proof_block = {
statement: string;
range: Range;
proofs: proof_step[];
};

export interface DocumentProofsResponse {
proofs: proof_block[];
}

0 comments on commit 0b05cfb

Please sign in to comment.