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

Formatting implementation using new tree #1109

Merged
merged 67 commits into from
Nov 14, 2014
Merged

Formatting implementation using new tree #1109

merged 67 commits into from
Nov 14, 2014

Conversation

vladima
Copy link
Contributor

@vladima vladima commented Nov 10, 2014

This PR adds implementation of code formatting that works atop of new tree. I would not suggest to review the code commit-by-commit as intermediate checkins here often contain non-relevant details that are ultimately removed in final implementation.

* { var x;
* }
* Normally indentation is applied only to the first token in line so at glance 'var' should not be touched.
* However if some format rule removes new line between ')' and '{' 'var' will become
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't quite get this comment. "if some format rule removes new line between ')' and '{'" then we'll have:

while (true) { var x;
}

And 'var' will not be the first token in line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. was thinking about another example with writing this comment, will make it more clear

return find(sourceFile);

function find(n: Node): Node {
var candidate = forEachChild(n, c => startEndContainsRange(c.getStart(sourceFile), c.end, range) && c);
Copy link
Member

Choose a reason for hiding this comment

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

You might actually be able to make this faster if you fed in the optional cbNodes argument to perform a binary search.

vladima added a commit that referenced this pull request Nov 14, 2014
Formatting implementation using new tree
@vladima vladima merged commit c8412c6 into master Nov 14, 2014
@vladima vladima deleted the formatting_scanner branch November 19, 2014 06:32
@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants