Skip to content

When handling a missing layout node, only make the placeholder present #1894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 11, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jul 10, 2023

This fixes a couple of formatting issues and resolves the question raised in #1727 (comment).

While at it do the following

  • Add a syntax trait for all missing nodes (because we’re using it for diagnostic generation)
  • Improve the generation of Traits.swift
  • Add missing comma in doc comments of missing nodes
  • Improve debugDescription of Diagnostic
    • Since SourceLocation is no longer ExpressibleByDebugDescription due to the addition of presumedFile and presumedLine, we need to manually print just line and column here.

ahoppen added 2 commits July 10, 2023 11:11
Since `SourceLocation` is no longer `ExpressibleByDebugDescription` due to the addition of `presumedFile` and `presumedLine`, we need to manually print just line and column here.
@ahoppen ahoppen requested review from bnbarham and kimdv July 10, 2023 09:14
@ahoppen ahoppen force-pushed the ahoppen/missing-nodes-fixit branch from 5bcee2d to d51cdce Compare July 10, 2023 09:16
@ahoppen
Copy link
Member Author

ahoppen commented Jul 10, 2023

@swift-ci Please test

let changes = missingNodes.map { node in
if let missing = node.asProtocol(MissingNodeSyntax.self) {
// For missing nodes, only make the placeholder present. Don’t make any
// missing nodes, e.g. in a malformed attribute, missing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// missing nodes, e.g. in a malformed attribute, missing.
// missing nodes, e.g. in a malformed attribute, present.

Copy link
Contributor

Choose a reason for hiding this comment

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

Out of interest, what other nodes were being made present? In eg. the @resultBuilder test case, I would have expected the MissingDeclSyntax to just have @resultBuilder + the placeholder token.

Copy link
Member Author

Choose a reason for hiding this comment

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

In https://github.com/apple/swift-syntax/pull/1727/files#diff-dbdc9e7622c775bb821fe2ed1fa1ef2dd474cd2fb597480275ad048b932244c3R73-R102 we had

@_specialize(e

which contained a missing :, identifier and ) in the attribute of the MissingDeclSyntax, which was made present by the Fix-It.

@bnbarham
Copy link
Contributor

Improve the generation of Traits.swift

Are you planning on adding docs for the other traits as well?

This fixes a couple of formatting issues and resolves the question raised in swiftlang#1727 (comment).
@ahoppen ahoppen force-pushed the ahoppen/missing-nodes-fixit branch from d51cdce to caddfd1 Compare July 11, 2023 06:05
@ahoppen
Copy link
Member Author

ahoppen commented Jul 11, 2023

Are you planning on adding docs for the other traits as well?

I am planning to add documentation to the traits as much as I’m planning to add documentation to all the syntax nodes. How soon I/the community will get to it 🤷🏽‍♂️

@ahoppen
Copy link
Member Author

ahoppen commented Jul 11, 2023

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Jul 11, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit 6864c93 into swiftlang:main Jul 11, 2023
@ahoppen ahoppen deleted the ahoppen/missing-nodes-fixit branch July 11, 2023 10:32
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