Unified: Implement {Constructor,Function,Variable}Declaration.toString - #22705
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Some constructors and destructuring variables now produce empty or incomplete display labels.
Review effort: Balanced
Findings: 1
What changed in this PR
Implements readable declaration labels for Unified AST nodes using language-specific keywords.
Changes:
- Adds plugin hooks and Swift keyword mappings.
- Implements declaration
toString()methods. - Updates control-flow test expectations.
| File | Description |
|---|---|
FacadeAst.qll |
Adds declaration names and display strings. |
AstPlugin.qll |
Defines declaration-keyword extension points. |
AstPluginSwift.qll |
Supplies Swift declaration keywords. |
cfg.swift |
Updates inline CFG expectations. |
cfg.expected |
Updates generated CFG output. |
basicblock-slices.expected |
Updates generated block-slice output. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| string getName() { result = this.getNameNode().getValue() } | ||
|
|
||
| override string toString() { | ||
| result = concat(getConstructorDeclarationKeyword(this) + " ") + concat(this.getName()) |
asgerf
left a comment
There was a problem hiding this comment.
Minor comment but OK to merge if you disagree
| bindingset[f] | ||
| string getFunctionDeclarationKeyword(FunctionDeclaration f) { none() } | ||
|
|
||
| bindingset[c] | ||
| string getConstructorDeclarationKeyword(ConstructorDeclaration c) { none() } | ||
|
|
||
| bindingset[cls] | ||
| string getClassLikeDeclarationKeyword(ClassLikeDeclaration cls) { none() } | ||
|
|
||
| bindingset[decl] | ||
| string getVariableDeclarationKeyword(VariableDeclaration decl) { none() } |
There was a problem hiding this comment.
Would it perhaps we worth simplifying this to something like?
predicate includeModifierInToString(Modifier m);and then the language plugin can decide if it's worth checking the node type or just the modifier text.
There was a problem hiding this comment.
I don't think we extract func modifiers, so we would then have to do that.

No description provided.