Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/misc-revisions'
Browse files Browse the repository at this point in the history
  • Loading branch information
jonlamb-gh committed Jan 16, 2024
2 parents 3870135 + f2ba7df commit 4d6c187
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 7 deletions.
12 changes: 10 additions & 2 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
},
{
"command": "auxon.modality.log",
"when": "view == auxon.segments || view == auxon.timelines",
"when": "view == auxon.segments || view == auxon.timelines || (view == auxon.events && viewItem == event)",
"group": "inline"
},
{
Expand Down Expand Up @@ -174,6 +174,10 @@
"command": "auxon.events.createEventAttrNotebook",
"when": "view == auxon.events && viewItem == eventAttribute"
},
{
"command": "auxon.events.logSelected",
"when": "view == auxon.events && listMultiSelection && viewItem == event"
},
{
"command": "auxon.specs.showLatest",
"when": "view == auxon.specs && viewItem == spec && !listMultiSelection",
Expand Down Expand Up @@ -466,6 +470,10 @@
"command": "auxon.events.createEventAttrNotebook",
"title": "View Attribute Plots in a Jupyter Notebook"
},
{
"command": "auxon.events.logSelected",
"title": "Log Selected Events"
},
{
"command": "auxon.specs.refresh",
"title": "Refresh Spec List",
Expand Down Expand Up @@ -597,7 +605,7 @@
},
{
"command": "auxon.modality.log",
"title": "View log",
"title": "View Log",
"icon": "$(open-preview)"
}
],
Expand Down
31 changes: 29 additions & 2 deletions vscode/src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as commonNotebookCells from "../templates/common.json";
import * as eventTimingNotebookCells from "../templates/eventTiming.json";
import * as eventAttributeValuesNotebookCells from "../templates/eventAttributeValues.json";
import * as eventMultiAttributeValuesNotebookCells from "../templates/eventMultiAttributeValues.json";
import * as modalityLog from "./modalityLog";

export class EventsTreeDataProvider implements vscode.TreeDataProvider<EventsTreeItemData> {
selectedTimelineId?: api.TimelineId = undefined;
Expand All @@ -30,6 +31,7 @@ export class EventsTreeDataProvider implements vscode.TreeDataProvider<EventsTre
context.subscriptions.push(
this.view,
vscode.commands.registerCommand("auxon.events.refresh", () => this.refresh()),
vscode.commands.registerCommand("auxon.events.logSelected", () => this.logSelectedCommand()),
vscode.commands.registerCommand("auxon.events.setSelectedTimeline", (timelineId, timelineName) =>
this.setSelectedTimeline(timelineId, timelineName)
),
Expand Down Expand Up @@ -73,7 +75,7 @@ export class EventsTreeDataProvider implements vscode.TreeDataProvider<EventsTre
attrs.push(attr.replace("event.", ""));
}
}
children.push(new EventNameTreeItemData(name, summary.n_instances, attrs));
children.push(new EventNameTreeItemData(name, summary.n_instances, attrs, this.selectedTimelineId));
}

children.sort((a, b) => a.eventName.localeCompare(b.eventName));
Expand All @@ -95,6 +97,19 @@ export class EventsTreeDataProvider implements vscode.TreeDataProvider<EventsTre
}
}

logSelectedCommand() {
const thingsToLog = [];
const literalTimelineId = "%" + this.selectedTimelineId.replace(/-/g, "");

for (const itemData of this.view.selection) {
thingsToLog.push(`${itemData.eventName}@*(_.timeline.id=${literalTimelineId})`);
}
vscode.commands.executeCommand(
modalityLog.MODALITY_LOG_COMMAND,
new modalityLog.ModalityLogCommandArgs({ thingToLog: thingsToLog })
);
}

async createEventTimingNotebook(item: EventNameTreeItemData) {
let selectedEventNames = this.view.selection.map((data) => data.eventName);
// Add the item the command was executed on, it may not be in the selection
Expand Down Expand Up @@ -225,7 +240,19 @@ export type EventsTreeItemData = EventNameTreeItemData | EventAttributeTreeItemD
export type EventsTreeItem = EventNameTreeItem | EventAttributeTreeItem;

export class EventNameTreeItemData {
constructor(public eventName: string, public numInstances: number, public attributes: string[]) {}
constructor(
public eventName: string,
public numInstances: number,
public attributes: string[],
public timelineId: api.TimelineId
) {}

getModalityLogCommandArgs(): modalityLog.ModalityLogCommandArgs {
const literalTimelineId = "%" + this.timelineId.replace(/-/g, "");
return new modalityLog.ModalityLogCommandArgs({
thingToLog: `${this.eventName}@*(_.timeline.id=${literalTimelineId})`,
});
}
}

class EventNameTreeItem extends vscode.TreeItem {
Expand Down
10 changes: 10 additions & 0 deletions vscode/src/segments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ export class SegmentsTreeDataProvider implements vscode.TreeDataProvider<Segment
items.push(new SegmentTreeItemData(segment, isActive));
}

items.sort((a, b) => {
if (a === null || a.name === null) {
return 1;
}
if (b === null || b.name === null) {
return -1;
}
return a.segment.latest_receive_time - b.segment.latest_receive_time;
});

if (
!isDeepStrictEqual(usedSegmentConfig, this.usedSegmentConfig) ||
!isDeepStrictEqual(activeSegmentIds, this.activeSegmentIds)
Expand Down
4 changes: 2 additions & 2 deletions vscode/src/specCoverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function specViewModel(sc: api.SpecCoverage): SpecViewModel {
}
for (const [_c_name, caseCoverage] of Object.entries(behaviorCoverage.case_coverage)) {
numSpecCases += 1;
if (caseCoverage.ever_matched) {
if (caseCoverage.ever_matched || (caseCoverage.case_type == "Prohibited" && !caseCoverage.ever_matched)) {
numSpecCasesCovered += 1;
}
}
Expand Down Expand Up @@ -223,7 +223,7 @@ function caseViewModel(cCov: api.CaseCoverage): CaseViewModel {
let status: Status = "not-executed";

if (cCov.case_type == "Prohibited") {
if (!cCov.ever_matched || cCov.matched_n_times > 0) {
if (cCov.ever_matched || cCov.matched_n_times > 0) {
status = "failed";
} else {
status = "passed";
Expand Down
10 changes: 9 additions & 1 deletion vscode/src/timelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,15 @@ export class TimelineGroupTreeItemData extends TimelineTreeItemData {
}

override children(): TimelineTreeItemData[] {
const timelines = this.timeline_group.timelines.sort();
const timelines = this.timeline_group.timelines.sort((a, b) => {
if (a === null || a.name === null) {
return 1;
}
if (b === null || b.name === null) {
return -1;
}
return a.name.localeCompare(b.name);
});
return timelines.map((timeline_overview) => new TimelineLeafTreeItemData(timeline_overview));
}
}
Expand Down

0 comments on commit 4d6c187

Please sign in to comment.