Skip to content

Unified: Implement {Constructor,Function,Variable}Declaration.toString - #22705

Merged
hvitved merged 1 commit into
github:mainfrom
hvitved:unified/more-to-string
Sep 30, 2026
Merged

hvitved merged 1 commit into
github:mainfrom
hvitved:unified/more-to-string

Conversation

@hvitved

@hvitved hvitved commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@hvitved hvitved added the no-change-note-required This PR does not need a change note label Sep 30, 2026
@hvitved
hvitved marked this pull request as ready for review September 30, 2026 08:15
@hvitved
hvitved requested a review from a team as a code owner September 30, 2026 08:15
@hvitved
hvitved requested review from asgerf and a balanced review from Copilot September 30, 2026 08:15

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Some constructors and destructuring variables now produce empty or incomplete display labels.

Review effort: Balanced
Findings: 1 Medium severity

Open (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 asgerf 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.

Minor comment but OK to merge if you disagree

Comment on lines +12 to +22
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() }

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.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think we extract func modifiers, so we would then have to do that.

@hvitved
hvitved merged commit f9840d9 into github:main Sep 30, 2026
14 of 16 checks passed
@hvitved
hvitved deleted the unified/more-to-string branch September 30, 2026 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants