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

Commit

Permalink
Make python a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
xnkevinnguyen committed Mar 5, 2020
1 parent b812b59 commit de43ea6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,5 +465,8 @@ export const HELPER_FILES = {
export const GLOBAL_ENV_VARS = {
PYTHON: "python",
};
export const LANGUAGE_VARS = {
PYTHON: { ID: "python", FILE_ENDS: ".py" },
};

export default CONSTANTS;
12 changes: 7 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
HELPER_FILES,
SERVER_INFO,
TelemetryEventName,
LANGUAGE_VARS,
} from "./constants";
import { CPXWorkspace } from "./cpxWorkspace";
import { DebugAdapterFactory } from "./debugger/debugAdapterFactory";
Expand Down Expand Up @@ -387,7 +388,10 @@ export async function activate(context: vscode.ExtensionContext) {

// tslint:disable-next-line: ban-comma-operator
vscode.workspace
.openTextDocument({ content: file, language: "python" })
.openTextDocument({
content: file,
language: LANGUAGE_VARS.PYTHON.ID,
})
.then((template: vscode.TextDocument) => {
vscode.window.showTextDocument(template, 1, false).then(() => {
openWebview();
Expand Down Expand Up @@ -516,7 +520,7 @@ export async function activate(context: vscode.ExtensionContext) {
if (
!fileSelectionService
.getCurrentTextDocument()
.fileName.endsWith(".py")
.fileName.endsWith(LANGUAGE_VARS.PYTHON.FILE_ENDS)
) {
utils.logToOutputChannel(
outChannel,
Expand Down Expand Up @@ -654,8 +658,6 @@ export async function activate(context: vscode.ExtensionContext) {
);

const deployCode = async (device: string) => {
console.info(`Sending code to ${device}`);

utils.logToOutputChannel(
outChannel,
CONSTANTS.INFO.DEPLOY_DEVICE,
Expand Down Expand Up @@ -944,7 +946,7 @@ export async function activate(context: vscode.ExtensionContext) {
debuggerCommunicationService
);
vscode.debug.registerDebugAdapterTrackerFactory(
"python",
LANGUAGE_VARS.PYTHON.ID,
debugAdapterFactory
);
// On Debug Session Start: Init comunication
Expand Down
3 changes: 2 additions & 1 deletion src/service/fileSelectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as vscode from "vscode";
import { VSCODE_MESSAGES_TO_WEBVIEW } from "../view/constants";
import { DeviceSelectionService } from "./deviceSelectionService";
import { MessagingService } from "./messagingService";
import { LANGUAGE_VARS } from "../constants";

export class FileSelectionService {
private currentFileAbsPath: string = "";
Expand Down Expand Up @@ -84,7 +85,7 @@ export class FileSelectionService {
private getActivePythonFile = () => {
const editors: vscode.TextEditor[] = vscode.window.visibleTextEditors;
const activeEditor = editors.find(
editor => editor.document.languageId === "python"
editor => editor.document.languageId === LANGUAGE_VARS.PYTHON.ID
);
if (activeEditor) {
this.currentTextDocument = activeEditor.document;
Expand Down

0 comments on commit de43ea6

Please sign in to comment.