Skip to content

Improve insertion positions of extracted constants#18861

Merged
amcasey merged 5 commits into
microsoft:masterfrom
amcasey:ConstantInsertionPosition
Oct 2, 2017
Merged

Improve insertion positions of extracted constants#18861
amcasey merged 5 commits into
microsoft:masterfrom
amcasey:ConstantInsertionPosition

Conversation

@amcasey
Copy link
Copy Markdown
Member

@amcasey amcasey commented Sep 29, 2017

...mostly by putting them closer to the extraction site.

They now also follow all leading comments in a file (unfortunately, including the doc comment on the first declaration).

Bonus: Special case declaration lists - declare the new variable as part of the list, rather than before it, in case it depends on an earlier entry.

...mostly by putting them closer to the extraction site.

They now also follow all leading comments in a file (unfortunately,
including the doc comment on the first declaration).

Bonus: Special case declaration lists - declare the new variable as part
of the list, rather than before it, in case it depends on an earlier
entry.
@weswigham
Copy link
Copy Markdown
Member

weswigham commented Sep 29, 2017

In #17327 I added some logic (getSourceFileImportLocation) to the import codefix to figure out where to place an import between comments at the top of the file if an import did not yet exist to determine a location from - and if I'm not mistaken, that should be the same place you'd like to extract a global constant to in a similar situation. Does it make sense to share that logic between extractSymbol and importFixes?

@amcasey
Copy link
Copy Markdown
Member Author

amcasey commented Sep 30, 2017

@weswigham done.

Now that we're smarter about where we declare the extracted local, we
can ignore usage problems in the innermost script - it'll always have
access to the same symbols as the extracted expression.
Using the same description as for functions was confusing because the
extracted constant was inserted below the top-level of that scope.
@amcasey amcasey merged commit 2df7058 into microsoft:master Oct 2, 2017
@amcasey amcasey deleted the ConstantInsertionPosition branch October 2, 2017 23:39
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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.

4 participants