From 6a1b66cb28b89e0c6706875fedd9fb70cf2ad850 Mon Sep 17 00:00:00 2001 From: Elaheh Rashedi Date: Mon, 20 Apr 2020 13:19:06 -0700 Subject: [PATCH 01/11] check offline/insiders VSIX --- Extension/src/common.ts | 27 +++++++++++++++++++++++++++ Extension/src/main.ts | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 712197b08..0444803b9 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -534,6 +534,33 @@ export function checkInstallLockFile(): Promise { return checkFileExists(getInstallLockPath()); } +/** Get the platform that the installed binaries belong to.*/ +export function getInstalledBinaryPlatform(): Promise { + return new Promise(async (resolve, reject) => { + // the debugAdapters folder is utilized to identify the platform + const path_to_check: string = getExtensionFilePath("debugAdapters"); + let installedPlatform: string = ""; + if (checkDirectoryExists(path_to_check)) { + const files: string[] = await readDir(path_to_check); + installedPlatform = "win32"; + if (files !== undefined) { + (files).forEach((element: string) => { + if (element.includes(".osx")) { + installedPlatform = "darwin"; + } else if (element.includes("linux-x86_64")) { + installedPlatform = "linux"; + } else if (element.includes("linux-x86")) { + installedPlatform = "linux32"; + } + }); + } + resolve (installedPlatform); + } else { + reject(installedPlatform); + } + }); +} + /** Reads the content of a text file */ export function readFileText(filePath: string, encoding: string = "utf8"): Promise { return new Promise((resolve, reject) => { diff --git a/Extension/src/main.ts b/Extension/src/main.ts index 41f1b338f..be6099016 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -48,6 +48,24 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Mon, 20 Apr 2020 15:57:36 -0700 Subject: [PATCH 02/11] draft --- Extension/src/githubAPI.ts | 4 ++-- Extension/src/main.ts | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Extension/src/githubAPI.ts b/Extension/src/githubAPI.ts index 2d77a888a..372cb7407 100644 --- a/Extension/src/githubAPI.ts +++ b/Extension/src/githubAPI.ts @@ -34,7 +34,7 @@ interface Build { * @param vsixName The name of the VSIX to search for * @return The download URL of the VSIX */ -function getVsixDownloadUrl(build: Build, vsixName: string): string { +export function getVsixDownloadUrl(build: Build, vsixName: string): string { const asset: Asset | undefined = build.assets.find(asset => asset.name === vsixName); const downloadUrl: string | null = (asset) ? asset.browser_download_url : null; if (!downloadUrl) { @@ -95,7 +95,7 @@ function isArrayOfBuilds(input: any): input is Build[] { * @param info Information about the user's operating system. * @return VSIX filename for the extension's releases matched to the user's platform. */ -function vsixNameForPlatform(info: PlatformInformation): string { +export function vsixNameForPlatform(info: PlatformInformation): string { const vsixName: string | undefined = function(platformInfo): string | undefined { switch (platformInfo.platform) { case 'win32': return 'cpptools-win32.vsix'; diff --git a/Extension/src/main.ts b/Extension/src/main.ts index be6099016..dd174001c 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -22,6 +22,7 @@ import { getInstallationInformation, InstallationInformation, setInstallationSta import { Logger, getOutputChannelLogger, showOutputChannel } from './logger'; import { CppTools1, NullCppTools } from './cppTools1'; import { CppSettings } from './LanguageServer/settings'; +import { vsixNameForPlatform, getVsixDownloadUrl } from './githubAPI'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -51,14 +52,16 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Tue, 21 Apr 2020 13:54:35 -0700 Subject: [PATCH 03/11] add offline url, modify warning message --- Extension/src/common.ts | 42 +++++++++++++++++--------------------- Extension/src/githubAPI.ts | 3 +++ Extension/src/main.ts | 23 ++++++++------------- Extension/src/platform.ts | 10 +++++++++ 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 0444803b9..14bbe4ea8 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -535,30 +535,26 @@ export function checkInstallLockFile(): Promise { } /** Get the platform that the installed binaries belong to.*/ -export function getInstalledBinaryPlatform(): Promise { - return new Promise(async (resolve, reject) => { - // the debugAdapters folder is utilized to identify the platform - const path_to_check: string = getExtensionFilePath("debugAdapters"); - let installedPlatform: string = ""; - if (checkDirectoryExists(path_to_check)) { - const files: string[] = await readDir(path_to_check); - installedPlatform = "win32"; - if (files !== undefined) { - (files).forEach((element: string) => { - if (element.includes(".osx")) { - installedPlatform = "darwin"; - } else if (element.includes("linux-x86_64")) { - installedPlatform = "linux"; - } else if (element.includes("linux-x86")) { - installedPlatform = "linux32"; - } - }); - } - resolve (installedPlatform); - } else { - reject(installedPlatform); +export async function getInstalledBinaryPlatform(): Promise { + // the debugAdapters folder is utilized to identify the platform + const path_to_check: string = getExtensionFilePath("debugAdapters"); + let installedPlatform: string = ""; + if (checkDirectoryExists(path_to_check)) { + const files: string[] = await readDir(path_to_check); + installedPlatform = "win32"; + if (files !== undefined) { + (files).forEach((element: string) => { + if (element.includes(".osx")) { + installedPlatform = "darwin"; + } else if (element.includes("linux-x86_64")) { + installedPlatform = "linux"; + } else if (element.includes("linux-x86")) { + installedPlatform = "linux32"; + } + }); } - }); + } + return installedPlatform; } /** Reads the content of a text file */ diff --git a/Extension/src/githubAPI.ts b/Extension/src/githubAPI.ts index 372cb7407..0d901d7c2 100644 --- a/Extension/src/githubAPI.ts +++ b/Extension/src/githubAPI.ts @@ -43,6 +43,9 @@ export function getVsixDownloadUrl(build: Build, vsixName: string): string { return downloadUrl; } +export function getOfflineDownloadUrl(): string { + return "https://github.com/microsoft/vscode-cpptools/releases"; +} /** * Determine whether an object is of type Asset. * @param input Incoming object. diff --git a/Extension/src/main.ts b/Extension/src/main.ts index dd174001c..051a8018a 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -16,13 +16,13 @@ import { PersistentState } from './LanguageServer/persistentState'; import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools'; import { getTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar } from './commands'; -import { PlatformInformation } from './platform'; +import { PlatformInformation, GetOsName } from './platform'; import { PackageManager, PackageManagerError, IPackage, VersionsMatch, ArchitecturesMatch, PlatformsMatch } from './packageManager'; import { getInstallationInformation, InstallationInformation, setInstallationStage, setInstallationType, InstallationType } from './installationInformation'; import { Logger, getOutputChannelLogger, showOutputChannel } from './logger'; import { CppTools1, NullCppTools } from './cppTools1'; import { CppSettings } from './LanguageServer/settings'; -import { vsixNameForPlatform, getVsixDownloadUrl } from './githubAPI'; +import { vsixNameForPlatform, getOfflineDownloadUrl } from './githubAPI'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -50,21 +50,16 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Mon, 20 Apr 2020 13:19:06 -0700 Subject: [PATCH 04/11] check offline/insiders VSIX --- Extension/src/common.ts | 27 +++++++++++++++++++++++++++ Extension/src/main.ts | 18 ++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 712197b08..0444803b9 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -534,6 +534,33 @@ export function checkInstallLockFile(): Promise { return checkFileExists(getInstallLockPath()); } +/** Get the platform that the installed binaries belong to.*/ +export function getInstalledBinaryPlatform(): Promise { + return new Promise(async (resolve, reject) => { + // the debugAdapters folder is utilized to identify the platform + const path_to_check: string = getExtensionFilePath("debugAdapters"); + let installedPlatform: string = ""; + if (checkDirectoryExists(path_to_check)) { + const files: string[] = await readDir(path_to_check); + installedPlatform = "win32"; + if (files !== undefined) { + (files).forEach((element: string) => { + if (element.includes(".osx")) { + installedPlatform = "darwin"; + } else if (element.includes("linux-x86_64")) { + installedPlatform = "linux"; + } else if (element.includes("linux-x86")) { + installedPlatform = "linux32"; + } + }); + } + resolve (installedPlatform); + } else { + reject(installedPlatform); + } + }); +} + /** Reads the content of a text file */ export function readFileText(filePath: string, encoding: string = "utf8"): Promise { return new Promise((resolve, reject) => { diff --git a/Extension/src/main.ts b/Extension/src/main.ts index 41f1b338f..be6099016 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -48,6 +48,24 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Mon, 20 Apr 2020 15:57:36 -0700 Subject: [PATCH 05/11] draft --- Extension/src/githubAPI.ts | 4 ++-- Extension/src/main.ts | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Extension/src/githubAPI.ts b/Extension/src/githubAPI.ts index ee6a5725a..d925e8843 100644 --- a/Extension/src/githubAPI.ts +++ b/Extension/src/githubAPI.ts @@ -35,7 +35,7 @@ export interface Build { * @param vsixName The name of the VSIX to search for * @return The download URL of the VSIX */ -function getVsixDownloadUrl(build: Build, vsixName: string): string { +export function getVsixDownloadUrl(build: Build, vsixName: string): string { const asset: Asset | undefined = build.assets.find(asset => asset.name === vsixName); const downloadUrl: string | null = (asset) ? asset.browser_download_url : null; if (!downloadUrl) { @@ -96,7 +96,7 @@ function isArrayOfBuilds(input: any): input is Build[] { * @param info Information about the user's operating system. * @return VSIX filename for the extension's releases matched to the user's platform. */ -function vsixNameForPlatform(info: PlatformInformation): string { +export function vsixNameForPlatform(info: PlatformInformation): string { const vsixName: string | undefined = function(platformInfo): string | undefined { switch (platformInfo.platform) { case 'win32': return 'cpptools-win32.vsix'; diff --git a/Extension/src/main.ts b/Extension/src/main.ts index be6099016..dd174001c 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -22,6 +22,7 @@ import { getInstallationInformation, InstallationInformation, setInstallationSta import { Logger, getOutputChannelLogger, showOutputChannel } from './logger'; import { CppTools1, NullCppTools } from './cppTools1'; import { CppSettings } from './LanguageServer/settings'; +import { vsixNameForPlatform, getVsixDownloadUrl } from './githubAPI'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -51,14 +52,16 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Tue, 21 Apr 2020 13:54:35 -0700 Subject: [PATCH 06/11] add offline url, modify warning message --- Extension/src/common.ts | 42 +++++++++++++++++--------------------- Extension/src/githubAPI.ts | 3 +++ Extension/src/main.ts | 23 ++++++++------------- Extension/src/platform.ts | 10 +++++++++ 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 0444803b9..14bbe4ea8 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -535,30 +535,26 @@ export function checkInstallLockFile(): Promise { } /** Get the platform that the installed binaries belong to.*/ -export function getInstalledBinaryPlatform(): Promise { - return new Promise(async (resolve, reject) => { - // the debugAdapters folder is utilized to identify the platform - const path_to_check: string = getExtensionFilePath("debugAdapters"); - let installedPlatform: string = ""; - if (checkDirectoryExists(path_to_check)) { - const files: string[] = await readDir(path_to_check); - installedPlatform = "win32"; - if (files !== undefined) { - (files).forEach((element: string) => { - if (element.includes(".osx")) { - installedPlatform = "darwin"; - } else if (element.includes("linux-x86_64")) { - installedPlatform = "linux"; - } else if (element.includes("linux-x86")) { - installedPlatform = "linux32"; - } - }); - } - resolve (installedPlatform); - } else { - reject(installedPlatform); +export async function getInstalledBinaryPlatform(): Promise { + // the debugAdapters folder is utilized to identify the platform + const path_to_check: string = getExtensionFilePath("debugAdapters"); + let installedPlatform: string = ""; + if (checkDirectoryExists(path_to_check)) { + const files: string[] = await readDir(path_to_check); + installedPlatform = "win32"; + if (files !== undefined) { + (files).forEach((element: string) => { + if (element.includes(".osx")) { + installedPlatform = "darwin"; + } else if (element.includes("linux-x86_64")) { + installedPlatform = "linux"; + } else if (element.includes("linux-x86")) { + installedPlatform = "linux32"; + } + }); } - }); + } + return installedPlatform; } /** Reads the content of a text file */ diff --git a/Extension/src/githubAPI.ts b/Extension/src/githubAPI.ts index d925e8843..e389cc04d 100644 --- a/Extension/src/githubAPI.ts +++ b/Extension/src/githubAPI.ts @@ -44,6 +44,9 @@ export function getVsixDownloadUrl(build: Build, vsixName: string): string { return downloadUrl; } +export function getOfflineDownloadUrl(): string { + return "https://github.com/microsoft/vscode-cpptools/releases"; +} /** * Determine whether an object is of type Asset. * @param input Incoming object. diff --git a/Extension/src/main.ts b/Extension/src/main.ts index dd174001c..051a8018a 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -16,13 +16,13 @@ import { PersistentState } from './LanguageServer/persistentState'; import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools'; import { getTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar } from './commands'; -import { PlatformInformation } from './platform'; +import { PlatformInformation, GetOsName } from './platform'; import { PackageManager, PackageManagerError, IPackage, VersionsMatch, ArchitecturesMatch, PlatformsMatch } from './packageManager'; import { getInstallationInformation, InstallationInformation, setInstallationStage, setInstallationType, InstallationType } from './installationInformation'; import { Logger, getOutputChannelLogger, showOutputChannel } from './logger'; import { CppTools1, NullCppTools } from './cppTools1'; import { CppSettings } from './LanguageServer/settings'; -import { vsixNameForPlatform, getVsixDownloadUrl } from './githubAPI'; +import { vsixNameForPlatform, getOfflineDownloadUrl } from './githubAPI'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -50,21 +50,16 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Tue, 21 Apr 2020 14:03:57 -0700 Subject: [PATCH 07/11] modify warning message --- Extension/src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extension/src/main.ts b/Extension/src/main.ts index 051a8018a..4e457bf86 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -55,7 +55,7 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Fri, 24 Apr 2020 11:29:18 -0700 Subject: [PATCH 08/11] fix reviewers comments --- Extension/src/githubAPI.ts | 7 ++----- Extension/src/main.ts | 11 +++++------ Extension/src/platform.ts | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Extension/src/githubAPI.ts b/Extension/src/githubAPI.ts index e389cc04d..71dc98cc2 100644 --- a/Extension/src/githubAPI.ts +++ b/Extension/src/githubAPI.ts @@ -12,7 +12,7 @@ import * as vscode from 'vscode'; import * as telemetry from './telemetry'; const testingInsidersVsixInstall: boolean = false; // Change this to true to enable testing of the Insiders vsix installation. - +export const releaseDownloadUrl: string = "https://github.com/microsoft/vscode-cpptools/releases"; /** * The object representation of a Build Asset. Each Asset corresponds to information about a release file on GitHub. */ @@ -35,7 +35,7 @@ export interface Build { * @param vsixName The name of the VSIX to search for * @return The download URL of the VSIX */ -export function getVsixDownloadUrl(build: Build, vsixName: string): string { +function getVsixDownloadUrl(build: Build, vsixName: string): string { const asset: Asset | undefined = build.assets.find(asset => asset.name === vsixName); const downloadUrl: string | null = (asset) ? asset.browser_download_url : null; if (!downloadUrl) { @@ -44,9 +44,6 @@ export function getVsixDownloadUrl(build: Build, vsixName: string): string { return downloadUrl; } -export function getOfflineDownloadUrl(): string { - return "https://github.com/microsoft/vscode-cpptools/releases"; -} /** * Determine whether an object is of type Asset. * @param input Incoming object. diff --git a/Extension/src/main.ts b/Extension/src/main.ts index 4e457bf86..6df72f313 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -16,13 +16,13 @@ import { PersistentState } from './LanguageServer/persistentState'; import { CppToolsApi, CppToolsExtension } from 'vscode-cpptools'; import { getTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar } from './commands'; -import { PlatformInformation, GetOsName } from './platform'; +import { PlatformInformation, GetOSName } from './platform'; import { PackageManager, PackageManagerError, IPackage, VersionsMatch, ArchitecturesMatch, PlatformsMatch } from './packageManager'; import { getInstallationInformation, InstallationInformation, setInstallationStage, setInstallationType, InstallationType } from './installationInformation'; import { Logger, getOutputChannelLogger, showOutputChannel } from './logger'; import { CppTools1, NullCppTools } from './cppTools1'; import { CppSettings } from './LanguageServer/settings'; -import { vsixNameForPlatform, getOfflineDownloadUrl } from './githubAPI'; +import { vsixNameForPlatform, releaseDownloadUrl } from './githubAPI'; nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })(); const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @@ -54,12 +54,11 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Sun, 26 Apr 2020 21:30:21 -0700 Subject: [PATCH 09/11] changing the approach to determine the platform --- Extension/src/common.ts | 23 +++++++---------------- Extension/src/main.ts | 2 +- Extension/src/platform.ts | 3 +-- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Extension/src/common.ts b/Extension/src/common.ts index 14bbe4ea8..adc66eed2 100644 --- a/Extension/src/common.ts +++ b/Extension/src/common.ts @@ -535,24 +535,15 @@ export function checkInstallLockFile(): Promise { } /** Get the platform that the installed binaries belong to.*/ -export async function getInstalledBinaryPlatform(): Promise { - // the debugAdapters folder is utilized to identify the platform - const path_to_check: string = getExtensionFilePath("debugAdapters"); +export function getInstalledBinaryPlatform(): string | undefined { + // the LLVM/bin folder is utilized to identify the platform let installedPlatform: string = ""; - if (checkDirectoryExists(path_to_check)) { - const files: string[] = await readDir(path_to_check); + if (checkFileExistsSync(path.join(extensionPath, "LLVM/bin/clang-format.exe"))) { installedPlatform = "win32"; - if (files !== undefined) { - (files).forEach((element: string) => { - if (element.includes(".osx")) { - installedPlatform = "darwin"; - } else if (element.includes("linux-x86_64")) { - installedPlatform = "linux"; - } else if (element.includes("linux-x86")) { - installedPlatform = "linux32"; - } - }); - } + } else if (checkFileExistsSync(path.join(extensionPath, "LLVM/bin/clang-format.darwin"))) { + installedPlatform = "darwin"; + } else if (checkFileExistsSync(path.join(extensionPath, "LLVM/bin/clang-format"))) { + installedPlatform = "linux"; } return installedPlatform; } diff --git a/Extension/src/main.ts b/Extension/src/main.ts index 6df72f313..6b31778ad 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -50,7 +50,7 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Sun, 26 Apr 2020 22:57:28 -0700 Subject: [PATCH 10/11] fixing the integration test --- Extension/src/main.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/Extension/src/main.ts b/Extension/src/main.ts index 75b41cc93..e981cb1cb 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -61,7 +61,6 @@ export async function activate(context: vscode.ExtensionContext): Promise Date: Sun, 26 Apr 2020 23:57:52 -0700 Subject: [PATCH 11/11] testing --- Extension/src/main.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Extension/src/main.ts b/Extension/src/main.ts index e981cb1cb..a085276d2 100644 --- a/Extension/src/main.ts +++ b/Extension/src/main.ts @@ -57,10 +57,11 @@ export async function activate(context: vscode.ExtensionContext): Promise { + if (selection === downloadLink) { + vscode.env.openExternal(vscode.Uri.parse(releaseDownloadUrl)); + } + }); } // Register a protocol handler to serve localized versions of the schema for c_cpp_properties.json