Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
8151f5e
extract helpers
mhegazy Aug 9, 2014
5e9b2b5
enbale getReferencesAtPosition
mhegazy Aug 12, 2014
32a5984
expose utility functions
mhegazy Aug 12, 2014
6a92b21
enable reference tests
mhegazy Aug 13, 2014
f45ab42
Enable some more tests
mhegazy Aug 13, 2014
f84d2af
disable resolution for now
mhegazy Aug 13, 2014
901e8a8
Add basic getReferences implementation
mhegazy Aug 13, 2014
69c653d
add some debug methods
mhegazy Aug 13, 2014
bfd1334
Handel getRefrences for labels
mhegazy Aug 13, 2014
fa1033a
add support for getReferences on property string index access
mhegazy Aug 13, 2014
55d0021
support getReferences on object literals
mhegazy Aug 13, 2014
d419982
Support getReferences on contextually typed object literal properties
mhegazy Aug 14, 2014
922d6d6
support getReferences on properties and index access wiht numeric and…
mhegazy Aug 14, 2014
7f53783
add new test for getReferences on enums
mhegazy Aug 14, 2014
f812297
include inherited properties from base classes and interfaces in getR…
mhegazy Aug 14, 2014
3251b7e
Support filtering references based on meaning
mhegazy Aug 18, 2014
2d4cec4
Updates after merge from master
mhegazy Aug 18, 2014
55512fa
Use new tree to get Bloom filters
mhegazy Aug 20, 2014
978c2ef
Fix getReferences for labels
mhegazy Aug 20, 2014
74518a9
respond to code review comments
mhegazy Aug 21, 2014
e0ffc47
Merge branch 'master' into getReferences
mhegazy Aug 21, 2014
bbeeb8d
update getSymbolInfo
mhegazy Aug 21, 2014
6965a06
Support getReferences on rightside of export assignment and import st…
mhegazy Aug 21, 2014
dbf9e47
use isDeclarationOrFunctionExpressionOrCatchVariableName instead of i…
mhegazy Aug 21, 2014
fefe2fb
Implement getScope
mhegazy Aug 22, 2014
c741e26
Support external module names correctelly
mhegazy Aug 23, 2014
8fcc8b2
Ensure range for string literal references are within the quotes to e…
mhegazy Aug 23, 2014
6953794
remove bloom filters
mhegazy Aug 23, 2014
892baf0
use Identifiers list from the parser to filter getReferences instead …
mhegazy Aug 23, 2014
5c1b245
Initial work on getOccurrencesAtPosition.
DanielRosenwasser Aug 25, 2014
aef859f
Merge branch 'master' into getReferences
DanielRosenwasser Aug 25, 2014
144eb8d
Added trivial syntax case.
DanielRosenwasser Aug 25, 2014
f948f5d
Re-added fourslash tests, corrected failures.
DanielRosenwasser Aug 26, 2014
e851e4b
Removed unused method.
DanielRosenwasser Aug 26, 2014
3c97210
add new unit test for used and unused imports
mhegazy Aug 26, 2014
5d15cd2
Beginning special casing for getOccurrencesAtPosition.
DanielRosenwasser Aug 26, 2014
558be4e
Implemented getOccsAtPos for try-catch-finally.
DanielRosenwasser Aug 26, 2014
1f77198
Made getOccs more resilient.
DanielRosenwasser Aug 26, 2014
8ab4df0
Added tests.
DanielRosenwasser Aug 26, 2014
88f37e5
Support for switch/case/default/break in getOccs
DanielRosenwasser Aug 27, 2014
3825c9b
Handled function boundaries.
DanielRosenwasser Aug 27, 2014
232e513
Moved null-guards to appropriate places, added helpers.
DanielRosenwasser Aug 27, 2014
0f9c1ad
Merge branch 'master' into getReferences
mhegazy Aug 27, 2014
50d0cdc
Better coverage against function boundaries.
DanielRosenwasser Aug 27, 2014
ea613fd
Replaced ES5 functions with analogous core.ts ones.
DanielRosenwasser Aug 27, 2014
04456a2
Made 'isAnyFunction' more exhaustive as it should be.
DanielRosenwasser Aug 27, 2014
0ce39a3
Addressed CR feedback.
DanielRosenwasser Aug 28, 2014
5b7da99
Update type baselines
mhegazy Aug 28, 2014
fd93a3b
What's in a name anyhow?
DanielRosenwasser Aug 28, 2014
813f28d
Removed assertion.
DanielRosenwasser Aug 28, 2014
41d8d6c
Merge pull request #549 from Microsoft/getOccurrences_switchCaseDefault
DanielRosenwasser Aug 28, 2014
dc0560a
Merge branch 'master' into getReferences
mhegazy Aug 29, 2014
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
Implemented getOccsAtPos for try-catch-finally.
  • Loading branch information
DanielRosenwasser committed Aug 26, 2014
commit 558be4ea22be84cdbed99e563b84359e0c49c718
20 changes: 20 additions & 0 deletions src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2169,10 +2169,30 @@ module ts {
}

switch (node.kind) {
case SyntaxKind.TryKeyword:
case SyntaxKind.CatchKeyword:
case SyntaxKind.FinallyKeyword:
return getTryCatchFinallyOccurrences(<TryStatement>node.parent.parent);
}

return undefined;

function getTryCatchFinallyOccurrences(tryStatement: TryStatement): ReferenceEntry[] {
var keywords: Node[] = [];

keywords.push(tryStatement.getFirstToken())

if (tryStatement.catchBlock) {
keywords.push(tryStatement.catchBlock.getFirstToken());
}

if (tryStatement.finallyBlock) {
keywords.push(tryStatement.finallyBlock.getFirstToken());
}

return keywordsToReferenceEntries(keywords);
}

function keywordsToReferenceEntries(keywords: Node[]): ReferenceEntry[]{
return keywords.map(keyword =>
new ReferenceEntry(filename, TypeScript.TextSpan.fromBounds(keyword.getStart(), keyword.end), /* isWriteAccess */ false)
Expand Down
27 changes: 27 additions & 0 deletions tests/cases/fourslash/getOccurrencesTryCatchFinally.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/// <reference path='fourslash.ts' />

/////*1*/[|try|] {
//// try {
//// }
//// catch (x) {
//// }
////
//// try {
//// }
//// finally {
//// }
////}
////[|cat/*2*/ch|] (e) {
////}
////[|fina/*3*/lly|] {
////}


for (var i = 1; i <= test.markers().length; i++) {
goTo.marker("" + i);
verify.occurrencesAtPositionCount(3);

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

////try {
//// [|t/*1*/r/*2*/y|] {
//// }
//// [|c/*3*/atch|] (x) {
//// }
////
//// try {
//// }
//// finally {
//// }
////}
////catch (e) {
////}
////finally {
////}


for (var i = 1; i <= test.markers().length; i++) {
goTo.marker("" + i);
verify.occurrencesAtPositionCount(2);

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

////try {
//// try {
//// }
//// catch (x) {
//// }
////
//// [|t/*1*/r/*2*/y|] {
//// }
//// [|finall/*3*/y|] {
//// }
////}
////catch (e) {
////}
////finally {
////}


for (var i = 1; i <= test.markers().length; i++) {
goTo.marker("" + i);
verify.occurrencesAtPositionCount(2);

test.ranges().forEach(range => {
verify.occurrencesAtPositionContains(range, false);
});
}