Skip to content

Fix occurrences for classexpressions #4531

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5885,6 +5885,7 @@ namespace ts {
result.push(getReferenceEntryFromNode(node));
}
break;
case SyntaxKind.ClassExpression:
case SyntaxKind.ClassDeclaration:
// Make sure the container belongs to the same class
// and has the appropriate static modifier from the original container.
Expand Down
56 changes: 56 additions & 0 deletions tests/cases/fourslash/getOccurrencesClassExpressionStaticThis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/// <reference path='fourslash.ts' />

////var x = class C {
//// public x;
//// public y;
//// public z;
//// public staticX;
//// constructor() {
//// this;
//// this.x;
//// this.y;
//// this.z;
//// }
//// foo() {
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// return this.x;
//// }
////
//// static bar() {
//// [|this|];
//// [|this|].staticX;
//// () => [|this|];
//// () => {
//// if ([|this|]) {
//// [|this|];
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////}

const ranges = test.ranges();
for (let r of ranges) {
goTo.position(r.start);

for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}
54 changes: 54 additions & 0 deletions tests/cases/fourslash/getOccurrencesClassExpressionThis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/// <reference path='fourslash.ts' />

////var x = class C {
//// public x;
//// public y;
//// public z;
//// constructor() {
//// [|this|];
//// [|this|].x;
//// [|this|].y;
//// [|this|].z;
//// }
//// foo() {
//// [|this|];
//// () => [|this|];
//// () => {
//// if ([|this|]) {
//// [|this|];
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// return [|this|].x;
//// }
////
//// static bar() {
//// this;
//// () => this;
//// () => {
//// if (this) {
//// this;
//// }
//// }
//// function inside() {
//// this;
//// (function (_) {
//// this;
//// })(this);
//// }
//// }
////}

const ranges = test.ranges();
for (let r of ranges) {
goTo.position(r.start);

for (let range of ranges) {
verify.occurrencesAtPositionContains(range, false);
}
}