Hook into VsRocq extension's API #26
Loading…
Reference in a new issue
No description provided.
Delete branch "vsrocq-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
vsrocq-apito Hook into VsRocq extension's API to check proof statusHook into VsRocq extension's API to check proof statusto Hook into VsRocq extension's APIHook into VsRocq extension's APIto WIP: Hook into VsRocq extension's API99062182edf4ee4a6accWIP: Hook into VsRocq extension's APIto Hook into VsRocq extension's API@ -14,3 +14,4 @@proofClause: RocqDefinitionLink | null;}export interface RocqDefinitionLink {You removed "definition" from the
definitionNamefield below, so also do it here.@ -20,3 +21,4 @@targetName: string;}export interface LoopAnnotation {(Perhaps off topic) Does it make sense to have
LoopAnnotationandFunctionAnnotationinherit the same superclassAnnotation, since we want to match onkind❓And rearrange interfaces such that
LoopAnnotationandFunctionAnnotationare next to each other in code@ -46,3 +60,3 @@clause: Node,existing: ClauseNode | null,keyword: 'PRE' | 'POST',clauseName: 'PRE' | 'POST',clauseName(defined here) vskind(defined ininterface RocqDefinitionLinkabove) - enforce one style?@ -59,2 +75,4 @@async function parseLinkClause(clause: Node,existing: RocqDefinitionLink | null,clauseName: 'SPEC' | 'PROOF',clauseName(defined here) vskind(defined ininterface RocqDefinitionLinkabove) - enforce one style?@ -155,3 +187,3 @@}});}const [firstInvClause] = invClauses;safer to use .head/.first or similar?
@ -0,0 +16,4 @@?.activate();}// proofDocumentUri:proofNameAdd better documentation & use doc comment
I'd prefer named parameters here (use a dictionary). Otherwise you pass a bare number with no explanation when calling this function.
@ -0,0 +21,4 @@vsRocqApi: VsRocqApi,proofDocumentUri: vscode.Uri,proofName: string,retries = 0,I thought it meant "what number retry are you on"❓ Make less ambigious by renaming to
maxRetriesor similar.@ -0,0 +37,4 @@if (!proofs) {return null;}const escapedProofName = proofName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');trims out
Theorem,Lemmafrom the proof name - document this, and perhaps rename the constantAlso why this regex in particular❓ Document the reason, or change the regex if it is overkill
@ -0,0 +24,4 @@retries = 0,): Promise<ProofBlock | null> {let proofs: DocumentProofsResponse | undefined;for (let attempt = 0; attempt < 1 + retries; attempt++) {Add comment explaining why this loop is needed
@ -0,0 +30,4 @@break;} catch {if (attempt < retries) {await new Promise((resolve) => setTimeout(resolve, 100));// Sleep for 100 ms before next retry@ -0,0 +48,4 @@return proof ?? null;}// proofDocumentUri:definitionNameAdd better documentation & use doc comment
@ -0,0 +88,4 @@return null;}function removeComments(Why is it needed❓ Document the reason
@ -0,0 +1,178 @@// copied from https://github.com/rocq-prover/vsrocq/blob/main/client/src/protocol/types.tsMark file as vendored or external (use .gitattributes file to do this)
@ -85,1 +85,4 @@const vsRocqApi = await getVsRocqApi();if (vsRocqApi === undefined) {vscode.window.showErrorMessage('failed to load vsrocq extension!');Remove, or hide from production (use debug logging or similar).
Dependency manager already checks for the presence of VsRocq.
@ -86,0 +87,4 @@if (vsRocqApi === undefined) {vscode.window.showErrorMessage('failed to load vsrocq extension!');} else {vscode.window.showInformationMessage('loaded vsrocq extension');Remove, or hide from production (use debug logging or similar).
Dependency manager already checks for the presence of VsRocq.
@ -86,0 +88,4 @@vscode.window.showErrorMessage('failed to load vsrocq extension!');} else {vscode.window.showInformationMessage('loaded vsrocq extension');// vsRocqApi.onProofStateChanged((p) => {Remove dead code.
@ -123,2 +136,4 @@),);// TODO: code completions suggesting proofs/definitions to link to when writing a PROOF or SPEC clauseRemove comment as it doesn't point to specific code & the issue is already present in the issue tracker.
@ -14,1 +23,4 @@): (doc: vscode.TextDocument) => Promise<void> {return async (doc) => {if (doc.languageId === 'c') {if (!vsRocqApi) {Slightly off-topic: Find a way to make
vsRocqApinon-nullable in this scope.@ -14,1 +25,4 @@if (doc.languageId === 'c') {if (!vsRocqApi) {vscode.window.showErrorMessage('failing to connect to VsRocq extension!!',Remove, or hide from production (use debug logging or similar).
Dependency manager already checks for the presence of VsRocq.
@ -28,0 +87,4 @@}}} catch {diagnostics.push(Is this the only kind of error we can catch from the code above?
@ -28,0 +58,4 @@vsRocqApi,fileUri,linkClause.targetName,3, // these are retries if the vsRocqApi might not be initialized should NOT be as many in onChangeDocumentLine width is too long.
@ -28,0 +85,4 @@);break;}}In general this file's indentation is too deep. We could attempt to flatten it out a bit more.
@ -198,11 +198,6 @@ suite('commands/createRocqModel (integration)', () => {);if (execution === undefined) {// A host advertised shell integration viaIs this comment still relevant❓ If so, we should restore it.
@ -0,0 +1,384 @@From Coq Require Import String List ZArith.Should we have a comment at the top of the file explaining the justification of this file?
@ -0,0 +29,4 @@);await vscode.window.showTextDocument(document);assert.ok(vsRocqApi);await delay(1_000); // letting vsrocq load the rocq documentMagic number that always delays this test by the same amount regardless of speed. Is it possible to use waitFor or another test utility?
@ -0,0 +33,4 @@return document;}test('vsrocq interpret to end', async () => {'VsRocq interpretToEnd notifies onProofStateChanged event listener'
@ -0,0 +43,4 @@});test('vsrocqApi get proof block', async () => {const document = await openAndShowTestRocqDoc('verif_sumarray.v');Test uses a lot of sensitive magic numbers for code position.
This could be fine if
verif_sumarray.vhad a notice comment at the top which mentions that editing the file could break this test.@ -0,0 +74,4 @@});test('gets blocks for minimal completed proofs', async () => {const document = await openAndShowTestRocqDoc('simple_proofs.v');Test uses sensitive magic numbers for code position.
This could be fine if
simple_proofs.vhad a notice comment at the top which mentions that editing the file could break this test.@ -0,0 +94,4 @@});test('handles exact proof names and non-proofs', async () => {const document = await openAndShowTestRocqDoc('edge_case_proofs.v');Test uses a lot of sensitive magic numbers for code position.
This could be fine if
edge_case_proofs.vhad a notice comment at the top which mentions that editing the file could break this test.@ -0,0 +134,4 @@});test('returns blocks for admitted and incomplete proofs', async () => {const document = await openAndShowTestRocqDoc('broken_proofs.v');Test uses a lot of sensitive magic numbers for code position.
This could be fine if
broken_proofs.vhad a notice comment at the top which mentions that editing the file could break this test.@ -0,0 +158,4 @@});test('gets ranges for single-line and multiline definitions', async () => {const document = await openAndShowTestRocqDoc('definitions.v');Test uses a lot of sensitive magic numbers for code position.
This could be fine if
definitions.vhad a notice comment at the top which mentions that editing the file could break this test.@ -0,0 +193,4 @@});test('matches definition names exactly and ignores comments', async () => {const document = await openAndShowTestRocqDoc('definitions.v');Test uses a lot of sensitive magic numbers for code position.
This could be fine if
definitions.vhad a notice comment at the top which mentions that editing the file could break this test.@ -0,0 +221,4 @@});test('gets definition ranges from verif_sumarray.v', async () => {const document = await openAndShowTestRocqDoc('verif_sumarray.v');Test uses a lot of sensitive magic numbers for code position.
This could be fine if
verif_sumarray.vhad a notice comment at the top which mentions that editing the file could break this test.This is epic