Skip to content

Commit

Permalink
Reorder tsconfig and move one more function
Browse files Browse the repository at this point in the history
  • Loading branch information
sandersn committed Apr 10, 2020
1 parent 6eacc9c commit 3428e27
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 39 deletions.
13 changes: 0 additions & 13 deletions src/services/codefixes/fixAddMissingMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,6 @@ namespace ts.codefix {
},
});

function getAllSupers(decl: ClassOrInterface | undefined, checker: TypeChecker): readonly ClassOrInterface[] {
const res: ClassLikeDeclaration[] = [];
while (decl) {
const superElement = getClassExtendsHeritageElement(decl);
const superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression);
const superDecl = superSymbol && find(superSymbol.declarations, isClassLike);
if (superDecl) { res.push(superDecl); }
decl = superDecl;
}
return res;
}

type ClassOrInterface = ClassLikeDeclaration | InterfaceDeclaration;
const enum InfoKind { Enum, ClassOrInterface }
interface EnumInfo {
readonly kind: InfoKind.Enum;
Expand Down
16 changes: 1 addition & 15 deletions src/services/codefixes/fixPropertyOverrideAccessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace ts.codefix {
endPosition = context.span.start + context.span.length
}
else if (context.errorCode === Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code) {
// TODO: A lot of these should be bails instead of asserts
const checker = context.program.getTypeChecker()
const node = getTokenAtPosition(context.sourceFile, context.span.start).parent;
Debug.assert(isAccessor(node), "it wasn't an accessor");
Expand All @@ -55,19 +56,4 @@ namespace ts.codefix {
const refactorContext = { ...context, file: context.sourceFile, startPosition, endPosition }
return getEditsForAction(refactorContext, Diagnostics.Generate_get_and_set_accessors.message);
}

// TODO: Stolen from a different codefix, should dedupe it somewhere.
function getAllSupers(decl: ClassOrInterface | undefined, checker: TypeChecker): readonly ClassOrInterface[] {
const res: ClassLikeDeclaration[] = [];
while (decl) {
const superElement = getClassExtendsHeritageElement(decl);
const superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression);
const superDecl = superSymbol && find(superSymbol.declarations, isClassLike);
if (superDecl) { res.push(superDecl); }
decl = superDecl;
}
return res;
}

type ClassOrInterface = ClassLikeDeclaration | InterfaceDeclaration;
}
16 changes: 15 additions & 1 deletion src/services/codefixes/generateAccessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace ts.codefix {
}

// TODO: Use a general type instead of Refactor* types
// TODO: Rename this to show that it generates accessor
// TODO: Rename this to show that it generates accessors
export function getEditsForAction(context: RefactorContext, _actionName: string): RefactorEditInfo | undefined {
const { file } = context;

Expand Down Expand Up @@ -217,4 +217,18 @@ namespace ts.codefix {
}
});
}

export function getAllSupers(decl: ClassOrInterface | undefined, checker: TypeChecker): readonly ClassOrInterface[] {
const res: ClassLikeDeclaration[] = [];
while (decl) {
const superElement = getClassExtendsHeritageElement(decl);
const superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression);
const superDecl = superSymbol && find(superSymbol.declarations, isClassLike);
if (superDecl) { res.push(superDecl); }
decl = superDecl;
}
return res;
}

export type ClassOrInterface = ClassLikeDeclaration | InterfaceDeclaration;
}
20 changes: 10 additions & 10 deletions src/services/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,30 @@
"codefixes/correctQualifiedNameToIndexedAccessType.ts",
"codefixes/convertToTypeOnlyExport.ts",
"codefixes/convertToTypeOnlyImport.ts",
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
"codefixes/importFixes.ts",
"codefixes/fixImplicitThis.ts",
"codefixes/fixSpelling.ts",
"codefixes/returnValueCorrect.ts",
"codefixes/fixAddMissingMember.ts",
"codefixes/fixAddMissingNewOperator.ts",
"codefixes/fixAwaitInSyncFunction.ts",
"codefixes/fixCannotFindModule.ts",
"codefixes/fixClassDoesntImplementInheritedAbstractMember.ts",
"codefixes/fixClassIncorrectlyImplementsInterface.ts",
"codefixes/fixClassSuperMustPrecedeThisAccess.ts",
"codefixes/fixConstructorForDerivedNeedSuperCall.ts",
"codefixes/fixEnableExperimentalDecorators.ts",
"codefixes/fixEnableJsxFlag.ts",
"codefixes/fixModuleAndTargetOptions.ts",
"codefixes/fixExtendsInterfaceBecomesImplements.ts",
"codefixes/fixForgottenThisPropertyAccess.ts",
"codefixes/fixImplicitThis.ts",
"codefixes/fixInvalidJsxCharacters.ts",
"codefixes/fixUnusedIdentifier.ts",
"codefixes/fixUnreachableCode.ts",
"codefixes/fixUnusedLabel.ts",
"codefixes/fixJSDocTypes.ts",
"codefixes/fixMissingCallParentheses.ts",
"codefixes/fixModuleAndTargetOptions.ts",
"codefixes/fixAwaitInSyncFunction.ts",
"codefixes/fixPropertyOverrideAccessor.ts",
"codefixes/fixSpelling.ts",
"codefixes/fixUnreachableCode.ts",
"codefixes/fixUnusedIdentifier.ts",
"codefixes/fixUnusedLabel.ts",
"codefixes/importFixes.ts",
"codefixes/returnValueCorrect.ts",
"codefixes/inferFromUsage.ts",
"codefixes/disableJsDiagnostics.ts",
"codefixes/helpers.ts",
Expand Down

0 comments on commit 3428e27

Please sign in to comment.