Skip to content
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

[SourceKit] Move Code Formatting Logic to libIDE #1686

Merged
merged 9 commits into from Mar 21, 2016
Merged

[SourceKit] Move Code Formatting Logic to libIDE #1686

merged 9 commits into from Mar 21, 2016

Conversation

regnerjr
Copy link
Contributor

[SourceKit] Move Code Formatting from SourceKit -> libIDE

Moved CodeFormatter, FormatContext, FormatWalker and associated classes, structures, functions to libIDE.

I have run the tests locally (OS X) utils/build-script -t

No new tests have been added since no features were added or removed.

This PR makes progress on - SR-146 but does not fulfill all of its scope.

Related bug number: (SR-146)

Ping: @akyrtzi @benlangmuir


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
OS X platform @swift-ci Please test OS X platform
Linux platform @swift-ci Please test Linux platform

Note: Only members of the Apple organization can trigger swift-ci.

@regnerjr regnerjr changed the title Move Code Formatting Logic to libIDE [SourceKit] Move Code Formatting Logic to libIDE Mar 15, 2016
@tkremenek
Copy link
Member

@swift-ci Please test

@tkremenek
Copy link
Member

@akyrtzi Please review.

@benlangmuir
Copy link
Member

Hi John,

Thanks for working on this!

I think we should squash/rebase some of the commits together to make the changes more independent. We aim for every commit to be able to build/test successfully on its own. I don't think we want them all squashed into one commit, but if we can make them more independent/logical it will be easier to review them.

[SourceKit] Apply failed rebase changes.
[SourceKit] Add Proper Headers to new files.

These should be rebased into the preceding commits. Basically the Headers should show up in t he same commit that the new file is added and the rebase change should be squashed into wherever the issue came from.

[SourceKit] Updated file header to reflect the new file names.
[SourceKit] Configure Formatting.cpp to be build with libIDE
[SourceKit] Fix headers to pull in Formatting from libIDE

Similarly, these look like they should be part of preceding commits. Every commit should independent and be able to build and test successfully on its own.

[SourceKit] Clean-up header comments.
[SourceKit] Move FormatContext and FormatWalker to .cpp
[SourceKit] Formatting - Move More types out of header file.
Should probably be squashed with the commit that moved them in the first place.

[SoureKit] Limited Formatting Ranges
Is this new functionality, or is it needed to make the existing tests pass? If it's new let's put it in a separate pull request (this one is big enough!). If it's necessary for existing functionality it should probably be squashed together with earlier commits so that they will work on their own.

[SourceKit] Update Documentation
[SourceKit] Undo some minor changes

More commits that should be squashed somewhere.

@tkremenek
Copy link
Member

@swift-ci Please test

size_t getExpandedIndentForLine(unsigned LineIndex, CodeFormatOptions Options,
StringRef Text);

class SwiftEditorLineRange {
Copy link
Member

Choose a reason for hiding this comment

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

How about "SourceLineRange", or even just "LineRange"? SwiftEditor doesn't really add anything here.

@regnerjr
Copy link
Contributor Author

Hi @benlangmuir & @akyrtzi I cleaned up the history and corrected the errors that @benlangmuir pointed out yesterday. Let me know if you see anything that needs more work. Thanks!

@@ -1491,7 +1491,7 @@ class CodeFormatter {
}
Builder.append(Line);
Consumer.recordFormattedText(Builder.str().str());
return SwiftEditorLineRange(LineIndex, 1);
return std::pair<SwiftEditorLineRange, StringRef> (SwiftEditorLineRange(LineIndex, 1), Text);
Copy link
Member

Choose a reason for hiding this comment

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

make_pair

@benlangmuir
Copy link
Member

This is looking awesome! I've made a few more suggestions on the individual commits here. Thanks for your hard work!

Move FormatContext & FormatWalker into new file.
Move CodeFormatOptions out of SwiftEditorDocument.
Move functions getTrimmedLineOffset & getLineOffset
out of SwiftEditor Document.
Rename Offset of Line functions
Declaring that the get the offset of some line index is more clear.
This helps de-couple us from the Swift Editor Document.
Moved getTrimmedTextForLine &  getExpandedIndentForLine
This help reduce the coupling to SwiftEditor Document and allows us
to format any text, whether or not is currently in an editor doc.
@regnerjr
Copy link
Contributor Author

Hey @benlangmuir! Thanks so much for you help. I am now a rebase, rewriting history master. Thanks for the great suggestions. I think I have now addressed all your comments, and ensured that each individual commit, builds and passes all tests. Let me know if there is anything more you'd like to see here. Thanks again.

@benlangmuir
Copy link
Member

@swift-ci Please test

benlangmuir added a commit that referenced this pull request Mar 21, 2016
[SourceKit] Move Code Formatting Logic to libIDE
@benlangmuir benlangmuir merged commit 65719e8 into apple:master Mar 21, 2016
@regnerjr regnerjr deleted the swift-format_SR-146 branch August 10, 2016 14:59
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.

None yet

4 participants