Skip to content

feat(search): support qualified symbol matching in workspace.rankNames and workspace.symbolQuery - #255

Merged
1lck merged 1 commit into
mainfrom
feat/qualified-symbol-search
Dec 3, 2026
Merged

1lck merged 1 commit into
mainfrom
feat/qualified-symbol-search

Conversation

@1lck

@1lck 1lck commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add split_qualified_symbol in rust/crates/project/src/name_matching.rs to split Class.member, Class#member, and ns::member at the last separator.
  • Add optional container on RankCandidate and opt-in qualifiedSymbols flag on RankNamesRequest in rust/crates/project/src/name_ranking.rs, matching member against name and qualifier against container or path without altering dotted filename ranking.
  • Add workspace.symbolQuery command (rust/crates/core/src/protocol/command.rs, rust/crates/core/src/runtime/dispatcher/workspace.rs) so hosts share Core's query splitting rule when querying LSP workspace/symbol.
  • Update rust/contracts/rust-core-api.md, rust/fixtures/search/rank-names-v1.json, and rust/crates/core/src/tests/rank_names.rs.

Verification

  • cargo fmt --all --manifest-path rust/Cargo.toml -- --check passed.
  • cargo test --manifest-path rust/Cargo.toml -p lithe-core rank_names passed (4 passed).

Devin Review

@1lck
1lck merged commit b000910 into main Dec 3, 2026
7 of 8 checks passed
@1lck
1lck deleted the feat/qualified-symbol-search branch December 3, 2026 03:36

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Devin Review

Comment on lines +255 to +257
let path = candidate.path.as_deref()?;
let normalized = qualifier.replace("::", "/").replace('.', "/");
let path_hit = match_name(&normalized, path).or_else(|| match_name(qualifier, path))?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Missing qualified symbols on Windows

match_qualified drops valid symbols with short container names when their package is supplied by a backslash-separated Windows path. match_container and the path fallback both look for forward slashes in that path.

Learn more

The rankNames contract accepts full candidate paths and lets them supply a symbol's qualifier. The text matcher only compares characters case-insensitively; it does not equate the two slash characters (match_fragments). With an LSP container that only identifies the class, the package check needs to match the package prefix against the path. Both that check and the full qualifier fallback compare a forward-slash pattern against the original path.

Example: Query com.example.UserService.getUser with a candidate named getUser, container UserService, and path C:\repo\src\com\example\UserService.java. This is dropped, while the same candidate with forward slashes matches.

Recommended fix: Use lithe_platform::paths::slash_separated with the relevant Platform for the path used by both qualified comparisons. Keep the original path for open/recent identity. Test the existing dotted-package fixture with native Windows separators.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +268 to +276
let (prefix, tail) = split_qualified_symbol(qualifier)?;
let tail_hit = match_name(tail, container)?;
if let Some(path) = path {
let normalized_prefix = prefix.replace("::", "/").replace('.', "/");
if match_name(&normalized_prefix, path).is_none() {
return None;
}
}
Some((tail_hit.degree / (PATH_DEGREE_DIVISOR * 2)).max(1))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Unverified packages in symbol results

When a candidate lacks a path, match_container accepts a class-name match without verifying the requested package. Methods from unrelated packages then appear under the same qualified query.

Learn more

The rankNames contract allows candidates without a path, but a qualified search still needs evidence for the whole qualifier. When a container does not match the whole qualifier, the fallback can combine the class from the container with the package from the path. Without a path, it currently returns the class-only match even though nothing establishes the package.

Example: Search for com.example.UserService.getUser with a candidate { "name": "getUser", "container": "UserService" } from org.other. It is returned despite having no matching package evidence.

Recommended fix: Require a matching path prefix for this fallback. Leave the full-container match available without a path.

Suggested change
let (prefix, tail) = split_qualified_symbol(qualifier)?;
let tail_hit = match_name(tail, container)?;
if let Some(path) = path {
let normalized_prefix = prefix.replace("::", "/").replace('.', "/");
if match_name(&normalized_prefix, path).is_none() {
return None;
}
}
Some((tail_hit.degree / (PATH_DEGREE_DIVISOR * 2)).max(1))
let (prefix, tail) = split_qualified_symbol(qualifier)?;
let tail_hit = match_name(tail, container)?;
let path = path?;
let normalized_prefix = prefix.replace("::", "/").replace('.', "/");
match_name(&normalized_prefix, path)?;
Some((tail_hit.degree / (PATH_DEGREE_DIVISOR * 2)).max(1))

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +182 to +193
} else if let Some((qualifier, member)) = qualified {
if let Some(hit) = match_qualified(qualifier, member, candidate) {
hit
} else if let Some(hit) = candidate
.path
.as_deref()
.and_then(|path| match_name(query, path))
{
((hit.degree / PATH_DEGREE_DIVISOR).max(1), Vec::new())
} else {
continue;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 File paths admit unrelated symbols

For qualified queries, rank_names_command returns symbols whose paths match the full query even when their names fail the member match. Unrelated symbols from those files appear in the results.

Learn more

The rankNames contract allows hosts to supply symbol or navigator lists. For a qualified query, the path can establish the qualifier but not the member. match_qualified rejects candidates whose symbol name fails the member match, but the caller then lets the path satisfy the whole query.

Example: A navigator list includes loadDefaults from src/config.read.ts. Searching for Config.read returns loadDefaults even though read does not match its name.

Recommended fix: Drop this path-only fallback for recognized qualified queries. Keep the direct name match for candidates whose names already include their qualifier and the existing path-only fallback for unqualified queries.

Suggested change
} else if let Some((qualifier, member)) = qualified {
if let Some(hit) = match_qualified(qualifier, member, candidate) {
hit
} else if let Some(hit) = candidate
.path
.as_deref()
.and_then(|path| match_name(query, path))
{
((hit.degree / PATH_DEGREE_DIVISOR).max(1), Vec::new())
} else {
continue;
}
} else if let Some((qualifier, member)) = qualified {
let Some(hit) = match_qualified(qualifier, member, candidate) else {
continue;
};
hit

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

xiaoyumuxi added a commit that referenced this pull request Dec 3, 2026
* feat(tree): 项目树与提交文件树支持紧凑显示单一子文件夹链

- workspace.projectTree.rows 新增可选 compact:已列出、只含一个子文件夹的非根文件夹与子文件夹合成一行(同 IDEA/VS Code),返回 heads 给出每行链首;选区与 top 落在链中文件夹时移到该行。
- git.changedFileGroups 新增可选 nest{compact}:按树列出全部上级文件夹并给出 depth 与 label,compact 时把无文件且只含一个文件夹的链合并,label 用 / 连接。
- 两个 fixture 增加对应用例,rust-core-api.md 补充契约。
- 顺手修 name_ranking.rs 的 clippy question_mark(#255 引入)。

Refs 1lck/Lithe-IDEA#2641

* feat(tree): 紧凑项目树按行返回缩进层级 depths

紧凑链无论多长只占一层缩进;链下的文件和文件夹要跟着少缩进。workspace.projectTree.rows 在 compact 时多返回 depths,每行一个:节点 depth 减去它上面与唯一子文件夹合并的文件夹数。补一个链套链的 fixture。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant