don't cache when empty, don't configure when fullFeatureSet is false (#455)

This commit is contained in:
Garrett Campbell 2023-04-11 14:16:17 -04:00 коммит произвёл GitHub
Родитель 1a481eb839
Коммит 5639198854
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 51 добавлений и 29 удалений

Просмотреть файл

@ -68,11 +68,11 @@ export interface MakefileConfiguration {
// If no particular current configuration is defined in settings, set to 'Default'.
let currentMakefileConfiguration: string;
export function getCurrentMakefileConfiguration(): string { return currentMakefileConfiguration; }
export function setCurrentMakefileConfiguration(configuration: string): void {
export async function setCurrentMakefileConfiguration(configuration: string): Promise<void> {
currentMakefileConfiguration = configuration;
statusBar.setConfiguration(currentMakefileConfiguration);
logger.message(`Setting configuration - ${currentMakefileConfiguration}`);
analyzeConfigureParams();
await analyzeConfigureParams();
}
// Read the current configuration from workspace state, update status bar item
@ -647,9 +647,9 @@ export function setConfigurationBuildLog(name: string): void { configurationBuil
// Analyze the settings of the current makefile configuration and the global workspace settings,
// according to various merging rules and decide what make command and build log
// apply to the current makefile configuration.
function analyzeConfigureParams(): void {
async function analyzeConfigureParams(): Promise<void> {
getBuildLogForConfiguration(currentMakefileConfiguration);
getCommandForConfiguration(currentMakefileConfiguration);
await getCommandForConfiguration(currentMakefileConfiguration);
getProblemMatchersForConfiguration(currentMakefileConfiguration);
}
@ -664,7 +664,7 @@ function getMakefileConfiguration(configuration: string | undefined): MakefileCo
// Helper to find in the array of MakefileConfiguration which command/args correspond to a configuration name.
// Higher level settings (like makefile.makePath, makefile.makefilePath or makefile.makeDirectory)
// also have an additional effect on the final command.
export function getCommandForConfiguration(configuration: string | undefined): void {
export async function getCommandForConfiguration(configuration: string | undefined): Promise<void> {
let makefileConfiguration: MakefileConfiguration | undefined = getMakefileConfiguration(configuration);
let makeParsedPathSettings: path.ParsedPath | undefined = makePath ? path.parse(makePath) : undefined;
@ -816,15 +816,15 @@ export function getCommandForConfiguration(configuration: string | undefined): v
};
telemetry.logEvent("makefileNotFound", telemetryProperties);
vscode.commands.executeCommand('setContext', "makefile:fullFeatureSet", false);
await extension.setFullFeatureSet(false);
disableAllOptionallyVisibleCommands();
} else {
vscode.commands.executeCommand('setContext', "makefile:fullFeatureSet", true);
await extension.setFullFeatureSet(true);
enableOptionallyVisibleCommands();
}
} else {
// If we have a build log, then we want Makefile Tools to be fully active and the UI visible.
vscode.commands.executeCommand('setContext', "makefile:fullFeatureSet", true);
await extension.setFullFeatureSet(true);
enableOptionallyVisibleCommands();
}
}
@ -865,7 +865,7 @@ export function getMakefileConfigurations(): MakefileConfiguration[] { return ma
export function setMakefileConfigurations(configurations: MakefileConfiguration[]): void { makefileConfigurations = configurations; }
// Read make configurations optionally defined by the user in settings: makefile.configurations.
function readMakefileConfigurations(): void {
async function readMakefileConfigurations(): Promise<void> {
let workspaceConfiguration: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration("makefile");
makefileConfigurations = workspaceConfiguration.get<MakefileConfiguration[]>("configurations") || [];
let detectedUnnamedConfigurations: boolean = false;
@ -919,7 +919,7 @@ function readMakefileConfigurations(): void {
if (currentMakefileConfiguration !== "Default" && !makefileConfigurationNames.includes(currentMakefileConfiguration)) {
logger.message(`Current makefile configuration ${currentMakefileConfiguration} is no longer present in the available list.` +
` Re-setting the current makefile configuration to default.`);
setConfigurationByName("Default");
await setConfigurationByName("Default");
}
}
@ -1042,7 +1042,7 @@ export async function initFromStateAndSettings(): Promise<void> {
readAdditionalCompilerNames();
readExcludeCompilerNames();
readCurrentMakefileConfiguration();
readMakefileConfigurations();
await readMakefileConfigurations();
readCurrentTarget();
await readCurrentLaunchConfiguration();
readDefaultLaunchConfiguration();
@ -1058,7 +1058,7 @@ export async function initFromStateAndSettings(): Promise<void> {
initOptionalFeatures();
readFeaturesVisibility();
analyzeConfigureParams();
await analyzeConfigureParams();
await extension._projectOutlineProvider.update(extension.getState().buildConfiguration,
extension.getState().buildTarget,
@ -1304,7 +1304,7 @@ export async function initFromStateAndSettings(): Promise<void> {
// todo: skip over updating the IntelliSense configuration provider if the current makefile configuration
// is not among the subobjects that suffered modifications.
extension.getState().configureDirty = true;
readMakefileConfigurations();
await readMakefileConfigurations();
updatedSettingsSubkeys.push(subKey);
}
@ -1413,7 +1413,7 @@ export async function initFromStateAndSettings(): Promise<void> {
}
// Final updates in some constructs that depend on more than one of the above settings.
analyzeConfigureParams();
await analyzeConfigureParams();
await extension._projectOutlineProvider.updateMakePathInfo(getConfigurationMakeCommand());
await extension._projectOutlineProvider.updateMakefilePathInfo(getConfigurationMakefile());
await extension._projectOutlineProvider.updateBuildLogPathInfo(getConfigurationBuildLog());
@ -1456,9 +1456,9 @@ export async function initFromStateAndSettings(): Promise<void> {
});
}
export function setConfigurationByName(configurationName: string): void {
export async function setConfigurationByName(configurationName: string): Promise<void> {
extension.getState().buildConfiguration = configurationName;
setCurrentMakefileConfiguration(configurationName);
await setCurrentMakefileConfiguration(configurationName);
extension._projectOutlineProvider.updateConfiguration(configurationName);
}
@ -1494,7 +1494,7 @@ export async function setNewConfiguration(): Promise<void> {
};
telemetry.logEvent("stateChanged", telemetryProperties);
setConfigurationByName(chosen);
await setConfigurationByName(chosen);
if (configureAfterCommand) {
logger.message("Automatically reconfiguring the project after a makefile configuration change.");

Просмотреть файл

@ -55,6 +55,13 @@ export class MakefileToolsExtension {
}
}
private fullFeatureSet: boolean = false;
public getFullFeatureSet(): boolean { return this.fullFeatureSet; }
public async setFullFeatureSet(newValue: boolean): Promise<void> {
await vscode.commands.executeCommand('setContext', "makefile:fullFeatureSet", newValue);
this.fullFeatureSet = newValue;
}
// Used for calling cppToolsAPI.notifyReady only once in a VSCode session.
private ranNotifyReadyInSession: boolean = false;
public getRanNotifyReadyInSession() : boolean { return this.ranNotifyReadyInSession; }
@ -192,9 +199,9 @@ export class MakefileToolsExtension {
export async function activate(context: vscode.ExtensionContext): Promise<void> {
statusBar = ui.getUI();
await vscode.commands.executeCommand('setContext', "makefile:fullFeatureSet", false);
configuration.disableAllOptionallyVisibleCommands();
extension = new MakefileToolsExtension(context);
configuration.disableAllOptionallyVisibleCommands();
await extension.setFullFeatureSet(false);
telemetry.activate();
@ -360,7 +367,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
// Read configuration info from settings
await configuration.initFromStateAndSettings();
if (configuration.getConfigureOnOpen()) {
if (configuration.getConfigureOnOpen() && extension.getFullFeatureSet()) {
// Always clean configure on open
await make.cleanConfigure(make.TriggeredBy.cleanConfigureOnOpen);
}

Просмотреть файл

@ -50,6 +50,7 @@ export enum ConfigureBuildReturnCodeTypes {
outOfDate = -4,
other = -5,
saveFailed = -6,
fullFeatureFalse = -7,
}
export enum Operations {
@ -767,6 +768,13 @@ interface ConfigurationCache {
};
}
function isConfigurationEmpty(configurationCache: ConfigurationCache): boolean {
if (configurationCache.buildTargets.length === 0 && configurationCache.launchTargets.length === 0 && configurationCache.customConfigurationProvider.workspaceBrowse.browsePath.length === 0) {
return true;
}
return false;
}
interface ConfigureSubphasesStatus {
loadFromCache?: ConfigureSubphaseStatus;
generateParseContent?: ConfigureSubphaseStatus;
@ -872,6 +880,11 @@ export async function configure(triggeredBy: TriggeredBy, updateTargets: boolean
let ranConfigureInCodebaseLifetime: boolean = extension.getState().ranConfigureInCodebaseLifetime;
extension.getState().ranConfigureInCodebaseLifetime = true;
// If `fullFeatureSet` is false and it wasn't a manual command invocation, return and `other` return value.
if (!extension.getFullFeatureSet() && !triggeredBy.includes("command pallette")) {
return ConfigureBuildReturnCodeTypes.fullFeatureFalse;
}
if (blockedByOp(Operations.configure)) {
return ConfigureBuildReturnCodeTypes.blocked;
}
@ -1003,6 +1016,7 @@ export async function configure(triggeredBy: TriggeredBy, updateTargets: boolean
}
};
if (!isConfigurationEmpty(ConfigurationCache)) {
// Rewrite the configuration cache according to the last updates of the internal arrays,
// but not if the configure was cancelled and not while running regression tests.
if (configurationCachePath && retc !== ConfigureBuildReturnCodeTypes.cancelled && process.env['MAKEFILE_TOOLS_TESTING'] !== '1') {
@ -1014,6 +1028,7 @@ export async function configure(triggeredBy: TriggeredBy, updateTargets: boolean
let compileCommands: parser.CompileCommand[] = ConfigurationCache.customConfigurationProvider.fileIndex.map(([, {compileCommand}]) => compileCommand);
util.writeFile(compileCommandsPath, JSON.stringify(compileCommands, undefined, 4));
}
}
let newBuildTarget: string | undefined = configuration.getCurrentTarget();
let configureElapsedTime: number = util.elapsedTimeSince(configureStartTime);