fix(dead-code): exclude annotated Tauri commands (#1543) (#2019)

Rust command attributes were not retained as decorators, so runtime entry points could appear as dead code.
Preserve tauri::command metadata in both native and fallback extraction and reuse the existing decorated exclusion.
Add SQLite regression coverage and native/fallback parity checks, including negative cases.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Colby Mchenry
2026-09-27 13:10:17 +00:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 9b5c8e49dd
commit 87e79c6ee8
4 changed files with 124 additions and 3 deletions
+15
View File
@@ -5313,6 +5313,21 @@ export class TreeSitterExtractor {
* (most non-decorator-using languages), the function is a no-op.
*/
private extractDecoratorsFor(declNode: SyntaxNode, decoratedId: string): void {
// Rust outer attributes are siblings, not children of the function.
// Preserve Tauri's runtime registration for the dead-code decorator rule.
if (this.language === 'rust' && declNode.type === 'function_item') {
for (let sibling = declNode.previousNamedSibling; sibling; sibling = sibling.previousNamedSibling) {
if (sibling.type === 'line_comment' || sibling.type === 'block_comment') continue;
if (sibling.type !== 'attribute_item') break;
const attribute = sibling.namedChild(0);
const name = attribute?.namedChild(0)?.text.replace(/\s/g, '');
if (name === 'tauri::command') {
const decorated = this.nodes.find(n => n.id === decoratedId);
if (decorated) decorated.decorators = ['tauri::command'];
break;
}
}
}
const consider = (n: SyntaxNode | null): void => {
if (!n) return;
// Solidity `modifier_invocation` (unique to that grammar) sits