Skip to content

Commit 55bf3e3

Browse files
committed
Use new engine for interface fixes
1 parent 7141a2a commit 55bf3e3

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/services/codefixes/fixClassIncorrectlyImplementsInterface.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,18 @@ namespace ts.codefix {
1111
if (token.kind === SyntaxKind.Identifier && isClassLike(token.parent)) {
1212
const classDeclaration = <ClassDeclaration>token.parent;
1313
const startPos: number = classDeclaration.members.pos;
14-
const classMembers = ts.map(getNamedClassMembers(classDeclaration), member => member.name.getText());
15-
const trackingAddedMembers: string[] = [];
16-
const interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration);
1714

18-
let textChanges: TextChange[] = undefined;
15+
const insertion = getMissingInterfaceMembersInsertion(classDeclaration, checker, context.newLineCharacter);
1916

20-
for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) {
21-
const newChanges = getCodeFixChanges(interfaceClauses[i], classMembers, startPos, checker, /*reference*/ false, trackingAddedMembers, context.newLineCharacter);
22-
// getMissingAbstractMemberChanges(classDeclaration, checker, context.newLineCharacter);
23-
textChanges = textChanges ? textChanges.concat(newChanges) : newChanges;
24-
}
25-
26-
if (textChanges && textChanges.length > 0) {
17+
if(insertion && insertion.length) {
2718
return [{
2819
description: getLocaleSpecificMessage(Diagnostics.Implement_interface_on_class),
2920
changes: [{
3021
fileName: sourceFile.fileName,
31-
textChanges: textChanges
22+
textChanges: [{
23+
span: { start: startPos, length: 0 },
24+
newText: insertion
25+
}]
3226
}]
3327
}];
3428
}

0 commit comments

Comments
 (0)