From 6f6f1b43f05671926c613be85b3f3ab1259f6343 Mon Sep 17 00:00:00 2001 From: Abdussalam Abdurrahman Date: Sun, 14 Oct 2018 15:38:48 -0700 Subject: [PATCH 01/25] [clojure] Add ".cljs" and ".cljc" to source file extension list --- src/clojure/clojure.contribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clojure/clojure.contribution.ts b/src/clojure/clojure.contribution.ts index fc0e885f..475308e6 100644 --- a/src/clojure/clojure.contribution.ts +++ b/src/clojure/clojure.contribution.ts @@ -12,7 +12,7 @@ const _monaco: typeof monaco = registerLanguage({ id: 'clojure', - extensions: ['.clj', '.clojure'], + extensions: ['.clj', '.cljs', '.cljc', '.clojure'], aliases: ['clojure', 'Clojure'], loader: () => _monaco.Promise.wrap(import('./clojure')), }); From c77f11b1b0e41749807ac5786868b468558bb232 Mon Sep 17 00:00:00 2001 From: Abdussalam Abdurrahman Date: Wed, 12 Sep 2018 18:32:24 -0700 Subject: [PATCH 02/25] [clojure] Add a word boundary to ensure exact matches for `(comment ...)`. --- src/clojure/clojure.test.ts | 24 ++++++++++++++++++++++++ src/clojure/clojure.ts | 4 ++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/clojure/clojure.test.ts b/src/clojure/clojure.test.ts index e4098fa1..80ae4050 100644 --- a/src/clojure/clojure.test.ts +++ b/src/clojure/clojure.test.ts @@ -792,6 +792,30 @@ testTokenization('clojure', [ {startIndex: 0, type: 'comment.clj'}, ], }, + { + line: '(comments foo bar)', + tokens: [ + {startIndex: 0, type: 'delimiter.parenthesis.clj'}, + {startIndex: 1, type: 'identifier.clj'}, + {startIndex: 9, type: 'white.clj'}, + {startIndex: 10, type: 'identifier.clj'}, + {startIndex: 13, type: 'white.clj'}, + {startIndex: 14, type: 'identifier.clj'}, + {startIndex: 17, type: 'delimiter.parenthesis.clj'}, + ] + }, + { + line: '(comment6 foo bar)', + tokens: [ + {startIndex: 0, type: 'delimiter.parenthesis.clj'}, + {startIndex: 1, type: 'identifier.clj'}, + {startIndex: 9, type: 'white.clj'}, + {startIndex: 10, type: 'identifier.clj'}, + {startIndex: 13, type: 'white.clj'}, + {startIndex: 14, type: 'identifier.clj'}, + {startIndex: 17, type: 'delimiter.parenthesis.clj'}, + ] + }, { line: '(comment foo', tokens: [ diff --git a/src/clojure/clojure.ts b/src/clojure/clojure.ts index df779450..03beb5b9 100644 --- a/src/clojure/clojure.ts +++ b/src/clojure/clojure.ts @@ -762,13 +762,13 @@ export const language = { whitespace: [ [/\s+/, 'white'], [/;.*$/, 'comment'], - [/\(comment/, 'comment', '@comment'], + [/\(comment\b/, 'comment', '@comment'], ], comment: [ [/\(/, 'comment', '@push'], [/\)/, 'comment', '@pop'], - [/[^)]/, 'comment'], + [/[^()]/, 'comment'], ], string: [ From 223c3eb54fbd91b734636866faf910252d16cd12 Mon Sep 17 00:00:00 2001 From: Abdussalam Abdurrahman Date: Mon, 24 Sep 2018 17:34:57 -0700 Subject: [PATCH 03/25] [clojure] Improve the regular expressions for various symbols. --- src/clojure/clojure.ts | 47 +++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/clojure/clojure.ts b/src/clojure/clojure.ts index 03beb5b9..59855ed4 100644 --- a/src/clojure/clojure.ts +++ b/src/clojure/clojure.ts @@ -13,20 +13,24 @@ export const conf: IRichLanguageConfiguration = { lineComment: ';;', }, - brackets: [['(', ')'], ['[', ']'], ['{', '}']], + brackets: [ + ['[', ']'], + ['(', ')'], + ['{', '}'] + ], autoClosingPairs: [ - {open: '(', close: ')'}, {open: '[', close: ']'}, - {open: '{', close: '}'}, {open: '"', close: '"'}, + {open: '(', close: ')'}, + {open: '{', close: '}'}, ], surroundingPairs: [ - {open: '(', close: ')'}, {open: '[', close: ']'}, - {open: '{', close: '}'}, {open: '"', close: '"'}, + {open: '(', close: ')'}, + {open: '{', close: '}'}, ], }; @@ -36,11 +40,26 @@ export const language = { tokenPostfix: '.clj', brackets: [ + {open: '[', close: ']', token: 'delimiter.square'}, {open: '(', close: ')', token: 'delimiter.parenthesis'}, {open: '{', close: '}', token: 'delimiter.curly'}, - {open: '[', close: ']', token: 'delimiter.square'}, ], + constants: ['true', 'false', 'nil'], + + // delimiters: /[\\\[\]\s"#'(),;@^`{}~]|$/, + + numbers: /^(?:[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?(?=[\\\[\]\s"#'(),;@^`{}~]|$))/, + + characters: /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/, + + escapes: /^\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?/, + + // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*/ + // simple-symbol := /^(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)/ + // qualified-symbol := ((<.>)*)? + qualifiedSymbols: /^(?:(?:[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*(?:\.[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*\/)?(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)*(?=[\\\[\]\s"(),;@^`{}~]|$))/, + specialForms: [ '.', 'catch', @@ -712,14 +731,6 @@ export const language = { 'zipmap', ], - constants: ['true', 'false', 'nil'], - - symbolCharacter: /[!#'*+\-.\/:<=>?_\w\xa1-\uffff]/, - - numbers: /[+\-]?\d+(?:(?:N|(?:[eE][+\-]?\d+))|(?:\.?\d*(?:M|(?:[eE][+\-]?\d+))?)|\/\d+|[xX][0-9a-fA-F]+|r[0-9a-zA-Z]+)?/, - - characters: /\\(?:backspace|formfeed|newline|return|space|tab|x[0-9A-Fa-f]{4}|u[0-9A-Fa-f]{4}|o[0-7]{3}|@symbolCharacter|[\\"()\[\]{}])/, - tokenizer: { root: [ // whitespaces and comments @@ -743,12 +754,10 @@ export const language = { // reader macro characters [/[#'@^`~]/, 'meta'], - // keywords - [/:@symbolCharacter+/, 'constant'], - // symbols - [/@symbolCharacter+/, { + [/@qualifiedSymbols/, { cases: { + '^:.+$': 'constant', // Clojure keywords (e.g., `:foo/bar`) '@specialForms': 'keyword', '@coreSymbols': 'keyword', '@constants': 'constant', @@ -777,7 +786,7 @@ export const language = { multiLineString: [ [/[^\\"]+/, 'string'], - [/@characters/, 'string'], + [/@escapes/, 'string'], [/"/, 'string', '@pop'] ], }, From 4061962186c3a31093f96849f6c09c141651e02f Mon Sep 17 00:00:00 2001 From: Abdussalam Abdurrahman Date: Thu, 6 Dec 2018 17:40:33 -0800 Subject: [PATCH 04/25] [clojure] Remove an file name extension that's uncommon --- src/clojure/clojure.contribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clojure/clojure.contribution.ts b/src/clojure/clojure.contribution.ts index 475308e6..d5d7e81c 100644 --- a/src/clojure/clojure.contribution.ts +++ b/src/clojure/clojure.contribution.ts @@ -12,7 +12,7 @@ const _monaco: typeof monaco = registerLanguage({ id: 'clojure', - extensions: ['.clj', '.cljs', '.cljc', '.clojure'], + extensions: ['.clj', '.cljs', '.cljc'], aliases: ['clojure', 'Clojure'], loader: () => _monaco.Promise.wrap(import('./clojure')), }); From 3f16600ec11acb56cf560a378e15c8978d034727 Mon Sep 17 00:00:00 2001 From: Abdussalam Abdurrahman Date: Fri, 7 Dec 2018 12:30:10 -0800 Subject: [PATCH 05/25] [clojure] Fix tokenization of escapes in strings The notation for escapes in strings follows that of the host platforms which is different from the notation for character literals in Clojure (e.g., "\n" vs `\newline`). --- src/clojure/clojure.test.ts | 73 +++++++++++++++++++++++++++++++++---- src/clojure/clojure.ts | 23 ++++++------ 2 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/clojure/clojure.test.ts b/src/clojure/clojure.test.ts index 80ae4050..57807964 100644 --- a/src/clojure/clojure.test.ts +++ b/src/clojure/clojure.test.ts @@ -754,13 +754,72 @@ testTokenization('clojure', [ ], 'string'), // strings - createTestCases([ - '\"I\'m a little teapot.\"', - '\"I\'m a \\\"little\\\" teapot.\"', - '\"I\'m', // this is - 'a little', // a multi-line - 'teapot.\"' // string - ], 'string'), + [ + { + line: '"I\'m a little teapot."', + tokens: [ + {startIndex: 0, type: 'string.clj'}, + ] + }, + { + line: '"I\'m a \\"little\\" teapot."', + tokens: [ + {startIndex: 0, type: 'string.clj'}, + {startIndex: 7, type: 'string.escape.clj'}, + {startIndex: 9, type: 'string.clj'}, + {startIndex: 15, type: 'string.escape.clj'}, + {startIndex: 17, type: 'string.clj'}, + ] + } + ], + + // multi-line strings + [ + { + line: '"I\'m', + tokens: [ + {startIndex: 0, type: 'string.clj'}, + ] + }, + { + line: '\\"a little\\"', + tokens: [ + {startIndex: 0, type: 'string.escape.clj'}, + {startIndex: 2, type: 'string.clj'}, + {startIndex: 10, type: 'string.escape.clj'}, + ] + }, + { + line: 'teapot."', + tokens: [ + {startIndex: 0, type: 'string.clj'}, + ] + } + ], + + // strings with other escapes in them (\" \' \\ \b \f \n \r \t) + [{ + line: '"the escape \\" \\\' \\\\ \\b \\f \\n \\r \\t characters"', + tokens: [ + {startIndex: 0, type: 'string.clj'}, + {startIndex: 12, type: 'string.escape.clj'}, + {startIndex: 14, type: 'string.clj'}, + {startIndex: 15, type: 'string.escape.clj'}, + {startIndex: 17, type: 'string.clj'}, + {startIndex: 18, type: 'string.escape.clj'}, + {startIndex: 20, type: 'string.clj'}, + {startIndex: 21, type: 'string.escape.clj'}, + {startIndex: 23, type: 'string.clj'}, + {startIndex: 24, type: 'string.escape.clj'}, + {startIndex: 26, type: 'string.clj'}, + {startIndex: 27, type: 'string.escape.clj'}, + {startIndex: 29, type: 'string.clj'}, + {startIndex: 30, type: 'string.escape.clj'}, + {startIndex: 32, type: 'string.clj'}, + {startIndex: 33, type: 'string.escape.clj'}, + {startIndex: 35, type: 'string.clj'}, + ] + }], // comments createTestCases([ diff --git a/src/clojure/clojure.ts b/src/clojure/clojure.ts index 59855ed4..a92f4745 100644 --- a/src/clojure/clojure.ts +++ b/src/clojure/clojure.ts @@ -53,7 +53,7 @@ export const language = { characters: /^(?:\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?(?=[\\\[\]\s"(),;@^`{}~]|$))/, - escapes: /^\\(?:backspace|formfeed|newline|return|space|tab|o[0-7]{3}|u[0-9A-Fa-f]{4}|x[0-9A-Fa-f]{4}|.)?/, + escapes: /^\\(?:["'\\bfnrt]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, // simple-namespace := /^[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*/ // simple-symbol := /^(?:\/|[^\\\/\[\]\d\s"#'(),;@^`{}~][^\\\[\]\s"(),;@^`{}~]*)/ @@ -756,16 +756,15 @@ export const language = { // symbols [/@qualifiedSymbols/, { - cases: { - '^:.+$': 'constant', // Clojure keywords (e.g., `:foo/bar`) - '@specialForms': 'keyword', - '@coreSymbols': 'keyword', - '@constants': 'constant', - '@default': 'identifier', + cases: { + '^:.+$': 'constant', // Clojure keywords (e.g., `:foo/bar`) + '@specialForms': 'keyword', + '@coreSymbols': 'keyword', + '@constants': 'constant', + '@default': 'identifier', + }, }, - }, ], - ], whitespace: [ @@ -785,9 +784,9 @@ export const language = { ], multiLineString: [ - [/[^\\"]+/, 'string'], - [/@escapes/, 'string'], - [/"/, 'string', '@pop'] + [/"/, 'string', '@popall'], + [/@escapes/, 'string.escape'], + [/./, 'string'] ], }, }; From f0df74079ca82ef3e56a5cba921f17ffab48c13a Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Wed, 21 Nov 2018 04:30:46 +0100 Subject: [PATCH 06/25] WIP: GraphQL first shot --- src/graphql/graphql.contribution.ts | 19 ++++ src/graphql/graphql.test.ts | 42 +++++++++ src/graphql/graphql.ts | 136 ++++++++++++++++++++++++++++ src/monaco.contribution.ts | 1 + test/setup.js | 1 + 5 files changed, 199 insertions(+) create mode 100644 src/graphql/graphql.contribution.ts create mode 100644 src/graphql/graphql.test.ts create mode 100644 src/graphql/graphql.ts diff --git a/src/graphql/graphql.contribution.ts b/src/graphql/graphql.contribution.ts new file mode 100644 index 00000000..a999c9e6 --- /dev/null +++ b/src/graphql/graphql.contribution.ts @@ -0,0 +1,19 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import { registerLanguage } from '../_.contribution'; + +// Allow for running under nodejs/requirejs in tests +const _monaco: typeof monaco = + typeof monaco === 'undefined' ? (self).monaco : monaco; + +registerLanguage({ + id: 'graphql', + extensions: ['.graphql', '.gql'], + aliases: ['GraphQL', 'graphql', 'gql'], + mimetypes: ['application/graphql'], + loader: () => _monaco.Promise.wrap(import('./graphql')), +}); diff --git a/src/graphql/graphql.test.ts b/src/graphql/graphql.test.ts new file mode 100644 index 00000000..668710fb --- /dev/null +++ b/src/graphql/graphql.test.ts @@ -0,0 +1,42 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import { testTokenization } from '../test/testRunner'; + +testTokenization('graphql', [ + // Keywords + [{ + line: 'scalar Date', + tokens: [ + { startIndex: 0, type: 'keyword.gql' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'type.identifier.gql' }, + ] + }], + + // Root schema definition + [{ + line: 'schema { query: Query }', + tokens: [ + { startIndex: 0, type: "keyword.gql" }, + { startIndex: 6, type: "" }, + { startIndex: 7, type: "delimiter.curly.gql" }, + { startIndex: 8, type: "" }, + { startIndex: 9, type: "keyword.gql" }, // this should be identifier! + { startIndex: 14, type: "delimiter.gql" }, + { startIndex: 15, type: "" }, + { startIndex: 16, type: "type.identifier.gql" }, + { startIndex: 21, type: "" }, + { startIndex: 22, type: "delimiter.curly.gql" }, + ] + }], + + // Comments - single line + + // Comments - range comment, single line + +]); diff --git a/src/graphql/graphql.ts b/src/graphql/graphql.ts new file mode 100644 index 00000000..95620114 --- /dev/null +++ b/src/graphql/graphql.ts @@ -0,0 +1,136 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export const conf: IRichLanguageConfiguration = { + comments: { + lineComment: '#' + }, + brackets: [ + ['{', '}'], + ['[', ']'], + ['(', ')'] + ], + autoClosingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '"""', close: '"""', notIn: ['string', 'comment'] }, + { open: '"', close: '"', notIn: ['string', 'comment'] }, + ], + surroundingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '"""', close: '"""' }, + { open: '"', close: '"' }, + ], + folding: { + offSide: true + } +}; + +export const language = { + // Set defaultToken to invalid to see what you do not tokenize yet + defaultToken: 'invalid', + tokenPostfix: '.gql', + + keywords: [ + 'null', 'true', 'false', + 'query', 'mutation', 'subscription', + 'extend', 'schema', 'directive', + 'scalar', 'type', 'interface', 'union', 'enum', 'input', + 'fragment', 'on', + ], + + typeKeywords: ['Int', 'Float', 'String', 'Boolean', 'ID'], + + directiveLocations: [ + 'SCHEMA', 'SCALAR', 'OBJECT', 'FIELD_DEFINITION', 'ARGUMENT_DEFINITION', + 'INTERFACE', 'UNION', 'ENUM', 'ENUM_VALUE', 'INPUT_OBJECT', 'INPUT_FIELD_DEFINITION', + 'QUERY', 'MUTATION', 'SUBSCRIPTION', 'FIELD', 'FRAGMENT_DEFINITION', + 'FRAGMENT_SPREAD', 'INLINE_FRAGMENT', 'VARIABLE_DEFINITION', + ], + + operators: ['=', '!', '?', ':', '&', '|'], + + // we include these common regular expressions + symbols: /[=!?:&|]+/, + + // https://facebook.github.io/graphql/draft/#sec-String-Value + escapes: /\\(?:["\\\/bfnrt]|u[0-9A-Fa-f]{4})/, + + // The main tokenizer for our languages + tokenizer: { + root: [ + // identifiers and keywords + [ + /[a-z_$][\w$]*/, + { + cases: { + '@keywords': 'keyword', + '@default': 'identifier', + }, + }, + ], + [ + /[A-Z][\w\$]*/, + { + cases: { + '@typeKeywords': 'keyword', + '@default': 'type.identifier', + }, + }, + ], // to show class names nicely + + // whitespace + { include: '@whitespace' }, + + // delimiters and operators + [/[{}()\[\]]/, '@brackets'], + [ + /@symbols/, + { cases: { '@operators': 'operator', '@default': '' } }, + ], + + // @ annotations. + // As an example, we emit a debugging log message on these tokens. + // Note: message are supressed during the first load -- change some lines to see them. + [ + /@\s*[a-zA-Z_\$][\w\$]*/, + { token: 'annotation', log: 'annotation token: $0' }, + ], + + // numbers + [/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'], + [/0[xX][0-9a-fA-F]+/, 'number.hex'], + [/\d+/, 'number'], + + // delimiter: after number because of .\d floats + [/[;,.]/, 'delimiter'], + + [/"""/, 'string', '@mlstring'], + + // strings + [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/"/, { token: 'string.quote', bracket: '@open', next: '@string' }], + ], + + mlstring: [[/[^"]+/, 'string'], ['"""', 'string', '@pop']], + + string: [ + [/[^\\"]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }], + ], + + whitespace: [[/[ \t\r\n]+/, ''], [/#.*$/, 'comment']], + }, +}; diff --git a/src/monaco.contribution.ts b/src/monaco.contribution.ts index ae9aad59..134795de 100644 --- a/src/monaco.contribution.ts +++ b/src/monaco.contribution.ts @@ -53,3 +53,4 @@ import './shell/shell.contribution'; import './perl/perl.contribution'; import './azcli/azcli.contribution'; import './apex/apex.contribution'; +import './graphql/graphql.contribution'; diff --git a/test/setup.js b/test/setup.js index fe8c8534..e7ed6372 100644 --- a/test/setup.js +++ b/test/setup.js @@ -38,6 +38,7 @@ define(['require'], function () { 'release/dev/dockerfile/dockerfile.test', 'release/dev/fsharp/fsharp.test', 'release/dev/go/go.test', + 'release/dev/graphql/graphql.test', 'release/dev/handlebars/handlebars.test', 'release/dev/html/html.test', 'release/dev/java/java.test', From f7abfe5a37fe2adba69d76aeacfb328056927b87 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Fri, 7 Dec 2018 23:25:21 +0100 Subject: [PATCH 07/25] build(graphql): add graphql to bundle --- scripts/bundle.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/bundle.js b/scripts/bundle.js index 614d5c83..76acc9e9 100644 --- a/scripts/bundle.js +++ b/scripts/bundle.js @@ -70,6 +70,7 @@ bundleOne('perl/perl'), bundleOne('powerquery/powerquery') bundleOne('azcli/azcli') bundleOne('apex/apex'); +bundleOne('graphql/graphql'); function bundleOne(moduleId, exclude) { requirejs.optimize({ From 3dd748c39ca29a72dce4a5fa433e706ccfca9fed Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Sat, 8 Dec 2018 00:34:55 +0100 Subject: [PATCH 08/25] test(graphql): query --- src/graphql/graphql.test.ts | 59 +++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/src/graphql/graphql.test.ts b/src/graphql/graphql.test.ts index 668710fb..c939da60 100644 --- a/src/graphql/graphql.test.ts +++ b/src/graphql/graphql.test.ts @@ -20,21 +20,70 @@ testTokenization('graphql', [ // Root schema definition [{ - line: 'schema { query: Query }', + line: 'schema { query: Query, mutation: Mutation subscription: Subscription }', tokens: [ { startIndex: 0, type: "keyword.gql" }, { startIndex: 6, type: "" }, { startIndex: 7, type: "delimiter.curly.gql" }, { startIndex: 8, type: "" }, - { startIndex: 9, type: "keyword.gql" }, // this should be identifier! - { startIndex: 14, type: "delimiter.gql" }, + { startIndex: 9, type: "keyword.gql" }, // this should be identifier + { startIndex: 14, type: "operator.gql" }, { startIndex: 15, type: "" }, { startIndex: 16, type: "type.identifier.gql" }, - { startIndex: 21, type: "" }, - { startIndex: 22, type: "delimiter.curly.gql" }, + { startIndex: 21, type: "delimiter.gql" }, + { startIndex: 22, type: "" }, + { startIndex: 23, type: "keyword.gql" }, // this should be identifier + { startIndex: 31, type: "operator.gql" }, + { startIndex: 32, type: "" }, + { startIndex: 33, type: "type.identifier.gql" }, + { startIndex: 41, type: "" }, + { startIndex: 42, type: "keyword.gql" }, // this should be identifier + { startIndex: 54, type: "operator.gql" }, + { startIndex: 55, type: "" }, + { startIndex: 56, type: "type.identifier.gql" }, + { startIndex: 68, type: "" }, + { startIndex: 69, type: "delimiter.curly.gql" }, ] }], + [{ + line: `query testQuery($intValue:Int=3){value(arg:{string:"string" int:$intValue}){field1 field2}}`, + tokens: [ + { startIndex: 0, type: "keyword.gql" }, // 'query' + { startIndex: 5, type: "" }, // ' ' + { startIndex: 6, type: "identifier.gql" }, // 'testQuery' + { startIndex: 15, type: "delimiter.parenthesis.gql" }, // '(' + { startIndex: 16, type: "identifier.gql" }, // '$intValue' + { startIndex: 25, type: "operator.gql" }, // ':' + { startIndex: 26, type: "keyword.gql" }, // 'Int' + { startIndex: 29, type: "operator.gql" }, // '=' + { startIndex: 30, type: "number.gql" }, // '3' + { startIndex: 31, type: "delimiter.parenthesis.gql" }, // ')' + { startIndex: 32, type: "delimiter.curly.gql" }, // '{' + { startIndex: 33, type: "identifier.gql" }, // 'value' + { startIndex: 38, type: "delimiter.parenthesis.gql" }, // '(' + { startIndex: 39, type: "identifier.gql" }, // 'arg' + { startIndex: 42, type: "operator.gql" }, // ':' + { startIndex: 43, type: "delimiter.curly.gql" }, // '{' + { startIndex: 44, type: "identifier.gql" }, // 'string' + { startIndex: 50, type: "operator.gql" }, // ':' + { startIndex: 51, type: "string.quote.gql" }, // '"' + { startIndex: 52, type: "string.gql" }, // 'string' + { startIndex: 58, type: "string.quote.gql" }, // '"' + { startIndex: 59, type: "" }, // ' ' + { startIndex: 60, type: "identifier.gql" }, // 'int' + { startIndex: 63, type: "operator.gql" }, // ':' + { startIndex: 64, type: "identifier.gql" }, // '$intValue' + { startIndex: 73, type: "delimiter.curly.gql" }, // '}' + { startIndex: 74, type: "delimiter.parenthesis.gql" }, // ')' + { startIndex: 75, type: "delimiter.curly.gql" }, // '{' + { startIndex: 76, type: "identifier.gql" }, // 'field1' + { startIndex: 82, type: "" }, // ' ' + { startIndex: 83, type: "identifier.gql" }, // 'field2' + { startIndex: 89, type: "delimiter.curly.gql" }, // '}}' + ], + }] + // Comments - single line // Comments - range comment, single line From d4687537fdf3287fe852a6de5fad0cb1e54b0c91 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Sat, 8 Dec 2018 00:59:44 +0100 Subject: [PATCH 09/25] test(graphql): more complex test --- src/graphql/graphql.test.ts | 66 ++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/src/graphql/graphql.test.ts b/src/graphql/graphql.test.ts index c939da60..99cc4464 100644 --- a/src/graphql/graphql.test.ts +++ b/src/graphql/graphql.test.ts @@ -82,10 +82,68 @@ testTokenization('graphql', [ { startIndex: 83, type: "identifier.gql" }, // 'field2' { startIndex: 89, type: "delimiter.curly.gql" }, // '}}' ], - }] - - // Comments - single line + }], - // Comments - range comment, single line + // More complex test: + // """ + // Node interface + // - allows (re)fetch arbitrary entity only by ID + // """ + // interface Node { + // id: ID! + // } + [ + { + line: '"""', + tokens: [ + { startIndex: 0, type: "string.gql" } + ], + }, + { + line: 'Node interface', + tokens: [ + { startIndex: 0, type: "string.gql" } + ], + }, + { + line: '- allows (re)fetch arbitrary entity only by ID', + tokens: [ + { startIndex: 0, type: "string.gql" } + ], + }, + { + line: '"""', + tokens: [ + { startIndex: 0, type: "string.gql" } + ], + }, + { + line: 'interface Node {', + tokens: [ + { startIndex: 0, type: "keyword.gql" }, + { startIndex: 9, type: "" }, + { startIndex: 10, type: "type.identifier.gql" }, + { startIndex: 14, type: "" }, + { startIndex: 15, type: "delimiter.curly.gql" }, + ], + }, + { + line: ' id: ID!', + tokens: [ + { startIndex: 0, type: "" }, + { startIndex: 2, type: "identifier.gql" }, + { startIndex: 4, type: "operator.gql" }, + { startIndex: 5, type: "" }, + { startIndex: 6, type: "keyword.gql" }, + { startIndex: 8, type: "operator.gql" }, + ], + }, + { + line: '}', + tokens: [ + { startIndex: 0, type: "delimiter.curly.gql", }, + ], + }, + ] ]); From d605a30cc7e89d8e2c436a696f8514e195c16cf7 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Sat, 8 Dec 2018 01:18:29 +0100 Subject: [PATCH 10/25] docs(readme): Add graphql to list of languages --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 84f2b10c..767be4d8 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Colorization and configuration supports for multiple languages for the Monaco Ed * dockerfile * fsharp * go +* graphql * handlebars * html * ini From faf8fd35c177535ed733f122177bf3706d7f47db Mon Sep 17 00:00:00 2001 From: Andrew Watson Date: Fri, 7 Dec 2018 16:19:01 -0800 Subject: [PATCH 11/25] Add kotlin-related files, start introducing language constructs --- src/kotlin/kotlin.contribution.ts | 18 +++ src/kotlin/kotlin.ts | 209 ++++++++++++++++++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 src/kotlin/kotlin.contribution.ts create mode 100644 src/kotlin/kotlin.ts diff --git a/src/kotlin/kotlin.contribution.ts b/src/kotlin/kotlin.contribution.ts new file mode 100644 index 00000000..b56711f0 --- /dev/null +++ b/src/kotlin/kotlin.contribution.ts @@ -0,0 +1,18 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +'use strict'; + +import { registerLanguage } from '../_.contribution'; + +// Allow for running under nodejs/requirejs in tests +const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); + +registerLanguage({ + id: 'kotlin', + extensions: ['.kt'], + aliases: ['Kotlin', 'kotlin'], + mimetypes: ['text/x-kotlin-source', 'text/x-kotlin'], + loader: () => _monaco.Promise.wrap(import('./kotlin')) +}); diff --git a/src/kotlin/kotlin.ts b/src/kotlin/kotlin.ts new file mode 100644 index 00000000..82e166b6 --- /dev/null +++ b/src/kotlin/kotlin.ts @@ -0,0 +1,209 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import IRichLanguageConfiguration = monaco.languages.LanguageConfiguration; +import ILanguage = monaco.languages.IMonarchLanguage; + +export const conf: IRichLanguageConfiguration = { + // the default separators except `@$` + wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, + comments: { + lineComment: '//', + blockComment: ['/*', '*/'], + }, + brackets: [ + ['{', '}'], + ['[', ']'], + ['(', ')'], + ], + autoClosingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '"', close: '"' }, + { open: '\'', close: '\'' }, + ], + surroundingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '"', close: '"' }, + { open: '\'', close: '\'' }, + { open: '<', close: '>' }, + ], + folding: { + markers: { + start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:))") + } + } +}; + +export const language = { + defaultToken: '', + tokenPostfix: '.java', + + keywords: [ + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + + ], + + operators: [ + '=', '>', '<', '!', '~', '?', ':', + '==', '<=', '>=', '!=', '&&', '||', '++', '--', + '+', '-', '*', '/', '&', '|', '^', '%', '<<', + '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=', + '^=', '%=', '<<=', '>>=', '>>>=' + ], + + // we include these common regular expressions + symbols: /[=>](?!@symbols)/, '@brackets'], + [/@symbols/, { + cases: { + '@operators': 'delimiter', + '@default': '' + } + }], + + // @ annotations. + [/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'], + + // numbers + [/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'], + [/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'], + [/0[xX](@hexdigits)[Ll]?/, 'number.hex'], + [/0(@octaldigits)[Ll]?/, 'number.octal'], + [/0[bB](@binarydigits)[Ll]?/, 'number.binary'], + [/(@digits)[fFdD]/, 'number.float'], + [/(@digits)[lL]?/, 'number'], + + // delimiter: after number because of .\d floats + [/[;,.]/, 'delimiter'], + + // strings + [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string + [/"/, 'string', '@string'], + + // characters + [/'[^\\']'/, 'string'], + [/(')(@escapes)(')/, ['string', 'string.escape', 'string']], + [/'/, 'string.invalid'] + ], + + whitespace: [ + [/[ \t\r\n]+/, ''], + [/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'], + [/\/\*/, 'comment', '@comment'], + [/\/\/.*$/, 'comment'], + ], + + comment: [ + [/[^\/*]+/, 'comment'], + // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-( + // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/ + [/\*\//, 'comment', '@pop'], + [/[\/*]/, 'comment'] + ], + //Identical copy of comment above, except for the addition of .doc + javadoc: [ + [/[^\/*]+/, 'comment.doc'], + // [/\/\*/, 'comment.doc', '@push' ], // nested comment not allowed :-( + [/\/\*/, 'comment.doc.invalid'], + [/\*\//, 'comment.doc', '@pop'], + [/[\/*]/, 'comment.doc'] + ], + + string: [ + [/[^\\"]+/, 'string'], + [/@escapes/, 'string.escape'], + [/\\./, 'string.escape.invalid'], + [/"/, 'string', '@pop'] + ], + }, +}; From 0d3e237e27710bd828381cce6813be4f17a84947 Mon Sep 17 00:00:00 2001 From: Andrew Watson Date: Fri, 7 Dec 2018 16:35:14 -0800 Subject: [PATCH 12/25] Add keywords --- src/kotlin/kotlin.ts | 76 +++++++------------------------------------- 1 file changed, 12 insertions(+), 64 deletions(-) diff --git a/src/kotlin/kotlin.ts b/src/kotlin/kotlin.ts index 82e166b6..c21a2a95 100644 --- a/src/kotlin/kotlin.ts +++ b/src/kotlin/kotlin.ts @@ -10,7 +10,7 @@ import ILanguage = monaco.languages.IMonarchLanguage; export const conf: IRichLanguageConfiguration = { // the default separators except `@$` - wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, + //wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, comments: { lineComment: '//', blockComment: ['/*', '*/'], @@ -37,8 +37,8 @@ export const conf: IRichLanguageConfiguration = { ], folding: { markers: { - start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:))") + //start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:))") } } }; @@ -48,67 +48,15 @@ export const language = { tokenPostfix: '.java', keywords: [ - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - '', - + 'as', 'as?', 'break', 'class', 'continue', 'do', 'else', 'false', 'for', 'fun', 'if', + 'in', '!in', 'interface', 'is', '!is', 'null', 'object', 'package', 'return', 'super', + 'this', 'throw', 'true', 'try', 'typealias', 'val', 'var', 'when', 'while', 'by', + 'catch', 'constructor', 'delegate', 'dynamic', 'field', 'file', 'finally', 'get', + 'import', 'init', 'param', 'property', 'receiver', 'set', 'setparam', 'where', 'actual', + 'abstract','annotation', 'companion', 'const', 'crossinline', 'data', 'enum', 'expect', + 'external', 'final', 'infix', 'inline', 'inner', 'internal', 'lateinit', 'noinline', + 'open', 'operator', 'out', 'override', 'private', 'protected', 'public', 'reified', + 'sealed', 'suspend', 'tailrec', 'vararg', 'field', 'it' ], operators: [ From c071453275d126841179fd7640e8fefac74776d7 Mon Sep 17 00:00:00 2001 From: Andrew Watson Date: Fri, 7 Dec 2018 16:45:09 -0800 Subject: [PATCH 13/25] Add operators --- src/kotlin/kotlin.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/kotlin/kotlin.ts b/src/kotlin/kotlin.ts index c21a2a95..bfe00319 100644 --- a/src/kotlin/kotlin.ts +++ b/src/kotlin/kotlin.ts @@ -60,11 +60,10 @@ export const language = { ], operators: [ - '=', '>', '<', '!', '~', '?', ':', - '==', '<=', '>=', '!=', '&&', '||', '++', '--', - '+', '-', '*', '/', '&', '|', '^', '%', '<<', - '>>', '>>>', '+=', '-=', '*=', '/=', '&=', '|=', - '^=', '%=', '<<=', '>>=', '>>>=' + '+', '-', '*', '/', '%', '=', '+=', '-=', '*=', '/=', + '%=', '++', '--', '&&', '||', '!', '==', '!=', '===', + '!==', '>', '<', '<=', '>=', '[', ']', '!!', '?.', '?:', + '::', '..', ':', '?', '->', '@', ';', '$', '_' ], // we include these common regular expressions @@ -133,8 +132,6 @@ export const language = { comment: [ [/[^\/*]+/, 'comment'], - // [/\/\*/, 'comment', '@push' ], // nested comment not allowed :-( - // [/\/\*/, 'comment.invalid' ], // this breaks block comments in the shape of /* //*/ [/\*\//, 'comment', '@pop'], [/[\/*]/, 'comment'] ], From 41797ecbbb30bd1c306490be4de4691ce15e4439 Mon Sep 17 00:00:00 2001 From: Andrew Watson Date: Fri, 7 Dec 2018 16:56:35 -0800 Subject: [PATCH 14/25] Update the language now, add monaco contrib --- src/kotlin/kotlin.ts | 8 ++++---- src/monaco.contribution.ts | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/kotlin/kotlin.ts b/src/kotlin/kotlin.ts index bfe00319..8d8210d4 100644 --- a/src/kotlin/kotlin.ts +++ b/src/kotlin/kotlin.ts @@ -10,10 +10,10 @@ import ILanguage = monaco.languages.IMonarchLanguage; export const conf: IRichLanguageConfiguration = { // the default separators except `@$` - //wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, + wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, comments: { lineComment: '//', - blockComment: ['/*', '*/'], + blockComment: ['/**', '*/'], }, brackets: [ ['{', '}'], @@ -37,8 +37,8 @@ export const conf: IRichLanguageConfiguration = { ], folding: { markers: { - //start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:))") + start: new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:))") } } }; diff --git a/src/monaco.contribution.ts b/src/monaco.contribution.ts index ae9aad59..9704c086 100644 --- a/src/monaco.contribution.ts +++ b/src/monaco.contribution.ts @@ -18,6 +18,7 @@ import './html/html.contribution'; import './ini/ini.contribution'; import './java/java.contribution'; import './javascript/javascript.contribution'; +import './kotlin/kotlin.contribution'; import './less/less.contribution'; import './lua/lua.contribution'; import './markdown/markdown.contribution'; From 140cba979d69eaf5add3c518a905652db479e1ca Mon Sep 17 00:00:00 2001 From: Andrew Watson Date: Fri, 7 Dec 2018 17:25:08 -0800 Subject: [PATCH 15/25] Lotsa upates getting tests to pass --- src/kotlin/kotlin.test.ts | 647 ++++++++++++++++++++++++++++++++++++++ src/kotlin/kotlin.ts | 4 +- test/setup.js | 1 + 3 files changed, 650 insertions(+), 2 deletions(-) create mode 100644 src/kotlin/kotlin.test.ts diff --git a/src/kotlin/kotlin.test.ts b/src/kotlin/kotlin.test.ts new file mode 100644 index 00000000..9e6a1743 --- /dev/null +++ b/src/kotlin/kotlin.test.ts @@ -0,0 +1,647 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +'use strict'; + +import { testTokenization } from '../test/testRunner'; + +testTokenization('kotlin', [ + // Comments - single line + [{ + line: '//', + tokens: [ + { startIndex: 0, type: 'comment.kt' } + ] + }], + + [{ + line: ' // a comment', + tokens: [ + { startIndex: 0, type: '' }, + { startIndex: 4, type: 'comment.kt' } + ] + }], + + // Broken nested tokens due to invalid comment tokenization + [{ + line: '/* //*/ a', + tokens: [ + { startIndex: 0, type: 'comment.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.kt' } + ] + }], + + [{ + line: '// a comment', + tokens: [ + { startIndex: 0, type: 'comment.kt' } + ] + }], + + [{ + line: '//sticky comment', + tokens: [ + { startIndex: 0, type: 'comment.kt' } + ] + }], + + [{ + line: '/almost a comment', + tokens: [ + { startIndex: 0, type: 'delimiter.kt' }, + { startIndex: 1, type: 'identifier.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.kt' }, + { startIndex: 9, type: '' }, + { startIndex: 10, type: 'identifier.kt' } + ] + }], + + [{ + line: '1 / 2; /* comment', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.kt' }, + { startIndex: 5, type: 'delimiter.kt' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'comment.kt' } + ] + }], + + // [{ + // line: 'var x = 1 // my comment // is a nice one', + // tokens: [ + // { startIndex: 0, type: 'keyword.var.kt' }, + // { startIndex: 3, type: '' }, + // { startIndex: 4, type: 'identifier.kt' }, + // { startIndex: 5, type: '' }, + // { startIndex: 6, type: 'delimiter.kt' }, + // { startIndex: 7, type: '' }, + // { startIndex: 8, type: 'number.kt' }, + // { startIndex: 9, type: '' }, + // { startIndex: 10, type: 'comment.kt' }, + // { startIndex: 12, type: '' }, + // { startIndex: 13, type: 'comment.kt' } + // ] + // }], + + // Comments - range comment, single line + [{ + line: '/* a simple comment */', + tokens: [ + { startIndex: 0, type: 'comment.kt' } + ] + }], + + [{ + line: 'var x = /* a simple comment */ 1', + tokens: [ + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.kt' }, + { startIndex: 30, type: '' }, + { startIndex: 31, type: 'number.kt' }, + ] + }], + + [{ + line: 'var x = /* comment */ 1; */', + tokens: [ + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.kt' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'number.kt' }, + { startIndex: 23, type: 'delimiter.kt' }, + { startIndex: 24, type: '' } + ] + }], + + [{ + line: 'x = /**/', + tokens: [ + { startIndex: 0, type: 'identifier.kt' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'comment.kt' }, + ] + }], + + [{ + line: 'var x = /** start a Java Doc comment', + tokens: [ + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'comment.doc.kt' } + ] + }, { + line: ' a ', + tokens: [ + { startIndex: 0, type: 'comment.doc.kt' } + ] + }, { + line: 'and end it */ 2', + tokens: [ + { startIndex: 0, type: 'comment.doc.kt' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'number.kt' }, + ] + }], + + [{ + line: '/** start of Java Doc', + tokens: [ + { startIndex: 0, type: 'comment.doc.kt' } + ] + }, { + line: 'a comment between without a star', + tokens: [ + { startIndex: 0, type: 'comment.doc.kt' } + ] + }, { + line: 'end of multiline comment*/', + tokens: [ + { startIndex: 0, type: 'comment.doc.kt' } + ] + }], + + // Keywords + [{ + line: 'package test; class Program { fun main(args: String[]) {} } }', + tokens: [ + { startIndex: 0, type: 'keyword.package.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'identifier.kt' }, + { startIndex: 12, type: 'delimiter.kt' }, + { startIndex: 13, type: '' }, + { startIndex: 14, type: 'keyword.class.kt' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'identifier.kt' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'delimiter.curly.kt' }, + { startIndex: 29, type: '' }, + { startIndex: 30, type: 'keyword.fun.kt' }, + { startIndex: 36, type: '' }, + { startIndex: 42, type: 'identifier.kt' }, + { startIndex: 46, type: 'delimiter.parenthesis.kt' }, + { startIndex: 47, type: 'identifier.kt' }, + { startIndex: 53, type: 'delimiter.square.kt' }, + { startIndex: 55, type: '' }, + { startIndex: 56, type: 'identifier.kt' }, + { startIndex: 60, type: 'delimiter.parenthesis.kt' }, + { startIndex: 61, type: '' }, + { startIndex: 62, type: 'delimiter.curly.kt' }, + { startIndex: 64, type: '' }, + { startIndex: 65, type: 'delimiter.curly.kt' }, + { startIndex: 66, type: '' }, + { startIndex: 67, type: 'delimiter.curly.kt' } + ] + }], + + // Numbers + [{ + line: '0', + tokens: [ + { startIndex: 0, type: 'number.kt' } + ] + }], + + [{ + line: '0.10', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '0x', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'identifier.kt' } + ] + }], + + [{ + line: '0x123', + tokens: [ + { startIndex: 0, type: 'number.hex.kt' } + ] + }], + + [{ + line: '0x5_2', + tokens: [ + { startIndex: 0, type: 'number.hex.kt' } + ] + }], + + [{ + line: '023L', + tokens: [ + { startIndex: 0, type: 'number.octal.kt' } + ] + }], + + [{ + line: '0123l', + tokens: [ + { startIndex: 0, type: 'number.octal.kt' } + ] + }], + + [{ + line: '05_2', + tokens: [ + { startIndex: 0, type: 'number.octal.kt' } + ] + }], + + [{ + line: '0b1010_0101', + tokens: [ + { startIndex: 0, type: 'number.binary.kt' } + ] + }], + + [{ + line: '0B001', + tokens: [ + { startIndex: 0, type: 'number.binary.kt' } + ] + }], + + [{ + line: '10e3', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '10f', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5e3', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5e-3', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5E3', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5E-3', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5F', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5f', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5D', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23.5d', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '1.72E3D', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '1.72E3d', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '1.72E-3d', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '1.72e3D', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '1.72e3d', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '1.72e-3d', + tokens: [ + { startIndex: 0, type: 'number.float.kt' } + ] + }], + + [{ + line: '23L', + tokens: [ + { startIndex: 0, type: 'number.kt' } + ] + }], + + [{ + line: '23l', + tokens: [ + { startIndex: 0, type: 'number.kt' } + ] + }], + + [{ + line: '0_52', + tokens: [ + { startIndex: 0, type: 'number.kt' } + ] + }], + + [{ + line: '5_2', + tokens: [ + { startIndex: 0, type: 'number.kt' } + ] + }], + + [{ + line: '5_______2', + tokens: [ + { startIndex: 0, type: 'number.kt' } + ] + }], + + [{ + line: '3_.1415F', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'identifier.kt' }, + { startIndex: 2, type: 'delimiter.kt' }, + { startIndex: 3, type: 'number.float.kt' } + ] + }], + + [{ + line: '3._1415F', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'delimiter.kt' }, + { startIndex: 2, type: 'identifier.kt' } + ] + }], + + [{ + line: '999_99_9999_L', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 11, type: 'identifier.kt' } + ] + }], + + [{ + line: '52_', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 2, type: 'identifier.kt' } + ] + }], + + [{ + line: '0_x52', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'identifier.kt' } + ] + }], + + [{ + line: '0x_52', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'identifier.kt' } + ] + }], + + [{ + line: '0x52_', + tokens: [ + { startIndex: 0, type: 'number.hex.kt' }, + { startIndex: 4, type: 'identifier.kt' } + ] + }], + + [{ + line: '052_', + tokens: [ + { startIndex: 0, type: 'number.octal.kt' }, + { startIndex: 3, type: 'identifier.kt' } + ] + }], + + [{ + line: '23.5L', + tokens: [ + { startIndex: 0, type: 'number.float.kt' }, + { startIndex: 4, type: 'identifier.kt' } + ] + }], + + [{ + line: '0+0', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: 'delimiter.kt' }, + { startIndex: 2, type: 'number.kt' } + ] + }], + + [{ + line: '100+10', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 3, type: 'delimiter.kt' }, + { startIndex: 4, type: 'number.kt' } + ] + }], + + [{ + line: '0 + 0', + tokens: [ + { startIndex: 0, type: 'number.kt' }, + { startIndex: 1, type: '' }, + { startIndex: 2, type: 'delimiter.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'number.kt' } + ] + }], + + // single line Strings + [{ + line: 'var s = "I\'m a Kotlin String";', + tokens: [ + { startIndex: 0, type: 'identifier.kt' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.kt' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.kt' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.kt' }, + { startIndex: 30, type: 'delimiter.kt' } + ] + }], + + [{ + line: 'String s = "concatenated" + " String" ;', + tokens: [ + { startIndex: 0, type: 'identifier.kt' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'identifier.kt' }, + { startIndex: 8, type: '' }, + { startIndex: 9, type: 'delimiter.kt' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'string.kt' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'delimiter.kt' }, + { startIndex: 27, type: '' }, + { startIndex: 28, type: 'string.kt' }, + { startIndex: 37, type: '' }, + { startIndex: 38, type: 'delimiter.kt' } + ] + }], + + [{ + line: '"quote in a string"', + tokens: [ + { startIndex: 0, type: 'string.kt' } + ] + }], + + [{ + line: '"escaping \\"quotes\\" is cool"', + tokens: [ + { startIndex: 0, type: 'string.kt' }, + { startIndex: 10, type: 'string.escape.kt' }, + { startIndex: 12, type: 'string.kt' }, + { startIndex: 18, type: 'string.escape.kt' }, + { startIndex: 20, type: 'string.kt' } + ] + }], + + [{ + line: '"\\"', + tokens: [ + { startIndex: 0, type: 'string.invalid.kt' } + ] + }], + + // Annotations + [{ + line: '@', + tokens: [ + { startIndex: 0, type: '' } + ] + }], + + [{ + line: '@Override', + tokens: [ + { startIndex: 0, type: 'annotation.kt' } + ] + }], + + [{ + line: '@SuppressWarnings(value = "aString")', + tokens: [ + { startIndex: 0, type: 'annotation.kt' }, + { startIndex: 17, type: 'delimiter.parenthesis.kt' }, + { startIndex: 18, type: 'identifier.kt' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'delimiter.kt' }, + { startIndex: 25, type: '' }, + { startIndex: 26, type: 'string.kt' }, + { startIndex: 35, type: 'delimiter.parenthesis.kt' } + ] + }], + + [{ + line: '@ AnnotationWithKeywordAfter private', + tokens: [ + { startIndex: 0, type: 'annotation.kt' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'keyword.private.kt' } + ] + }] +]); + diff --git a/src/kotlin/kotlin.ts b/src/kotlin/kotlin.ts index 8d8210d4..732ef3f8 100644 --- a/src/kotlin/kotlin.ts +++ b/src/kotlin/kotlin.ts @@ -13,7 +13,7 @@ export const conf: IRichLanguageConfiguration = { wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, comments: { lineComment: '//', - blockComment: ['/**', '*/'], + blockComment: ['/*', '*/'], }, brackets: [ ['{', '}'], @@ -45,7 +45,7 @@ export const conf: IRichLanguageConfiguration = { export const language = { defaultToken: '', - tokenPostfix: '.java', + tokenPostfix: '.kt', keywords: [ 'as', 'as?', 'break', 'class', 'continue', 'do', 'else', 'false', 'for', 'fun', 'if', diff --git a/test/setup.js b/test/setup.js index fe8c8534..b7ce51ed 100644 --- a/test/setup.js +++ b/test/setup.js @@ -42,6 +42,7 @@ define(['require'], function () { 'release/dev/html/html.test', 'release/dev/java/java.test', 'release/dev/javascript/javascript.test', + 'release/dev/kotlin/kotlin.test', 'release/dev/less/less.test', 'release/dev/lua/lua.test', 'release/dev/markdown/markdown.test', From a6f2e04d34cb4af7baf0571431cc0629c94bc1f7 Mon Sep 17 00:00:00 2001 From: Andrew Watson Date: Fri, 7 Dec 2018 17:54:35 -0800 Subject: [PATCH 16/25] Finish up getting tests working --- src/kotlin/kotlin.test.ts | 106 +++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/src/kotlin/kotlin.test.ts b/src/kotlin/kotlin.test.ts index 9e6a1743..58dda733 100644 --- a/src/kotlin/kotlin.test.ts +++ b/src/kotlin/kotlin.test.ts @@ -184,36 +184,43 @@ testTokenization('kotlin', [ ] }], +/** + +package test class Program { fun main(vararg args: String) {} } } + + */ + // Keywords [{ - line: 'package test; class Program { fun main(args: String[]) {} } }', + line: 'package test class Program { fun main(vararg args: String) {} } }', tokens: [ { startIndex: 0, type: 'keyword.package.kt' }, { startIndex: 7, type: '' }, { startIndex: 8, type: 'identifier.kt' }, - { startIndex: 12, type: 'delimiter.kt' }, - { startIndex: 13, type: '' }, - { startIndex: 14, type: 'keyword.class.kt' }, - { startIndex: 19, type: '' }, - { startIndex: 20, type: 'identifier.kt' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'delimiter.curly.kt' }, - { startIndex: 29, type: '' }, - { startIndex: 30, type: 'keyword.fun.kt' }, - { startIndex: 36, type: '' }, - { startIndex: 42, type: 'identifier.kt' }, - { startIndex: 46, type: 'delimiter.parenthesis.kt' }, - { startIndex: 47, type: 'identifier.kt' }, - { startIndex: 53, type: 'delimiter.square.kt' }, - { startIndex: 55, type: '' }, - { startIndex: 56, type: 'identifier.kt' }, - { startIndex: 60, type: 'delimiter.parenthesis.kt' }, + { startIndex: 12, type: '' }, + { startIndex: 13, type: 'keyword.class.kt' }, + { startIndex: 18, type: '' }, + { startIndex: 19, type: 'identifier.kt' }, + { startIndex: 26, type: '' }, + { startIndex: 27, type: 'delimiter.curly.kt' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'keyword.fun.kt' }, + { startIndex: 32, type: '' }, + { startIndex: 33, type: 'identifier.kt' }, + { startIndex: 37, type: 'delimiter.parenthesis.kt' }, + { startIndex: 38, type: 'keyword.vararg.kt' }, + { startIndex: 44, type: '' }, + { startIndex: 45, type: 'identifier.kt' }, + { startIndex: 49, type: 'delimiter.kt' }, + { startIndex: 50, type: '' }, + { startIndex: 51, type: 'identifier.kt' }, + { startIndex: 57, type: 'delimiter.parenthesis.kt' }, + { startIndex: 58, type: '' }, + { startIndex: 59, type: 'delimiter.curly.kt' }, { startIndex: 61, type: '' }, { startIndex: 62, type: 'delimiter.curly.kt' }, - { startIndex: 64, type: '' }, - { startIndex: 65, type: 'delimiter.curly.kt' }, - { startIndex: 66, type: '' }, - { startIndex: 67, type: 'delimiter.curly.kt' } + { startIndex: 63, type: '' }, + { startIndex: 64, type: 'delimiter.curly.kt' } ] }], @@ -549,35 +556,32 @@ testTokenization('kotlin', [ // single line Strings [{ - line: 'var s = "I\'m a Kotlin String";', + line: 'var s = "I\'m a Kotlin String"', tokens: [ - { startIndex: 0, type: 'identifier.kt' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.kt' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.kt' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.kt' }, - { startIndex: 30, type: 'delimiter.kt' } + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.kt' }, ] }], [{ - line: 'String s = "concatenated" + " String" ;', + line: 'var s = "concatenated" + " String"', tokens: [ - { startIndex: 0, type: 'identifier.kt' }, - { startIndex: 6, type: '' }, - { startIndex: 7, type: 'identifier.kt' }, - { startIndex: 8, type: '' }, - { startIndex: 9, type: 'delimiter.kt' }, - { startIndex: 10, type: '' }, - { startIndex: 11, type: 'string.kt' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'delimiter.kt' }, - { startIndex: 27, type: '' }, - { startIndex: 28, type: 'string.kt' }, - { startIndex: 37, type: '' }, - { startIndex: 38, type: 'delimiter.kt' } + { startIndex: 0, type: 'keyword.var.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: '' }, + { startIndex: 6, type: 'delimiter.kt' }, + { startIndex: 7, type: '' }, + { startIndex: 8, type: 'string.kt' }, + { startIndex: 22, type: '' }, + { startIndex: 23, type: 'delimiter.kt' }, + { startIndex: 24, type: '' }, + { startIndex: 25, type: 'string.kt' }, ] }], @@ -615,23 +619,19 @@ testTokenization('kotlin', [ }], [{ - line: '@Override', + line: '@Inject', tokens: [ { startIndex: 0, type: 'annotation.kt' } ] }], [{ - line: '@SuppressWarnings(value = "aString")', + line: '@SuppressWarnings("aString")', tokens: [ { startIndex: 0, type: 'annotation.kt' }, { startIndex: 17, type: 'delimiter.parenthesis.kt' }, - { startIndex: 18, type: 'identifier.kt' }, - { startIndex: 23, type: '' }, - { startIndex: 24, type: 'delimiter.kt' }, - { startIndex: 25, type: '' }, - { startIndex: 26, type: 'string.kt' }, - { startIndex: 35, type: 'delimiter.parenthesis.kt' } + { startIndex: 18, type: 'string.kt' }, + { startIndex: 27, type: 'delimiter.parenthesis.kt' } ] }], From 0eed4aa6528a4645372938d100dbfde3835ec64c Mon Sep 17 00:00:00 2001 From: Andrew Watson Date: Fri, 7 Dec 2018 17:55:55 -0800 Subject: [PATCH 17/25] Add language to bundle js --- scripts/bundle.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/bundle.js b/scripts/bundle.js index 614d5c83..a59785a6 100644 --- a/scripts/bundle.js +++ b/scripts/bundle.js @@ -35,6 +35,7 @@ bundleOne('ini/ini'); bundleOne('pug/pug'); bundleOne('java/java'); bundleOne('javascript/javascript'); +bundleOne('kotlin/kotlin'); bundleOne('less/less'); bundleOne('lua/lua'); bundleOne('markdown/markdown'); From 1ff4648d0563998b7dbe56dc6a9dcd4ccebac9e8 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Sat, 8 Dec 2018 03:35:28 +0100 Subject: [PATCH 18/25] feat(graphql): treat block strings as markdown --- src/graphql/graphql.test.ts | 10 ++-------- src/graphql/graphql.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/graphql/graphql.test.ts b/src/graphql/graphql.test.ts index 99cc4464..20f112b4 100644 --- a/src/graphql/graphql.test.ts +++ b/src/graphql/graphql.test.ts @@ -100,15 +100,9 @@ testTokenization('graphql', [ ], }, { - line: 'Node interface', + line: 'This is MarkDown', tokens: [ - { startIndex: 0, type: "string.gql" } - ], - }, - { - line: '- allows (re)fetch arbitrary entity only by ID', - tokens: [ - { startIndex: 0, type: "string.gql" } + { startIndex: 0, type: "" } ], }, { diff --git a/src/graphql/graphql.ts b/src/graphql/graphql.ts index 95620114..2799971f 100644 --- a/src/graphql/graphql.ts +++ b/src/graphql/graphql.ts @@ -115,14 +115,19 @@ export const language = { // delimiter: after number because of .\d floats [/[;,.]/, 'delimiter'], - [/"""/, 'string', '@mlstring'], + [/"""/, + { token: 'string', next: '@mlstring', nextEmbedded: 'markdown' } + ], // strings [/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string [/"/, { token: 'string.quote', bracket: '@open', next: '@string' }], ], - mlstring: [[/[^"]+/, 'string'], ['"""', 'string', '@pop']], + mlstring: [ + [/[^"]+/, 'string'], + ['"""', { token: 'string', next: '@pop', nextEmbedded: '@pop' }] + ], string: [ [/[^\\"]+/, 'string'], From 4ab50c667ea5c94314282664f4f23f7b8becb073 Mon Sep 17 00:00:00 2001 From: Pavel Lang Date: Sat, 8 Dec 2018 03:47:39 +0100 Subject: [PATCH 19/25] fix(graphql): add implements to keywords --- src/graphql/graphql.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphql/graphql.ts b/src/graphql/graphql.ts index 2799971f..5d4cbd07 100644 --- a/src/graphql/graphql.ts +++ b/src/graphql/graphql.ts @@ -45,7 +45,7 @@ export const language = { 'null', 'true', 'false', 'query', 'mutation', 'subscription', 'extend', 'schema', 'directive', - 'scalar', 'type', 'interface', 'union', 'enum', 'input', + 'scalar', 'type', 'interface', 'union', 'enum', 'input', 'implements', 'fragment', 'on', ], From 2683160fab01e0ab5dd66d18ff74f923f05b5a19 Mon Sep 17 00:00:00 2001 From: Caleb Tseng Date: Mon, 10 Dec 2018 14:53:49 -0800 Subject: [PATCH 20/25] Adding class highlighting and unit tests --- src/kotlin/kotlin.test.ts | 56 ++++++++++++++++++++++++++++----------- src/kotlin/kotlin.ts | 4 +++ 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/src/kotlin/kotlin.test.ts b/src/kotlin/kotlin.test.ts index 58dda733..848fc768 100644 --- a/src/kotlin/kotlin.test.ts +++ b/src/kotlin/kotlin.test.ts @@ -8,6 +8,44 @@ import { testTokenization } from '../test/testRunner'; testTokenization('kotlin', [ + // inline reified function + [{ + line: 'inline fun foo()', + tokens: [ + { startIndex: 0, type: 'keyword.inline.kt' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'keyword.fun.kt' }, + { startIndex: 10, type: '' }, + { startIndex: 11, type: 'delimiter.angle.kt' }, + { startIndex: 12, type: 'keyword.reified.kt' }, + { startIndex: 19, type: '' }, + { startIndex: 20, type: 'type.identifier.kt' }, + { startIndex: 21, type: '' }, + { startIndex: 22, type: 'delimiter.kt' }, + { startIndex: 23, type: '' }, + { startIndex: 24, type: 'type.identifier.kt' }, + { startIndex: 27, type: 'delimiter.angle.kt' }, + { startIndex: 28, type: '' }, + { startIndex: 29, type: 'identifier.kt' }, + { startIndex: 32, type: 'delimiter.parenthesis.kt' }, + ] + }], + + // Val declaration and assignment + [{ + line: 'val x: X=5', + tokens: [ + { startIndex: 0, type: 'keyword.val.kt' }, + { startIndex: 3, type: '' }, + { startIndex: 4, type: 'identifier.kt' }, + { startIndex: 5, type: 'delimiter.kt' }, + { startIndex: 6, type: '' }, + { startIndex: 7, type: 'type.identifier.kt' }, + { startIndex: 8, type: 'delimiter.kt' }, + { startIndex: 9, type: 'number.kt' }, + ] + }], + // Comments - single line [{ line: '//', @@ -184,12 +222,6 @@ testTokenization('kotlin', [ ] }], -/** - -package test class Program { fun main(vararg args: String) {} } } - - */ - // Keywords [{ line: 'package test class Program { fun main(vararg args: String) {} } }', @@ -200,7 +232,7 @@ package test class Program { fun main(vararg args: String) {} } } { startIndex: 12, type: '' }, { startIndex: 13, type: 'keyword.class.kt' }, { startIndex: 18, type: '' }, - { startIndex: 19, type: 'identifier.kt' }, + { startIndex: 19, type: 'type.identifier.kt' }, { startIndex: 26, type: '' }, { startIndex: 27, type: 'delimiter.curly.kt' }, { startIndex: 28, type: '' }, @@ -213,7 +245,7 @@ package test class Program { fun main(vararg args: String) {} } } { startIndex: 45, type: 'identifier.kt' }, { startIndex: 49, type: 'delimiter.kt' }, { startIndex: 50, type: '' }, - { startIndex: 51, type: 'identifier.kt' }, + { startIndex: 51, type: 'type.identifier.kt' }, { startIndex: 57, type: 'delimiter.parenthesis.kt' }, { startIndex: 58, type: '' }, { startIndex: 59, type: 'delimiter.curly.kt' }, @@ -517,14 +549,6 @@ package test class Program { fun main(vararg args: String) {} } } ] }], - [{ - line: '23.5L', - tokens: [ - { startIndex: 0, type: 'number.float.kt' }, - { startIndex: 4, type: 'identifier.kt' } - ] - }], - [{ line: '0+0', tokens: [ diff --git a/src/kotlin/kotlin.ts b/src/kotlin/kotlin.ts index 732ef3f8..6e57fc0b 100644 --- a/src/kotlin/kotlin.ts +++ b/src/kotlin/kotlin.ts @@ -76,7 +76,11 @@ export const language = { // The main tokenizer for our languages tokenizer: { + root: [ + // class name highlighting + [/[A-Z][\w\$]*/, 'type.identifier' ], + // identifiers and keywords [/[a-zA-Z_$][\w$]*/, { cases: { From ea1dd2c5cf7c76e4479d485a2dc71ec7fac0082d Mon Sep 17 00:00:00 2001 From: Brijesh Bittu <717550+brijeshb42@users.noreply.github.com> Date: Sat, 15 Dec 2018 10:08:55 +0530 Subject: [PATCH 21/25] Update ruby auto indent rules Copied rules from `vscode/extensions/ruby/language-configuration.json` --- src/ruby/ruby.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ruby/ruby.ts b/src/ruby/ruby.ts index bc5b14c1..35250315 100644 --- a/src/ruby/ruby.ts +++ b/src/ruby/ruby.ts @@ -31,7 +31,11 @@ export const conf: IRichLanguageConfiguration = { { open: '(', close: ')' }, { open: '"', close: '"' }, { open: '\'', close: '\'' }, - ] + ], + indentationRules: { + increaseIndentPattern: new RegExp('^\\s*((begin|class|(private|protected)\\s+def|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|case)|([^#]*\\sdo\\b)|([^#]*=\\s*(case|if|unless)))\\b([^#\\{;]|("|\'|\/).*\\4)*(#.*)?$'), + decreaseIndentPattern: new RegExp('^\\s*([}\\]]([,)]?\\s*(#|$)|\\.[a-zA-Z_]\\w*\\b)|(end|rescue|ensure|else|elsif|when)\\b)'), + } }; /* From 6b675164e593a05a80d0338eadf7ae1705133e8f Mon Sep 17 00:00:00 2001 From: Abdussalam Abdurrahman Date: Mon, 17 Dec 2018 21:01:26 -0800 Subject: [PATCH 22/25] Add ".edn" to the list of file name extensions --- src/clojure/clojure.contribution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clojure/clojure.contribution.ts b/src/clojure/clojure.contribution.ts index d5d7e81c..f02cc461 100644 --- a/src/clojure/clojure.contribution.ts +++ b/src/clojure/clojure.contribution.ts @@ -12,7 +12,7 @@ const _monaco: typeof monaco = registerLanguage({ id: 'clojure', - extensions: ['.clj', '.cljs', '.cljc'], + extensions: ['.clj', '.cljs', '.cljc', '.edn'], aliases: ['clojure', 'Clojure'], loader: () => _monaco.Promise.wrap(import('./clojure')), }); From 35c57b599039469c56cce1deebaed43cc2a33c1b Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 9 Jan 2019 16:14:09 +0100 Subject: [PATCH 23/25] Adopt native promises --- src/_.contribution.ts | 8 ++++---- src/apex/apex.contribution.ts | 5 +---- src/azcli/azcli.contribution.ts | 5 +---- src/bat/bat.contribution.ts | 5 +---- src/clojure/clojure.contribution.ts | 6 +----- src/coffee/coffee.contribution.ts | 5 +---- src/cpp/cpp.contribution.ts | 7 ++----- src/csharp/csharp.contribution.ts | 5 +---- src/csp/csp.contribution.ts | 5 +---- src/css/css.contribution.ts | 5 +---- src/dockerfile/dockerfile.contribution.ts | 5 +---- src/fsharp/fsharp.contribution.ts | 5 +---- src/go/go.contribution.ts | 5 +---- src/handlebars/handlebars.contribution.ts | 5 +---- src/html/html.contribution.ts | 5 +---- src/ini/ini.contribution.ts | 5 +---- src/java/java.contribution.ts | 5 +---- src/javascript/javascript.contribution.ts | 5 +---- src/less/less.contribution.ts | 5 +---- src/lua/lua.contribution.ts | 5 +---- src/markdown/markdown.contribution.ts | 5 +---- src/msdax/msdax.contribution.ts | 5 +---- src/mysql/mysql.contribution.ts | 5 +---- src/objective-c/objective-c.contribution.ts | 5 +---- src/perl/perl.contribution.ts | 5 +---- src/pgsql/pgsql.contribution.ts | 5 +---- src/php/php.contribution.ts | 5 +---- src/postiats/postiats.contribution.ts | 5 +---- src/powerquery/powerquery.contribution.ts | 5 +---- src/powershell/powershell.contribution.ts | 5 +---- src/pug/pug.contribution.ts | 5 +---- src/python/python.contribution.ts | 5 +---- src/r/r.contribution.ts | 5 +---- src/razor/razor.contribution.ts | 5 +---- src/redis/redis.contribution.ts | 5 +---- src/redshift/redshift.contribution.ts | 5 +---- src/ruby/ruby.contribution.ts | 5 +---- src/rust/rust.contribution.ts | 5 +---- src/sb/sb.contribution.ts | 5 +---- src/scheme/scheme.contribution.ts | 6 +----- src/scss/scss.contribution.ts | 5 +---- src/shell/shell.contribution.ts | 6 +----- src/solidity/solidity.contribution.ts | 5 +---- src/sql/sql.contribution.ts | 5 +---- src/st/st.contribution.ts | 5 +---- src/swift/swift.contribution.ts | 5 +---- src/typescript/typescript.contribution.ts | 5 +---- src/vb/vb.contribution.ts | 5 +---- src/xml/xml.contribution.ts | 5 +---- src/yaml/yaml.contribution.ts | 5 +---- 50 files changed, 54 insertions(+), 204 deletions(-) diff --git a/src/_.contribution.ts b/src/_.contribution.ts index 80594a56..5aafec65 100644 --- a/src/_.contribution.ts +++ b/src/_.contribution.ts @@ -8,7 +8,7 @@ const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); interface ILang extends monaco.languages.ILanguageExtensionPoint { - loader: () => monaco.Promise; + loader: () => Promise; } interface ILangImpl { @@ -18,7 +18,7 @@ interface ILangImpl { let languageDefinitions: { [languageId: string]: ILang } = {}; -function _loadLanguage(languageId: string): monaco.Promise { +function _loadLanguage(languageId: string): Promise { const loader = languageDefinitions[languageId].loader; return loader().then((mod) => { _monaco.languages.setMonarchTokensProvider(languageId, mod.language); @@ -26,9 +26,9 @@ function _loadLanguage(languageId: string): monaco.Promise { }); } -let languagePromises: { [languageId: string]: monaco.Promise } = {}; +let languagePromises: { [languageId: string]: Promise } = {}; -export function loadLanguage(languageId: string): monaco.Promise { +export function loadLanguage(languageId: string): Promise { if (!languagePromises[languageId]) { languagePromises[languageId] = _loadLanguage(languageId); } diff --git a/src/apex/apex.contribution.ts b/src/apex/apex.contribution.ts index d7a38595..921873df 100644 --- a/src/apex/apex.contribution.ts +++ b/src/apex/apex.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'apex', extensions: ['.cls'], aliases: ['Apex', 'apex'], mimetypes: ['text/x-apex-source', 'text/x-apex'], - loader: () => _monaco.Promise.wrap(import('./apex')) + loader: () => import('./apex') }); diff --git a/src/azcli/azcli.contribution.ts b/src/azcli/azcli.contribution.ts index c94c07bd..50511a41 100644 --- a/src/azcli/azcli.contribution.ts +++ b/src/azcli/azcli.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'azcli', extensions: ['.azcli'], aliases: ['Azure CLI', 'azcli'], - loader: () => _monaco.Promise.wrap(import('./azcli')) + loader: () => import('./azcli') }); diff --git a/src/bat/bat.contribution.ts b/src/bat/bat.contribution.ts index 91261712..a17f9d0f 100644 --- a/src/bat/bat.contribution.ts +++ b/src/bat/bat.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'bat', extensions: ['.bat', '.cmd'], aliases: ['Batch', 'bat'], - loader: () => _monaco.Promise.wrap(import('./bat')) + loader: () => import('./bat') }); diff --git a/src/clojure/clojure.contribution.ts b/src/clojure/clojure.contribution.ts index fc0e885f..01c6738d 100644 --- a/src/clojure/clojure.contribution.ts +++ b/src/clojure/clojure.contribution.ts @@ -6,13 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = - typeof monaco === 'undefined' ? (self).monaco : monaco; - registerLanguage({ id: 'clojure', extensions: ['.clj', '.clojure'], aliases: ['clojure', 'Clojure'], - loader: () => _monaco.Promise.wrap(import('./clojure')), + loader: () => import('./clojure') }); diff --git a/src/coffee/coffee.contribution.ts b/src/coffee/coffee.contribution.ts index 2e180f64..67f67311 100644 --- a/src/coffee/coffee.contribution.ts +++ b/src/coffee/coffee.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'coffeescript', extensions: ['.coffee'], aliases: ['CoffeeScript', 'coffeescript', 'coffee'], mimetypes: ['text/x-coffeescript', 'text/coffeescript'], - loader: () => _monaco.Promise.wrap(import('./coffee')) + loader: () => import('./coffee') }); diff --git a/src/cpp/cpp.contribution.ts b/src/cpp/cpp.contribution.ts index e69b052b..60700bff 100644 --- a/src/cpp/cpp.contribution.ts +++ b/src/cpp/cpp.contribution.ts @@ -6,18 +6,15 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'c', extensions: ['.c', '.h'], aliases: ['C', 'c'], - loader: () => _monaco.Promise.wrap(import('./cpp')) + loader: () => import('./cpp') }); registerLanguage({ id: 'cpp', extensions: ['.cpp', '.cc', '.cxx', '.hpp', '.hh', '.hxx'], aliases: ['C++', 'Cpp', 'cpp'], - loader: () => _monaco.Promise.wrap(import('./cpp')) + loader: () => import('./cpp') }); diff --git a/src/csharp/csharp.contribution.ts b/src/csharp/csharp.contribution.ts index ba1b4c8a..3a34f302 100644 --- a/src/csharp/csharp.contribution.ts +++ b/src/csharp/csharp.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'csharp', extensions: ['.cs', '.csx', '.cake'], aliases: ['C#', 'csharp'], - loader: () => _monaco.Promise.wrap(import('./csharp')) + loader: () => import('./csharp') }); diff --git a/src/csp/csp.contribution.ts b/src/csp/csp.contribution.ts index 3deef58d..bd522448 100644 --- a/src/csp/csp.contribution.ts +++ b/src/csp/csp.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'csp', extensions: [], aliases: ['CSP', 'csp'], - loader: () => _monaco.Promise.wrap(import('./csp')) + loader: () => import('./csp') }); diff --git a/src/css/css.contribution.ts b/src/css/css.contribution.ts index bb39d00f..f434e2dc 100644 --- a/src/css/css.contribution.ts +++ b/src/css/css.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'css', extensions: ['.css'], aliases: ['CSS', 'css'], mimetypes: ['text/css'], - loader: () => _monaco.Promise.wrap(import('./css')) + loader: () => import('./css') }); diff --git a/src/dockerfile/dockerfile.contribution.ts b/src/dockerfile/dockerfile.contribution.ts index d4200e08..30cb3ba7 100644 --- a/src/dockerfile/dockerfile.contribution.ts +++ b/src/dockerfile/dockerfile.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'dockerfile', extensions: ['.dockerfile'], filenames: ['Dockerfile'], aliases: ['Dockerfile'], - loader: () => _monaco.Promise.wrap(import('./dockerfile')) + loader: () => import('./dockerfile') }); diff --git a/src/fsharp/fsharp.contribution.ts b/src/fsharp/fsharp.contribution.ts index bd9a0c05..0cae93f7 100644 --- a/src/fsharp/fsharp.contribution.ts +++ b/src/fsharp/fsharp.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'fsharp', extensions: ['.fs', '.fsi', '.ml', '.mli', '.fsx', '.fsscript'], aliases: ['F#', 'FSharp', 'fsharp'], - loader: () => _monaco.Promise.wrap(import('./fsharp')) + loader: () => import('./fsharp') }); diff --git a/src/go/go.contribution.ts b/src/go/go.contribution.ts index 2e0bd2cd..76771e01 100644 --- a/src/go/go.contribution.ts +++ b/src/go/go.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'go', extensions: ['.go'], aliases: ['Go'], - loader: () => _monaco.Promise.wrap(import('./go')) + loader: () => import('./go') }); diff --git a/src/handlebars/handlebars.contribution.ts b/src/handlebars/handlebars.contribution.ts index a0252eed..de7bd310 100644 --- a/src/handlebars/handlebars.contribution.ts +++ b/src/handlebars/handlebars.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'handlebars', extensions: ['.handlebars', '.hbs'], aliases: ['Handlebars', 'handlebars'], mimetypes: ['text/x-handlebars-template'], - loader: () => _monaco.Promise.wrap(import('./handlebars')) + loader: () => import('./handlebars') }); diff --git a/src/html/html.contribution.ts b/src/html/html.contribution.ts index a9eabe15..ec632e8e 100644 --- a/src/html/html.contribution.ts +++ b/src/html/html.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'html', extensions: ['.html', '.htm', '.shtml', '.xhtml', '.mdoc', '.jsp', '.asp', '.aspx', '.jshtm'], aliases: ['HTML', 'htm', 'html', 'xhtml'], mimetypes: ['text/html', 'text/x-jshtm', 'text/template', 'text/ng-template'], - loader: () => _monaco.Promise.wrap(import('./html')) + loader: () => import('./html') }); diff --git a/src/ini/ini.contribution.ts b/src/ini/ini.contribution.ts index a8344d48..7176bdcb 100644 --- a/src/ini/ini.contribution.ts +++ b/src/ini/ini.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'ini', extensions: ['.ini', '.properties', '.gitconfig'], filenames: ['config', '.gitattributes', '.gitconfig', '.editorconfig'], aliases: ['Ini', 'ini'], - loader: () => _monaco.Promise.wrap(import('./ini')) + loader: () => import('./ini') }); diff --git a/src/java/java.contribution.ts b/src/java/java.contribution.ts index 866a69be..1680542d 100644 --- a/src/java/java.contribution.ts +++ b/src/java/java.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'java', extensions: ['.java', '.jav'], aliases: ['Java', 'java'], mimetypes: ['text/x-java-source', 'text/x-java'], - loader: () => _monaco.Promise.wrap(import('./java')) + loader: () => import('./java') }); diff --git a/src/javascript/javascript.contribution.ts b/src/javascript/javascript.contribution.ts index 32c75b71..8f3cc5cb 100644 --- a/src/javascript/javascript.contribution.ts +++ b/src/javascript/javascript.contribution.ts @@ -6,9 +6,6 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'javascript', extensions: ['.js', '.es6', '.jsx'], @@ -16,5 +13,5 @@ registerLanguage({ filenames: ['jakefile'], aliases: ['JavaScript', 'javascript', 'js'], mimetypes: ['text/javascript'], - loader: () => _monaco.Promise.wrap(import('./javascript')) + loader: () => import('./javascript') }); diff --git a/src/less/less.contribution.ts b/src/less/less.contribution.ts index cc61fbce..ccaf885a 100644 --- a/src/less/less.contribution.ts +++ b/src/less/less.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'less', extensions: ['.less'], aliases: ['Less', 'less'], mimetypes: ['text/x-less', 'text/less'], - loader: () => _monaco.Promise.wrap(import('./less')) + loader: () => import('./less') }); diff --git a/src/lua/lua.contribution.ts b/src/lua/lua.contribution.ts index bec757e0..274f7780 100644 --- a/src/lua/lua.contribution.ts +++ b/src/lua/lua.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'lua', extensions: ['.lua'], aliases: ['Lua', 'lua'], - loader: () => _monaco.Promise.wrap(import('./lua')) + loader: () => import('./lua') }); diff --git a/src/markdown/markdown.contribution.ts b/src/markdown/markdown.contribution.ts index 0aa96e6d..16563180 100644 --- a/src/markdown/markdown.contribution.ts +++ b/src/markdown/markdown.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'markdown', extensions: ['.md', '.markdown', '.mdown', '.mkdn', '.mkd', '.mdwn', '.mdtxt', '.mdtext'], aliases: ['Markdown', 'markdown'], - loader: () => _monaco.Promise.wrap(import('./markdown')) + loader: () => import('./markdown') }); diff --git a/src/msdax/msdax.contribution.ts b/src/msdax/msdax.contribution.ts index 69df2d00..381f6907 100644 --- a/src/msdax/msdax.contribution.ts +++ b/src/msdax/msdax.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'msdax', extensions: ['.dax', '.msdax'], aliases: ['DAX', 'MSDAX'], - loader: () => _monaco.Promise.wrap(import('./msdax')) + loader: () => import('./msdax') }); diff --git a/src/mysql/mysql.contribution.ts b/src/mysql/mysql.contribution.ts index f1476d28..9525a188 100644 --- a/src/mysql/mysql.contribution.ts +++ b/src/mysql/mysql.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'mysql', extensions: [], aliases: ['MySQL', 'mysql'], - loader: () => _monaco.Promise.wrap(import('./mysql')) + loader: () => import('./mysql') }); diff --git a/src/objective-c/objective-c.contribution.ts b/src/objective-c/objective-c.contribution.ts index e57176f0..ea333e59 100644 --- a/src/objective-c/objective-c.contribution.ts +++ b/src/objective-c/objective-c.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'objective-c', extensions: ['.m'], aliases: ['Objective-C'], - loader: () => _monaco.Promise.wrap(import('./objective-c')) + loader: () => import('./objective-c') }); diff --git a/src/perl/perl.contribution.ts b/src/perl/perl.contribution.ts index 0f18b87f..11ecff9e 100644 --- a/src/perl/perl.contribution.ts +++ b/src/perl/perl.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = typeof monaco === 'undefined' ? (self).monaco : monaco; - registerLanguage({ id: 'perl', extensions: ['.pl'], aliases: ['Perl', 'pl'], - loader: () => _monaco.Promise.wrap(import('./perl')), + loader: () => import('./perl'), }); diff --git a/src/pgsql/pgsql.contribution.ts b/src/pgsql/pgsql.contribution.ts index f3ff6b4c..e3d2f330 100644 --- a/src/pgsql/pgsql.contribution.ts +++ b/src/pgsql/pgsql.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'pgsql', extensions: [], aliases: ['PostgreSQL', 'postgres', 'pg', 'postgre'], - loader: () => _monaco.Promise.wrap(import('./pgsql')) + loader: () => import('./pgsql') }); diff --git a/src/php/php.contribution.ts b/src/php/php.contribution.ts index c5df88db..890a2235 100644 --- a/src/php/php.contribution.ts +++ b/src/php/php.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'php', extensions: ['.php', '.php4', '.php5', '.phtml', '.ctp'], aliases: ['PHP', 'php'], mimetypes: ['application/x-php'], - loader: () => _monaco.Promise.wrap(import('./php')) + loader: () => import('./php') }); diff --git a/src/postiats/postiats.contribution.ts b/src/postiats/postiats.contribution.ts index 77e7c2b7..406350df 100644 --- a/src/postiats/postiats.contribution.ts +++ b/src/postiats/postiats.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'postiats', extensions: ['.dats', '.sats', '.hats'], aliases: ['ATS', 'ATS/Postiats'], - loader: () => _monaco.Promise.wrap(import('./postiats')) + loader: () => import('./postiats') }); diff --git a/src/powerquery/powerquery.contribution.ts b/src/powerquery/powerquery.contribution.ts index 7ffdd692..4a7ebf65 100644 --- a/src/powerquery/powerquery.contribution.ts +++ b/src/powerquery/powerquery.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'powerquery', extensions: ['.pq', '.pqm'], aliases: ['PQ', 'M', 'Power Query', 'Power Query M'], - loader: () => _monaco.Promise.wrap(import('./powerquery')) + loader: () => import('./powerquery') }); diff --git a/src/powershell/powershell.contribution.ts b/src/powershell/powershell.contribution.ts index 7b83a61e..4ff5d4f1 100644 --- a/src/powershell/powershell.contribution.ts +++ b/src/powershell/powershell.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'powershell', extensions: ['.ps1', '.psm1', '.psd1'], aliases: ['PowerShell', 'powershell', 'ps', 'ps1'], - loader: () => _monaco.Promise.wrap(import('./powershell')) + loader: () => import('./powershell') }); diff --git a/src/pug/pug.contribution.ts b/src/pug/pug.contribution.ts index f1e0e9d5..f8bba8d4 100644 --- a/src/pug/pug.contribution.ts +++ b/src/pug/pug.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'pug', extensions: ['.jade', '.pug'], aliases: ['Pug', 'Jade', 'jade'], - loader: () => _monaco.Promise.wrap(import('./pug')) + loader: () => import('./pug') }); diff --git a/src/python/python.contribution.ts b/src/python/python.contribution.ts index 10c25580..4fad385b 100644 --- a/src/python/python.contribution.ts +++ b/src/python/python.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'python', extensions: ['.py', '.rpy', '.pyw', '.cpy', '.gyp', '.gypi'], aliases: ['Python', 'py'], firstLine: '^#!/.*\\bpython[0-9.-]*\\b', - loader: () => _monaco.Promise.wrap(import('./python')) + loader: () => import('./python') }); diff --git a/src/r/r.contribution.ts b/src/r/r.contribution.ts index 7857845a..c78eedbe 100644 --- a/src/r/r.contribution.ts +++ b/src/r/r.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'r', extensions: ['.r', '.rhistory', '.rprofile', '.rt'], aliases: ['R', 'r'], - loader: () => _monaco.Promise.wrap(import('./r')) + loader: () => import('./r') }); diff --git a/src/razor/razor.contribution.ts b/src/razor/razor.contribution.ts index 96d762f2..631393bf 100644 --- a/src/razor/razor.contribution.ts +++ b/src/razor/razor.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'razor', extensions: ['.cshtml'], aliases: ['Razor', 'razor'], mimetypes: ['text/x-cshtml'], - loader: () => _monaco.Promise.wrap(import('./razor')) + loader: () => import('./razor') }); diff --git a/src/redis/redis.contribution.ts b/src/redis/redis.contribution.ts index f9cbed66..db5d99f1 100644 --- a/src/redis/redis.contribution.ts +++ b/src/redis/redis.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'redis', extensions: ['.redis'], aliases: ['redis'], - loader: () => _monaco.Promise.wrap(import('./redis')) + loader: () => import('./redis') }); diff --git a/src/redshift/redshift.contribution.ts b/src/redshift/redshift.contribution.ts index f40d0803..b5d55580 100644 --- a/src/redshift/redshift.contribution.ts +++ b/src/redshift/redshift.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'redshift', extensions: [], aliases: ['Redshift', 'redshift'], - loader: () => _monaco.Promise.wrap(import('./redshift')) + loader: () => import('./redshift') }); diff --git a/src/ruby/ruby.contribution.ts b/src/ruby/ruby.contribution.ts index 24e290ff..5bc17f0c 100644 --- a/src/ruby/ruby.contribution.ts +++ b/src/ruby/ruby.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'ruby', extensions: ['.rb', '.rbx', '.rjs', '.gemspec', '.pp'], filenames: ['rakefile'], aliases: ['Ruby', 'rb'], - loader: () => _monaco.Promise.wrap(import('./ruby')) + loader: () => import('./ruby') }); diff --git a/src/rust/rust.contribution.ts b/src/rust/rust.contribution.ts index 15dd4f29..e19552d3 100644 --- a/src/rust/rust.contribution.ts +++ b/src/rust/rust.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'rust', extensions: ['.rs', '.rlib'], aliases: ['Rust', 'rust'], - loader: () => _monaco.Promise.wrap(import('./rust')) + loader: () => import('./rust') }); diff --git a/src/sb/sb.contribution.ts b/src/sb/sb.contribution.ts index d35dc0b9..a884be64 100644 --- a/src/sb/sb.contribution.ts +++ b/src/sb/sb.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'sb', extensions: ['.sb'], aliases: ['Small Basic', 'sb'], - loader: () => _monaco.Promise.wrap(import('./sb')) + loader: () => import('./sb') }); diff --git a/src/scheme/scheme.contribution.ts b/src/scheme/scheme.contribution.ts index ac8eb9b2..5e889627 100644 --- a/src/scheme/scheme.contribution.ts +++ b/src/scheme/scheme.contribution.ts @@ -6,13 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = - typeof monaco === 'undefined' ? (self).monaco : monaco; - registerLanguage({ id: 'scheme', extensions: ['.scm', '.ss', '.sch', '.rkt'], aliases: ['scheme', 'Scheme'], - loader: () => _monaco.Promise.wrap(import('./scheme')), + loader: () => import('./scheme'), }); diff --git a/src/scss/scss.contribution.ts b/src/scss/scss.contribution.ts index bc9634fc..5823653d 100644 --- a/src/scss/scss.contribution.ts +++ b/src/scss/scss.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'scss', extensions: ['.scss'], aliases: ['Sass', 'sass', 'scss'], mimetypes: ['text/x-scss', 'text/scss'], - loader: () => _monaco.Promise.wrap(import('./scss')) + loader: () => import('./scss') }); diff --git a/src/shell/shell.contribution.ts b/src/shell/shell.contribution.ts index a73f71bc..fec2f18f 100644 --- a/src/shell/shell.contribution.ts +++ b/src/shell/shell.contribution.ts @@ -6,13 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = - typeof monaco === 'undefined' ? (self).monaco : monaco; - registerLanguage({ id: 'shell', extensions: ['.sh', '.bash'], aliases: ['Shell', 'sh'], - loader: () => _monaco.Promise.wrap(import('./shell')), + loader: () => import('./shell'), }); diff --git a/src/solidity/solidity.contribution.ts b/src/solidity/solidity.contribution.ts index 98d465de..53525cd9 100644 --- a/src/solidity/solidity.contribution.ts +++ b/src/solidity/solidity.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'sol', extensions: ['.sol'], aliases: ['sol', 'solidity', 'Solidity'], - loader: () => _monaco.Promise.wrap(import('./solidity')) + loader: () => import('./solidity') }); diff --git a/src/sql/sql.contribution.ts b/src/sql/sql.contribution.ts index 629782f4..00b4a72e 100644 --- a/src/sql/sql.contribution.ts +++ b/src/sql/sql.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'sql', extensions: ['.sql'], aliases: ['SQL'], - loader: () => _monaco.Promise.wrap(import('./sql')) + loader: () => import('./sql') }); diff --git a/src/st/st.contribution.ts b/src/st/st.contribution.ts index 20a33b3f..05947174 100644 --- a/src/st/st.contribution.ts +++ b/src/st/st.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'st', extensions: ['.st', '.iecst', '.iecplc', '.lc3lib'], aliases: ['StructuredText', 'scl', 'stl'], - loader: () => _monaco.Promise.wrap(import('./st')) + loader: () => import('./st') }); diff --git a/src/swift/swift.contribution.ts b/src/swift/swift.contribution.ts index d6ffb098..2ce789f1 100644 --- a/src/swift/swift.contribution.ts +++ b/src/swift/swift.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'swift', aliases: ['Swift', 'swift'], extensions: ['.swift'], mimetypes: ['text/swift'], - loader: () => _monaco.Promise.wrap(import('./swift')) + loader: () => import('./swift') }); diff --git a/src/typescript/typescript.contribution.ts b/src/typescript/typescript.contribution.ts index bc0483e2..f7c0dfc7 100644 --- a/src/typescript/typescript.contribution.ts +++ b/src/typescript/typescript.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'typescript', extensions: ['.ts', '.tsx'], aliases: ['TypeScript', 'ts', 'typescript'], mimetypes: ['text/typescript'], - loader: () => _monaco.Promise.wrap(>import('./typescript')) + loader: () => >import('./typescript') }); diff --git a/src/vb/vb.contribution.ts b/src/vb/vb.contribution.ts index 744e2958..735d8cbd 100644 --- a/src/vb/vb.contribution.ts +++ b/src/vb/vb.contribution.ts @@ -6,12 +6,9 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'vb', extensions: ['.vb'], aliases: ['Visual Basic', 'vb'], - loader: () => _monaco.Promise.wrap(import('./vb')) + loader: () => import('./vb') }); diff --git a/src/xml/xml.contribution.ts b/src/xml/xml.contribution.ts index 35e8ad07..3208840e 100644 --- a/src/xml/xml.contribution.ts +++ b/src/xml/xml.contribution.ts @@ -6,14 +6,11 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'xml', extensions: ['.xml', '.dtd', '.ascx', '.csproj', '.config', '.wxi', '.wxl', '.wxs', '.xaml', '.svg', '.svgz'], firstLine: '(\\<\\?xml.*)|(\\ _monaco.Promise.wrap(import('./xml')) + loader: () => import('./xml') }); diff --git a/src/yaml/yaml.contribution.ts b/src/yaml/yaml.contribution.ts index 6d3c37a2..85f04171 100644 --- a/src/yaml/yaml.contribution.ts +++ b/src/yaml/yaml.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'yaml', extensions: ['.yaml', '.yml'], aliases: ['YAML', 'yaml', 'YML', 'yml'], mimetypes: ['application/x-yaml'], - loader: () => _monaco.Promise.wrap(import('./yaml')) + loader: () => import('./yaml') }); From 3c3465db2917505859bfd297116ee37c9f47da9d Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 9 Jan 2019 16:14:57 +0100 Subject: [PATCH 24/25] More native promises --- src/graphql/graphql.contribution.ts | 6 +----- src/test/testRunner.ts | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/graphql/graphql.contribution.ts b/src/graphql/graphql.contribution.ts index a999c9e6..1379e5ce 100644 --- a/src/graphql/graphql.contribution.ts +++ b/src/graphql/graphql.contribution.ts @@ -6,14 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = - typeof monaco === 'undefined' ? (self).monaco : monaco; - registerLanguage({ id: 'graphql', extensions: ['.graphql', '.gql'], aliases: ['GraphQL', 'graphql', 'gql'], mimetypes: ['application/graphql'], - loader: () => _monaco.Promise.wrap(import('./graphql')), + loader: () => import('./graphql') }); diff --git a/src/test/testRunner.ts b/src/test/testRunner.ts index f425a0b6..f99a424b 100644 --- a/src/test/testRunner.ts +++ b/src/test/testRunner.ts @@ -30,7 +30,7 @@ export function testTokenization(_language:string|string[], tests:ITestItem[][]) let mainLanguage = languages[0]; suite(mainLanguage + ' tokenization', () => { test('', (done) => { - _monaco.Promise.join(languages.map(l => loadLanguage(l))).then(() => { + Promise.all(languages.map(l => loadLanguage(l))).then(() => { // clean stack setTimeout(() => { runTests(mainLanguage, tests); From c4eea357d9165995156eee278d08b6291fed986e Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Thu, 10 Jan 2019 12:58:32 +0100 Subject: [PATCH 25/25] Remove usage of monaco.Promise --- src/kotlin/kotlin.contribution.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/kotlin/kotlin.contribution.ts b/src/kotlin/kotlin.contribution.ts index b56711f0..884c5c95 100644 --- a/src/kotlin/kotlin.contribution.ts +++ b/src/kotlin/kotlin.contribution.ts @@ -6,13 +6,10 @@ import { registerLanguage } from '../_.contribution'; -// Allow for running under nodejs/requirejs in tests -const _monaco: typeof monaco = (typeof monaco === 'undefined' ? (self).monaco : monaco); - registerLanguage({ id: 'kotlin', extensions: ['.kt'], aliases: ['Kotlin', 'kotlin'], mimetypes: ['text/x-kotlin-source', 'text/x-kotlin'], - loader: () => _monaco.Promise.wrap(import('./kotlin')) + loader: () => import('./kotlin') });