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
103 changes: 27 additions & 76 deletions Extension/src/LanguageServer/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,75 +423,16 @@ export function registerCommands(enabled: boolean): void {
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.RestartIntelliSenseForFile', enabled ? onRestartIntelliSenseForFile : onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.GenerateDoxygenComment', enabled ? onGenerateDoxygenComment : onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.CreateDeclarationOrDefinition', enabled ? onCreateDeclarationOrDefinition : onDisabledCommand));
// ---------------- Wrappers -------------
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.ConfigurationSelectUI_Telemetry', enabled ?
() => {
logForUIExperiment("ConfigurationSelect");
onSelectConfiguration();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.RescanWorkspaceUI_Telemetry', enabled ?
() => {
logForUIExperiment("RescanWorkspace");
onRescanWorkspace();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.ShowIdleCodeAnalysisCommandsUI_Telemetry', enabled ?
() => {
logForUIExperiment("ShowIdleCodeAnalysisCommands");
onShowIdleCodeAnalysisCommands();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.ShowActiveCodeAnalysisCommandsUI_Telemetry', enabled ?
() => {
logForUIExperiment("ShowActiveCodeAnalysisCommands");
onShowActiveCodeAnalysisCommands();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.PauseParsingUI_Telemetry', enabled ?
() => {
logForUIExperiment("ParsingCommands");
onPauseParsing();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.ResumeParsingUI_Telemetry', enabled ?
() => {
logForUIExperiment("ParsingCommands");
onResumeParsing();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.CheckForCompilerUI_Telemetry', enabled ?
() => {
logForUIExperiment("CheckForCompiler");
onCheckForCompiler();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.RestartIntelliSenseForFileUI_Telemetry', enabled ?
() => {
logForUIExperiment("RestartIntelliSenseForFile");
onRestartIntelliSenseForFile();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.ShowReferencesProgressUI_Telemetry', enabled ?
() => {
logForUIExperiment("ShowReferencesProgress");
onShowReferencesProgress();
}
: onDisabledCommand));
commandDisposables.push(vscode.commands.registerCommand('C_Cpp.ShowParsingCommandsUI_Telemetry', enabled ?
() => {
logForUIExperiment("ParsingCommands");
onShowParsingCommands();
}
: onDisabledCommand));
// ----------------------------------------
}

async function logForUIExperiment(command: string): Promise<void> {
async function logForUIExperiment(command: string, sender?: any): Promise<void> {
const settings: CppSettings = new CppSettings((vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) ? vscode.workspace.workspaceFolders[0]?.uri : undefined);
const isNewUI: string = ui.isNewUI.toString();
const isOverridden: string = (settings.experimentalFeatures ?? false).toString();
telemetry.logLanguageServerEvent(`experiment${command}`, { newUI: isNewUI, uiOverride: isOverridden });
const properties: {[key: string]: string} = {
newUI: ui.isNewUI.toString(),
uiOverride: (settings.experimentalFeatures ?? false).toString(),
sender: util.isString(sender) ? sender : 'commandPalette'
};
telemetry.logLanguageServerEvent(`experiment${command}`, properties);
}

function onDisabledCommand(): void {
Expand All @@ -506,7 +447,8 @@ function onDisabledCommand(): void {
vscode.window.showWarningMessage(message);
}

function onRestartIntelliSenseForFile(): void {
function onRestartIntelliSenseForFile(sender?: any): void {
logForUIExperiment("RestartIntelliSenseForFile", sender);
const activeEditor: vscode.TextEditor | undefined = vscode.window.activeTextEditor;
if (!activeEditor || !activeEditor.document || activeEditor.document.uri.scheme !== "file" ||
(activeEditor.document.languageId !== "c" && activeEditor.document.languageId !== "cpp" && activeEditor.document.languageId !== "cuda-cpp")) {
Expand Down Expand Up @@ -590,7 +532,8 @@ function selectDefaultCompiler(): void {
clients.ActiveClient.promptSelectCompiler(true);
}

function onSelectConfiguration(): void {
function onSelectConfiguration(sender?: any): void {
logForUIExperiment("ConfigurationSelect", sender);
if (!isFolderOpen()) {
vscode.window.showInformationMessage(localize("configuration.select.first", 'Open a folder first to select a configuration.'));
} else {
Expand Down Expand Up @@ -656,7 +599,8 @@ function onGoToPrevDirectiveInGroup(): void {
client.handleGoToDirectiveInGroup(false);
}

function onCheckForCompiler(): void {
function onCheckForCompiler(sender?: any): void {
logForUIExperiment("CheckForCompiler", sender);
const client: Client = getActiveClient();
client.handleCheckForCompiler();
}
Expand Down Expand Up @@ -769,11 +713,13 @@ function onToggleDimInactiveRegions(): void {
settings.update<boolean>("dimInactiveRegions", !settings.dimInactiveRegions);
}

function onPauseParsing(): void {
function onPauseParsing(sender?: any): void {
logForUIExperiment("ParsingCommands", sender);
clients.ActiveClient.pauseParsing();
}

function onResumeParsing(): void {
function onResumeParsing(sender?: any): void {
logForUIExperiment("ParsingCommands", sender);
clients.ActiveClient.resumeParsing();
}

Expand All @@ -789,19 +735,23 @@ function onCancelCodeAnalysis(): void {
clients.ActiveClient.CancelCodeAnalysis();
}

function onShowParsingCommands(): void {
function onShowParsingCommands(sender?: any): void {
logForUIExperiment("ParsingCommands", sender);
clients.ActiveClient.handleShowParsingCommands();
}

function onShowActiveCodeAnalysisCommands(): void {
function onShowActiveCodeAnalysisCommands(sender?: any): void {
logForUIExperiment("ShowActiveCodeAnalysisCommands", sender);
clients.ActiveClient.handleShowActiveCodeAnalysisCommands();
}

function onShowIdleCodeAnalysisCommands(): void {
function onShowIdleCodeAnalysisCommands(sender?: any): void {
logForUIExperiment("ShowIdleCodeAnalysisCommands", sender);
clients.ActiveClient.handleShowIdleCodeAnalysisCommands();
}

function onShowReferencesProgress(): void {
function onShowReferencesProgress(sender?: any): void {
logForUIExperiment("ShowReferencesProgress", sender);
clients.ActiveClient.handleReferencesIcon();
}

Expand Down Expand Up @@ -898,7 +848,8 @@ function onLogDiagnostics(): void {
clients.ActiveClient.logDiagnostics();
}

function onRescanWorkspace(): void {
function onRescanWorkspace(sender?: string): void {
logForUIExperiment("RescanWorkspace", sender);
clients.ActiveClient.rescanFolder();
}

Expand Down
26 changes: 22 additions & 4 deletions Extension/src/LanguageServer/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ interface ConfigurationStatus {
priority: ConfigurationPriority;
}

const commandArguments: string[] = ['oldUI']; // We report the sender of the command

export class OldUI implements UI {
private configStatusBarItem: vscode.StatusBarItem;
private browseEngineStatusBarItem: vscode.StatusBarItem;
Expand Down Expand Up @@ -84,14 +86,22 @@ export class OldUI implements UI {
const configTooltip: string = localize("c.cpp.configuration.tooltip", "C/C++ Configuration");
this.configStatusBarItem = vscode.window.createStatusBarItem("c.cpp.configuration.tooltip", vscode.StatusBarAlignment.Right, 0);
this.configStatusBarItem.name = configTooltip;
this.configStatusBarItem.command = "C_Cpp.ConfigurationSelectUI_Telemetry";
this.configStatusBarItem.command = {
command: "C_Cpp.ConfigurationSelect",
title: configTooltip,
arguments: commandArguments
};
this.configStatusBarItem.tooltip = configTooltip;
this.ShowConfiguration = true;

this.referencesStatusBarItem = vscode.window.createStatusBarItem("c.cpp.references.statusbar", vscode.StatusBarAlignment.Right, 901);
this.referencesStatusBarItem.name = localize("c.cpp.references.statusbar", "C/C++ References Status");
this.referencesStatusBarItem.tooltip = "";
this.referencesStatusBarItem.command = "C_Cpp.ShowReferencesProgressUI_Telemetry";
this.referencesStatusBarItem.command = {
command: "C_Cpp.ShowReferencesProgress",
title: this.referencesStatusBarItem.name,
arguments: commandArguments
};
this.ShowReferencesIcon = false;

this.intelliSenseStatusBarItem = vscode.window.createStatusBarItem("c.cpp.intellisense.statusbar", vscode.StatusBarAlignment.Right, 903);
Expand Down Expand Up @@ -133,7 +143,11 @@ export class OldUI implements UI {

private setIsParsingWorkspacePausable(val: boolean): void {
if (val) {
this.browseEngineStatusBarItem.command = "C_Cpp.ShowParsingCommandsUI_Telemetry";
this.browseEngineStatusBarItem.command = {
command: "C_Cpp.ShowParsingCommands",
title: this.browseEngineStatusBarItem.name ?? '',
arguments: commandArguments
};
} else {
this.browseEngineStatusBarItem.command = undefined;
}
Expand Down Expand Up @@ -189,7 +203,11 @@ export class OldUI implements UI {
this.intelliSenseStatusBarItem.tooltip = (this.isUpdatingIntelliSense ? this.updatingIntelliSenseTooltip : "")
+ (twoStatus ? " | " : "")
+ (val ? this.runningCodeAnalysisTooltip : "");
this.intelliSenseStatusBarItem.command = val ? "C_Cpp.ShowActiveCodeAnalysisCommandsUI_Telemetry" : undefined;
this.intelliSenseStatusBarItem.command = val ? {
command: "C_Cpp.ShowActiveCodeAnalysisCommands",
title: this.intelliSenseStatusBarItem.name ?? '',
arguments: commandArguments
} : undefined;
}

private updateCodeAnalysisTooltip(): void {
Expand Down
Loading