perf: parse filenames in parse() insteadof render()

This commit is contained in:
harttle
2021-09-30 22:15:09 +08:00
committed by Jun Yang
parent 24f5346084
commit 8273c17dab
13 changed files with 80 additions and 68 deletions
+4 -8
View File
@@ -5,19 +5,15 @@ import { TokenKind } from '../parser/token-kind'
import { parseStringLiteral } from '../parser/parse-string-literal'
export class PropertyAccessToken extends Token {
public propertyName: string
constructor (
public variable: IdentifierToken | QuotedToken,
public props: (IdentifierToken | QuotedToken | PropertyAccessToken)[],
end: number
) {
super(TokenKind.PropertyAccess, variable.input, variable.begin, end, variable.file)
}
getVariableAsText () {
if (this.variable instanceof IdentifierToken) {
return this.variable.getText()
} else {
return parseStringLiteral(this.variable.getText())
}
this.propertyName = this.variable instanceof IdentifierToken
? this.variable.getText()
: parseStringLiteral(this.variable.getText())
}
}