This commit is contained in:
Corey Johnson 2025-11-05 13:31:31 -08:00
parent 7589518ca7
commit fa67c26c0a
2 changed files with 31 additions and 22 deletions

View File

@ -83,7 +83,7 @@
"compile": "bun run compile:client && bun run compile:server", "compile": "bun run compile:client && bun run compile:server",
"compile:client": "bun build client/src/extension.ts --outdir client/dist --target node --format cjs --external vscode", "compile:client": "bun build client/src/extension.ts --outdir client/dist --target node --format cjs --external vscode",
"compile:server": "bun build server/src/server.ts --outdir server/dist --target node --format cjs", "compile:server": "bun build server/src/server.ts --outdir server/dist --target node --format cjs",
"watch": "bun run compile:client --watch", "watch": "bun run compile:client --watch & bun run compile:server --watch",
"package": "bun run compile:client --minify && bun run compile:server --minify", "package": "bun run compile:client --minify && bun run compile:server --minify",
"check-types": "tsc --noEmit", "check-types": "tsc --noEmit",
"build-and-install": "bun run package && bunx @vscode/vsce package --allow-missing-repository && code --install-extension shrimp-*.vsix" "build-and-install": "bun run package && bunx @vscode/vsce package --allow-missing-repository && code --install-extension shrimp-*.vsix"

View File

@ -55,10 +55,13 @@ function walkTree(node: SyntaxNode, document: TextDocument, builder: SemanticTok
} }
// Map Lezer node IDs to semantic token type indices and modifiers // Map Lezer node IDs to semantic token type indices and modifiers
function getTokenType(nodeTypeId: number, parentTypeId?: number): { type: number; modifiers: number } | undefined { function getTokenType(
nodeTypeId: number,
parentTypeId?: number
): { type: number; modifiers: number } | undefined {
switch (nodeTypeId) { switch (nodeTypeId) {
case Terms.Identifier: case Terms.Identifier:
// Check parent to determine if this identifier is a function call or variable // Check parent to determine context
if (parentTypeId === Terms.FunctionCall) { if (parentTypeId === Terms.FunctionCall) {
return { return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.function), type: TOKEN_TYPES.indexOf(SemanticTokenTypes.function),
@ -77,12 +80,36 @@ function getTokenType(nodeTypeId: number, parentTypeId?: number): { type: number
modifiers: 0, modifiers: 0,
} }
} }
if (parentTypeId === Terms.Params) {
return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.parameter),
modifiers: 0,
}
}
if (parentTypeId === Terms.DotGet) {
return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.property),
modifiers: 0,
}
}
// Otherwise it's a regular variable // Otherwise it's a regular variable
return { return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.variable), type: TOKEN_TYPES.indexOf(SemanticTokenTypes.variable),
modifiers: 0, modifiers: 0,
} }
case Terms.IdentifierBeforeDot:
return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.variable),
modifiers: 0,
}
case Terms.NamedArgPrefix:
return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.property),
modifiers: 0,
}
case Terms.AssignableIdentifier: case Terms.AssignableIdentifier:
return { return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.variable), type: TOKEN_TYPES.indexOf(SemanticTokenTypes.variable),
@ -124,24 +151,12 @@ function getTokenType(nodeTypeId: number, parentTypeId?: number): { type: number
case Terms.keyword: case Terms.keyword:
case Terms.Do: case Terms.Do:
case Terms.colon:
return { return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.keyword), type: TOKEN_TYPES.indexOf(SemanticTokenTypes.keyword),
modifiers: 0, modifiers: 0,
} }
case Terms.Params:
case Terms.NamedParam:
return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.parameter),
modifiers: 0,
}
case Terms.DotGet:
return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.property),
modifiers: 0,
}
case Terms.Regex: case Terms.Regex:
return { return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.regexp), type: TOKEN_TYPES.indexOf(SemanticTokenTypes.regexp),
@ -154,12 +169,6 @@ function getTokenType(nodeTypeId: number, parentTypeId?: number): { type: number
modifiers: 0, modifiers: 0,
} }
case Terms.NamedArg:
return {
type: TOKEN_TYPES.indexOf(SemanticTokenTypes.property),
modifiers: 0,
}
default: default:
return undefined return undefined
} }