(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken)
| 133304 | return !!((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.kind === 305 /* SyntaxKind.SourceFile */; })); |
| 133305 | } |
| 133306 | function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) { |
| 133307 | var typeChecker = program.getTypeChecker(); |
| 133308 | var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions); |
| 133309 | var start = ts.timestamp(); |
| 133310 | var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853 |
| 133311 | // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.) |
| 133312 | log("getCompletionData: Get current token: " + (ts.timestamp() - start)); |
| 133313 | start = ts.timestamp(); |
| 133314 | var insideComment = ts.isInComment(sourceFile, position, currentToken); |
| 133315 | log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); |
| 133316 | var insideJsDocTagTypeExpression = false; |
| 133317 | var isInSnippetScope = false; |
| 133318 | if (insideComment) { |
| 133319 | if (ts.hasDocComment(sourceFile, position)) { |
| 133320 | if (sourceFile.text.charCodeAt(position - 1) === 64 /* CharacterCodes.at */) { |
| 133321 | // The current position is next to the '@' sign, when no tag name being provided yet. |
| 133322 | // Provide a full list of tag names |
| 133323 | return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; |
| 133324 | } |
| 133325 | else { |
| 133326 | // When completion is requested without "@", we will have check to make sure that |
| 133327 | // there are no comments prefix the request position. We will only allow "*" and space. |
| 133328 | // e.g |
| 133329 | // /** |c| /* |
| 133330 | // |
| 133331 | // /** |
| 133332 | // |c| |
| 133333 | // */ |
| 133334 | // |
| 133335 | // /** |
| 133336 | // * |c| |
| 133337 | // */ |
| 133338 | // |
| 133339 | // /** |
| 133340 | // * |c| |
| 133341 | // */ |
| 133342 | var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); |
| 133343 | if (!/[^\*|\s(/)]/.test(sourceFile.text.substring(lineStart, position))) { |
| 133344 | return { kind: 2 /* CompletionDataKind.JsDocTag */ }; |
| 133345 | } |
| 133346 | } |
| 133347 | } |
| 133348 | // Completion should work inside certain JsDoc tags. For example: |
| 133349 | // /** @type {number | string} */ |
| 133350 | // Completion should work in the brackets |
| 133351 | var tag = getJsDocTagAtPosition(currentToken, position); |
| 133352 | if (tag) { |
| 133353 | if (tag.tagName.pos <= position && position <= tag.tagName.end) { |
| 133354 | return { kind: 1 /* CompletionDataKind.JsDocTagName */ }; |
| 133355 | } |
| 133356 | var typeExpression = tryGetTypeExpressionFromTag(tag); |
| 133357 | if (typeExpression) { |
| 133358 | currentToken = ts.getTokenAtPosition(sourceFile, position); |
| 133359 | if (!currentToken || |
| 133360 | (!ts.isDeclarationName(currentToken) && |
| 133361 | (currentToken.parent.kind !== 347 /* SyntaxKind.JSDocPropertyTag */ || |
| 133362 | currentToken.parent.name !== currentToken))) { |
| 133363 | // Use as type location if inside tag's type expression |
no test coverage detected
searching dependent graphs…