Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.7k
Adding additional parse checking logic#14407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8d8bd90
Adding additional parse checking logic to determine if idle state has…
1782057
Only checking for tag parsing now. Added cancellation token for propa…
213ba36
Fixed command registration to be consistent with naming rules, and to…
9916c0f
Added interface for PendingTagParsingCalls. Fixed NullClient definition.
5c033d4
Setting of pendingCall timer + listener now done on initialization.
38a4179
Merge branch 'main' into dev/serramirez/addParseCheck2
bobbrow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -104,6 +104,12 @@ interface ConfigStateReceived { | ||
| timeout: boolean; | ||
| } | ||
| interface PendingTagParsingCall { | ||
| promise: ManualPromise<boolean>; | ||
| timer: NodeJS.Timeout; | ||
| cancellationListener: vscode.Disposable; | ||
| } | ||
| let workspaceHash: string = ""; | ||
| let workspaceDisposables: vscode.Disposable[] = []; | ||
| @@ -805,6 +811,7 @@ export interface Client { | ||
| setCurrentConfigName(configurationName: string): Thenable<void>; | ||
| getCurrentConfigName(): Thenable<string | undefined>; | ||
| getCurrentConfigCustomVariable(variableName: string): Thenable<string>; | ||
| waitForTagParsing(timeout: number, token: vscode.CancellationToken): Promise<boolean>; | ||
| getVcpkgInstalled(): Thenable<boolean>; | ||
| getVcpkgEnabled(): Thenable<boolean>; | ||
| getCurrentCompilerPathAndArgs(): Thenable<util.CompilerPathAndArgs | undefined>; | ||
| @@ -919,6 +926,7 @@ export class DefaultClient implements Client { | ||
| private configStateReceived: ConfigStateReceived = { compilers: false, compileCommands: false, configProviders: undefined, timeout: false }; | ||
| private showConfigureIntelliSenseButton: boolean = false; | ||
| private pendingTagParsingCalls: PendingTagParsingCall[] = []; | ||
| /** A queue of asynchronous tasks that need to be processed befofe ready is considered active. */ | ||
| private static queue = new Array<[ManualPromise<unknown>, () => Promise<unknown>] | [ManualPromise<unknown>]>(); | ||
| @@ -1008,6 +1016,62 @@ export class DefaultClient implements Client { | ||
| }; | ||
| } | ||
| // If there are any pending calls that were waiting for tag parsing to complete, we can resolve them since it's finished. If there are no pending calls, this does nothing. | ||
| private resolvePendingTagParsingCallsIfReady(): void { | ||
| if (!this.pendingTagParsingCalls.length || this.IsTagParsing) { | ||
| return; | ||
| } | ||
| const pendingCalls: PendingTagParsingCall[] = this.pendingTagParsingCalls; | ||
| this.pendingTagParsingCalls = []; | ||
| pendingCalls.forEach(pendingCall => { | ||
| if (pendingCall.timer) { | ||
| clearTimeout(pendingCall.timer); | ||
| } | ||
| pendingCall.cancellationListener.dispose(); | ||
| pendingCall.promise.resolve(true); | ||
| }); | ||
| } | ||
| public async waitForTagParsing(timeout: number, token: vscode.CancellationToken): Promise<boolean> { | ||
| // On initialization, the client has UI bools all set to false which could cause an early return. We want to ensure it's ready first. | ||
| await this.ready; | ||
| if (!this.IsTagParsing) { | ||
| return true; | ||
| } | ||
| if (token.isCancellationRequested) { | ||
| throw new vscode.CancellationError(); | ||
| } | ||
| const pendingCall: PendingTagParsingCall = { | ||
| promise: new ManualPromise<boolean>(), | ||
| timer: global.setTimeout(() => { | ||
| const index: number = this.pendingTagParsingCalls.indexOf(pendingCall); | ||
| if (index !== -1) { | ||
| this.pendingTagParsingCalls.splice(index, 1); | ||
| } | ||
| pendingCall.cancellationListener.dispose(); | ||
| pendingCall.promise.resolve(false); | ||
| }, timeout), | ||
| cancellationListener: token.onCancellationRequested(() => { | ||
| const index: number = this.pendingTagParsingCalls.indexOf(pendingCall); | ||
| if (index !== -1) { | ||
| this.pendingTagParsingCalls.splice(index, 1); | ||
| } | ||
| clearTimeout(pendingCall.timer); | ||
| pendingCall.cancellationListener.dispose(); | ||
| pendingCall.promise.reject(new vscode.CancellationError()); | ||
| }) | ||
| }; | ||
| this.pendingTagParsingCalls.push(pendingCall); | ||
| return pendingCall.promise; | ||
| } | ||
| private getName(workspaceFolder?: vscode.WorkspaceFolder): string { | ||
| return workspaceFolder ? workspaceFolder.name : "untitled"; | ||
| } | ||
| @@ -2893,6 +2957,8 @@ export class DefaultClient implements Client { | ||
| } else if (message.includes("/")) { | ||
| this.lastInvokedLspMessage = message; | ||
| } | ||
| this.resolvePendingTagParsingCallsIfReady(); | ||
bobbrow marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| } | ||
| private updateTagParseStatus(tagParseStatus: TagParseStatus): void { | ||
| @@ -4208,6 +4274,14 @@ export class DefaultClient implements Client { | ||
| } | ||
| public dispose(): void { | ||
| this.pendingTagParsingCalls.forEach(pendingCall => { | ||
| if (pendingCall.timer) { | ||
| clearTimeout(pendingCall.timer); | ||
| } | ||
| pendingCall.cancellationListener.dispose(); | ||
| pendingCall.promise.resolve(false); | ||
| }); | ||
| this.pendingTagParsingCalls = []; | ||
| this.disposables.forEach((d) => d.dispose()); | ||
| this.disposables = []; | ||
| if (this.documentFormattingProviderDisposable) { | ||
| @@ -4360,6 +4434,7 @@ class NullClient implements Client { | ||
| setCurrentConfigName(configurationName: string): Thenable<void> { return Promise.resolve(); } | ||
| getCurrentConfigName(): Thenable<string> { return Promise.resolve(""); } | ||
| getCurrentConfigCustomVariable(variableName: string): Thenable<string> { return Promise.resolve(""); } | ||
| waitForTagParsing(timeout: number, token: vscode.CancellationToken): Promise<boolean> { return Promise.resolve(true); } | ||
| getVcpkgInstalled(): Thenable<boolean> { return Promise.resolve(false); } | ||
| getVcpkgEnabled(): Thenable<boolean> { return Promise.resolve(false); } | ||
| getCurrentCompilerPathAndArgs(): Thenable<util.CompilerPathAndArgs | undefined> { return Promise.resolve(undefined); } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -430,6 +430,7 @@ export async function registerCommands(enabled: boolean): Promise<void> { | ||
| commandDisposables.push(vscode.commands.registerCommand('cpptools.activeConfigName', enabled ? onGetActiveConfigName : onDisabledCommand)); | ||
| commandDisposables.push(vscode.commands.registerCommand('cpptools.activeConfigCustomVariable', enabled ? onGetActiveConfigCustomVariable : onDisabledCommand)); | ||
| commandDisposables.push(vscode.commands.registerCommand('cpptools.setActiveConfigName', enabled ? onSetActiveConfigName : onDisabledCommand)); | ||
| commandDisposables.push(vscode.commands.registerCommand('cpptools.waitForTagParsing', enabled ? onWaitForTagParsing : () => true)); | ||
| 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)); | ||
| @@ -977,6 +978,10 @@ function onGetActiveConfigCustomVariable(variableName: string): Thenable<string> | ||
| return clients.ActiveClient.getCurrentConfigCustomVariable(variableName); | ||
| } | ||
| async function onWaitForTagParsing(timeout: number, token: vscode.CancellationToken): Promise<boolean> { | ||
sergior2 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return clients.getDefaultClient().waitForTagParsing(timeout, token); | ||
| } | ||
| function onLogDiagnostics(): Promise<void> { | ||
| return clients.ActiveClient.logDiagnostics(); | ||
| } | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.