Skip to content

Conversation

@a7medev
Copy link
Member

@a7medev a7medev commented Aug 11, 2025

Problem

We're implementing signature help which needs to extract the signature label out of declarations or types similar to the existing behavior in code completion.

The problem is the logic for building a structured CodeCompletionString is currently tied to code completion. The logic mostly lives in CodeCompletionResultBuilder and CompletionLookup and requires completion-specific objects like CodeCompletionContext and CodeCompletionResultSink making them hard to reuse.

Solution

To make this logic reusable, we introduce CodeCompletionStringBuilder which is responsible for performing primitive CodeCompletionString building logic (e.g. adding call arguments). We move most of the methods for building CodeCompletionStrings out of CodeCompletionResultBuilder and CompletionLookup into CodeCompletionStringBuilder which doesn't depend on completion-specific objects like the old implementation.

Existing code completion logic should still behave exactly the same.

Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Thanks! Couple more comments, but otherwise LGTM

@a7medev a7medev force-pushed the refactor/extract-code-completion-string-builder branch 6 times, most recently from cf00131 to fb566f1 Compare August 26, 2025 21:11
@a7medev a7medev requested a review from hamishknight August 26, 2025 21:15
@a7medev
Copy link
Member Author

a7medev commented Aug 26, 2025

@hamishknight I've addressed all the comments. Can you please recheck? 🙏🏼

…lder

[IDE] Move primitive completion function label into CodeCompletionStringBuilder

[IDE] NFC: Remove unneeded string builder methods on CodeCompletionResultBuilder

[IDE] Move addValueBaseName into CodeCompletionStringBuilder

[IDE] Make CodeCompletionResultBuilder a CodeCompletionStringBuilder

[IDE] Explicitly pass DeclContext in CodeCompletionStringBuilder

[IDE] Reduce includes in CodeCompletionStringBuilder.h
@a7medev a7medev force-pushed the refactor/extract-code-completion-string-builder branch from fb566f1 to ec1b146 Compare August 26, 2025 21:40
Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Thanks!

@hamishknight
Copy link
Contributor

@swift-ci please test

@a7medev a7medev force-pushed the refactor/extract-code-completion-string-builder branch from 870afba to ec1b146 Compare August 28, 2025 16:25
@hamishknight hamishknight merged commit 4f010f0 into swiftlang:main Aug 28, 2025
5 checks passed
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.

3 participants