Add prettier

This commit is contained in:
Alex Dima 2020-09-02 17:44:31 +02:00
parent 1ca4a3a0aa
commit 3efc637414
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0
156 changed files with 51562 additions and 37461 deletions

View file

@ -8,288 +8,302 @@
import { testTokenization } from '../test/testRunner';
testTokenization('redis', [
// Numbers
[{
line: '123',
tokens: [
{ startIndex: 0, type: 'number.redis' }
]
}],
[
{
line: '123',
tokens: [{ startIndex: 0, type: 'number.redis' }]
}
],
[{
line: '-123',
tokens: [
{ startIndex: 0, type: 'operator.redis' },
{ startIndex: 1, 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: '0XaBc123',
tokens: [
{ startIndex: 0, type: 'number.redis' }
]
}],
[
{
line: '0XaBc123',
tokens: [{ startIndex: 0, type: 'number.redis' }]
}
],
[{
line: '0x',
tokens: [
{ startIndex: 0, type: 'number.redis' }
]
}],
[
{
line: '0x',
tokens: [{ startIndex: 0, type: 'number.redis' }]
}
],
[{
line: '0x0',
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: '0xAB_CD',
tokens: [
{ startIndex: 0, type: 'number.redis' },
{ startIndex: 4, type: 'identifier.redis' }
]
}
],
[{
line: '$',
tokens: [
{ startIndex: 0, type: 'number.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',
tokens: [
{ startIndex: 0, type: 'number.redis' }
]
}],
[
{
line: '$-+-123',
tokens: [{ startIndex: 0, type: 'number.redis' }]
}
],
[{
line: '$123.5678',
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: '$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: '$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: '$.0',
tokens: [
{ startIndex: 0, type: 'number.redis' }
]
}],
[
{
line: '$.0',
tokens: [{ startIndex: 0, type: 'number.redis' }]
}
],
[{
line: '.',
tokens: [
{ startIndex: 0, type: 'delimiter.redis' }
]
}],
[
{
line: '.',
tokens: [{ startIndex: 0, type: 'delimiter.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: '123.5678',
tokens: [{ startIndex: 0, type: 'number.redis' }]
}
],
[{
line: '0.99',
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: '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: '.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: '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: '1E2',
tokens: [{ startIndex: 0, type: 'number.redis' }]
}
],
[{
line: '0.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: '1.E2',
tokens: [{ startIndex: 0, type: 'number.redis' }]
}
],
[{
line: '.1E2',
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.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' },
]
}],
[
{
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: '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:
'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' }
]
}],
[
{
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' }
]
}
]
]);

View file

@ -19,14 +19,14 @@ export const conf: IRichLanguageConfiguration = {
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '"', close: '"' },
{ open: '\'', close: '\'' },
{ open: "'", close: "'" }
],
surroundingPairs: [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '"', close: '"' },
{ open: '\'', close: '\'' },
{ open: "'", close: "'" }
]
};
@ -41,24 +41,203 @@ export const language = <ILanguage>{
],
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"
'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
@ -81,27 +260,31 @@ export const language = <ILanguage>{
{ include: '@scopes' },
[/[;,.]/, 'delimiter'],
[/[()]/, '@brackets'],
[/[\w@#$]+/, {
cases: {
'@keywords': 'keyword',
'@operators': 'operator',
'@builtinVariables': 'predefined',
'@builtinFunctions': 'predefined',
'@default': 'identifier'
[
/[\w@#$]+/,
{
cases: {
'@keywords': 'keyword',
'@operators': 'operator',
'@builtinVariables': 'predefined',
'@builtinFunctions': 'predefined',
'@default': 'identifier'
}
}
}],
[/[<>=!%&+\-*/|~^]/, 'operator'],
],
whitespace: [
[/\s+/, 'white']
],
[/[<>=!%&+\-*/|~^]/, 'operator']
],
whitespace: [[/\s+/, 'white']],
pseudoColumns: [
[/[$][A-Za-z_][\w@#$]*/, {
cases: {
'@pseudoColumns': 'predefined',
'@default': 'identifier'
[
/[$][A-Za-z_][\w@#$]*/,
{
cases: {
'@pseudoColumns': 'predefined',
'@default': 'identifier'
}
}
}],
]
],
numbers: [
[/0[xX][0-9a-fA-F]*/, 'number'],
@ -115,7 +298,7 @@ export const language = <ILanguage>{
string: [
[/[^']+/, 'string'],
[/''/, 'string'],
[/'/, { token: 'string', next: '@pop' }],
[/'/, { token: 'string', next: '@pop' }]
],
stringDouble: [
[/[^"]+/, 'string.double'],