-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes based on PR feedback (part 1)
- Loading branch information
Showing
18 changed files
with
202 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"documentSymbol": { | ||
"percent": 0.1 | ||
}, | ||
|
||
"semanticHighlighting": { | ||
"percent": 0.1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
server/src/services/documentSymbol/visitors/YulFunctionDefinition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { SymbolKind } from "vscode-languageserver-types"; | ||
import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; | ||
import { SymbolVisitor } from "../SymbolVisitor"; | ||
|
||
export class YulFunctionDefinition extends SymbolVisitor { | ||
public ruleKind = RuleKind.YulFunctionDefinition; | ||
public symbolKind = SymbolKind.Function; | ||
public nameTokenKind = TokenKind.YulIdentifier; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 7 additions & 12 deletions
19
...ghlight/highlighters/NumberHighlighter.ts → ...highlighters/EnumDefinitionHighlighter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
import { SemanticTokenTypes } from "vscode-languageserver-protocol"; | ||
import { TokenKind } from "@nomicfoundation/slang/kinds"; | ||
import { NodeType } from "@nomicfoundation/slang/cst"; | ||
import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; | ||
import { HighlightVisitor } from "../HighlightVisitor"; | ||
import { SlangNodeWrapper } from "../../../parser/slangHelpers"; | ||
|
||
const numberKinds = new Set([ | ||
TokenKind.HexLiteral, | ||
TokenKind.YulHexLiteral, | ||
TokenKind.DecimalLiteral, | ||
]); | ||
|
||
// Highlights numbers | ||
export class NumberHighlighter extends HighlightVisitor { | ||
public tokenKinds = numberKinds; | ||
export class EnumDefinitionHighlighter extends HighlightVisitor { | ||
public tokenKinds = new Set([TokenKind.Identifier]); | ||
|
||
public enter(nodeWrapper: SlangNodeWrapper): void { | ||
const ancestors = nodeWrapper.pathRuleNodes; | ||
if ( | ||
nodeWrapper.type === NodeType.Token && | ||
numberKinds.has(nodeWrapper.kind as TokenKind) | ||
nodeWrapper.kind === TokenKind.Identifier && | ||
ancestors[ancestors.length - 1]?.kind === RuleKind.EnumDefinition | ||
) { | ||
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.number); | ||
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type); | ||
} | ||
} | ||
} |
19 changes: 7 additions & 12 deletions
19
...ghlight/highlighters/StringHighlighter.ts → ...ighlighters/ErrorDefinitionHighlighter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,20 @@ | ||
import { SemanticTokenTypes } from "vscode-languageserver-protocol"; | ||
import { TokenKind } from "@nomicfoundation/slang/kinds"; | ||
import { NodeType } from "@nomicfoundation/slang/cst"; | ||
import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; | ||
import { HighlightVisitor } from "../HighlightVisitor"; | ||
import { SlangNodeWrapper } from "../../../parser/slangHelpers"; | ||
|
||
const stringKinds = new Set([ | ||
TokenKind.HexStringLiteral, | ||
TokenKind.AsciiStringLiteral, | ||
TokenKind.UnicodeStringLiteral, | ||
]); | ||
|
||
// Highlights strings | ||
export class StringHighlighter extends HighlightVisitor { | ||
public tokenKinds = stringKinds; | ||
export class ErrorDefinitionHighlighter extends HighlightVisitor { | ||
public tokenKinds = new Set([TokenKind.Identifier]); | ||
|
||
public enter(nodeWrapper: SlangNodeWrapper): void { | ||
const ancestors = nodeWrapper.pathRuleNodes; | ||
if ( | ||
nodeWrapper.type === NodeType.Token && | ||
stringKinds.has(nodeWrapper.kind as TokenKind) | ||
nodeWrapper.kind === TokenKind.Identifier && | ||
ancestors[ancestors.length - 1]?.kind === RuleKind.ErrorDefinition | ||
) { | ||
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.string); | ||
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type); | ||
} | ||
} | ||
} |
103 changes: 0 additions & 103 deletions
103
server/src/services/semanticHighlight/highlighters/KeywordHighlighter.ts
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
server/src/services/semanticHighlight/highlighters/LibraryDefinitionHighlighter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { SemanticTokenTypes } from "vscode-languageserver-protocol"; | ||
import { NodeType } from "@nomicfoundation/slang/cst"; | ||
import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; | ||
import { HighlightVisitor } from "../HighlightVisitor"; | ||
import { SlangNodeWrapper } from "../../../parser/slangHelpers"; | ||
|
||
export class LibraryDefinitionHighlighter extends HighlightVisitor { | ||
public tokenKinds = new Set([TokenKind.Identifier]); | ||
|
||
public enter(nodeWrapper: SlangNodeWrapper): void { | ||
const ancestors = nodeWrapper.pathRuleNodes; | ||
if ( | ||
nodeWrapper.type === NodeType.Token && | ||
nodeWrapper.kind === TokenKind.Identifier && | ||
ancestors[ancestors.length - 1]?.kind === RuleKind.LibraryDefinition | ||
) { | ||
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type); | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...services/semanticHighlight/highlighters/UserDefinedValueTypeDefinitionHighlighter copy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { SemanticTokenTypes } from "vscode-languageserver-protocol"; | ||
import { NodeType } from "@nomicfoundation/slang/cst"; | ||
import { RuleKind, TokenKind } from "@nomicfoundation/slang/kinds"; | ||
import { HighlightVisitor } from "../HighlightVisitor"; | ||
import { SlangNodeWrapper } from "../../../parser/slangHelpers"; | ||
|
||
export class UserDefinedValueTypeDefinitionHighlighter extends HighlightVisitor { | ||
public tokenKinds = new Set([TokenKind.Identifier]); | ||
|
||
public enter(nodeWrapper: SlangNodeWrapper): void { | ||
const ancestors = nodeWrapper.pathRuleNodes; | ||
if ( | ||
nodeWrapper.type === NodeType.Token && | ||
nodeWrapper.kind === TokenKind.Identifier && | ||
ancestors[ancestors.length - 1]?.kind === | ||
RuleKind.UserDefinedValueTypeDefinition | ||
) { | ||
this.tokenBuilder.addToken(nodeWrapper, SemanticTokenTypes.type); | ||
} | ||
} | ||
} |
Oops, something went wrong.