Skip to content

Commit f56be99

Browse files
author
Arthur Ozga
committed
cleanup
1 parent 1939c65 commit f56be99

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/harness/fourslash.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,10 +2292,10 @@ namespace FourSlash {
22922292
this.raiseError("Exactly one range should be specified in the testfile.");
22932293
}
22942294

2295-
const actualText = this.normalizeNewlines(this.rangeText(ranges[0]));
2295+
const actualText = this.rangeText(ranges[0]);
22962296

22972297
const result = includeWhiteSpace
2298-
? actualText === this.normalizeNewlines(expectedText)
2298+
? normalizeNewLines(actualText) === normalizeNewLines(expectedText)
22992299
: this.removeWhitespace(actualText) === this.removeWhitespace(expectedText);
23002300

23012301
if (!result) {

src/services/codefixes/fixAddMissingMember.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace ts.codefix {
33
registerCodeFix({
44
errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code,
5-
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code],
5+
Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code],
66
getCodeActions: getActionsForAddMissingMember
77
});
88

@@ -33,13 +33,12 @@ namespace ts.codefix {
3333
return undefined;
3434
}
3535

36+
const tokenName = token.getText(sourceFile);
3637
const isStatic = hasModifier(classMemberDeclaration, ModifierFlags.Static);
3738

3839
return isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile();
3940

4041
function getActionsForAddMissingMemberInJavaScriptFile(): CodeAction[] | undefined {
41-
const memberName = token.getText();
42-
4342
if (isStatic) {
4443
if (classDeclaration.kind === SyntaxKind.ClassExpression) {
4544
return undefined;
@@ -48,12 +47,12 @@ namespace ts.codefix {
4847
const className = classDeclaration.name.getText();
4948

5049
return [{
51-
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_static_property_0), [memberName]),
50+
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_static_property_0), [tokenName]),
5251
changes: [{
5352
fileName: sourceFile.fileName,
5453
textChanges: [{
5554
span: { start: classDeclaration.getEnd(), length: 0 },
56-
newText: `${context.newLineCharacter}${className}.${memberName} = undefined;${context.newLineCharacter}`
55+
newText: `${context.newLineCharacter}${className}.${tokenName} = undefined;${context.newLineCharacter}`
5756
}]
5857
}]
5958
}];
@@ -66,12 +65,12 @@ namespace ts.codefix {
6665
}
6766

6867
return [{
69-
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [memberName]),
68+
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]),
7069
changes: [{
7170
fileName: sourceFile.fileName,
7271
textChanges: [{
7372
span: { start: classConstructor.body.getEnd() - 1, length: 0 },
74-
newText: `this.${memberName} = undefined;${context.newLineCharacter}`
73+
newText: `this.${tokenName} = undefined;${context.newLineCharacter}`
7574
}]
7675
}]
7776
}];
@@ -80,7 +79,6 @@ namespace ts.codefix {
8079

8180
function getActionsForAddMissingMemberInTypeScriptFile(): CodeAction[] | undefined {
8281
const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile);
83-
const tokenName = token.getText(sourceFile);
8482
let actions: CodeAction[];
8583

8684
if (token.parent.parent.kind === SyntaxKind.CallExpression) {
@@ -107,15 +105,15 @@ namespace ts.codefix {
107105
const property = createProperty(
108106
/*decorators*/undefined,
109107
/*modifiers*/ isStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined,
110-
token.getText(sourceFile),
108+
tokenName,
111109
/*questionToken*/ undefined,
112110
typeNode,
113111
/*initializer*/ undefined);
114112
const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
115113
propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter });
116114

117115
(actions || (actions = [])).push({
118-
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]),
116+
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [tokenName]),
119117
changes: propertyChangeTracker.getChanges()
120118
});
121119

@@ -139,7 +137,7 @@ namespace ts.codefix {
139137
indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter });
140138

141139
actions.push({
142-
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]),
140+
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [tokenName]),
143141
changes: indexSignatureChangeTracker.getChanges()
144142
});
145143
}

0 commit comments

Comments
 (0)