diff --git a/CHANGELOG.md b/CHANGELOG.md index 4447bd4..f7ff0da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index 8f082b1..f3f942f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index 613f577..797619c 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/releases/code-stats-vscode-1.0.3.vsix b/releases/code-stats-vscode-1.0.4.vsix similarity index 87% rename from releases/code-stats-vscode-1.0.3.vsix rename to releases/code-stats-vscode-1.0.4.vsix index 9f575a3..68d85d0 100644 Binary files a/releases/code-stats-vscode-1.0.3.vsix and b/releases/code-stats-vscode-1.0.4.vsix differ diff --git a/src/code-stats-api.ts b/src/code-stats-api.ts index c0fb4a0..20381ab 100644 --- a/src/code-stats-api.ts +++ b/src/code-stats-api.ts @@ -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); diff --git a/src/utils.ts b/src/utils.ts index 0ad6013..302b07d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -17,4 +17,69 @@ export function getISOTimestamp(date: Date): string { ":" + pad(date.getSeconds()) + prefix + pad(offset / 60) + pad(offset % 60); -} \ No newline at end of file +} + +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; +} diff --git a/src/xp-counter.ts b/src/xp-counter.ts index bc60dff..aa8ec7b 100644 --- a/src/xp-counter.ts +++ b/src/xp-counter.ts @@ -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;