Skip to content

Commit 5cfd322

Browse files
committed
Added empty workspace message and file decorators.
1 parent 9fece83 commit 5cfd322

12 files changed

Lines changed: 69 additions & 59 deletions

File tree

package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,20 @@
107107
"name": "DeepCode Extension",
108108
"when": "!deepcode:error && deepcode:loggedIn && !deepcode:uploadApproved"
109109
},
110+
{
111+
"id": "deepcode.views.empty",
112+
"name": "DeepCode Extension",
113+
"when": "!deepcode:error && deepcode:loggedIn && deepcode:uploadApproved && !deepcode:workspaceFound"
114+
},
110115
{
111116
"id": "deepcode.views.progress",
112117
"name": "DeepCode Analysis",
113-
"when": "!deepcode:error && deepcode:loggedIn && deepcode:uploadApproved && !deepcode:analysisCompleted"
118+
"when": "!deepcode:error && deepcode:loggedIn && deepcode:uploadApproved && deepcode:workspaceFound && !deepcode:analysisCompleted"
114119
},
115120
{
116121
"id": "deepcode.views.analysis",
117122
"name": "DeepCode Analysis",
118-
"when": "!deepcode:error && deepcode:loggedIn && deepcode:uploadApproved && deepcode:analysisCompleted"
123+
"when": "!deepcode:error && deepcode:loggedIn && deepcode:uploadApproved && deepcode:workspaceFound && deepcode:analysisCompleted"
119124
},
120125
{
121126
"id": "deepcode.views.support",
@@ -142,6 +147,10 @@
142147
"view": "deepcode.views.tc",
143148
"contents": "Thanks for connecting with DeepCode. ✅\n 👉 You are almost set 🤗. DeepCode's proprietary AI model is analysing the code remotely on DeepCode's servers. Let's confirm you know this and start the remote analysis of this workspace - feel free to check out our [terms](https://www.deepcode.ai/tc?utm_source=vsc).\n[Accept and start analysing](command:deepcode.approve 'Upload code to DeepCode')\nYou can always change this later in the [configuration panel](command:deepcode.settings)."
144149
},
150+
{
151+
"view": "deepcode.views.empty",
152+
"contents": "Open a workspace or a folder in Visual Studio Code to start the analysis."
153+
},
145154
{
146155
"view": "deepcode.views.progress",
147156
"contents": "Analysis in progress"
@@ -165,10 +174,6 @@
165174
}
166175
],
167176
"commandPalette": [
168-
{
169-
"command": "deepcode.approve",
170-
"when": "false"
171-
},
172177
{
173178
"command": "deepcode.login",
174179
"when": "!deepcode:loggedIn"
@@ -189,10 +194,6 @@
189194
{
190195
"command": "deepcode.login",
191196
"title": "DeepCode login"
192-
},
193-
{
194-
"command": "deepcode.approve",
195-
"title": "DeepCode approve upload and start analysis"
196197
}
197198
]
198199
},

src/deepcode/DeepCodeExtension.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,10 @@ class DeepCodeExtension extends DeepCodeLib implements DeepCode.ExtensionInterfa
9090
new IssueProvider(this)
9191
);
9292

93-
// context.subscriptions.push(
94-
// { dispose: this.startExtension() },
95-
// );
96-
9793
this.activateAll();
9894
this.startExtension();
9995
}
10096

101-
// public startExtension(): any {
102-
// this.activateAll();
103-
// this.activateExtensionAnalyzeActions();
104-
// }
105-
10697
}
10798

10899
export default DeepCodeExtension;

src/deepcode/constants/commands.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// vscode commands used in extension work
2-
// old "_extensions.manage" is deprecated;
32
export const VSCODE_GO_TO_SETTINGS_COMMAND = "workbench.action.openSettings";
43
export const VSCODE_ADD_COMMENT_COMMAND = "editor.action.addCommentLine";
54

src/deepcode/constants/views.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ export const DEEPCODE_VIEW_SUPPORT = "deepcode.views.support";
22
export const DEEPCODE_VIEW_PROGRESS = "deepcode.views.progress";
33
export const DEEPCODE_VIEW_ANALYSIS = "deepcode.views.analysis";
44

5+
// Having multiple boolean contexts instead of a single context
6+
// with multiple values helps us to avoid flickering UI.
57
export const DEEPCODE_CONTEXT = {
68
LOGGEDIN: "loggedIn",
79
APPROVED: "uploadApproved",
10+
ANALYZING: "workspaceFound",
811
COMPLETED: "analysisCompleted",
912
ERROR: "error",
1013
};

src/deepcode/http/requests.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
ServiceAI,
3-
AnalyseRequestDto
4-
} from "@deepcode/tsc";
5-
1+
import { ServiceAI } from "@deepcode/tsc";
62
import { IDE_NAME } from "../constants/general";
73

84
const AI = new ServiceAI();

src/deepcode/lib/modules/BundlesModule.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { BUNDLE_EVENTS } from "../../constants/events";
99
import LoginModule from "../../lib/modules/LoginModule";
1010
import { setContext } from "../../utils/vscodeCommandsUtils";
1111
import { DEEPCODE_ANALYSIS_STATUS, DEEPCODE_CONTEXT } from "../../constants/views";
12+
import { errorsLogs } from "../../messages/errorsServerLogMessages";
1213

1314
abstract class BundlesModule extends LoginModule
1415
implements DeepCode.BundlesModuleInterface {
@@ -141,25 +142,30 @@ abstract class BundlesModule extends LoginModule
141142
}
142143

143144
public async performBundlesActions(path: string): Promise<void> {
145+
setContext(DEEPCODE_CONTEXT.COMPLETED, false);
144146
if (!Object.keys(this.serverFilesFilterList).length) {
145147
await this.createFilesFilterList();
146148
this.filesWatcher.activate(this);
147149

148150
if (!Object.keys(this.serverFilesFilterList).length) {
151+
this.processError(new Error(errorsLogs.filtersFiles), {
152+
message: errorsLogs.filtersFiles,
153+
data: {
154+
filters: this.serverFilesFilterList
155+
}
156+
});
149157
return;
150158
}
151159
}
152160

153-
setContext(DEEPCODE_CONTEXT.COMPLETED, false);
154161
if (!this.token || !this.uploadApproved) {
155162
await this.checkSession();
156163
await this.checkApproval();
157164
return;
158165
}
159166

160167
this.files = await this.startCollectingFiles(path, this.serverFilesFilterList);
161-
console.log("this.files",this.files);
162-
168+
163169
this.serviceAI.on(BUNDLE_EVENTS.buildBundleProgress, (processed: number, total: number) => {
164170
this.onBuildBundleProgress(processed, total);
165171
});
@@ -268,21 +274,22 @@ abstract class BundlesModule extends LoginModule
268274
try {
269275
const workspaceFolders: readonly vscode.WorkspaceFolder[] | undefined = vscode.workspace.workspaceFolders;
270276
if (!workspaceFolders || !workspaceFolders.length) {
271-
setContext(DEEPCODE_CONTEXT.COMPLETED, true);
277+
setContext(DEEPCODE_CONTEXT.ANALYZING, false);
272278
return;
273279
}
274280

275281
this.createWorkspacesList(workspaceFolders);
276282

277283
if (this.workspacesPaths.length) {
284+
setContext(DEEPCODE_CONTEXT.ANALYZING, true);
278285
this.updateCurrentWorkspacePath(this.workspacesPaths[0]);
279286

280287
await this.updateHashesBundles();
281288
for await (const path of this.workspacesPaths) {
282289
await this.performBundlesActions(path);
283290
}
284291
} else {
285-
setContext(DEEPCODE_CONTEXT.COMPLETED, true);
292+
setContext(DEEPCODE_CONTEXT.ANALYZING, false);
286293
}
287294
} catch(err) {
288295
await this.processError(err);

src/deepcode/utils/packageUtils.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,12 @@ import {
99
import { DCIGNORE_FILENAME, GITIGNORE_FILENAME, EXCLUDED_NAMES } from "../constants/filesConstants";
1010
import { ALLOWED_PAYLOAD_SIZE } from "../constants/general";
1111

12-
// let filesProgress = { processed: 0, total: 0 };
13-
14-
// The file limit was hardcoded to 2mb but seems to be a function of ALLOWED_PAYLOAD_SIZE
15-
// TODO what exactly is transmitted eventually and what is a good exact limit?
16-
const SAFE_PAYLOAD_SIZE = ALLOWED_PAYLOAD_SIZE / 2; // safe size for requests0
12+
const SAFE_PAYLOAD_SIZE = ALLOWED_PAYLOAD_SIZE / 2;
1713

1814
interface ProgressInterface {
1915
onProgress: (value: number) => void,
2016
percentDone?: number;
21-
multiplier?: number,
22-
// filesProcessed: number;
23-
// totalFiles: number;
24-
// percentDone: number;
25-
// progressWindow: Progress<{ increment: number; message: string }>;
17+
multiplier?: number;
2618
}
2719

2820
interface CreateListOfFiles {

src/deepcode/utils/vscodeCommandsUtils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const startDeepCodeCommand = (): void => {
1616
};
1717

1818
export function setContext(key: string, value: unknown) {
19+
console.log("DeepCode context",key, value);
1920
vscode.commands.executeCommand('setContext', `${DEEPCODE_CONTEXT_PREFIX}${key}`, value);
2021
};
2122

src/deepcode/view/IssueProvider.ts

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import DeepCode from "../../interfaces/DeepCodeInterfaces";
21
import { Uri, Range, Diagnostic } from 'vscode';
32
import { NodeProvider } from './NodeProvider'
43
import { Node } from './Node'
@@ -10,15 +9,44 @@ interface ISeverityCounts {
109
}
1110

1211
export class IssueProvider extends NodeProvider {
12+
getSymbolTextSpacing(): string {
13+
return " ";
14+
}
15+
16+
getSuperscriptNumber(n: number): string {
17+
let res: string = "";
18+
const nDigits = Math.round(n).toString().split('');
19+
const digitMap: { [digit: string]: string } = {
20+
'0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴',
21+
'5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹',
22+
}
23+
for (let d of nDigits) res += digitMap[d] || "";
24+
return res;
25+
}
26+
27+
getSeveritySymbol(severity: number): string {
28+
return {
29+
[DEEPCODE_SEVERITIES.error]: "❌",
30+
[DEEPCODE_SEVERITIES.warning]: "⚠️",
31+
[DEEPCODE_SEVERITIES.information]: "ℹ️",
32+
}[severity] || "💡";
33+
}
34+
1335
getIssueText(text: string, severity: number): string {
14-
return "(" + severity + ") " + text;
36+
return `${this.getSeveritySymbol(severity)}${this.getSymbolTextSpacing()}${text}`;
1537
}
1638

1739
getFileText(text: string, counts: ISeverityCounts ): string {
18-
return "[" + counts[DEEPCODE_SEVERITIES.error]
19-
+ "|" + counts[DEEPCODE_SEVERITIES.warning]
20-
+ "|" + counts[DEEPCODE_SEVERITIES.information]
21-
+ "] " + text;
40+
let res :string = "";
41+
for (let s of [
42+
DEEPCODE_SEVERITIES.error,
43+
DEEPCODE_SEVERITIES.warning,
44+
DEEPCODE_SEVERITIES.information,
45+
]) {
46+
if (counts[s]) res += `${this.getSeveritySymbol(s)}${this.getSuperscriptNumber(counts[s])} `;
47+
}
48+
res += `${this.getSymbolTextSpacing()}${text}`;
49+
return res;
2250
}
2351

2452
getRootChildren(): Node[] {

src/deepcode/view/Node.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Node extends TreeItem {
2828
if (!desc && options.issue) {
2929
desc = options.issue.uri.path.split('/').pop() || "";
3030
if (options.issue.range) {
31-
desc += "[" + (options.issue.range.start.line + 1) + ",";
31+
desc += "[" + (options.issue.range.start.line + 1) + ", ";
3232
desc += (options.issue.range.start.character + 1) + "]";
3333
}
3434
}
@@ -42,7 +42,10 @@ export class Node extends TreeItem {
4242
title: '',
4343
arguments: [options.issue.uri, options.issue.range],
4444
});
45-
this.resourceUri = (options.link && Uri.parse(options.link)) || (options.issue && options.issue.uri);
45+
// Not using `options.issue.uri` to avoid default file decorators (see Explorer tab)
46+
// However, as of August 2020, there is still no way to manually decorate tree items
47+
// https://github.com/microsoft/vscode/issues/47502
48+
this.resourceUri = options.link ? Uri.parse(options.link) : undefined;
4649
this.parent = options.parent;
4750
this.children = options.children;
4851
}

0 commit comments

Comments
 (0)