代码提示优化

This commit is contained in:
mxd
2021-12-17 23:00:53 +08:00
parent 1dfc83b948
commit 4dfdd918ca
2 changed files with 6 additions and 11 deletions

View File

@@ -299,9 +299,9 @@ const quickSuggestions = [
['ife', 'if (${1:condition}) {\r\n\t$2\r\n} else { \r\n\t$3\r\n}', '判断'],
['for', 'for (item in ${1:collection}) {\r\n\t$2\r\n}', '循环集合'],
['exit', 'exit ${1:code}, ${2:message};', '退出'],
['info', 'log.info($1);', 'info日志'],
['debug', 'log.debug($1);', 'debug日志'],
['err', 'log.error($1);', 'error日志'],
['logi', 'log.info($1);', 'info日志'],
['logd', 'log.debug($1);', 'debug日志'],
['loge', 'log.error($1);', 'error日志'],
['ass', 'assert ${1:condition} : ${2:code}, ${3:message}', '校验参数']
]

View File

@@ -589,14 +589,9 @@ export class Parser {
}
if (this.stream.match(TokenType.StringLiteral, false)) {
key = this.stream.expect(TokenType.StringLiteral);
} else if (this.stream.match(TokenType.LeftBracket, false)) { // [key]
let opening = this.stream.expect(TokenType.LeftBracket).getSpan();
this.stream.expect(TokenType.Identifier);
let closing = this.stream.expect(TokenType.RightBracket).getSpan();
let span = new Span(opening, closing);
let dynamicKey = span.getText();
dynamicKey = dynamicKey.substring(1, dynamicKey.length - 1);
key = new VariableAccess(span, dynamicKey);
} else if (this.stream.match(TokenType.LeftBracket, true)) { // [key]
key = this.parseExpression()
this.stream.expect(TokenType.RightBracket);
} else {
key = this.stream.expect(TokenType.Identifier);
}