filter out C++ headers outside the current opened folder. (#12803)
This commit is contained in:
Родитель
23c9fb5a9f
Коммит
34f0dd673c
|
@ -529,7 +529,7 @@ interface GetIncludesParams {
|
|||
maxDepth: number;
|
||||
}
|
||||
|
||||
interface GetIncludesResult {
|
||||
export interface GetIncludesResult {
|
||||
includedFiles: string[];
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import * as util from '../common';
|
|||
import { getCrashCallStacksChannel } from '../logger';
|
||||
import { PlatformInformation } from '../platform';
|
||||
import * as telemetry from '../telemetry';
|
||||
import { Client, DefaultClient, DoxygenCodeActionCommandArguments, openFileVersions } from './client';
|
||||
import { Client, DefaultClient, DoxygenCodeActionCommandArguments, GetIncludesResult, openFileVersions } from './client';
|
||||
import { ClientCollection } from './clientCollection';
|
||||
import { CodeActionDiagnosticInfo, CodeAnalysisDiagnosticIdentifiersAndUri, codeAnalysisAllFixes, codeAnalysisCodeToFixes, codeAnalysisFileToCodeActions } from './codeAnalysis';
|
||||
import { CppBuildTaskProvider } from './cppBuildTaskProvider';
|
||||
|
@ -282,7 +282,7 @@ export async function activate(): Promise<void> {
|
|||
api.registerRelatedFilesProvider(
|
||||
{ extensionId: util.extensionContext.extension.id, languageId },
|
||||
async (_uri: vscode.Uri, _context: { flags: Record<string, unknown> }, token: vscode.CancellationToken) =>
|
||||
({ entries: (await clients.ActiveClient.getIncludes(1, token))?.includedFiles.map(file => vscode.Uri.file(file)) ?? [] })
|
||||
({ entries: (await getIncludesWithCancellation(1, token))?.includedFiles.map(file => vscode.Uri.file(file)) ?? [] })
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
|
@ -1413,13 +1413,28 @@ export async function preReleaseCheck(): Promise<void> {
|
|||
}
|
||||
}
|
||||
|
||||
export async function getIncludes(maxDepth: number): Promise<any> {
|
||||
const tokenSource = new vscode.CancellationTokenSource();
|
||||
const includes = await clients.ActiveClient.getIncludes(maxDepth, tokenSource.token);
|
||||
tokenSource.dispose();
|
||||
export async function getIncludesWithCancellation(maxDepth: number, token: vscode.CancellationToken): Promise<GetIncludesResult> {
|
||||
const includes = await clients.ActiveClient.getIncludes(maxDepth, token);
|
||||
const wksFolder = clients.ActiveClient.RootUri?.toString();
|
||||
|
||||
if (!wksFolder) {
|
||||
return includes;
|
||||
}
|
||||
|
||||
includes.includedFiles = includes.includedFiles.filter(header => vscode.Uri.file(header).toString().startsWith(wksFolder));
|
||||
return includes;
|
||||
}
|
||||
|
||||
async function getIncludes(maxDepth: number): Promise<GetIncludesResult> {
|
||||
const tokenSource = new vscode.CancellationTokenSource();
|
||||
try {
|
||||
const includes = await getIncludesWithCancellation(maxDepth, tokenSource.token);
|
||||
return includes;
|
||||
} finally {
|
||||
tokenSource.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
async function getCopilotApi(): Promise<CopilotApi | undefined> {
|
||||
const copilotExtension = vscode.extensions.getExtension<CopilotApi>('github.copilot');
|
||||
if (!copilotExtension) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче