Added manual mapping to language names

This commit is contained in:
Juha Ristolainen 2017-03-18 09:25:20 +00:00
parent e4d94c5878
commit 8695493a02
7 changed files with 86 additions and 4 deletions

View File

@ -6,6 +6,10 @@ All notable changes to the "code-stats-vscode" extension will be documented in t
### Changed
## [1.0.4] - 2017-03-18
### Added
Added a manual mapping to natural language language names.
## [1.0.3] - 2017-03-18
### Added
Added license for the logo from Nicd.

View File

@ -18,6 +18,10 @@ This extension contributes the following settings:
## Release Notes
### 1.0.4
Added a manual mapping to natural language language names.
### 1.0.3
Fixed an accumulation of XP bug.

View File

@ -2,7 +2,7 @@
"name": "code-stats-vscode",
"displayName": "Code::Stats",
"description": "Code::Stats package for Visual Studio Code",
"version": "1.0.3",
"version": "1.0.4",
"publisher": "juha-ristolainen",
"icon": "logo.png",
"repository": {

View File

@ -1,6 +1,6 @@
import { Pulse } from "./pulse";
import { getISOTimestamp } from "./utils";
import { getISOTimestamp, getLanguageName } from "./utils";
import * as axios from "axios";
export class CodeStatsAPI {
@ -30,8 +30,9 @@ export class CodeStatsAPI {
const data = new ApiJSON(new Date());
for (let lang of pulse.xps.keys()) {
let languageName: string = getLanguageName(lang);
let xp: number = pulse.getXP(lang);
data.xps.push(new ApiXP(lang, xp));
data.xps.push(new ApiXP(languageName, xp));
}
let json: string = JSON.stringify(data);

View File

@ -18,3 +18,68 @@ export function getISOTimestamp(date: Date): string {
prefix + pad(offset / 60) +
pad(offset % 60);
}
export function getLanguageName(langId: string): string {
// currently supported language ids in vscode as of 2017-03-18
let languageNames: { [key:string]: string; } = {
"plaintext": "Plain text",
"Log": "Log",
"bat": "bat",
"clojure": "Clojure",
"coffeescript": "CoffeeScript",
"c": "C",
"cpp": "C++",
"csharp": "C#",
"css": "CSS",
"diff": "Diff",
"dockerfile": "Docker",
"fsharpcss": "F#",
"git-commit": "Git",
"git-rebase": "Git",
"go": "Go",
"groovy": "Groovy",
"handlebars": "Handlebars",
"hlsl": "HLSL",
"html": "HTML",
"ini": ".ini",
"properties": ".properties",
"java": "Java",
"javascriptreact": "JavaScript (React)",
"javascript": "JavaScript",
"jsx-tags": "JavaScript (JSX)",
"json": "JSON",
"less": "CSS (LESS)",
"lua": "Lua",
"makefile": "Makefile",
"markdown": "Markdown",
"objective-c": "Objective-C",
"perl": "Perl",
"perl6": "Perl 6",
"php": "PHP",
"powershell": "PowerShell",
"jade": "Jade",
"python": "Python",
"r": "R",
"razor": "Razor",
"ruby": "Ruby",
"rust": "Rust",
"scss": "CSS (SCSS)",
"shaderlab": "Shaderlab",
"shellscript": "Shell script",
"sql": "SQL",
"swift": "Swift",
"typescript": "TypeScript",
"typescriptreact": "TypeScript (React)",
"vb": "Visual Basic",
"xml": "XML",
"xsl": "XSL",
"yaml": "YAML"
};
let languageName: string = languageNames[langId];
if (languageName === null || languageName === undefined) {
return "Unknown";
}
return languageName;
}

View File

@ -18,6 +18,14 @@ export class XpCounter {
constructor() {
this.pulse = new Pulse();
/*
let allLanguages = languages.getLanguages().then(
(result => {
console.log(JSON.stringify(result));
})
);
*/
let config: WorkspaceConfiguration = workspace.getConfiguration("codestats");
if (!config) {
return;