Add 'prefixText' and 'suffixText' when renaming shorthand properties (#27356)

* Add 'prefixText' and 'suffixText' when renaming shorthand properties

* Make prefixText and suffixText missing instead of undefined

* Fix test
This commit is contained in:
Andy
2018-09-26 16:58:01 -07:00
committed by GitHub
parent 0b12e9dc01
commit 0a97663843
38 changed files with 327 additions and 227 deletions

View File

@@ -1135,7 +1135,12 @@ namespace ts.server.protocol {
/** The file to which the spans apply */
file: string;
/** The text spans in this group */
locs: TextSpan[];
locs: RenameTextSpan[];
}
export interface RenameTextSpan extends TextSpan {
readonly prefixText?: string;
readonly suffixText?: string;
}
export interface RenameResponseBody {

View File

@@ -1190,10 +1190,11 @@ namespace ts.server {
private toSpanGroups(locations: ReadonlyArray<RenameLocation>): ReadonlyArray<protocol.SpanGroup> {
const map = createMap<protocol.SpanGroup>();
for (const { fileName, textSpan } of locations) {
for (const { fileName, textSpan, originalTextSpan: _, originalFileName: _1, ...prefixSuffixText } of locations) {
let group = map.get(fileName);
if (!group) map.set(fileName, group = { file: fileName, locs: [] });
group.locs.push(this.toLocationTextSpan(textSpan, Debug.assertDefined(this.projectService.getScriptInfo(fileName))));
const scriptInfo = Debug.assertDefined(this.projectService.getScriptInfo(fileName));
group.locs.push({ ...this.toLocationTextSpan(textSpan, scriptInfo), ...prefixSuffixText });
}
return arrayFrom(map.values());
}