-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Add isDefinition to references #9148
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
Changes from 2 commits
5a7f746
ac9e617
792b23e
7bf40c4
102a890
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1208,7 +1208,7 @@ namespace ts { | |
textSpan: TextSpan; | ||
fileName: string; | ||
isWriteAccess: boolean; | ||
isDefinition?: boolean; | ||
isDefinition: boolean; | ||
} | ||
|
||
export interface DocumentHighlights { | ||
|
@@ -5750,7 +5750,8 @@ namespace ts { | |
result.push({ | ||
fileName: entry.fileName, | ||
textSpan: highlightSpan.textSpan, | ||
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference | ||
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference, | ||
isDefinition: false | ||
}); | ||
} | ||
} | ||
|
@@ -6740,7 +6741,7 @@ namespace ts { | |
fileName: node.getSourceFile().fileName, | ||
textSpan: createTextSpanFromBounds(start, end), | ||
isWriteAccess: isWriteAccess(node), | ||
isDefinition: isDeclarationName(node) | ||
isDefinition: isDeclarationName(node) || node.parent.kind === SyntaxKind.ComputedPropertyName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not push this into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not true all the time -- isDeclarationName additionally checks that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried pushing it further, but computed property's symbols started disappearing from our symbol baselines. I did discover |
||
}; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// <reference path='fourslash.ts' /> | ||
////const { [|{| "isDefinition": true |}x|], y } = { x: 1, y: 2 }; | ||
////const z = [|{| "isDefinition": false |}x|]; | ||
var firstRange = test.ranges()[0]; | ||
goTo.position(firstRange.start, firstRange.fileName); | ||
test.ranges().forEach(range => { | ||
verify.referencesAtPositionContains(range, undefined, range.marker.data.isDefinition); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/// <reference path='fourslash.ts' /> | ||
////let o = { ["[|{| "isDefinition": true |}foo|]"]: 12 }; | ||
////let y = o.[|{| "isDefinition": false |}foo|]; | ||
////let z = o['[|{| "isDefinition": false |}foo|]']; | ||
var firstRange = test.ranges()[0]; | ||
goTo.position(firstRange.start, firstRange.fileName); | ||
test.ranges().forEach(range => { | ||
verify.referencesAtPositionContains(range, undefined, range.marker.data.isDefinition); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/// <reference path='fourslash.ts' /> | ||
// @Filename: m.ts | ||
////export var [|{| "isDefinition": true |}x|] = 12; | ||
// @Filename: main.ts | ||
////import { [|{| "isDefinition": true |}x|] } from "./m"; | ||
////const y = [|{| "isDefinition": false |}x|]; | ||
var firstRange = test.ranges()[0]; | ||
goTo.position(firstRange.start, firstRange.fileName); | ||
test.ranges().forEach(range => { | ||
verify.referencesAtPositionContains(range, undefined, range.marker.data.isDefinition); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// <reference path='fourslash.ts' /> | ||
////let o = { [|{| "isDefinition": true |}1|]: 12 }; | ||
////let y = o[[|{| "isDefinition": false |}1|]]; | ||
var firstRange = test.ranges()[0]; | ||
goTo.position(firstRange.start, firstRange.fileName); | ||
test.ranges().forEach(range => { | ||
verify.referencesAtPositionContains(range, undefined, range.marker.data.isDefinition); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// <reference path='fourslash.ts' /> | ||
////let o = { "[|{| "isDefinition": true |}x|]": 12 }; | ||
////let y = o.[|{| "isDefinition": false |}x|]; | ||
var firstRange = test.ranges()[0]; | ||
goTo.position(firstRange.start, firstRange.fileName); | ||
test.ranges().forEach(range => { | ||
verify.referencesAtPositionContains(range, undefined, range.marker.data.isDefinition); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undefined
otherwise?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry looking at the code below, it is always set, so why make it optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it was necessary for API additions. I'll make it required if that's not the case.