Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codefix for implementing interfaces #11547

Merged
merged 101 commits into from
Dec 30, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
1438f9a
Codefixes for implement interface and change extends to implements.
Oct 11, 2016
7a5cb5f
Merge branch 'pvb/codeaction/api' into interfaceFixes
Oct 12, 2016
bf3e487
Merge branch 'master' into interfaceFixes
Oct 13, 2016
6b4f6b5
Remove Type Assignability QuickFix
aozgaa Oct 25, 2016
151f940
Refactor classDeclarations
aozgaa Oct 25, 2016
d1cea73
Refactor Loop
aozgaa Oct 25, 2016
c2feab6
Rename Tests
aozgaa Oct 25, 2016
f74872d
temp
aozgaa Oct 26, 2016
2abf906
Merge branch 'master' into interfaceFixes
aozgaa Oct 26, 2016
132b746
Covnert to Doc Comment
aozgaa Oct 26, 2016
ecc029f
more temp
aozgaa Oct 26, 2016
a66b0ae
Split CodeFixes in Separate Files
aozgaa Oct 26, 2016
5d9a4e3
Move codeFixProvider.ts
aozgaa Oct 27, 2016
3ac9ffa
Nerf Extends to implements For Now
aozgaa Oct 27, 2016
d24236b
Simplify getCodeFixChanges
aozgaa Oct 27, 2016
7758e6d
Rename Most Tests
aozgaa Oct 28, 2016
7272833
Rename and Add a Test
aozgaa Oct 28, 2016
834245c
Add Failing Tests
aozgaa Oct 28, 2016
c89b97b
Add removeAbstractModifier Fix
aozgaa Oct 29, 2016
16dc834
extends->implements w/ implements keyword present
aozgaa Oct 29, 2016
cbaea99
Cleanup Extends -> Interface Change
aozgaa Oct 31, 2016
bc21346
Refactor fourslash testing for codeFixes
aozgaa Nov 1, 2016
99ae5d9
Remove unused tests
aozgaa Nov 1, 2016
aa6ecd4
Fix linting errors
aozgaa Nov 1, 2016
3240000
Merge branch 'master' into interfaceFixes
aozgaa Nov 1, 2016
0380f3f
Recognize modifiers
aozgaa Nov 2, 2016
1b60a97
Remove unused
aozgaa Nov 2, 2016
e5279fd
Rename and simplify fourslash interface
aozgaa Nov 2, 2016
04968ab
fix references to codefixes?
aozgaa Nov 2, 2016
d02eb6c
fix jakefile1
aozgaa Nov 2, 2016
3b0b696
broken
aozgaa Nov 3, 2016
36c5bef
Add tests and simplify existing ones
aozgaa Nov 4, 2016
1b8486d
Still re-writing missing member grabber
aozgaa Nov 4, 2016
b7b30aa
Add straggling Test
aozgaa Nov 4, 2016
71d1744
Test Fixes
aozgaa Nov 8, 2016
8c35185
Expose More TypeChecker
aozgaa Nov 8, 2016
bc1bb0e
Make test failure more readable
aozgaa Nov 8, 2016
0ce53f0
rename tests
aozgaa Nov 8, 2016
b26ba83
Expose signatureToString, addSupressAnyReturn Flag
aozgaa Nov 8, 2016
11cea6a
Use TypeChecker to Get Types, Print
aozgaa Nov 8, 2016
7141a2a
Better error message in fourslash
aozgaa Nov 8, 2016
55bf3e3
Use new engine for interface fixes
aozgaa Nov 8, 2016
4441380
tests: edit expected type params
aozgaa Nov 8, 2016
1ec234a
Edit error handling tests
aozgaa Nov 8, 2016
6bd35fb
Fix Type Param method Tests
aozgaa Nov 8, 2016
4973852
fix linter errors
aozgaa Nov 8, 2016
1d6ef6a
cleanup
aozgaa Nov 9, 2016
d842a6f
Merge branch 'master' into interfaceFixes
aozgaa Nov 9, 2016
b1e97b3
Get one fix per interface
aozgaa Nov 10, 2016
c650c33
Update tests
aozgaa Nov 10, 2016
0591e1b
Simplify Testing
aozgaa Nov 10, 2016
263734f
Add a test
aozgaa Nov 14, 2016
4b202ab
Initialize result to empy array
aozgaa Nov 14, 2016
357ed7e
Remove Inner Loop
aozgaa Nov 14, 2016
f6fc320
Get Ancestor instead of manual walk
aozgaa Nov 14, 2016
efd16c7
Spell out names fully
aozgaa Nov 14, 2016
bba96da
remove multiple implements TODO
aozgaa Nov 14, 2016
cfe50d1
Fix extends -> implements for decorators/modifiers
aozgaa Nov 14, 2016
ad3035d
remove generated file from PR
aozgaa Nov 14, 2016
d8b359f
Fix typo and capitalization
aozgaa Nov 14, 2016
6400d53
Fix handling of default class
aozgaa Nov 14, 2016
c010a0e
Use getTypeOfSymbolAtLocation
aozgaa Nov 15, 2016
395d736
Remove getSymbolOfNode from TypeChecker interface
aozgaa Nov 15, 2016
d7d4bf6
Handle class expressions
aozgaa Nov 15, 2016
a94d955
Aggregate changes before building result
aozgaa Nov 15, 2016
43afb80
remove fix
aozgaa Nov 15, 2016
6ed8d18
unexpose resolveStructuredTypeMembers
aozgaa Nov 15, 2016
389959a
Merge branch 'master' into interfaceFixes
aozgaa Nov 15, 2016
69118cd
Merge branch 'master' into interfaceFixes
Nov 17, 2016
4af0e2a
Merge branch 'master' into interfaceFixes
Nov 28, 2016
680af0f
use getStart()
Nov 28, 2016
16b146f
Use array instead of map
Nov 28, 2016
f37640a
Add args to diagnostic message
Nov 28, 2016
5d6a714
move helpers under codefix dir
Nov 28, 2016
bf48564
FIx typo in method stub.
Nov 29, 2016
ba80ce6
stubbing extra completions
Nov 29, 2016
8134d64
Merge branch 'master' into interfaceFixes
Dec 5, 2016
0c1772b
Merge branch 'interfaceFixes' of https://github.com/Microsoft/TypeScr…
Dec 5, 2016
f0c7713
implement getters/setters as property
Dec 5, 2016
c511aea
Add Support for multiple signatures
Dec 7, 2016
5cd0ea3
handle well-known computed property/method names
Dec 8, 2016
c22e47d
add test for computed literals
Dec 8, 2016
c1a41b9
Expose indexSignaturePrinting
Dec 8, 2016
2f51b36
add missing index signature support
Dec 9, 2016
97b3d7a
make index signature fix work with generics
Dec 9, 2016
819a654
Add tests and fix rest parameters
Dec 9, 2016
5e48e33
cleanup
Dec 9, 2016
1338b94
Simplify rest parameter handling
Dec 9, 2016
b9ae36c
Simplify index signature generation
Dec 9, 2016
d724517
Merge branch 'master' into interfaceFixes
Dec 9, 2016
469745b
Synthetic signature uses existing parameter names
Dec 12, 2016
1ba6c86
Merge branch 'master' into interfaceFixes
Dec 12, 2016
ad01110
Consolidate Tests
Dec 12, 2016
3cfac08
abstract class expr instantiation and abstract fix works with class expr
Dec 14, 2016
4673812
refactor fix
Dec 14, 2016
4b02099
add tests
Dec 14, 2016
8be8819
simplify and inline methods
Dec 14, 2016
d75d548
implicit any for synthesized signature
Dec 14, 2016
4af3937
Merge branch 'master' into interfaceFixes
Dec 14, 2016
97f18c9
Cleanup
Dec 14, 2016
3fc94bb
Rename Tests
Dec 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Synthetic signature uses existing parameter names
  • Loading branch information
Arthur Ozga committed Dec 12, 2016
commit 469745b1819c32851f61c04bb5032e3e035d1e4d
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace ts.codefix {

const insertion = getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter);

if (insertion) {
if (insertion.length) {
return [{
description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format is a little hard to read

changes: [{
Expand Down
5 changes: 4 additions & 1 deletion src/services/codefixes/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ namespace ts.codefix {
newSignatureDeclaration.name = signatures[0].getDeclaration().name;

let maxNonRestArgs = -1;
let maxArgsIndex = 0;
let minArgumentCount = signatures[0].minArgumentCount;
let hasRestParameter = false;
for (let i = 0; i < signatures.length; i++) {
Expand All @@ -102,8 +103,10 @@ namespace ts.codefix {
const nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0);
if (nonRestLength > maxNonRestArgs) {
maxNonRestArgs = nonRestLength;
maxArgsIndex = i;
}
}
const maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(symbol => symbol.getName());

const anyTypeNode: TypeNode = createNode(SyntaxKind.AnyKeyword) as TypeNode;
const optionalToken = createToken(SyntaxKind.QuestionToken);
Expand All @@ -130,7 +133,7 @@ namespace ts.codefix {

function createParameterDeclaration(index: number, minArgCount: number, typeNode: TypeNode, enclosingSignatureDeclaration: SignatureDeclaration): ParameterDeclaration {
const newParameter = createNode(SyntaxKind.Parameter) as ParameterDeclaration;
newParameter.symbol = checker.createSymbol(SymbolFlags.FunctionScopedVariable, "arg" + index);
newParameter.symbol = checker.createSymbol(SymbolFlags.FunctionScopedVariable, maxArgsParameterSymbolNames[index] || "rest");
newParameter.symbol.valueDeclaration = newParameter;
newParameter.symbol.declarations = [newParameter];
newParameter.type = typeNode;
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/fourslash/codeFixClassExtendsAbstractMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ verify.rangeAfterCodeFix(`
f(a: number, b: string): boolean;
f(a: string, b: number): Function;
f(a: string): Function;
f(arg0: any, arg1?: any) {
f(a: any, b?: any) {
throw new Error('Method not implemented.');
}
`);
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ verify.rangeAfterCodeFix(`
[Symbol.toPrimitive](hint: "number"): number;
[Symbol.toPrimitive](hint: "default"): number;
[Symbol.toPrimitive](hint: "string"): string;
[Symbol.toPrimitive](arg0: any) {
[Symbol.toPrimitive](hint: any) {
throw new Error('Method not implemented.');
}
[Symbol.toStringTag]: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ verify.rangeAfterCodeFix(`
method(a: number, b: string): boolean;
method(a: string, b: number): Function;
method(a: string): Function;
method(arg0: any, arg1?: any) {
method(a: any, b?: any) {
throw new Error('Method not implemented.');
}
`);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ verify.rangeAfterCodeFix(`
method(a: number, ...b: string[]): boolean;
method(a: string, ...b: number[]): Function;
method(a: string): Function;
method(arg0: any, ...arg1?: any[]) {
method(a: any, ...b?: any[]) {
throw new Error('Method not implemented.');
}
`);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ verify.rangeAfterCodeFix(`
method(a: number, ...b: string[]): boolean;
method(a: string, b: number): Function;
method(a: string): Function;
method(arg0: any, arg1?: any, ...arg2?: any[]) {
method(a: any, b?: any, ...rest?: any[]) {
throw new Error('Method not implemented.');
}
`);