Skip to content

Commit d6ac176

Browse files
committed
Respond to code review comments
1 parent 66ac508 commit d6ac176

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

src/services/services.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,17 +2019,15 @@ module ts {
20192019
}
20202020

20212021
/** Returns true if the position is within a comment */
2022-
function isInsideComment(token: Node, position: number): boolean {
2023-
var sourceFile = token.getSourceFile();
2024-
2025-
// The position has to be: 1. in the leading trivia (before tokek.getStart()), and 2. within a comment
2026-
return position <= token.getStart() &&
2022+
function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean {
2023+
// The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment
2024+
return position <= token.getStart(sourceFile) &&
20272025
(isInsideCommentRange(getTrailingCommentRanges(sourceFile.text, token.getFullStart())) ||
20282026
isInsideCommentRange(getLeadingCommentRanges(sourceFile.text, token.getFullStart())));
20292027

20302028
function isInsideCommentRange(comments: CommentRange[]): boolean {
20312029
return forEach(comments, comment => {
2032-
// either we are 1. completely inside the comment, or 2. at the end of
2030+
// either we are 1. completely inside the comment, or 2. at the end of the comment
20332031
if (comment.pos < position && position < comment.end) {
20342032
return true;
20352033
}
@@ -2363,8 +2361,8 @@ module ts {
23632361
var currentToken = getTokenAtPosition(sourceFile, position);
23642362

23652363
// Completion not allowed inside comments, bail out if this is the case
2366-
if (isInsideComment(currentToken, position)) {
2367-
host.log("Returning an empty list because completion was blocked.");
2364+
if (isInsideComment(sourceFile, currentToken, position)) {
2365+
host.log("Returning an empty list because completion was inside a comment.");
23682366
return undefined;
23692367
}
23702368

@@ -2380,7 +2378,7 @@ module ts {
23802378

23812379
// Check if this is a valid completion location
23822380
if (previousToken && isCompletionListBlocker(previousToken)) {
2383-
host.log("Returning an empty list because completion was blocked.");
2381+
host.log("Returning an empty list because completion was requested in an invalid position.");
23842382
return undefined;
23852383
}
23862384

@@ -5157,7 +5155,7 @@ module ts {
51575155
// OK, we have found a match in the file. This is only an acceptable match if
51585156
// it is contained within a comment.
51595157
var token = getTokenAtPosition(sourceFile, matchPosition);
5160-
if (!isInsideComment(token, matchPosition)) {
5158+
if (!isInsideComment(sourceFile, token, matchPosition)) {
51615159
continue;
51625160
}
51635161

0 commit comments

Comments
 (0)