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

Commit de43ea6

Browse files
committed
Make python a constant
1 parent b812b59 commit de43ea6

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,5 +465,8 @@ export const HELPER_FILES = {
465465
export const GLOBAL_ENV_VARS = {
466466
PYTHON: "python",
467467
};
468+
export const LANGUAGE_VARS = {
469+
PYTHON: { ID: "python", FILE_ENDS: ".py" },
470+
};
468471

469472
export default CONSTANTS;

src/extension.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
HELPER_FILES,
1919
SERVER_INFO,
2020
TelemetryEventName,
21+
LANGUAGE_VARS,
2122
} from "./constants";
2223
import { CPXWorkspace } from "./cpxWorkspace";
2324
import { DebugAdapterFactory } from "./debugger/debugAdapterFactory";
@@ -387,7 +388,10 @@ export async function activate(context: vscode.ExtensionContext) {
387388

388389
// tslint:disable-next-line: ban-comma-operator
389390
vscode.workspace
390-
.openTextDocument({ content: file, language: "python" })
391+
.openTextDocument({
392+
content: file,
393+
language: LANGUAGE_VARS.PYTHON.ID,
394+
})
391395
.then((template: vscode.TextDocument) => {
392396
vscode.window.showTextDocument(template, 1, false).then(() => {
393397
openWebview();
@@ -516,7 +520,7 @@ export async function activate(context: vscode.ExtensionContext) {
516520
if (
517521
!fileSelectionService
518522
.getCurrentTextDocument()
519-
.fileName.endsWith(".py")
523+
.fileName.endsWith(LANGUAGE_VARS.PYTHON.FILE_ENDS)
520524
) {
521525
utils.logToOutputChannel(
522526
outChannel,
@@ -654,8 +658,6 @@ export async function activate(context: vscode.ExtensionContext) {
654658
);
655659

656660
const deployCode = async (device: string) => {
657-
console.info(`Sending code to ${device}`);
658-
659661
utils.logToOutputChannel(
660662
outChannel,
661663
CONSTANTS.INFO.DEPLOY_DEVICE,
@@ -944,7 +946,7 @@ export async function activate(context: vscode.ExtensionContext) {
944946
debuggerCommunicationService
945947
);
946948
vscode.debug.registerDebugAdapterTrackerFactory(
947-
"python",
949+
LANGUAGE_VARS.PYTHON.ID,
948950
debugAdapterFactory
949951
);
950952
// On Debug Session Start: Init comunication

src/service/fileSelectionService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as vscode from "vscode";
22
import { VSCODE_MESSAGES_TO_WEBVIEW } from "../view/constants";
33
import { DeviceSelectionService } from "./deviceSelectionService";
44
import { MessagingService } from "./messagingService";
5+
import { LANGUAGE_VARS } from "../constants";
56

67
export class FileSelectionService {
78
private currentFileAbsPath: string = "";
@@ -84,7 +85,7 @@ export class FileSelectionService {
8485
private getActivePythonFile = () => {
8586
const editors: vscode.TextEditor[] = vscode.window.visibleTextEditors;
8687
const activeEditor = editors.find(
87-
editor => editor.document.languageId === "python"
88+
editor => editor.document.languageId === LANGUAGE_VARS.PYTHON.ID
8889
);
8990
if (activeEditor) {
9091
this.currentTextDocument = activeEditor.document;

0 commit comments

Comments
 (0)