Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Extension/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ export function initializeTemporaryCommandRegistrar(): void {
tempCommandRegistrar = new TemporaryCommandRegistrar();
}

export function geTemporaryCommandRegistrarInstance(): TemporaryCommandRegistrar {
export function getTemporaryCommandRegistrarInstance(): TemporaryCommandRegistrar {
return tempCommandRegistrar;
}
55 changes: 31 additions & 24 deletions Extension/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import * as Telemetry from './telemetry';
import * as util from './common';
import * as vscode from 'vscode';

import { geTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar} from './commands';
import { getTemporaryCommandRegistrarInstance, initializeTemporaryCommandRegistrar } from './commands';
import { PlatformInformation } from './platform';
import { PackageManager, PackageManagerError, PackageManagerWebResponseError, IPackage } from './packageManager';
import { PersistentState } from './LanguageServer/persistentState';
import { initializeInstallationInformation, getInstallationInformationInstance, InstallationInformation , setInstallationStage } from './installationInformation';
import { initializeInstallationInformation, getInstallationInformationInstance, InstallationInformation, setInstallationStage } from './installationInformation';

const releaseNotesVersion: number = 3;

Expand All @@ -44,15 +44,18 @@ export function deactivate(): Thenable<void> {
async function processRuntimeDependencies(): Promise<void> {
const installLockExists: boolean = await util.checkInstallLockFile();

// Offline Scenario: Lock file exists but package.json has not had its activationEvents rewritten.
if (installLockExists) {
// Offline Scenario: Lock file exists but package.json has not had its activationEvents rewritten.
if (util.packageJson.activationEvents && util.packageJson.activationEvents.length == 1) {
try {
await offlineInstallation();
} catch (error) {
vscode.window.showErrorMessage('The installation of the C/C++ extension failed. Please see the output window for more information.');
util.getOutputChannel().show();
}
// The extension have been installed and activated before.
} else {
await finalizeExtensionActivation();
}
// No lock file, need to download and install dependencies.
} else {
Expand All @@ -67,7 +70,7 @@ async function processRuntimeDependencies(): Promise<void> {
async function offlineInstallation(): Promise<void> {
setInstallationStage('getPlatformInfo');
const info: PlatformInformation = await PlatformInformation.GetPlatformInformation();

setInstallationStage('makeBinariesExecutable');
await makeBinariesExecutable();

Expand All @@ -84,7 +87,7 @@ async function offlineInstallation(): Promise<void> {
async function onlineInstallation(): Promise<void> {
setInstallationStage('getPlatformInfo');
const info: PlatformInformation = await PlatformInformation.GetPlatformInformation();

await downloadAndInstallPackages(info);

setInstallationStage('makeBinariesExecutable');
Expand Down Expand Up @@ -156,7 +159,7 @@ function touchInstallLockFile(): Promise<void> {
}

function handleError(error: any): void {
let installationInformation: InstallationInformation = getInstallationInformationInstance();
let installationInformation: InstallationInformation = getInstallationInformationInstance();
installationInformation.hasError = true;
installationInformation.telemetryProperties['stage'] = installationInformation.stage;
let errorMessage: string;
Expand Down Expand Up @@ -211,7 +214,7 @@ function handleError(error: any): void {
}

function sendTelemetry(info: PlatformInformation): boolean {
let installBlob: InstallationInformation = getInstallationInformationInstance();
let installBlob: InstallationInformation = getInstallationInformationInstance();
const success: boolean = !installBlob.hasError;

installBlob.telemetryProperties['success'] = success.toString();
Expand Down Expand Up @@ -250,27 +253,31 @@ async function postInstall(info: PlatformInformation): Promise<void> {
if (!installSuccess) {
return Promise.reject<void>("");
} else {
const cpptoolsJsonFile: string = util.getExtensionFilePath("cpptools.json");

try {
const exists: boolean = await util.checkFileExists(cpptoolsJsonFile);
if (exists) {
const cpptoolsString: string = await util.readFileText(cpptoolsJsonFile);
await cpptoolsJsonUtils.processCpptoolsJson(cpptoolsString);
}
} catch (error) {
// Ignore any cpptoolsJsonFile errors
}

geTemporaryCommandRegistrarInstance().activateLanguageServer();

// Notify user's if debugging may not be supported on their OS.
util.checkDistro(info);

// Redownload cpptools.json after activation so it's not blocked.
// It'll be used after the extension reloads.
return cpptoolsJsonUtils.downloadCpptoolsJsonPkg();
return finalizeExtensionActivation();
}
}

async function finalizeExtensionActivation(): Promise<void> {
const cpptoolsJsonFile: string = util.getExtensionFilePath("cpptools.json");

try {
const exists: boolean = await util.checkFileExists(cpptoolsJsonFile);
if (exists) {
const cpptoolsString: string = await util.readFileText(cpptoolsJsonFile);
await cpptoolsJsonUtils.processCpptoolsJson(cpptoolsString);
}
} catch (error) {
// Ignore any cpptoolsJsonFile errors
}

getTemporaryCommandRegistrarInstance().activateLanguageServer();

// Redownload cpptools.json after activation so it's not blocked.
// It'll be used after the extension reloads.
return cpptoolsJsonUtils.downloadCpptoolsJsonPkg();
}

function rewriteManifest(): Promise<void> {
Expand Down