Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 57395fb

Browse files
Merge pull request #170 from microsoft/users/t-xunguy/cpx-components-refactor
Refactor toolbar and actionbar
2 parents 33ad456 + faabb51 commit 57395fb

28 files changed

+256
-279
lines changed

src/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
import * as nls from "vscode-nls";
54
import * as path from "path";
65
import { MessageItem } from "vscode";
6+
import * as nls from "vscode-nls";
77

88
// Debugger Server
99
export const SERVER_INFO = {
@@ -288,7 +288,7 @@ export enum TelemetryEventName {
288288
SIMULATOR_BUTTON_AB = "SIMULATOR.BUTTON.AB",
289289
SIMULATOR_SWITCH = "SIMULATOR.SWITCH",
290290

291-
//Sensors
291+
// Sensors
292292
SIMULATOR_TEMPERATURE_SENSOR = "SIMULATOR.TEMPERATURE",
293293
SIMULATOR_LIGHT_SENSOR = " SIMULATOR.LIGHT",
294294
SIMULATOR_MOTION_SENSOR = "SIMULATOR.MOTION",

src/deviceContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import * as fs from "fs";
77
import * as path from "path";
8-
import * as utils from "./extension_utils/utils";
98
import * as vscode from "vscode";
10-
import { CPXWorkspace } from "./cpxWorkspace";
119
import CONSTANTS, { CPX_CONFIG_FILE } from "./constants";
10+
import { CPXWorkspace } from "./cpxWorkspace";
11+
import * as utils from "./extension_utils/utils";
1212

1313
export class DeviceContext implements vscode.Disposable {
1414
public static getInstance(): DeviceContext {

src/extension.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ import * as cp from "child_process";
55
import * as fs from "fs";
66
import * as open from "open";
77
import * as path from "path";
8-
import * as utils from "./extension_utils/utils";
98
import * as vscode from "vscode";
109
import {
1110
CONFIG,
1211
CONSTANTS,
1312
CPX_CONFIG_FILE,
1413
DialogResponses,
14+
SERVER_INFO,
1515
TelemetryEventName,
16-
WebviewMessages,
17-
SERVER_INFO
16+
WebviewMessages
1817
} from "./constants";
1918
import { CPXWorkspace } from "./cpxWorkspace";
20-
import { SimulatorDebugConfigurationProvider } from "./simulatorDebugConfigurationProvider";
19+
import { DebuggerCommunicationServer } from "./debuggerCommunicationServer";
20+
import * as utils from "./extension_utils/utils";
2121
import { SerialMonitor } from "./serialMonitor";
22+
import { SimulatorDebugConfigurationProvider } from "./simulatorDebugConfigurationProvider";
2223
import TelemetryAI from "./telemetry/telemetryAI";
2324
import { UsbDetector } from "./usbDetector";
24-
import { DebuggerCommunicationServer } from "./debuggerCommunicationServer";
2525

2626
let currentFileAbsPath: string = "";
2727
let currentTextDocument: vscode.TextDocument;
@@ -830,13 +830,13 @@ const updateCurrentFileIfPython = async (
830830
};
831831

832832
const handleButtonPressTelemetry = (buttonState: any) => {
833-
if (buttonState["button_a"] && buttonState["button_b"]) {
833+
if (buttonState.button_a && buttonState.button_b) {
834834
telemetryAI.trackFeatureUsage(TelemetryEventName.SIMULATOR_BUTTON_AB);
835-
} else if (buttonState["button_a"]) {
835+
} else if (buttonState.button_a) {
836836
telemetryAI.trackFeatureUsage(TelemetryEventName.SIMULATOR_BUTTON_A);
837-
} else if (buttonState["button_b"]) {
837+
} else if (buttonState.button_b) {
838838
telemetryAI.trackFeatureUsage(TelemetryEventName.SIMULATOR_BUTTON_B);
839-
} else if (buttonState["switch"]) {
839+
} else if (buttonState.switch) {
840840
telemetryAI.trackFeatureUsage(TelemetryEventName.SIMULATOR_SWITCH);
841841
}
842842
};
@@ -872,9 +872,9 @@ const handleSensorTelemetry = (sensor: string) => {
872872
};
873873

874874
const checkForTelemetry = (sensorState: any) => {
875-
if (sensorState["shake"]) {
875+
if (sensorState.shake) {
876876
handleSensorTelemetry("shake");
877-
} else if (sensorState["touch"]) {
877+
} else if (sensorState.touch) {
878878
handleSensorTelemetry("touch");
879879
}
880880
};

src/extension_utils/dependencyChecker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { CONSTANTS } from "../constants";
21
import * as cp from "child_process";
3-
import * as os from "os";
42
import * as compareVersions from 'compare-versions';
3+
import * as os from "os";
54
import * as util from "util";
5+
import { CONSTANTS } from "../constants";
66
const exec = util.promisify(cp.exec);
77

88
interface IPayloadResponse {

src/extension_utils/utils.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4+
import * as cp from "child_process";
45
import * as fs from "fs";
5-
import * as path from "path";
6+
import * as open from "open";
67
import * as os from "os";
7-
import { DependencyChecker } from "./dependencyChecker";
8-
import { DeviceContext } from "../deviceContext";
8+
import * as path from "path";
9+
import * as util from "util";
910
import * as vscode from "vscode";
1011
import {
1112
CONFIG,
1213
CONSTANTS,
1314
CPX_CONFIG_FILE,
1415
DialogResponses,
15-
USER_CODE_NAMES,
16-
SERVER_INFO
16+
SERVER_INFO,
17+
USER_CODE_NAMES
1718
} from "../constants";
1819
import { CPXWorkspace } from "../cpxWorkspace";
19-
import * as cp from "child_process";
20-
import * as util from "util";
21-
import * as open from "open";
20+
import { DeviceContext } from "../deviceContext";
21+
import { DependencyChecker } from "./dependencyChecker";
22+
2223
const exec = util.promisify(cp.exec);
2324

2425
// tslint:disable-next-line: export-name
@@ -76,7 +77,7 @@ export function tryParseJSON(jsonString: string): any | boolean {
7677
if (jsonObj && typeof jsonObj === "object") {
7778
return jsonObj;
7879
}
79-
} catch (exception) {}
80+
} catch (exception) { }
8081

8182
return false;
8283
}
@@ -305,14 +306,14 @@ export const installPythonDependencies = async (context: vscode.ExtensionContext
305306
let installed: boolean = false;
306307
try {
307308
vscode.window.showInformationMessage(CONSTANTS.INFO.INSTALLING_PYTHON_DEPENDENCIES);
308-
309+
309310
const requirementsPath: string = getPathToScript(context, CONSTANTS.FILESYSTEM.OUTPUT_DIRECTORY, "requirements.txt");
310311

311312
// run command to download dependencies to out/python_libs
312313
const { stdout } = await exec(`${pythonExecutable} -m pip install -r ${requirementsPath} -t ${pathToLibs}`);
313314
console.info(stdout);
314315
installed = true;
315-
316+
316317
vscode.window.showInformationMessage(CONSTANTS.INFO.SUCCESSFUL_INSTALL);
317318
} catch (err) {
318319

src/serialMonitor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
// Credit: A majority of this code was taken from the Visual Studio Code Arduino extension with some modifications to suit our purposes.
55

66
import * as vscode from "vscode";
7+
import CONSTANTS, { DialogResponses, STATUS_BAR_PRIORITY } from "./constants";
8+
import { DeviceContext } from "./deviceContext";
79
import { outChannel } from "./extension";
810
import { logToOutputChannel } from "./extension_utils/utils";
9-
import { DeviceContext } from "./deviceContext";
10-
import CONSTANTS, { STATUS_BAR_PRIORITY, DialogResponses } from "./constants";
1111
import { SerialPortControl } from "./serialPortControl";
1212

1313
export interface ISerialPortDetail {

src/serialPortControl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
// Credit: A majority of this code was taken from the Visual Studio Code Arduino extension with some modifications to suit our purposes.
55

6-
import { CONSTANTS } from "./constants";
76
import * as os from "os";
87
import { OutputChannel } from "vscode";
8+
import { CONSTANTS } from "./constants";
99
import { logToOutputChannel } from "./extension_utils/utils";
1010

1111
interface ISerialPortDetail {

src/simulatorDebugConfigurationProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Licensed under the MIT license.
33

44
import * as vscode from "vscode";
5+
import { CONSTANTS, DialogResponses } from "./constants";
56
import {
6-
validCodeFileName,
7-
getServerPortConfig
7+
getServerPortConfig,
8+
validCodeFileName
89
} from "./extension_utils/utils";
9-
import { CONSTANTS, DialogResponses } from "./constants";
1010

1111
let shouldShowInvalidFileNamePopup: boolean = true;
1212

src/telemetry/getPackageInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as vscode from 'vscode';
21
import * as fs from 'fs'
32
import * as path from 'path';
3+
import * as vscode from 'vscode';
44

55
export interface IPackageJson {
66
name?: string;

src/test/suite/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
// to report the results back to the caller. When the tests are finished, return
1111
// a possible error to the callback or null if none.
1212

13-
import * as path from 'path';
14-
import * as Mocha from 'mocha';
1513
import * as glob from 'glob';
14+
import * as Mocha from 'mocha';
15+
import * as path from 'path';
1616

1717
// tslint:disable-next-line: export-name
1818
export function run(): Promise<void> {

0 commit comments

Comments
 (0)