Skip to content

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Aug 9, 2021

To clarify that the edits passed to IncrementalParseTransition are applied concurrently, introduce a new ConcurrentEdit type that provides the guarantee and allows translation of sequentially applied edits to the expected concurrent form.

Fixes rdar://72848263

@ahoppen ahoppen requested a review from akyrtzi August 9, 2021 21:59
@ahoppen
Copy link
Member Author

ahoppen commented Aug 9, 2021

@swift-ci Please test

@akyrtzi
Copy link
Contributor

akyrtzi commented Aug 9, 2021

isEditArrayValid() can be made internal now.
Also normalizeEdits() is only useful to be made public for testing purposes, should we have it underscored?

Copy link
Contributor

@akyrtzi akyrtzi left a comment

Choose a reason for hiding this comment

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

We should:

  • Make it clear in documentation comments that the edits are considered concurrent
  • Make the initializer accept normalized edits with a precondition to check them (or maybe throw an error, though that would change API/ABI)
  • Provide the normalizeEdits() as helper function but have it accept either concurrent or cumulative edits

@ahoppen ahoppen force-pushed the pr/normalize-edits branch from 4ad6e0d to 4741d83 Compare August 11, 2021 11:39
@ahoppen ahoppen changed the title Normalize edits passed to an incremental parse transition Clarify that edits passed to IncrementalParseTransition are concurrent and add function to transform sequential edits to concurrent Aug 11, 2021
@ahoppen
Copy link
Member Author

ahoppen commented Aug 11, 2021

OK, I refactored the PR pretty significantly (although the translation algorithm stayed mostly the same).

IncrementalParseTransition now takes ConcurrentEdits instead of [SourceEdit]. ConcurrentEdits can either be initialized from [SourceEdit] that are already guaranteed to be in concurrent form or from an array of sequentially applied edits, which are then translated to concurrent edits in the expected form. This way, the user of the API always needs to make a deliberate choice which constructor of ConcurrentEdits to invoke and thus shouldn’t make any false assumptions about how the edits are interpreted.

I kept the old initializer, made it call through to ConcurrentEdits.init(concurrent:) and marked it as deprecated so the change isn’t API breaking for now.

@ahoppen ahoppen force-pushed the pr/normalize-edits branch from 4741d83 to 6a7d732 Compare August 11, 2021 11:48
@swiftlang swiftlang deleted a comment from swift-ci Aug 11, 2021
@swiftlang swiftlang deleted a comment from swift-ci Aug 11, 2021
@ahoppen ahoppen force-pushed the pr/normalize-edits branch from 6a7d732 to 71351c4 Compare August 11, 2021 15:17
@ahoppen
Copy link
Member Author

ahoppen commented Aug 11, 2021

@swift-ci Please test

@swiftlang swiftlang deleted a comment from swift-ci Aug 11, 2021
@swiftlang swiftlang deleted a comment from swift-ci Aug 11, 2021
@akyrtzi
Copy link
Contributor

akyrtzi commented Aug 12, 2021

This API isn't used much, a search on GitHub only showed the stress-tester, but having a transitional step is goodness.

/// 1. not be overlapping.
/// 2. be in increasing source offset order.
public struct ConcurrentEdits {
/// The raw concurrent edits. Are guranteed to satisfy the requirements
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo "guranteed"

…ent and add function to transform sequential edits to concurrent

To clarify that the edits passed to `IncrementalParseTransition` are applied concurrently, introduce a new `ConcurrentEdit` type that provides the guarantee and allows translation of sequentially applied edits to the expected concurrent form.

Fixes rdar://72848263
@ahoppen ahoppen force-pushed the pr/normalize-edits branch from 71351c4 to a70ff2d Compare August 24, 2021 08:18
@ahoppen
Copy link
Member Author

ahoppen commented Aug 24, 2021

@swift-ci Please test

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