Skip to content

Commit

Permalink
fix: Adapt to the ancestors order change in Slang v0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanewok authored and kanej committed Apr 17, 2024
1 parent 1a7e83d commit c550d8a
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ContractDefinitionHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
nodeWrapper.label === NodeLabel.Name &&
ancestors[ancestors.length - 1]?.kind === RuleKind.ContractDefinition
ancestors[0]?.kind === RuleKind.ContractDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CustomTypeHighlighter extends HighlightVisitor {
nodeWrapper.kind === TokenKind.Identifier &&
// NOTE: This only supports highlighting the first identifier in the path
nodeWrapper.label === NodeLabel.Item &&
ancestors[ancestors.length - 2]?.kind === RuleKind.TypeName
ancestors[1]?.kind === RuleKind.TypeName
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class EnumDefinitionHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
nodeWrapper.label === NodeLabel.Name &&
ancestors[ancestors.length - 1]?.kind === RuleKind.EnumDefinition
ancestors[0]?.kind === RuleKind.EnumDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ErrorDefinitionHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
nodeWrapper.label === NodeLabel.Name &&
ancestors[ancestors.length - 1]?.kind === RuleKind.ErrorDefinition
ancestors[0]?.kind === RuleKind.ErrorDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class EventDefinitionHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
nodeWrapper.label === NodeLabel.Name &&
ancestors[ancestors.length - 1]?.kind === RuleKind.EventDefinition
ancestors[0]?.kind === RuleKind.EventDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class EventEmissionHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
// NOTE: This only highlights the first identifier (in path) in the event emission statement
ancestors[ancestors.length - 2]?.kind === RuleKind.EmitStatement
ancestors[1]?.kind === RuleKind.EmitStatement
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class FunctionCallHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
// NOTE: This only supports the basic case of a function call with positional arguments "(a,b,c)"
ancestors[ancestors.length - 2]?.kind === RuleKind.FunctionCallExpression
ancestors[1]?.kind === RuleKind.FunctionCallExpression
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.function);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class FunctionDefinitionHighlighter extends HighlightVisitor {
nodeWrapper.kind === TokenKind.Identifier &&
// TODO: Support also 'receive' and 'fallback' functions post 0.6.0
nodeWrapper.label === NodeLabel.Variant &&
ancestors[ancestors.length - 2]?.kind === RuleKind.FunctionDefinition
ancestors[1]?.kind === RuleKind.FunctionDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.function);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class InterfaceDefinitionHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
nodeWrapper.label === NodeLabel.Name &&
ancestors[ancestors.length - 1]?.kind === RuleKind.InterfaceDefinition
ancestors[0]?.kind === RuleKind.InterfaceDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class LibraryDefinitionHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
nodeWrapper.label === NodeLabel.Name &&
ancestors[ancestors.length - 1]?.kind === RuleKind.LibraryDefinition
ancestors[0]?.kind === RuleKind.LibraryDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class StructDefinitionHighlighter extends HighlightVisitor {
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
nodeWrapper.label === NodeLabel.Name &&
ancestors[ancestors.length - 1]?.kind === RuleKind.StructDefinition
ancestors[0]?.kind === RuleKind.StructDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export class UserDefinedValueTypeDefinitionHighlighter extends HighlightVisitor
nodeWrapper.type === NodeType.Token &&
nodeWrapper.kind === TokenKind.Identifier &&
nodeWrapper.label === NodeLabel.Name &&
ancestors[ancestors.length - 1]?.kind ===
RuleKind.UserDefinedValueTypeDefinition
ancestors[0]?.kind === RuleKind.UserDefinedValueTypeDefinition
) {
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type);
}
Expand Down

0 comments on commit c550d8a

Please sign in to comment.