Skip to content

Add textChanges methods to insert nodes at the start of multiline bodies #20445

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
2 commits merged into from
Dec 5, 2017

Conversation

ghost
Copy link

@ghost ghost commented Dec 4, 2017

Fixes #20073

Calling insertNodeAfter to insert a node after an open brace is hacky anyway and caused problems when there wasn't already a newline after the open brace. This adds new ChangeTracker methods to insert a node at the beginning of a constructor or class.

this.replaceNode(sourceFile, ctr.body, createBlock([newStatement], /*multiLine*/ true), { useNonAdjustedEndPosition: true });
}
else {
this.insertNodeAfter(sourceFile, getOpenBrace(ctr, sourceFile), newStatement, { suffix: newLineCharacter });
Copy link
Member

Choose a reason for hiding this comment

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

Is this different from inserting it before the first statement?

Copy link
Member

Choose a reason for hiding this comment

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

If there's no linebreak after the brace, the new statement will appear on the same line?

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, failed to account for single-line constructors with statements in them. We should probably just make it multiline if it isn't already.

@ghost ghost merged commit 8f23bf8 into master Dec 5, 2017
@ghost ghost deleted the codeFixSuper branch December 5, 2017 16:33
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
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.

1 participant