From 03ea38f31fe49e31218ef17d77173b492ddf4d79 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 11 Aug 2015 23:20:03 -0700 Subject: [PATCH] Fix bugs and add support for @param expressions --- src/services/services.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index d541cf1e4b5..4b618e71c4e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2937,7 +2937,16 @@ namespace ts { switch (tag.kind) { case SyntaxKind.JSDocTypeTag: let typeTag = tag; - insideJsDocTagExpression = position > typeTag.typeExpression.pos && position < typeTag.typeExpression.end; + if (typeTag.typeExpression) { + insideJsDocTagExpression = position > typeTag.typeExpression.pos && position < typeTag.typeExpression.end; + }; + break; + case SyntaxKind.JSDocParameterTag: + let paramTag = tag; + if (paramTag.typeExpression) { + insideJsDocTagExpression = position > paramTag.typeExpression.pos && position < paramTag.typeExpression.end; + }; + break; } } if (!insideJsDocTagExpression) { @@ -3731,11 +3740,17 @@ namespace ts { } // The current position is right after an At sign - // Or if the current position is in a tag name - if (sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at || - getJsDocTagAtPosition(sourceFile, position)) { + if (sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) { return getAllJsDocCompletionEntries(); - } + } + + // Or if the current position is in a tag name + let tag = getJsDocTagAtPosition(sourceFile, position); + if (tag) { + if (position >= tag.atToken.end && position <= tag.tagName.end) { + return getAllJsDocCompletionEntries(); + } + } } function getAllJsDocCompletionEntries(): CompletionEntry[] {