mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat: Add programming language to CLI events (#6071)
Co-authored-by: christine betts <chrstn@uw.edu> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Adam Weidman <65992621+adamfweidman@users.noreply.github.com> Co-authored-by: JaeHo Jang <diehreo@gmail.com> Co-authored-by: Jacob Richman <jacob314@gmail.com> Co-authored-by: Victor May <mayvic@google.com> Co-authored-by: Gaurav <39389231+gsquared94@users.noreply.github.com> Co-authored-by: joshualitt <joshualitt@google.com> Co-authored-by: Billy Biggs <bbiggs@google.com> Co-authored-by: Ricardo Fabbri <rfabbri@gmail.com> Co-authored-by: Arya Gummadi <aryagummadi@google.com> Co-authored-by: Tommaso Sciortino <sciortino@gmail.com> Co-authored-by: Gal Zahavi <38544478+galz10@users.noreply.github.com> Co-authored-by: Shreya Keshive <skeshive@gmail.com> Co-authored-by: Ben Guo <36952867+HunDun0Ben@users.noreply.github.com> Co-authored-by: Ben Guo <hundunben@gmail.com> Co-authored-by: mkusaka <hinoshita1992@gmail.com>
This commit is contained in:
103
packages/core/src/utils/language-detection.ts
Normal file
103
packages/core/src/utils/language-detection.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import * as path from 'path';
|
||||
|
||||
const extensionToLanguageMap: { [key: string]: string } = {
|
||||
'.ts': 'TypeScript',
|
||||
'.js': 'JavaScript',
|
||||
'.mjs': 'JavaScript',
|
||||
'.cjs': 'JavaScript',
|
||||
'.jsx': 'JavaScript',
|
||||
'.tsx': 'TypeScript',
|
||||
'.py': 'Python',
|
||||
'.java': 'Java',
|
||||
'.go': 'Go',
|
||||
'.rb': 'Ruby',
|
||||
'.php': 'PHP',
|
||||
'.phtml': 'PHP',
|
||||
'.cs': 'C#',
|
||||
'.cpp': 'C++',
|
||||
'.cxx': 'C++',
|
||||
'.cc': 'C++',
|
||||
'.c': 'C',
|
||||
'.h': 'C/C++',
|
||||
'.hpp': 'C++',
|
||||
'.swift': 'Swift',
|
||||
'.kt': 'Kotlin',
|
||||
'.rs': 'Rust',
|
||||
'.m': 'Objective-C',
|
||||
'.mm': 'Objective-C',
|
||||
'.pl': 'Perl',
|
||||
'.pm': 'Perl',
|
||||
'.lua': 'Lua',
|
||||
'.r': 'R',
|
||||
'.scala': 'Scala',
|
||||
'.sc': 'Scala',
|
||||
'.sh': 'Shell',
|
||||
'.ps1': 'PowerShell',
|
||||
'.bat': 'Batch',
|
||||
'.cmd': 'Batch',
|
||||
'.sql': 'SQL',
|
||||
'.html': 'HTML',
|
||||
'.htm': 'HTML',
|
||||
'.css': 'CSS',
|
||||
'.less': 'Less',
|
||||
'.sass': 'Sass',
|
||||
'.scss': 'Sass',
|
||||
'.json': 'JSON',
|
||||
'.xml': 'XML',
|
||||
'.yaml': 'YAML',
|
||||
'.yml': 'YAML',
|
||||
'.md': 'Markdown',
|
||||
'.markdown': 'Markdown',
|
||||
'.dockerfile': 'Dockerfile',
|
||||
'.vim': 'Vim script',
|
||||
'.vb': 'Visual Basic',
|
||||
'.fs': 'F#',
|
||||
'.clj': 'Clojure',
|
||||
'.cljs': 'Clojure',
|
||||
'.dart': 'Dart',
|
||||
'.ex': 'Elixir',
|
||||
'.erl': 'Erlang',
|
||||
'.hs': 'Haskell',
|
||||
'.lisp': 'Lisp',
|
||||
'.rkt': 'Racket',
|
||||
'.groovy': 'Groovy',
|
||||
'.jl': 'Julia',
|
||||
'.tex': 'LaTeX',
|
||||
'.ino': 'Arduino',
|
||||
'.asm': 'Assembly',
|
||||
'.s': 'Assembly',
|
||||
'.toml': 'TOML',
|
||||
'.vue': 'Vue',
|
||||
'.svelte': 'Svelte',
|
||||
'.gohtml': 'Go Template',
|
||||
'.hbs': 'Handlebars',
|
||||
'.ejs': 'EJS',
|
||||
'.erb': 'ERB',
|
||||
'.jsp': 'JSP',
|
||||
'.dockerignore': 'Docker',
|
||||
'.gitignore': 'Git',
|
||||
'.npmignore': 'npm',
|
||||
'.editorconfig': 'EditorConfig',
|
||||
'.prettierrc': 'Prettier',
|
||||
'.eslintrc': 'ESLint',
|
||||
'.babelrc': 'Babel',
|
||||
'.tsconfig': 'TypeScript',
|
||||
'.flow': 'Flow',
|
||||
'.graphql': 'GraphQL',
|
||||
'.proto': 'Protocol Buffers',
|
||||
};
|
||||
|
||||
export function getLanguageFromFilePath(filePath: string): string | undefined {
|
||||
const extension = path.extname(filePath).toLowerCase();
|
||||
if (extension) {
|
||||
return extensionToLanguageMap[extension];
|
||||
}
|
||||
const filename = path.basename(filePath).toLowerCase();
|
||||
return extensionToLanguageMap[`.${filename}`];
|
||||
}
|
||||
Reference in New Issue
Block a user