Path: blob/main/src/vs/workbench/services/languageDetection/common/languageDetectionWorkerService.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { URI } from '../../../../base/common/uri.js';6import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';78export const ILanguageDetectionService = createDecorator<ILanguageDetectionService>('ILanguageDetectionService');910export const LanguageDetectionLanguageEventSource = 'languageDetection';1112export interface ILanguageDetectionService {13readonly _serviceBrand: undefined;1415/**16* @param languageId The languageId to check if language detection is currently enabled.17* @returns whether or not language detection is on for this language.18*/19isEnabledForLanguage(languageId: string): boolean;2021/**22* @param resource The resource to detect the language for.23* @param supportedLangs Optional. When populated, the model will only return languages from the provided list24* @returns the language id for the given resource or undefined if the model is not confident enough.25*/26detectLanguage(resource: URI, supportedLangs?: string[]): Promise<string | undefined>;27}2829export type LanguageDetectionHintConfig = {30untitledEditors: boolean;31notebookEditors: boolean;32};3334//#region Telemetry events3536export const AutomaticLanguageDetectionLikelyWrongId = 'automaticlanguagedetection.likelywrong';3738export interface IAutomaticLanguageDetectionLikelyWrongData {39currentLanguageId: string;40nextLanguageId: string;41lineCount: number;42modelPreference: string;43}4445export type AutomaticLanguageDetectionLikelyWrongClassification = {46owner: 'TylerLeonhardt';47comment: 'Used to determine how often language detection is likely wrong.';48currentLanguageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The language id we guessed.' };49nextLanguageId: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The language id the user chose.' };50lineCount: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The number of lines in the file.' };51modelPreference: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'What the user\'s model preference is.' };52};5354export const LanguageDetectionStatsId = 'automaticlanguagedetection.stats';5556export interface ILanguageDetectionStats {57languages: string;58confidences: string;59timeSpent: number;60}6162export type LanguageDetectionStatsClassification = {63owner: 'TylerLeonhardt';64comment: 'Used to determine how definitive language detection is and how long it takes.';65languages: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The languages the model supports.' };66confidences: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The confidences of those languages.' };67timeSpent: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'How long the operation took.' };68};6970//#endregion717273