Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec related fixes #42

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
},
{
"command": "auxon.specs.showVersion",
"when": "view == auxon.specs && viewItem == specVersion && !listMultiSelection && false",
"when": "view == auxon.specs && viewItem == specVersion && !listMultiSelection",
"group": "1_context@1"
},
{
Expand Down
5 changes: 4 additions & 1 deletion vscode/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export async function activate(context: vscode.ExtensionContext) {
eventsProvider.setSelectedTimelines(selection);
});

new specs.SpecsTreeDataProvider(apiClient, specCoverageProvider, wss, context);
const specsProvider = new specs.SpecsTreeDataProvider(apiClient, specCoverageProvider, wss, context);
// Pre-load specs provided so that the deviant panel can reveal spec tree items without having the user
// explicitly load the specs panel first
const _ignored = specsProvider.getChildren();

new mutators.MutatorsTreeDataProvider(apiClient, wss, context);
new mutations.MutationsTreeDataProvider(apiClient, wss, context);
Expand Down
23 changes: 23 additions & 0 deletions vscode/src/specFileCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,26 @@ export function runConformEvalCommand(args: SpecEvalCommandArgs): Thenable<vscod

return vscode.tasks.executeTask(task);
}

export async function inspectSpecSpeqtr(specNameOrVersion: string): Promise<string | undefined> {
const conform = config.toolPath("conform");

try {
const res = await execFile(
conform,
["spec", "inspect", "--with-speqtr", "--format", "json", specNameOrVersion],
{
encoding: "utf8",
}
);
const data = JSON.parse(res.stdout);
return data.target_version.content.speqtr;
} catch (e: any /* eslint-disable-line @typescript-eslint/no-explicit-any */) {
if (Object.prototype.hasOwnProperty.call(e, "stderr")) {
vscode.window.showErrorMessage(e.stderr.trim());
} else {
vscode.window.showErrorMessage(e.toString());
}
return undefined;
}
}
25 changes: 25 additions & 0 deletions vscode/src/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ export class SpecsTreeDataProvider implements vscode.TreeDataProvider<SpecsTreeI
vscode.commands.registerCommand("auxon.specs.evalVersion.dryRun", (item: SpecVersionTreeItemData) =>
this.evalVersionDryRun(item)
),
vscode.commands.registerCommand("auxon.specs.showLatest", (item: NamedSpecTreeItemData) =>
this.showLatest(item)
),
vscode.commands.registerCommand("auxon.specs.showVersion", (item: SpecVersionTreeItemData) =>
this.showVersion(item)
),
vscode.commands.registerCommand("auxon.specs.delete", (item: NamedSpecTreeItemData) =>
this.deleteSpec(item)
),
Expand Down Expand Up @@ -203,6 +209,14 @@ export class SpecsTreeDataProvider implements vscode.TreeDataProvider<SpecsTreeI
this.conformEval({ spec_version: spec.specVersion, dry_run: true });
}

async showLatest(spec: NamedSpecTreeItemData) {
await this.showSpec(spec.specMetadata.name);
}

async showVersion(spec: SpecVersionTreeItemData) {
await this.showSpec(spec.specVersion);
}

async deleteSpec(spec: NamedSpecTreeItemData) {
const answer = await vscode.window.showInformationMessage(
`Really delete spec '${spec.specMetadata.name}'? This will delete all spec versions and stored results.`,
Expand Down Expand Up @@ -309,6 +323,17 @@ export class SpecsTreeDataProvider implements vscode.TreeDataProvider<SpecsTreeI
conformEval(args: specFileCommands.SpecEvalCommandArgs) {
specFileCommands.runConformEvalCommand(args);
}

async showSpec(specNameOrVersion: string) {
const speqtr = await specFileCommands.inspectSpecSpeqtr(specNameOrVersion);
if (speqtr) {
const doc = await vscode.workspace.openTextDocument({
language: "speqtr",
content: speqtr,
});
await vscode.window.showTextDocument(doc);
}
}
}

// This is the base of all the tree item data classes
Expand Down
Loading