diff --git a/color-code-k8s.yml b/color-code-k8s.yml index 169cea5..ce3e5e2 100644 --- a/color-code-k8s.yml +++ b/color-code-k8s.yml @@ -16,47 +16,4 @@ spec: protocol: TCP type: LoadBalancer --- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: color-code-deployment - namespace: incredible-dev - labels: - name: color-code -spec: - replicas: 1 - selector: - matchLabels: - app: color-code - template: - metadata: - labels: - app: color-code - spec: - containers: - - name: color-code - image: CONTAINER_IMAGE - imagePullPolicy: Always - env: - - name: PORT - value: '3000' - - name: AUTH_TOKEN - valueFrom: - secretKeyRef: - name: idev-secrets - key: COLOR_CODES_AUTH_TOKEN - ports: - - name: http - containerPort: 3000 - protocol: TCP - securityContext: - privileged: false - readOnlyRootFilesystem: true - allowPrivilegeEscalation: false - resources: - requests: - cpu: 50m - memory: 64Mi - limits: - cpu: 150m - memory: 128Mi + diff --git a/color_codes.js b/color_codes.js index e99daf9..3984596 100644 --- a/color_codes.js +++ b/color_codes.js @@ -1,98 +1,99 @@ // Allows absolute paths -require('module-alias/register'); +require("module-alias/register"); -const express = require('express'); +const express = require("express"); const app = express(); -const port = parseInt(process.env.PORT || '') || 3000; -const authToken = process.env.AUTH_TOKEN || ''; +const port = parseInt(process.env.PORT || "") || 3000; +const authToken = process.env.AUTH_TOKEN || ""; /** * NOTE: Do not delete these unused imports. */ -const vsctm = require('@root/release/main'); -const themedTokenize = require('@root/out/tests/themedTokenizerCustom'); -const main = require('@root/out/main'); -const plist = require('@root/out/plist'); -const Resolver = require('@root/out/tests/resolver'); -const onigLib = require('@root/out/tests/onigLibs'); -const themes = require('@root/out/tests/themes_custom'); +const vsctm = require("@root/release/main"); +const themedTokenize = require("@root/out/tests/themedTokenizerCustom"); +const main = require("@root/out/main"); +const plist = require("@root/out/plist"); +const Resolver = require("@root/out/tests/resolver"); +const onigLib = require("@root/out/tests/onigLibs"); +const themes = require("@root/out/tests/themes_custom"); -const THEMES_PATH = './testcases/themes/'; +const THEMES_PATH = "./testcases/themes/"; app.use(express.json()); const langExtensions = { - batch: '.bat', - c: '.c', - 'c++': '.cpp', - clojure: '.clj', - css: '.css', - dockerfile: '.dockerfile', - go: '.go', - html: '.html', - jade: '.jade', - java: '.java', - javascript: '.js', - javascriptreact: '.jsx', - json: '.json', - markdown: '.md', - 'objective-c': '.m', - perl: '.pl', - php: '.php', - powershell: '.ps1', - properties: '.properties', - python: '.py', - r: '.r', - ruby: '.rb', - rust: '.rs', - scss: '.scss', - shellscript: '.sh', - sql: '.sql', - swift: '.swift', - typescript: '.ts', - typescriptreact: '.tsx', - xml: '.xml', - yaml: '.yaml', - graphql: '.graphql', - haskell: '.hs', - matlab: '.m', - toml: '.toml', + batch: ".bat", + c: ".c", + "c++": ".cpp", + clojure: ".clj", + css: ".css", + dockerfile: ".dockerfile", + go: ".go", + html: ".html", + jade: ".jade", + java: ".java", + javascript: ".js", + javascriptreact: ".jsx", + json: ".json", + markdown: ".md", + "objective-c": ".m", + perl: ".pl", + php: ".php", + powershell: ".ps1", + properties: ".properties", + python: ".py", + r: ".r", + ruby: ".rb", + rust: ".rs", + scss: ".scss", + shellscript: ".sh", + sql: ".sql", + swift: ".swift", + typescript: ".ts", + typescriptreact: ".tsx", + xml: ".xml", + yaml: ".yaml", + graphql: ".graphql", + haskell: ".hs", + matlab: ".m", + toml: ".toml", + bash: ".bash", }; const getTheme = { - abyss: ['Abyss.tmTheme'], - dark_vs: ['dark_vs.json'], - light_vs: ['light_vs.json'], - hc_black: ['hc_black.json'], - dark_plus: ['dark_plus.json', 'dark_vs.json'], - light_plus: ['light_plus.json', 'light_vs.json'], - kimbie_dark: ['Kimbie_dark.tmTheme'], - monokai: ['Monokai.tmTheme'], - monokai_dimmed: ['dimmed-monokai.tmTheme'], - quietlight: ['QuietLight.tmTheme'], - red: ['red.tmTheme'], - solarized_dark: ['Solarized-dark.tmTheme'], - solarized_light: ['Solarized-light.tmTheme'], - tomorrow_night_blue: ['Tomorrow-Night-Blue.tmTheme'], + abyss: ["Abyss.tmTheme"], + dark_vs: ["dark_vs.json"], + light_vs: ["light_vs.json"], + hc_black: ["hc_black.json"], + dark_plus: ["dark_plus.json", "dark_vs.json"], + light_plus: ["light_plus.json", "light_vs.json"], + kimbie_dark: ["Kimbie_dark.tmTheme"], + monokai: ["Monokai.tmTheme"], + monokai_dimmed: ["dimmed-monokai.tmTheme"], + quietlight: ["QuietLight.tmTheme"], + red: ["red.tmTheme"], + solarized_dark: ["Solarized-dark.tmTheme"], + solarized_light: ["Solarized-light.tmTheme"], + tomorrow_night_blue: ["Tomorrow-Night-Blue.tmTheme"], }; -app.get('/', (req, res) => { - res.send('UP'); +app.get("/", (req, res) => { + res.send("UP"); }); const requestValidate = (req, res, next) => { - if (req.headers['x-secret'] !== authToken) { + if (req.headers["x-secret"] !== authToken) { return res .status(401) - .json({ success: false, errors: ['Invalid auth token'] }); + .json({ success: false, errors: ["Invalid auth token"] }); } next(); }; -app.post('/color-codes', requestValidate, async (req, res) => { - const code = req.body.code || ''; - const theme = req.body.theme || 'dark_plus'; +app.post("/color-codes", requestValidate, async (req, res) => { + const code = req.body.code || ""; + const theme = req.body.theme || "dark_plus"; let language = req.body.language; try { @@ -102,7 +103,7 @@ app.post('/color-codes', requestValidate, async (req, res) => { throw err; } - console.log('theme:', theme, 'language:', language); + console.log("theme:", theme, "language:", language); if (!(theme in getTheme)) { const err = new Error(`theme "${theme}" is invalid`); @@ -110,7 +111,7 @@ app.post('/color-codes', requestValidate, async (req, res) => { throw err; } if (!(language in langExtensions)) { - language = 'javascript'; + language = "javascript"; } const color_codes = await themes.getColorCodes( diff --git a/kuber/production/deployment.yml b/kuber/production/deployment.yml new file mode 100644 index 0000000..d5de2fe --- /dev/null +++ b/kuber/production/deployment.yml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: color-code-deployment + namespace: incredible-dev + labels: + name: color-code +spec: + replicas: 5 + strategy: + type: RollingUpdate + rollingUpdate: + maxUnavailable: 2 + maxSurge: 2 + selector: + matchLabels: + app: color-code + template: + metadata: + labels: + app: color-code + spec: + containers: + - name: color-code + image: CONTAINER_IMAGE + imagePullPolicy: Always + env: + - name: PORT + value: '3000' + - name: AUTH_TOKEN + valueFrom: + secretKeyRef: + name: idev-secrets + key: COLOR_CODES_AUTH_TOKEN + ports: + - name: http + containerPort: 3000 + protocol: TCP + securityContext: + privileged: false + readOnlyRootFilesystem: true + allowPrivilegeEscalation: false \ No newline at end of file diff --git a/kuber/production/service.yml b/kuber/production/service.yml new file mode 100644 index 0000000..fdbf0c2 --- /dev/null +++ b/kuber/production/service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: color-code-service + namespace: incredible-dev + labels: + name: color-code + app: color-code +spec: + selector: + app: color-code + ports: + - name: http + port: 80 + targetPort: 3000 + protocol: TCP + type: LoadBalancer \ No newline at end of file diff --git a/kuber/staging/staging-deployment.yml b/kuber/staging/staging-deployment.yml new file mode 100644 index 0000000..3b1fb26 --- /dev/null +++ b/kuber/staging/staging-deployment.yml @@ -0,0 +1,44 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: color-code-deployment + namespace: incredible-dev + labels: + name: color-code +spec: + replicas: 1 + selector: + matchLabels: + app: color-code + template: + metadata: + labels: + app: color-code + spec: + containers: + - name: color-code + image: CONTAINER_IMAGE + imagePullPolicy: Always + env: + - name: PORT + value: '3000' + - name: AUTH_TOKEN + valueFrom: + secretKeyRef: + name: idev-secrets + key: COLOR_CODES_AUTH_TOKEN + ports: + - name: http + containerPort: 3000 + protocol: TCP + securityContext: + privileged: false + readOnlyRootFilesystem: true + allowPrivilegeEscalation: false + resources: + requests: + cpu: 100m + memory: 64Mi + limits: + cpu: 250m + memory: 256Mi \ No newline at end of file diff --git a/kuber/staging/staging-service.yml b/kuber/staging/staging-service.yml new file mode 100644 index 0000000..fdbf0c2 --- /dev/null +++ b/kuber/staging/staging-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: color-code-service + namespace: incredible-dev + labels: + name: color-code + app: color-code +spec: + selector: + app: color-code + ports: + - name: http + port: 80 + targetPort: 3000 + protocol: TCP + type: LoadBalancer \ No newline at end of file diff --git a/src/tests/themedTokenizerCustom.ts b/src/tests/themedTokenizerCustom.ts index 20996e7..286891a 100644 --- a/src/tests/themedTokenizerCustom.ts +++ b/src/tests/themedTokenizerCustom.ts @@ -1,45 +1,51 @@ /*--------------------------------------------------------- -* Copyright (C) Microsoft Corporation. All rights reserved. + * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ -import { IGrammar, StackElement } from '../main'; -import { StackElementMetadata } from '../grammar'; +import { IGrammar, StackElement } from "../main"; +import { StackElementMetadata } from "../grammar"; export interface IThemedTokenLine { - content: string; - color: string; - lineNumber: number; + content: string; + color: string; + lineNumber: number; } -export function tokenizeWithThemeLine(colorMap: string[], fileContents: string, grammar: IGrammar): IThemedTokenLine[] { - const lines = fileContents.split(/\r\n|\r|\n/); +export function tokenizeWithThemeLine( + colorMap: string[], + fileContents: string, + grammar: IGrammar +): IThemedTokenLine[] { + const lines = fileContents.split(/\r\n|\r|\n/); - let ruleStack: StackElement | null = null; - let actual: IThemedTokenLine[] = [], actualLen = 0; + let ruleStack: StackElement | null = null; + let actual: IThemedTokenLine[] = [], + actualLen = 0; - for (let i = 0, len = lines.length; i < len; i++) { - const line = lines[i]; - const result = grammar.tokenizeLine2(line, ruleStack); - const tokensLength = result.tokens.length / 2; - for (let j = 0; j < tokensLength; j++) { - const startIndex = result.tokens[2 * j]; - const nextStartIndex = j + 1 < tokensLength ? result.tokens[2 * j + 2] : line.length; - const tokenText = line.substring(startIndex, nextStartIndex); - if (tokenText === '') { - continue; - } - const metadata = result.tokens[2 * j + 1]; - const foreground = StackElementMetadata.getForeground(metadata); - const foregroundColor = colorMap[foreground]; + for (let i = 0, len = lines.length; i < len; i++) { + const line = lines[i]; + const result = grammar.tokenizeLine2(line, ruleStack); + const tokensLength = result.tokens.length / 2; + for (let j = 0; j < tokensLength; j++) { + const startIndex = result.tokens[2 * j]; + const nextStartIndex = + j + 1 < tokensLength ? result.tokens[2 * j + 2] : line.length; + const tokenText = line.substring(startIndex, nextStartIndex); + if (tokenText === "") { + continue; + } + const metadata = result.tokens[2 * j + 1]; + const foreground = StackElementMetadata.getForeground(metadata); + const foregroundColor = colorMap[foreground]; - actual[actualLen++] = { - content: tokenText, - color: foregroundColor, - lineNumber: i - }; - } - ruleStack = result.ruleStack; - } + actual[actualLen++] = { + content: tokenText, + color: foregroundColor, + lineNumber: i, + }; + } + ruleStack = result.ruleStack; + } - return actual; + return actual; } diff --git a/test-cases/themes/grammars.json b/test-cases/themes/grammars.json index a8b81e0..11645b3 100644 --- a/test-cases/themes/grammars.json +++ b/test-cases/themes/grammars.json @@ -1,285 +1,290 @@ [ - { - "language": "bat", - "scopeName": "source.dosbatch", - "path": "./syntaxes/Batch File.tmLanguage" - }, - { - "language": "clojure", - "scopeName": "source.clojure", - "path": "./syntaxes/Clojure.tmLanguage" - }, - { - "language": "coffeescript", - "scopeName": "source.coffee", - "path": "./syntaxes/coffeescript.json" - }, - { - "language": "c", - "scopeName": "source.c", - "path": "./syntaxes/c.json" - }, - { - "language": "cpp", - "scopeName": "source.cpp", - "path": "./syntaxes/c++.json" - }, - { - "scopeName": "source.c.platform", - "path": "./syntaxes/Platform.tmLanguage" - }, - { - "language": "css", - "scopeName": "source.css", - "path": "./syntaxes/css.plist" - }, - { - "language": "diff", - "scopeName": "source.diff", - "path": "./syntaxes/diff.tmLanguage" - }, - { - "language": "dockerfile", - "scopeName": "source.dockerfile", - "path": "./syntaxes/Dockerfile.tmLanguage" - }, - { - "language": "fsharp", - "scopeName": "source.fsharp", - "path": "./syntaxes/fsharp.json" - }, - { - "language": "git-commit", - "scopeName": "text.git-commit", - "path": "./syntaxes/git-commit.tmLanguage" - }, - { - "language": "git-rebase", - "scopeName": "text.git-rebase", - "path": "./syntaxes/git-rebase.tmLanguage" - }, - { - "language": "go", - "scopeName": "source.go", - "path": "./syntaxes/go.json" - }, - { - "language": "groovy", - "scopeName": "source.groovy", - "path": "./syntaxes/Groovy.tmLanguage" - }, - { - "language": "handlebars", - "scopeName": "text.html.handlebars", - "path": "./syntaxes/Handlebars.json" - }, - { - "language": "html", - "scopeName": "text.html.basic", - "path": "./syntaxes/html.json", - "embeddedLanguages": { - "text.html": "html", - "source.css": "css", - "source.js": "javascript", - "source.python": "python", - "source.smarty": "smarty" - } - }, - { - "language": "haskell", - "scopeName": "source.haskell", - "path": "./syntaxes/Haskell.tmLanguage" - }, - { - "language": "ini", - "scopeName": "source.properties", - "path": "./syntaxes/properties.plist" - }, - { - "language": "properties", - "scopeName": "source.properties", - "path": "./syntaxes/properties.plist" - }, - { - "language": "jade", - "scopeName": "text.jade", - "path": "./syntaxes/Jade.json" - }, - { - "language": "java", - "scopeName": "source.java", - "path": "./syntaxes/java.json" - }, - { - "language": "javascriptreact", - "scopeName": "source.js", - "path": "./syntaxes/JavaScript.tmLanguage.json" - }, - { - "language": "javascript", - "scopeName": "source.js", - "path": "./syntaxes/JavaScript.tmLanguage.json" - }, - { - "scopeName": "source.js.regexp", - "path": "./syntaxes/Regular Expressions (JavaScript).tmLanguage" - }, - { - "language": "json", - "scopeName": "source.json", - "path": "./syntaxes/JSON.tmLanguage" - }, - { - "language": "less", - "scopeName": "source.css.less", - "path": "./syntaxes/less.tmLanguage.json" - }, - { - "language": "lua", - "scopeName": "source.lua", - "path": "./syntaxes/lua.json" - }, - { - "language": "makefile", - "scopeName": "source.makefile", - "path": "./syntaxes/Makefile.json" - }, - { - "language": "markdown", - "scopeName": "text.html.markdown", - "path": "./syntaxes/markdown.tmLanguage" - }, - { - "language": "objective-c", - "scopeName": "source.objc", - "path": "./syntaxes/Objective-C.tmLanguage" - }, - { - "language": "perl", - "scopeName": "source.perl", - "path": "./syntaxes/Perl.plist" - }, - { - "language": "perl6", - "scopeName": "source.perl.6", - "path": "./syntaxes/Perl 6.tmLanguage" - }, - { - "language": "php", - "scopeName": "text.html.php", - "path": "./syntaxes/php.json", - "embeddedLanguages": { - "text.html": "html", - "source.php": "php", - "source.sql": "sql", - "text.xml": "xml", - "source.js": "javascript", - "source.json": "json", - "source.css": "css" - } - }, - { - "language": "powershell", - "scopeName": "source.powershell", - "path": "./syntaxes/PowershellSyntax.tmLanguage" - }, - { - "language": "python", - "scopeName": "source.python", - "path": "./syntaxes/MagicPython.tmLanguage.json" - }, - { - "scopeName": "source.regexp.python", - "path": "./syntaxes/MagicRegExp.tmLanguage.json" - }, - { - "language": "r", - "scopeName": "source.r", - "path": "./syntaxes/R.plist" - }, - { - "language": "razor", - "scopeName": "text.html.cshtml", - "path": "./syntaxes/cshtml.json" - }, - { - "language": "ruby", - "scopeName": "source.ruby", - "path": "./syntaxes/Ruby.plist" - }, - { - "language": "rust", - "path": "./syntaxes/rust.json", - "scopeName": "source.rust" - }, - { - "language": "scss", - "scopeName": "source.css.scss", - "path": "./syntaxes/scss.json" - }, - { - "language": "shaderlab", - "path": "./syntaxes/shaderlab.json", - "scopeName": "source.shaderlab" - }, - { - "language": "shellscript", - "scopeName": "source.shell", - "path": "./syntaxes/Shell-Unix-Bash.tmLanguage.json" - }, - { - "language": "sql", - "scopeName": "source.sql", - "path": "./syntaxes/SQL.plist" - }, - { - "language": "swift", - "scopeName": "source.swift", - "path": "./syntaxes/swift.json" - }, - { - "language": "typescript", - "scopeName": "source.ts", - "path": "./syntaxes/TypeScript.tmLanguage.json" - }, - { - "language": "typescriptreact", - "scopeName": "source.tsx", - "path": "./syntaxes/TypeScriptReact.tmLanguage.json" - }, - { - "language": "vb", - "scopeName": "source.asp.vb.net", - "path": "./syntaxes/ASPVBnet.plist" - }, - { - "language": "xml", - "scopeName": "text.xml", - "path": "./syntaxes/xml.json" - }, - { - "language": "xsl", - "scopeName": "text.xml.xsl", - "path": "./syntaxes/xsl.json" - }, - { - "language": "yaml", - "scopeName": "source.yaml", - "path": "./syntaxes/yaml.json" - }, - { - "language": "graphql", - "scopeName": "source.graphql", - "path": "./syntaxes/graphql.json" - }, - { - "language": "matlab", - "scopeName": "source.matlab", - "path": "./syntaxes/MATLAB.tmLanguage" - }, - { - "language": "toml", - "scopeName": "source.toml", - "path": "./syntaxes/TOML.tmLanguage" - } -] \ No newline at end of file + { + "language": "bat", + "scopeName": "source.dosbatch", + "path": "./syntaxes/Batch File.tmLanguage" + }, + { + "language": "clojure", + "scopeName": "source.clojure", + "path": "./syntaxes/Clojure.tmLanguage" + }, + { + "language": "coffeescript", + "scopeName": "source.coffee", + "path": "./syntaxes/coffeescript.json" + }, + { + "language": "c", + "scopeName": "source.c", + "path": "./syntaxes/c.json" + }, + { + "language": "cpp", + "scopeName": "source.cpp", + "path": "./syntaxes/c++.json" + }, + { + "scopeName": "source.c.platform", + "path": "./syntaxes/Platform.tmLanguage" + }, + { + "language": "css", + "scopeName": "source.css", + "path": "./syntaxes/css.plist" + }, + { + "language": "diff", + "scopeName": "source.diff", + "path": "./syntaxes/diff.tmLanguage" + }, + { + "language": "dockerfile", + "scopeName": "source.dockerfile", + "path": "./syntaxes/Dockerfile.tmLanguage" + }, + { + "language": "fsharp", + "scopeName": "source.fsharp", + "path": "./syntaxes/fsharp.json" + }, + { + "language": "git-commit", + "scopeName": "text.git-commit", + "path": "./syntaxes/git-commit.tmLanguage" + }, + { + "language": "git-rebase", + "scopeName": "text.git-rebase", + "path": "./syntaxes/git-rebase.tmLanguage" + }, + { + "language": "go", + "scopeName": "source.go", + "path": "./syntaxes/go.json" + }, + { + "language": "groovy", + "scopeName": "source.groovy", + "path": "./syntaxes/Groovy.tmLanguage" + }, + { + "language": "handlebars", + "scopeName": "text.html.handlebars", + "path": "./syntaxes/Handlebars.json" + }, + { + "language": "html", + "scopeName": "text.html.basic", + "path": "./syntaxes/html.json", + "embeddedLanguages": { + "text.html": "html", + "source.css": "css", + "source.js": "javascript", + "source.python": "python", + "source.smarty": "smarty" + } + }, + { + "language": "haskell", + "scopeName": "source.haskell", + "path": "./syntaxes/Haskell.tmLanguage" + }, + { + "language": "ini", + "scopeName": "source.properties", + "path": "./syntaxes/properties.plist" + }, + { + "language": "properties", + "scopeName": "source.properties", + "path": "./syntaxes/properties.plist" + }, + { + "language": "jade", + "scopeName": "text.jade", + "path": "./syntaxes/Jade.json" + }, + { + "language": "java", + "scopeName": "source.java", + "path": "./syntaxes/java.json" + }, + { + "language": "javascriptreact", + "scopeName": "source.js", + "path": "./syntaxes/JavaScript.tmLanguage.json" + }, + { + "language": "javascript", + "scopeName": "source.js", + "path": "./syntaxes/JavaScript.tmLanguage.json" + }, + { + "scopeName": "source.js.regexp", + "path": "./syntaxes/Regular Expressions (JavaScript).tmLanguage" + }, + { + "language": "json", + "scopeName": "source.json", + "path": "./syntaxes/JSON.tmLanguage" + }, + { + "language": "less", + "scopeName": "source.css.less", + "path": "./syntaxes/less.tmLanguage.json" + }, + { + "language": "lua", + "scopeName": "source.lua", + "path": "./syntaxes/lua.json" + }, + { + "language": "makefile", + "scopeName": "source.makefile", + "path": "./syntaxes/Makefile.json" + }, + { + "language": "markdown", + "scopeName": "text.html.markdown", + "path": "./syntaxes/markdown.tmLanguage" + }, + { + "language": "objective-c", + "scopeName": "source.objc", + "path": "./syntaxes/Objective-C.tmLanguage" + }, + { + "language": "perl", + "scopeName": "source.perl", + "path": "./syntaxes/Perl.plist" + }, + { + "language": "perl6", + "scopeName": "source.perl.6", + "path": "./syntaxes/Perl 6.tmLanguage" + }, + { + "language": "php", + "scopeName": "text.html.php", + "path": "./syntaxes/php.json", + "embeddedLanguages": { + "text.html": "html", + "source.php": "php", + "source.sql": "sql", + "text.xml": "xml", + "source.js": "javascript", + "source.json": "json", + "source.css": "css" + } + }, + { + "language": "powershell", + "scopeName": "source.powershell", + "path": "./syntaxes/PowershellSyntax.tmLanguage" + }, + { + "language": "python", + "scopeName": "source.python", + "path": "./syntaxes/MagicPython.tmLanguage.json" + }, + { + "scopeName": "source.regexp.python", + "path": "./syntaxes/MagicRegExp.tmLanguage.json" + }, + { + "language": "r", + "scopeName": "source.r", + "path": "./syntaxes/R.plist" + }, + { + "language": "razor", + "scopeName": "text.html.cshtml", + "path": "./syntaxes/cshtml.json" + }, + { + "language": "ruby", + "scopeName": "source.ruby", + "path": "./syntaxes/Ruby.plist" + }, + { + "language": "rust", + "path": "./syntaxes/rust.json", + "scopeName": "source.rust" + }, + { + "language": "scss", + "scopeName": "source.css.scss", + "path": "./syntaxes/scss.json" + }, + { + "language": "shaderlab", + "path": "./syntaxes/shaderlab.json", + "scopeName": "source.shaderlab" + }, + { + "language": "shellscript", + "scopeName": "source.shell", + "path": "./syntaxes/Shell-Unix-Bash.tmLanguage.json" + }, + { + "language": "sql", + "scopeName": "source.sql", + "path": "./syntaxes/SQL.plist" + }, + { + "language": "swift", + "scopeName": "source.swift", + "path": "./syntaxes/swift.json" + }, + { + "language": "typescript", + "scopeName": "source.ts", + "path": "./syntaxes/TypeScript.tmLanguage.json" + }, + { + "language": "typescriptreact", + "scopeName": "source.tsx", + "path": "./syntaxes/TypeScriptReact.tmLanguage.json" + }, + { + "language": "vb", + "scopeName": "source.asp.vb.net", + "path": "./syntaxes/ASPVBnet.plist" + }, + { + "language": "xml", + "scopeName": "text.xml", + "path": "./syntaxes/xml.json" + }, + { + "language": "xsl", + "scopeName": "text.xml.xsl", + "path": "./syntaxes/xsl.json" + }, + { + "language": "yaml", + "scopeName": "source.yaml", + "path": "./syntaxes/yaml.json" + }, + { + "language": "graphql", + "scopeName": "source.graphql", + "path": "./syntaxes/graphql.json" + }, + { + "language": "matlab", + "scopeName": "source.matlab", + "path": "./syntaxes/MATLAB.tmLanguage" + }, + { + "language": "toml", + "scopeName": "source.toml", + "path": "./syntaxes/TOML.tmLanguage" + }, + { + "language": "bash", + "scopeName": "source.shell", + "path": "./syntaxes/Shell-Unix-Bash.tmLanguage.json" + } +] diff --git a/test-cases/themes/languages.json b/test-cases/themes/languages.json index 4ea2571..5c98810 100644 --- a/test-cases/themes/languages.json +++ b/test-cases/themes/languages.json @@ -1,793 +1,453 @@ [ - { - "id": "toml", - "extensions": [ - ".toml" - ], - "aliases": [ - "TOML", - "toml" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "graphql", - "extensions": [ - ".graphql" - ], - "aliases": [ - "GraphQL", - "graphql" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "matlab", - "extensions": [ - ".m" - ], - "aliases": [ - "MATLAB" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "haskell", - "extensions": [ - ".hs" - ], - "aliases": [ - "Haskell", - "haskell" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "bat", - "extensions": [ - ".bat", - ".cmd" - ], - "aliases": [ - "Batch", - "bat" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "clojure", - "aliases": [ - "Clojure", - "clojure" - ], - "extensions": [ - ".clj", - ".cljs", - ".cljx", - ".clojure", - ".edn" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "coffeescript", - "extensions": [ - ".coffee", - ".cson" - ], - "aliases": [ - "CoffeeScript", - "coffeescript", - "coffee" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "c", - "extensions": [ - ".c" - ], - "aliases": [ - "C", - "c" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "cpp", - "extensions": [ - ".cpp", - ".cc", - ".cxx", - ".hpp", - ".hh", - ".hxx", - ".h", - ".mm", - ".ino", - ".inl" - ], - "aliases": [ - "C++", - "Cpp", - "cpp" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "css", - "aliases": [ - "CSS", - "css" - ], - "extensions": [ - ".css" - ], - "mimetypes": [ - "text/css" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "diff", - "aliases": [ - "Diff", - "diff" - ], - "extensions": [ - ".patch", - ".diff", - ".rej" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "dockerfile", - "extensions": [ - ".dockerfile" - ], - "filenames": [ - "Dockerfile" - ], - "aliases": [ - "Dockerfile" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "fsharp", - "extensions": [ - ".fs", - ".fsi", - ".fsx", - ".fsscript" - ], - "aliases": [ - "F#", - "FSharp", - "fsharp" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "git-commit", - "aliases": [ - "Git Commit Message", - "git-commit" - ], - "filenames": [ - "COMMIT_EDITMSG", - "MERGE_MSG" - ], - "configuration": "./git-commit.language-configuration.json" - }, - { - "id": "git-rebase", - "aliases": [ - "Git Rebase Message", - "git-rebase" - ], - "filenames": [ - "git-rebase-todo" - ], - "configuration": "./git-rebase.language-configuration.json" - }, - { - "id": "go", - "extensions": [ - ".go" - ], - "aliases": [ - "Go" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "groovy", - "aliases": [ - "Groovy", - "groovy" - ], - "extensions": [ - ".groovy", - ".gvy", - ".gradle" - ], - "firstLine": "^#!.*\\bgroovy\\b", - "configuration": "./language-configuration.json" - }, - { - "id": "handlebars", - "extensions": [ - ".handlebars", - ".hbs" - ], - "aliases": [ - "Handlebars", - "handlebars" - ], - "mimetypes": [ - "text/x-handlebars-template" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "html", - "extensions": [ - ".html", - ".htm", - ".shtml", - ".xhtml", - ".mdoc", - ".jsp", - ".asp", - ".aspx", - ".jshtm", - ".vue" - ], - "aliases": [ - "HTML", - "htm", - "html", - "xhtml" - ], - "mimetypes": [ - "text/html", - "text/x-jshtm", - "text/template", - "text/ng-template", - "application/xhtml+xml" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "ini", - "extensions": [ - ".ini" - ], - "aliases": [ - "Ini", - "ini" - ], - "configuration": "./ini.language-configuration.json" - }, - { - "id": "properties", - "extensions": [ - ".properties", - ".gitconfig" - ], - "filenames": [ - "config", - ".gitattributes", - ".gitconfig", - "gitconfig", - ".editorconfig" - ], - "aliases": [ - "properties", - "properties" - ], - "configuration": "./properties.language-configuration.json" - }, - { - "id": "jade", - "extensions": [ - ".jade", - ".pug" - ], - "aliases": [ - "Jade", - "jade" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "java", - "extensions": [ - ".java", - ".jav" - ], - "aliases": [ - "Java", - "java" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "javascriptreact", - "aliases": [ - "JavaScript React", - "jsx" - ], - "extensions": [ - ".jsx" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "javascript", - "aliases": [ - "JavaScript", - "javascript", - "js" - ], - "extensions": [ - ".js", - ".es6" - ], - "filenames": [ - "jakefile" - ], - "firstLine": "^#!.*\\bnode", - "mimetypes": [ - "text/javascript" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "json", - "aliases": [ - "JSON", - "json" - ], - "extensions": [ - ".json", - ".bowerrc", - ".jshintrc", - ".jscsrc", - ".eslintrc", - ".babelrc", - ".webmanifest" - ], - "mimetypes": [ - "application/json", - "application/manifest+json" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "less", - "aliases": [ - "Less", - "less" - ], - "extensions": [ - ".less" - ], - "mimetypes": [ - "text/x-less", - "text/less" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "lua", - "extensions": [ - ".lua" - ], - "aliases": [ - "Lua", - "lua" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "makefile", - "aliases": [ - "Makefile", - "makefile" - ], - "filenames": [ - "Makefile", - "makefile", - "GNUmakefile", - "OCamlMakefile" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "markdown", - "aliases": [ - "Markdown", - "markdown" - ], - "extensions": [ - ".md", - ".mdown", - ".markdown", - ".markdn" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "objective-c", - "extensions": [ - ".m" - ], - "aliases": [ - "Objective-C" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "perl", - "aliases": [ - "Perl", - "perl" - ], - "extensions": [ - ".pl", - ".pm", - ".pod", - ".t", - ".PL", - ".psgi" - ], - "firstLine": "^#!.*\\bperl\\b", - "configuration": "./perl.language-configuration.json" - }, - { - "id": "perl6", - "aliases": [ - "Perl 6", - "perl6" - ], - "extensions": [ - ".p6", - ".pl6", - ".pm6", - ".nqp" - ], - "firstLine": "(^#!.*\\bperl6\\b)|use\\s+v6", - "configuration": "./perl6.language-configuration.json" - }, - { - "id": "php", - "extensions": [ - ".php", - ".php4", - ".php5", - ".phtml", - ".ctp" - ], - "aliases": [ - "PHP", - "php" - ], - "mimetypes": [ - "application/x-php" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "powershell", - "extensions": [ - ".ps1", - ".psm1", - ".psd1", - ".pssc", - ".psrc" - ], - "aliases": [ - "PowerShell", - "powershell", - "ps", - "ps1" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "python", - "extensions": [ - ".py", - ".rpy", - ".pyw", - ".cpy", - ".gyp", - ".gypi" - ], - "aliases": [ - "Python", - "py" - ], - "firstLine": "^#!/.*\\bpython[0-9.-]*\\b", - "configuration": "./language-configuration.json" - }, - { - "id": "r", - "extensions": [ - ".r", - ".rhistory", - ".rprofile", - ".rt" - ], - "aliases": [ - "R", - "r" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "razor", - "extensions": [ - ".cshtml" - ], - "aliases": [ - "Razor", - "razor" - ], - "mimetypes": [ - "text/x-cshtml" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "ruby", - "extensions": [ - ".rb", - ".rbx", - ".rjs", - ".gemspec", - ".rake", - ".ru" - ], - "filenames": [ - "rakefile", - "gemfile", - "guardfile" - ], - "aliases": [ - "Ruby", - "rb" - ], - "firstLine": "^#!/.*\\bruby\\b", - "configuration": "./language-configuration.json" - }, - { - "id": "rust", - "extensions": [ - ".rs" - ], - "aliases": [ - "Rust", - "rust" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "scss", - "aliases": [ - "Sass", - "scss" - ], - "extensions": [ - ".scss" - ], - "mimetypes": [ - "text/x-scss", - "text/scss" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "shaderlab", - "extensions": [ - ".shader", - ".cginc" - ], - "aliases": [ - "ShaderLab", - "shaderlab" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "shellscript", - "aliases": [ - "Shell Script (Bash)", - "shellscript", - "bash", - "sh", - "zsh" - ], - "extensions": [ - ".sh", - ".bash", - ".bashrc", - ".bash_aliases", - ".bash_profile", - ".bash_login", - ".ebuild", - ".install", - ".profile", - ".bash_logout", - ".zsh", - ".zshrc", - ".zprofile", - ".zlogin", - ".zlogout", - ".zshenv" - ], - "filenames": [ - "PKGBUILD" - ], - "firstLine": "^#!.*\\b(bash|zsh|sh|tcsh).*|^#\\s*-\\*-[^*]*mode:\\s*shell-script[^*]*-\\*-", - "configuration": "./language-configuration.json", - "mimetypes": [ - "text/x-shellscript" - ] - }, - { - "id": "sql", - "extensions": [ - ".sql", - ".dsql" - ], - "aliases": [ - "SQL" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "swift", - "aliases": [ - "Swift", - "swift" - ], - "extensions": [ - ".swift" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "typescript", - "aliases": [ - "TypeScript", - "ts", - "typescript" - ], - "extensions": [ - ".ts" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "typescriptreact", - "aliases": [ - "TypeScript React", - "tsx" - ], - "extensions": [ - ".tsx" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "vb", - "extensions": [ - ".vb", - ".brs", - ".vbs", - ".bas" - ], - "aliases": [ - "Visual Basic", - "vb" - ], - "configuration": "./language-configuration.json" - }, - { - "id": "xml", - "extensions": [ - ".xml", - ".xsd", - ".ascx", - ".atom", - ".axml", - ".bpmn", - ".config", - ".cpt", - ".csl", - ".csproj", - ".csproj.user", - ".dita", - ".ditamap", - ".dtd", - ".dtml", - ".fsproj", - ".fxml", - ".iml", - ".isml", - ".jmx", - ".launch", - ".menu", - ".mxml", - ".nuspec", - ".opml", - ".owl", - ".proj", - ".pt", - ".pubxml", - ".pubxml.user", - ".rdf", - ".rng", - ".rss", - ".shproj", - ".storyboard", - ".svg", - ".targets", - ".tld", - ".tmx", - ".vbproj", - ".vbproj.user", - ".vcxproj", - ".vcxproj.filters", - ".wsdl", - ".wxi", - ".wxl", - ".wxs", - ".xaml", - ".xbl", - ".xib", - ".xlf", - ".xliff", - ".xpdl", - ".xul", - ".xoml" - ], - "firstLine": "(\\<\\?xml.*)|(\\|&&|\\|\\|", + "name": "keyword.operator.logical.shell" + }, + { + "match": "(?[>=]?|==|!=|^|\\|{1,2}|&{1,2}|\\?|\\:|,|=|[*/%+\\-&^|]=|<<=|>>=", + "name": "keyword.operator.arithmetic.shell" + }, + { + "match": "0[xX][0-9A-Fa-f]+", + "name": "constant.numeric.hex.shell" + }, + { + "match": "0\\d+", + "name": "constant.numeric.octal.shell" + }, + { + "match": "\\d{1,2}#[0-9a-zA-Z@_]+", + "name": "constant.numeric.other.shell" + }, + { + "match": "\\d+", + "name": "constant.numeric.integer.shell" + } + ] + }, + "pathname": { + "patterns": [ + { + "match": "(?<=\\s|:|=|^)~", + "name": "keyword.operator.tilde.shell" + }, + { + "match": "\\*|\\?", + "name": "keyword.operator.glob.shell" + }, + { + "begin": "([?*+@!])(\\()", + "beginCaptures": { + "1": { + "name": "keyword.operator.extglob.shell" + }, + "2": { + "name": "punctuation.definition.extglob.shell" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.extglob.shell" + } + }, + "name": "meta.structure.extglob.shell", + "patterns": [ + { + "include": "$self" + } + ] + } + ] + }, + "pipeline": { + "patterns": [ + { + "match": "(?<=^|;|&|\\s)(time)(?=\\s|;|&|$)", + "name": "keyword.other.shell" + }, + { + "match": "[|!]", + "name": "keyword.operator.pipe.shell" + } + ] + }, + "redirection": { + "patterns": [ + { + "begin": "[><]\\(", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.shell" + } + }, + "end": "\\)", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.shell" + } + }, + "name": "string.interpolated.process-substitution.shell", + "patterns": [ + { + "include": "$self" + } + ] + }, + { + "match": "(?])(&>|\\d*>&\\d*|\\d*(>>|>|<)|\\d*<&|\\d*<>)(?![<>])", + "name": "keyword.operator.redirect.shell" + } + ] + }, + "string": { + "patterns": [ + { + "match": "\\\\.", + "name": "constant.character.escape.shell" + }, + { + "begin": "'", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.shell" + } + }, + "end": "'", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.shell" + } + }, + "name": "string.quoted.single.shell" + }, + { + "begin": "\\$?\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.shell" + } + }, + "end": "\"", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.shell" + } + }, + "name": "string.quoted.double.shell", + "patterns": [ + { + "match": "\\\\[\\$`\"\\\\\\n]", + "name": "constant.character.escape.shell" + }, + { + "include": "#variable" + }, + { + "include": "#interpolation" + } + ] + }, + { + "begin": "\\$'", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.shell" + } + }, + "end": "'", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.shell" + } + }, + "name": "string.quoted.single.dollar.shell", + "patterns": [ + { + "match": "\\\\(a|b|e|f|n|r|t|v|\\\\|')", + "name": "constant.character.escape.ansi-c.shell" + }, + { + "match": "\\\\[0-9]{3}", + "name": "constant.character.escape.octal.shell" + }, + { + "match": "\\\\x[0-9a-fA-F]{2}", + "name": "constant.character.escape.hex.shell" + }, + { + "match": "\\\\c.", + "name": "constant.character.escape.control-char.shell" + } + ] + } + ] + }, + "support": { + "patterns": [ + { + "match": "(?<=^|;|&|\\s)(?::|\\.)(?=\\s|;|&|$)", + "name": "support.function.builtin.shell" + }, + { + "match": "(?<=^|;|&|\\s)(?:alias|bg|bind|break|builtin|caller|cd|command|compgen|complete|dirs|disown|echo|enable|eval|exec|exit|false|fc|fg|getopts|hash|help|history|jobs|kill|let|logout|popd|printf|pushd|pwd|read|readonly|set|shift|shopt|source|suspend|test|times|trap|true|type|ulimit|umask|unalias|unset|wait)(?=\\s|;|&|$)", + "name": "support.function.builtin.shell" + } + ] + }, + "variable": { + "patterns": [ + { + "captures": { + "1": { + "name": "punctuation.definition.variable.shell" + } + }, + "match": "(\\$)[a-zA-Z_][a-zA-Z0-9_]*", + "name": "variable.other.normal.shell" + }, + { + "captures": { + "1": { + "name": "punctuation.definition.variable.shell" + } + }, + "match": "(\\$)[-*@#?$!0_]", + "name": "variable.other.special.shell" + }, + { + "captures": { + "1": { + "name": "punctuation.definition.variable.shell" + } + }, + "match": "(\\$)[1-9]", + "name": "variable.other.positional.shell" + }, + { + "begin": "\\${", + "beginCaptures": { + "0": { + "name": "punctuation.definition.variable.shell" + } + }, + "end": "}", + "endCaptures": { + "0": { + "name": "punctuation.definition.variable.shell" + } + }, + "name": "variable.other.bracket.shell", + "patterns": [ + { + "match": "!|:[-=?]?|\\*|@|#{1,2}|%{1,2}|/", + "name": "keyword.operator.expansion.shell" + }, + { + "captures": { + "1": { + "name": "punctuation.section.array.shell" + }, + "3": { + "name": "punctuation.section.array.shell" + } + }, + "match": "(\\[)([^\\]]+)(\\])" + }, + { + "include": "#variable" + }, + { + "include": "#string" + } + ] + } + ] + } + } +}