mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52:56 +01:00
Reorganize project
This commit is contained in:
parent
49f2283894
commit
93c48edccc
121 changed files with 875 additions and 426 deletions
17
src/redis/redis.contribution.ts
Normal file
17
src/redis/redis.contribution.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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' ? (<any>self).monaco : monaco);
|
||||
|
||||
registerLanguage({
|
||||
id: 'redis',
|
||||
extensions: ['.redis'],
|
||||
aliases: ['redis'],
|
||||
loader: () => _monaco.Promise.wrap(import('./redis'))
|
||||
});
|
||||
295
src/redis/redis.test.ts
Normal file
295
src/redis/redis.test.ts
Normal file
|
|
@ -0,0 +1,295 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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('redis', [
|
||||
|
||||
// Numbers
|
||||
[{
|
||||
line: '123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'operator.redis' },
|
||||
{ startIndex: 1, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '0xaBc123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '0XaBc123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '0x',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '0x0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '0xAB_CD',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$-+-123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$123.5678',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$0.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$99.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$0.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '$.0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'delimiter.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '123',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '123.5678',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '0.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '.99',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '99.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '0.',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '.0',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '1E-2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '1E+2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '0.1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '1.E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: '.1E2',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'number.redis' }
|
||||
]
|
||||
}],
|
||||
|
||||
// Strings
|
||||
|
||||
[{
|
||||
line: 'SET key1 "Hello"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'string.double.redis' },
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: 'SET key1 \'Hello\'',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'string.redis' },
|
||||
]
|
||||
}],
|
||||
|
||||
// Commands
|
||||
|
||||
[{
|
||||
line: 'DEL key1 key2 key3',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 3, type: 'white.redis' },
|
||||
{ startIndex: 4, type: 'identifier.redis' },
|
||||
{ startIndex: 8, type: 'white.redis' },
|
||||
{ startIndex: 9, type: 'identifier.redis' },
|
||||
{ startIndex: 13, type: 'white.redis' },
|
||||
{ startIndex: 14, type: 'identifier.redis' },
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: 'GEOADD Sicily 13.361389 38.115556 "Palermo" 15.087269 37.502669 "Catania"',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 6, type: 'white.redis' },
|
||||
{ startIndex: 7, type: 'identifier.redis' },
|
||||
{ startIndex: 13, type: 'white.redis' },
|
||||
{ startIndex: 14, type: 'number.redis' },
|
||||
{ startIndex: 23, type: 'white.redis' },
|
||||
{ startIndex: 24, type: 'number.redis' },
|
||||
{ startIndex: 33, type: 'white.redis' },
|
||||
{ startIndex: 34, type: 'string.double.redis' },
|
||||
{ startIndex: 43, type: 'white.redis' },
|
||||
{ startIndex: 44, type: 'number.redis' },
|
||||
{ startIndex: 53, type: 'white.redis' },
|
||||
{ startIndex: 54, type: 'number.redis' },
|
||||
{ startIndex: 63, type: 'white.redis' },
|
||||
{ startIndex: 64, type: 'string.double.redis' },
|
||||
]
|
||||
}],
|
||||
|
||||
[{
|
||||
line: 'HGET myhash field1',
|
||||
tokens: [
|
||||
{ startIndex: 0, type: 'keyword.redis' },
|
||||
{ startIndex: 4, type: 'white.redis' },
|
||||
{ startIndex: 5, type: 'identifier.redis' },
|
||||
{ startIndex: 11, type: 'white.redis' },
|
||||
{ startIndex: 12, type: 'identifier.redis' }
|
||||
]
|
||||
}],
|
||||
]);
|
||||
129
src/redis/redis.ts
Normal file
129
src/redis/redis.ts
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* 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 = {
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
],
|
||||
surroundingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"' },
|
||||
{ open: '\'', close: '\'' },
|
||||
]
|
||||
};
|
||||
|
||||
export const language = <ILanguage>{
|
||||
defaultToken: '',
|
||||
tokenPostfix: '.redis',
|
||||
ignoreCase: true,
|
||||
|
||||
brackets: [
|
||||
{ open: '[', close: ']', token: 'delimiter.square' },
|
||||
{ open: '(', close: ')', token: 'delimiter.parenthesis' }
|
||||
],
|
||||
|
||||
keywords: [
|
||||
"APPEND", "AUTH", "BGREWRITEAOF", "BGSAVE", "BITCOUNT", "BITFIELD", "BITOP", "BITPOS", "BLPOP", "BRPOP", "BRPOPLPUSH",
|
||||
"CLIENT", "KILL", "LIST", "GETNAME", "PAUSE", "REPLY", "SETNAME", "CLUSTER", "ADDSLOTS", "COUNT-FAILURE-REPORTS",
|
||||
"COUNTKEYSINSLOT", "DELSLOTS", "FAILOVER", "FORGET", "GETKEYSINSLOT", "INFO", "KEYSLOT", "MEET", "NODES", "REPLICATE",
|
||||
"RESET", "SAVECONFIG", "SET-CONFIG-EPOCH", "SETSLOT", "SLAVES", "SLOTS", "COMMAND", "COUNT", "GETKEYS", "CONFIG", "GET",
|
||||
"REWRITE", "SET", "RESETSTAT", "DBSIZE", "DEBUG", "OBJECT", "SEGFAULT", "DECR", "DECRBY", "DEL", "DISCARD", "DUMP", "ECHO",
|
||||
"EVAL", "EVALSHA", "EXEC", "EXISTS", "EXPIRE", "EXPIREAT", "FLUSHALL", "FLUSHDB", "GEOADD", "GEOHASH", "GEOPOS", "GEODIST",
|
||||
"GEORADIUS", "GEORADIUSBYMEMBER", "GETBIT", "GETRANGE", "GETSET", "HDEL", "HEXISTS", "HGET", "HGETALL", "HINCRBY", "HINCRBYFLOAT",
|
||||
"HKEYS", "HLEN", "HMGET", "HMSET", "HSET", "HSETNX", "HSTRLEN", "HVALS", "INCR", "INCRBY", "INCRBYFLOAT", "KEYS", "LASTSAVE",
|
||||
"LINDEX", "LINSERT", "LLEN", "LPOP", "LPUSH", "LPUSHX", "LRANGE", "LREM", "LSET", "LTRIM", "MGET", "MIGRATE", "MONITOR",
|
||||
"MOVE", "MSET", "MSETNX", "MULTI", "PERSIST", "PEXPIRE", "PEXPIREAT", "PFADD", "PFCOUNT", "PFMERGE", "PING", "PSETEX",
|
||||
"PSUBSCRIBE", "PUBSUB", "PTTL", "PUBLISH", "PUNSUBSCRIBE", "QUIT", "RANDOMKEY", "READONLY", "READWRITE", "RENAME", "RENAMENX",
|
||||
"RESTORE", "ROLE", "RPOP", "RPOPLPUSH", "RPUSH", "RPUSHX", "SADD", "SAVE", "SCARD", "SCRIPT", "FLUSH", "LOAD", "SDIFF",
|
||||
"SDIFFSTORE", "SELECT", "SETBIT", "SETEX", "SETNX", "SETRANGE", "SHUTDOWN", "SINTER", "SINTERSTORE", "SISMEMBER", "SLAVEOF",
|
||||
"SLOWLOG", "SMEMBERS", "SMOVE", "SORT", "SPOP", "SRANDMEMBER", "SREM", "STRLEN", "SUBSCRIBE", "SUNION", "SUNIONSTORE", "SWAPDB",
|
||||
"SYNC", "TIME", "TOUCH", "TTL", "TYPE", "UNSUBSCRIBE", "UNLINK", "UNWATCH", "WAIT", "WATCH", "ZADD", "ZCARD", "ZCOUNT", "ZINCRBY",
|
||||
"ZINTERSTORE", "ZLEXCOUNT", "ZRANGE", "ZRANGEBYLEX", "ZREVRANGEBYLEX", "ZRANGEBYSCORE", "ZRANK", "ZREM", "ZREMRANGEBYLEX",
|
||||
"ZREMRANGEBYRANK", "ZREMRANGEBYSCORE", "ZREVRANGE", "ZREVRANGEBYSCORE", "ZREVRANK", "ZSCORE", "ZUNIONSTORE", "SCAN", "SSCAN",
|
||||
"HSCAN", "ZSCAN"
|
||||
],
|
||||
operators: [
|
||||
// NOT SUPPORTED
|
||||
],
|
||||
builtinFunctions: [
|
||||
// NOT SUPPORTED
|
||||
],
|
||||
builtinVariables: [
|
||||
// NOT SUPPORTED
|
||||
],
|
||||
pseudoColumns: [
|
||||
// NOT SUPPORTED
|
||||
],
|
||||
tokenizer: {
|
||||
root: [
|
||||
{ include: '@whitespace' },
|
||||
{ include: '@pseudoColumns' },
|
||||
{ include: '@numbers' },
|
||||
{ include: '@strings' },
|
||||
{ include: '@scopes' },
|
||||
[/[;,.]/, 'delimiter'],
|
||||
[/[()]/, '@brackets'],
|
||||
[/[\w@#$]+/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@operators': 'operator',
|
||||
'@builtinVariables': 'predefined',
|
||||
'@builtinFunctions': 'predefined',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
[/[<>=!%&+\-*/|~^]/, 'operator'],
|
||||
],
|
||||
whitespace: [
|
||||
[/\s+/, 'white']
|
||||
],
|
||||
pseudoColumns: [
|
||||
[/[$][A-Za-z_][\w@#$]*/, {
|
||||
cases: {
|
||||
'@pseudoColumns': 'predefined',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
],
|
||||
numbers: [
|
||||
[/0[xX][0-9a-fA-F]*/, 'number'],
|
||||
[/[$][+-]*\d*(\.\d*)?/, 'number'],
|
||||
[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']
|
||||
],
|
||||
strings: [
|
||||
[/'/, { token: 'string', next: '@string' }],
|
||||
[/"/, { token: 'string.double', next: '@stringDouble' }]
|
||||
],
|
||||
string: [
|
||||
[/[^']+/, 'string'],
|
||||
[/''/, 'string'],
|
||||
[/'/, { token: 'string', next: '@pop' }],
|
||||
],
|
||||
stringDouble: [
|
||||
[/[^"]+/, 'string.double'],
|
||||
[/""/, 'string.double'],
|
||||
[/"/, { token: 'string.double', next: '@pop' }]
|
||||
],
|
||||
scopes: [
|
||||
// NOT SUPPORTED
|
||||
]
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue