Skip to content

Conversation

a7medev
Copy link
Member

@a7medev a7medev commented Sep 19, 2025

  1. Moves signature help formatting into a new SignatureHelpFormatter class inside IDE.
  2. Adds the signature help request to swift-ide-test and moves most tests to test/IDE instead of test/SourceKit.
  3. Moves CodeCompletionStringBuilder.h into lib/IDE to be a private implementation detail of IDE just like CodeCompletionResultBuilder now that signature help formatting is also part of IDE.

Comment on lines +33 to +43
struct Parameter {
/// The offset of the parameter text in the signature text.
unsigned Offset;

/// The length of the parameter text in the signature text.
unsigned Length;

/// The internal parameter name.
llvm::StringRef Name;

Parameter() {}
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the DocComment field since we now rely on SourceKit-LSP to parse the signature's documentation and extract the parameter documentation.

Comment on lines 7 to 9
// CLOSURE_PARAM: Begin signatures, 1 items
// CLOSURE_PARAM-NEXT: Signature[Active]: body(<param active>Value</param>) -> Result
// CLOSURE_PARAM-NEXT: End signatures
Copy link
Member Author

Choose a reason for hiding this comment

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

Switched back to FileCheck from diff for swift-ide-test tests since the output is much nicer now besides that swift-ide-test prints "found code completion token <TOKEN> at offset OFFSET>" which we don't want to match with diff.

virtual void cancelled() = 0;
};

struct SignatureHelpResponse {
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need a separate SourceKit::SignatureHelpResponse since swift::ide::FormattedSignatureHelp already includes all the information in a format that could just be output by SourceKit.


class SignatureHelpFormatter {
private:
llvm::BumpPtrAllocator &Allocator;
Copy link
Member Author

Choose a reason for hiding this comment

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

SignatureHelpFormatter doesn't own its allocator to make the lifetime of the results it returns more explicit to the caller.

}
ExitCode = doSignatureHelp(
InitInvok, options::SourceFilename, options::SecondSourceFilename,
options::CodeCompletionToken, options::CodeCompletionDiagnostics);
Copy link
Member Author

Choose a reason for hiding this comment

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

Should I add separate -signature-help-token and -signature-help-diagnostics flags to avoid confusion or is relying on the existing code completion options fine here? I feel neutral to be honest.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with re-using the completion options for this

@a7medev
Copy link
Member Author

a7medev commented Sep 19, 2025

@swift-ci please test

@a7medev
Copy link
Member Author

a7medev commented Sep 19, 2025

@swift-ci please test macOS

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.

Very nice, thanks!

}
ExitCode = doSignatureHelp(
InitInvok, options::SourceFilename, options::SecondSourceFilename,
options::CodeCompletionToken, options::CodeCompletionDiagnostics);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with re-using the completion options for this

Comment on lines +1 to +3
// RUN: %target-swift-ide-test -signature-help -code-completion-token=CURRY_TOPLEVEL -source-filename=%s | %FileCheck %s --check-prefix=CURRY_TOPLEVEL
// RUN: %target-swift-ide-test -signature-help -code-completion-token=CURRY_MEMBER_PARTIAL -source-filename=%s | %FileCheck %s --check-prefix=CURRY_MEMBER_PARTIAL
// RUN: %target-swift-ide-test -signature-help -code-completion-token=CURRY_MEMBER_FULL -source-filename=%s | %FileCheck %s --check-prefix=CURRY_MEMBER_FULL
Copy link
Contributor

Choose a reason for hiding this comment

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

If we end up adding more signature help test cases with multiple places to do the request, it might be worth seeing if we can adapt batch-code-completion to also work for signature help. For now I think this is fine though since there aren't many of them

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree. We don't have many such tests at the moment though so I think it's fine for now.

@a7medev a7medev force-pushed the refactor/signature-help-to-ide branch from c6d547c to 7089473 Compare September 26, 2025 19:33
@a7medev
Copy link
Member Author

a7medev commented Sep 26, 2025

@swift-ci please smoke test

@a7medev a7medev force-pushed the refactor/signature-help-to-ide branch from 7089473 to 456a40a Compare September 26, 2025 19:40
@a7medev
Copy link
Member Author

a7medev commented Sep 26, 2025

@swift-ci please smoke test

@hamishknight hamishknight merged commit a7dd04e into swiftlang:main Sep 29, 2025
3 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.

2 participants