Skip to content

Commit

Permalink
get isense client by uri (#13059)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukka authored Dec 17, 2024
1 parent fbf8135 commit afb208d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 5 additions & 4 deletions Extension/src/LanguageServer/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ interface DidChangeActiveEditorParams {
}

interface GetIncludesParams {
fileUri: string;
maxDepth: number;
}

Expand Down Expand Up @@ -827,7 +828,7 @@ export interface Client {
setShowConfigureIntelliSenseButton(show: boolean): void;
addTrustedCompiler(path: string): Promise<void>;
getCopilotHoverProvider(): CopilotHoverProvider | undefined;
getIncludes(maxDepth: number): Promise<GetIncludesResult>;
getIncludes(uri: vscode.Uri, maxDepth: number): Promise<GetIncludesResult>;
getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult>;
getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult>;
filesEncodingChanged(filesEncodingChanged: FilesEncodingChanged): void;
Expand Down Expand Up @@ -2291,8 +2292,8 @@ export class DefaultClient implements Client {
* the UI results and always re-requests (no caching).
*/

public async getIncludes(maxDepth: number): Promise<GetIncludesResult> {
const params: GetIncludesParams = { maxDepth: maxDepth };
public async getIncludes(uri: vscode.Uri, maxDepth: number): Promise<GetIncludesResult> {
const params: GetIncludesParams = { fileUri: uri.toString(), maxDepth };
await this.ready;
return this.languageClient.sendRequest(IncludesRequest, params);
}
Expand Down Expand Up @@ -4235,7 +4236,7 @@ class NullClient implements Client {
setShowConfigureIntelliSenseButton(show: boolean): void { }
addTrustedCompiler(path: string): Promise<void> { return Promise.resolve(); }
getCopilotHoverProvider(): CopilotHoverProvider | undefined { return undefined; }
getIncludes(maxDepth: number): Promise<GetIncludesResult> { return Promise.resolve({} as GetIncludesResult); }
getIncludes(uri: vscode.Uri, maxDepth: number): Promise<GetIncludesResult> { return Promise.resolve({} as GetIncludesResult); }
getChatContext(uri: vscode.Uri, token: vscode.CancellationToken): Promise<ChatContextResult> { return Promise.resolve({} as ChatContextResult); }
getProjectContext(uri: vscode.Uri): Promise<ProjectContextResult> { return Promise.resolve({} as ProjectContextResult); }
filesEncodingChanged(filesEncodingChanged: FilesEncodingChanged): void { }
Expand Down
12 changes: 6 additions & 6 deletions Extension/src/LanguageServer/copilotProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as util from '../common';
import * as logger from '../logger';
import * as telemetry from '../telemetry';
import { GetIncludesResult } from './client';
import { getActiveClient } from './extension';
import { getClients } from './extension';
import { getCompilerArgumentFilterMap, getProjectContext } from './lmTool';

nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
Expand Down Expand Up @@ -46,7 +46,7 @@ export async function registerRelatedFilesProvider(): Promise<void> {
const telemetryProperties: Record<string, string> = {};
const telemetryMetrics: Record<string, number> = {};
try {
const getIncludesHandler = async () => (await getIncludes(1))?.includedFiles.map(file => vscode.Uri.file(file)) ?? [];
const getIncludesHandler = async () => (await getIncludes(uri, 1))?.includedFiles.map(file => vscode.Uri.file(file)) ?? [];
const getTraitsHandler = async () => {
const projectContext = await getProjectContext(uri, context);

Expand Down Expand Up @@ -157,10 +157,10 @@ export async function registerRelatedFilesProvider(): Promise<void> {
}
}

async function getIncludes(maxDepth: number): Promise<GetIncludesResult> {
const activeClient = getActiveClient();
const includes = await activeClient.getIncludes(maxDepth);
const wksFolder = activeClient.RootUri?.toString();
async function getIncludes(uri: vscode.Uri, maxDepth: number): Promise<GetIncludesResult> {
const client = getClients().getClientFor(uri);
const includes = await client.getIncludes(uri, maxDepth);
const wksFolder = client.RootUri?.toString();

if (!wksFolder) {
return includes;
Expand Down

0 comments on commit afb208d

Please sign in to comment.