Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/services/languageDetection/common/languageDetectionWorkerService.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { URI } from '../../../../base/common/uri.js';
7
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
8
9
export const ILanguageDetectionService = createDecorator<ILanguageDetectionService>('ILanguageDetectionService');
10
11
export const LanguageDetectionLanguageEventSource = 'languageDetection';
12
13
export interface ILanguageDetectionService {
14
readonly _serviceBrand: undefined;
15
16
/**
17
* @param languageId The languageId to check if language detection is currently enabled.
18
* @returns whether or not language detection is on for this language.
19
*/
20
isEnabledForLanguage(languageId: string): boolean;
21
22
/**
23
* @param resource The resource to detect the language for.
24
* @param supportedLangs Optional. When populated, the model will only return languages from the provided list
25
* @returns the language id for the given resource or undefined if the model is not confident enough.
26
*/
27
detectLanguage(resource: URI, supportedLangs?: string[]): Promise<string | undefined>;
28
}
29
30
export type LanguageDetectionHintConfig = {
31
untitledEditors: boolean;
32
notebookEditors: boolean;
33
};
34
35
//#region Telemetry events
36
37
export const AutomaticLanguageDetectionLikelyWrongId = 'automaticlanguagedetection.likelywrong';
38
39
export interface IAutomaticLanguageDetectionLikelyWrongData {
40
currentLanguageId: string;
41
nextLanguageId: string;
42
lineCount: number;
43
modelPreference: string;
44
}
45
46
export type AutomaticLanguageDetectionLikelyWrongClassification = {
47
owner: 'TylerLeonhardt';
48
comment: 'Used to determine how often language detection is likely wrong.';
49
currentLanguageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The language id we guessed.' };
50
nextLanguageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The language id the user chose.' };
51
lineCount: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The number of lines in the file.' };
52
modelPreference: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'What the user\'s model preference is.' };
53
};
54
55
export const LanguageDetectionStatsId = 'automaticlanguagedetection.stats';
56
57
export interface ILanguageDetectionStats {
58
languages: string;
59
confidences: string;
60
timeSpent: number;
61
}
62
63
export type LanguageDetectionStatsClassification = {
64
owner: 'TylerLeonhardt';
65
comment: 'Used to determine how definitive language detection is and how long it takes.';
66
languages: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The languages the model supports.' };
67
confidences: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The confidences of those languages.' };
68
timeSpent: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'How long the operation took.' };
69
};
70
71
//#endregion
72
73