Skip to content

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