Skip to content

Commit eb01e92

Browse files
committed
respond to code review comments
1 parent eeefae0 commit eb01e92

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/services/services.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,7 @@ module ts {
19591959
}
19601960
}
19611961

1962+
/** Get the token whose text contains the position, or the containing node. */
19621963
function getNodeAtPosition(sourceFile: SourceFile, position: number) {
19631964
var current: Node = sourceFile;
19641965
outer: while (true) {
@@ -1969,14 +1970,14 @@ module ts {
19691970
current = child;
19701971
continue outer;
19711972
}
1972-
if (child.end > position) {
1973-
break;
1974-
}
19751973
}
19761974
return current;
19771975
}
19781976
}
19791977

1978+
/** Get a token that contains the position. This is guaranteed to return a token, the position can be in the
1979+
* leading trivia or within the token text.
1980+
*/
19801981
function getTokenAtPosition(sourceFile: SourceFile, position: number) {
19811982
var current: Node = sourceFile;
19821983
outer: while (true) {
@@ -1986,10 +1987,7 @@ module ts {
19861987
if (child.getFullStart() <= position && position < child.getEnd()) {
19871988
current = child;
19881989
continue outer;
1989-
}
1990-
if (child.end > position) {
1991-
break;
1992-
}
1990+
}
19931991
}
19941992
return current;
19951993
}
@@ -3577,7 +3575,8 @@ module ts {
35773575
var token = getTokenAtPosition(sourceFile, matchPosition);
35783576

35793577
if (token.getStart() <= matchPosition && matchPosition < token.getEnd()) {
3580-
// match was within the token itself. Not in the comment. Keep searching // descriptor.
3578+
// match was within the token itself. Not in the comment. Keep searching
3579+
// descriptor.
35813580
continue;
35823581
}
35833582

0 commit comments

Comments
 (0)