Skip to content

Add syntax highlighting for project symbol search#188

Open
da-r-k wants to merge 1 commit intozed-extensions:mainfrom
da-r-k:feat/label-for-symbol
Open

Add syntax highlighting for project symbol search#188
da-r-k wants to merge 1 commit intozed-extensions:mainfrom
da-r-k:feat/label-for-symbol

Conversation

@da-r-k
Copy link

@da-r-k da-r-k commented Feb 9, 2026

Summary

Implements label_for_symbol to provide syntax-highlighted labels in the project symbol picker (cmd-t). Currently, Java symbols appear as plain grey text with no highlighting, unlike Rust and other languages that already implement this.

Ref: zed-industries/zed#36383, zed-industries/zed#37176

Changes

  • Add label_for_symbol to the Extension for Java impl
  • Import Symbol and SymbolKind from the extension API
  • Generate Tree-sitter-parseable code snippets for each symbol kind so the Java grammar produces correct AST nodes and syntax highlighting
  • Wrap member-level constructs (methods, fields, constructors) inside class _ { } since Java's Tree-sitter grammar requires class context for these declarations
  • Display symbols in Java declaration order (type before name): void doWork(String, int), String fieldName
  • Show keyword prefixes for type declarations: class, interface, enum, package

Supported symbol kinds

Kind Display example Tree-sitter context
Class class MyClass class MyClass {}
Interface interface Runnable interface Runnable {}
Enum enum Status enum Status {}
Constructor MyClass(String, int) class MyClass { MyClass() {} }
Method void doWork(String, int) class _ { void doWork() {} }
Field String name class _ { String name; }
Constant MAX_SIZE class _ { static final int MAX_SIZE; }
EnumMember ACTIVE enum _ { ACTIVE }
Variable count class _ { int count; }
Package package com.example package com.example;

Screenshot:

image

Implement `label_for_symbol` to provide syntax-highlighted labels in the
project symbol picker (cmd-t). Without this, Java symbols appear as
plain grey text.

Each symbol kind generates a Tree-sitter-parseable code snippet wrapped
in the appropriate context (e.g. methods/fields inside `class _ { }`)
so the Java grammar can produce correct AST nodes for highlighting.

Supported symbols:
- Class, Interface, Enum: keyword prefix + name
- Method/Function: return type + name + params (Java declaration order)
- Constructor: name + params
- Field/Property: type + name (Java declaration order)
- Constant, EnumMember, Variable: highlighted name
- Package/Module/Namespace: keyword prefix + name

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cla-bot
Copy link

cla-bot bot commented Feb 9, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @da-r-k on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@da-r-k
Copy link
Author

da-r-k commented Feb 9, 2026

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Feb 9, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @da-r-k on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@cla-bot
Copy link

cla-bot bot commented Feb 9, 2026

The cla-bot has been summoned, and re-checked this pull request!

@da-r-k
Copy link
Author

da-r-k commented Feb 9, 2026

@cla-bot check

@cla-bot cla-bot bot added the cla-signed label Feb 9, 2026
@cla-bot
Copy link

cla-bot bot commented Feb 9, 2026

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant