Skip to content

Commit 76a00e5

Browse files
committed
Send variant analysis on viewLoaded message
When the `viewLoaded` message is received by the view, it will now retrieve the variant analysis from the manager and send it to the view. This will allow the view to display the variant analysis.
1 parent 1d02c19 commit 76a00e5

File tree

3 files changed

+24
-158
lines changed

3 files changed

+24
-158
lines changed

extensions/ql-vscode/src/remote-queries/variant-analysis-manager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export class VariantAnalysisManager extends DisposableObject implements VariantA
6868
return this.views.get(variantAnalysisId);
6969
}
7070

71+
public async getVariantAnalysis(variantAnalysisId: number): Promise<VariantAnalysis | undefined> {
72+
return this.variantAnalyses.get(variantAnalysisId);
73+
}
74+
7175
public async loadResults(variantAnalysisId: number, repositoryFullName: string): Promise<void> {
7276
const variantAnalysis = this.variantAnalyses.get(variantAnalysisId);
7377
if (!variantAnalysis) {

extensions/ql-vscode/src/remote-queries/variant-analysis-view-manager.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { VariantAnalysis } from './shared/variant-analysis';
2+
13
export interface VariantAnalysisViewInterface {
24
variantAnalysisId: number;
35
openView(): Promise<void>;
@@ -6,4 +8,6 @@ export interface VariantAnalysisViewInterface {
68
export interface VariantAnalysisViewManager<T extends VariantAnalysisViewInterface> {
79
registerView(view: T): void;
810
unregisterView(view: T): void;
11+
12+
getVariantAnalysis(variantAnalysisId: number): Promise<VariantAnalysis | undefined>;
913
}

extensions/ql-vscode/src/remote-queries/variant-analysis-view.ts

Lines changed: 16 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ import { FromVariantAnalysisMessage, ToVariantAnalysisMessage } from '../pure/in
55
import { assertNever } from '../pure/helpers-pure';
66
import {
77
VariantAnalysis,
8-
VariantAnalysisQueryLanguage,
9-
VariantAnalysisRepoStatus,
108
VariantAnalysisScannedRepositoryResult,
119
VariantAnalysisScannedRepositoryState,
12-
VariantAnalysisStatus
1310
} from './shared/variant-analysis';
1411
import { VariantAnalysisViewInterface, VariantAnalysisViewManager } from './variant-analysis-view-manager';
1512

@@ -82,14 +79,7 @@ export class VariantAnalysisView extends AbstractWebview<ToVariantAnalysisMessag
8279
protected async onMessage(msg: FromVariantAnalysisMessage): Promise<void> {
8380
switch (msg.t) {
8481
case 'viewLoaded':
85-
this.onWebViewLoaded();
86-
87-
void logger.log('Variant analysis view loaded');
88-
89-
await this.postMessage({
90-
t: 'setVariantAnalysis',
91-
variantAnalysis: this.getVariantAnalysis(),
92-
});
82+
await this.onWebViewLoaded();
9383

9484
break;
9585
case 'stopVariantAnalysis':
@@ -103,152 +93,20 @@ export class VariantAnalysisView extends AbstractWebview<ToVariantAnalysisMessag
10393
}
10494
}
10595

106-
private getVariantAnalysis(): VariantAnalysis {
107-
return {
108-
id: this.variantAnalysisId,
109-
controllerRepoId: 1,
110-
actionsWorkflowRunId: 789263,
111-
query: {
112-
name: 'Example query',
113-
filePath: 'example.ql',
114-
language: VariantAnalysisQueryLanguage.Javascript,
115-
},
116-
databases: {},
117-
status: VariantAnalysisStatus.InProgress,
118-
scannedRepos: [
119-
{
120-
repository: {
121-
id: 1,
122-
fullName: 'octodemo/hello-world-1',
123-
private: false,
124-
},
125-
analysisStatus: VariantAnalysisRepoStatus.Pending,
126-
},
127-
{
128-
repository: {
129-
id: 2,
130-
fullName: 'octodemo/hello-world-2',
131-
private: false,
132-
},
133-
analysisStatus: VariantAnalysisRepoStatus.Pending,
134-
},
135-
{
136-
repository: {
137-
id: 3,
138-
fullName: 'octodemo/hello-world-3',
139-
private: false,
140-
},
141-
analysisStatus: VariantAnalysisRepoStatus.Pending,
142-
},
143-
{
144-
repository: {
145-
id: 4,
146-
fullName: 'octodemo/hello-world-4',
147-
private: false,
148-
},
149-
analysisStatus: VariantAnalysisRepoStatus.Pending,
150-
},
151-
{
152-
repository: {
153-
id: 5,
154-
fullName: 'octodemo/hello-world-5',
155-
private: false,
156-
},
157-
analysisStatus: VariantAnalysisRepoStatus.Pending,
158-
},
159-
{
160-
repository: {
161-
id: 6,
162-
fullName: 'octodemo/hello-world-6',
163-
private: false,
164-
},
165-
analysisStatus: VariantAnalysisRepoStatus.Pending,
166-
},
167-
{
168-
repository: {
169-
id: 7,
170-
fullName: 'octodemo/hello-world-7',
171-
private: false,
172-
},
173-
analysisStatus: VariantAnalysisRepoStatus.Pending,
174-
},
175-
{
176-
repository: {
177-
id: 8,
178-
fullName: 'octodemo/hello-world-8',
179-
private: false,
180-
},
181-
analysisStatus: VariantAnalysisRepoStatus.Pending,
182-
},
183-
{
184-
repository: {
185-
id: 9,
186-
fullName: 'octodemo/hello-world-9',
187-
private: false,
188-
},
189-
analysisStatus: VariantAnalysisRepoStatus.Pending,
190-
},
191-
{
192-
repository: {
193-
id: 10,
194-
fullName: 'octodemo/hello-world-10',
195-
private: false,
196-
},
197-
analysisStatus: VariantAnalysisRepoStatus.Pending,
198-
},
199-
],
200-
skippedRepos: {
201-
notFoundRepos: {
202-
repositoryCount: 2,
203-
repositories: [
204-
{
205-
fullName: 'octodemo/hello-globe'
206-
},
207-
{
208-
fullName: 'octodemo/hello-planet'
209-
}
210-
]
211-
},
212-
noCodeqlDbRepos: {
213-
repositoryCount: 4,
214-
repositories: [
215-
{
216-
id: 100,
217-
fullName: 'octodemo/no-db-1'
218-
},
219-
{
220-
id: 101,
221-
fullName: 'octodemo/no-db-2'
222-
},
223-
{
224-
id: 102,
225-
fullName: 'octodemo/no-db-3'
226-
},
227-
{
228-
id: 103,
229-
fullName: 'octodemo/no-db-4'
230-
}
231-
]
232-
},
233-
overLimitRepos: {
234-
repositoryCount: 1,
235-
repositories: [
236-
{
237-
id: 201,
238-
fullName: 'octodemo/over-limit-1'
239-
}
240-
]
241-
},
242-
accessMismatchRepos: {
243-
repositoryCount: 1,
244-
repositories: [
245-
{
246-
id: 205,
247-
fullName: 'octodemo/private'
248-
}
249-
]
250-
}
251-
},
252-
};
96+
protected async onWebViewLoaded() {
97+
super.onWebViewLoaded();
98+
99+
void logger.log('Variant analysis view loaded');
100+
101+
const variantAnalysis = await this.manager.getVariantAnalysis(this.variantAnalysisId);
102+
103+
if (!variantAnalysis) {
104+
return;
105+
}
106+
107+
await this.postMessage({
108+
t: 'setVariantAnalysis',
109+
variantAnalysis,
110+
});
253111
}
254112
}

0 commit comments

Comments
 (0)