Skip to content

Commit fad05f8

Browse files
committed
cleanup
1 parent 309b6a7 commit fad05f8

File tree

2 files changed

+6
-95
lines changed

2 files changed

+6
-95
lines changed

src/services/completions.ts

+5-22
Original file line numberDiff line numberDiff line change
@@ -868,43 +868,26 @@ namespace ts.Completions {
868868
// /**
869869
// * |c|
870870
// */
871-
/* https://coderwall.com/p/zbc2zw/the-comment-toggle-trick
872-
if (sourceFile.text.charCodeAt(position - 1) === CharacterCodes.at) {
873-
// The current position is next to the '@' sign, when no tag name being provided yet.
874-
// Provide a full list of tag names
875-
return { kind: CompletionDataKind.JsDocTagName };
876-
}
877-
else {
878-
const lineStart = getLineStartPositionForPosition(position, sourceFile);
879-
// or !/[^/\s\*]/.test(sourceFile.text.substring(lineStart, position))
880-
if (!(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/))) {
881-
return { kind: CompletionDataKind.JsDocTag };
882-
}
883-
}
884-
/*/
885871
const lineStart = getLineStartPositionForPosition(position, sourceFile);
886872
const jsdocFragment = sourceFile.text.substring(lineStart, position);
887873
const reJSDocFragment = /^(?:\s*\/\*\*\s+|\s+\*?\s+)(@(?:\w+)?)?/g;
888874
const match = reJSDocFragment.exec(jsdocFragment);
889875
if (match && reJSDocFragment.lastIndex === jsdocFragment.length) {
890876
return {
891-
kind: match[1] ? CompletionDataKind.JsDocTagName: CompletionDataKind.JsDocTag
877+
kind: match[1]
878+
// The current position is next to the '@' sign, when no tag name being provided yet.
879+
// Provide a full list of tag names
880+
? CompletionDataKind.JsDocTagName:
881+
CompletionDataKind.JsDocTag
892882
};
893883
}
894-
//*/
895884
}
896885

897886
// Completion should work inside certain JsDoc tags. For example:
898887
// /** @type {number | string} */
899888
// Completion should work in the brackets
900889
const tag = getJsDocTagAtPosition(currentToken, position);
901890
if (tag) {
902-
/* https://coderwall.com/p/zbc2zw/the-comment-toggle-trick
903-
if (tag.tagName.pos <= position && position <= tag.tagName.end) {
904-
return { kind: CompletionDataKind.JsDocTagName };
905-
}
906-
/*/
907-
//*/
908891
if (isTagWithTypeExpression(tag) && tag.typeExpression && tag.typeExpression.kind === SyntaxKind.JSDocTypeExpression) {
909892
currentToken = getTokenAtPosition(sourceFile, position);
910893
if (!currentToken ||

tests/cases/fourslash/completionsJsdocTag.ts

+1-73
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@
9292
//// */
9393
////
9494

95-
// also, can support the inline jsdoc tags
96-
/////**
97-
//// * link to {/*70*/
98-
//// */
99-
////
100-
/////**
101-
//// * link to {@/*71*/
102-
//// */
103-
////
104-
10595
verify.completions({ marker: "", includes: { name: "@property", text: "@property", kind: "keyword" } });
10696

10797

@@ -113,72 +103,17 @@ test.markerNames().forEach(marker => {
113103
let completionOpt: FourSlashInterface.CompletionsOptions;
114104
const n = +marker;
115105
switch (n) {
116-
/* https://coderwall.com/p/zbc2zw/the-comment-toggle-trick
117-
118-
// - - - - - -
119-
// before fix
120-
// - - - - - -
121-
122106
// jsdoc tags will be listed when there is more than one whitespace after "*"
123107
case 10: case 11:
124108
// Also, if there are two or more blanks at the beginning of the line
125109
case 20: case 21:
126-
127-
// 5x - jsdoc tag completions should not occur
128-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
129-
// jsdoc tags will be listed but this does not the expected behavior
130-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
131-
case 50: case 51: case 52:
132-
completionOpt = { marker, includes: ["@abstract", "@access"] };
133-
break;
134-
135-
// 3x - jsdoc tag names will be listed
136-
case 30: case 31: case 32: case 33: case 34: case 35: case 36:
137-
138-
// 4x - jsdoc tag name completions should not occur
139-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
140-
// jsdoc tag names will be listed but this does not the expected behavior
141-
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142-
case 40: case 41: case 42: case 43: case 44: case 45: case 46:
143-
144-
// does not the expected behavior... because ts.JsDoc@jsDocTagNames is missing inline jsdoc tag name
145-
// In other words, inline jsdoc tag is interpreted as not intending to support
146-
case 71:
147-
completionOpt = {
148-
marker,
149-
triggerCharacter: "@",
150-
includes: ["package", "param"]
151-
};
152-
break;
153-
/*/
154-
155-
// - - - - - -
156-
// after fix
157-
// - - - - - -
158-
159-
// jsdoc tags will be listed when there is more than one whitespace after "*"
160-
case 10: case 11:
161-
// Also, if there are two or more blanks at the beginning of the line
162-
case 20: case 21:
163-
164-
// // also, can support the inline jsdoc tags
165-
// case 70:
166110
completionOpt = { marker, includes: [
167111
"@abstract", "@access",
168112
]};
169113
break;
170114

171115
// 3x - jsdoc tag names will be listed
172116
case 30: case 31: case 32: case 33: case 34: case 35: case 36:
173-
174-
// // 4x - jsdoc tag name completions should not occur
175-
// // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
176-
// // this behavior does not by getCompletionData.insideComment.hasDocComment clause
177-
// // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
178-
// case 40: case 41: case 42:
179-
180-
// // also, can support the inline jsdoc tags
181-
// case 71:
182117
completionOpt = {
183118
marker,
184119
triggerCharacter: "@",
@@ -205,19 +140,12 @@ test.markerNames().forEach(marker => {
205140
case 50: case 51: case 52:
206141
completionOpt = { marker, exact: [] };
207142
break;
208-
//*/
209143

210144
default:
211145
break;
212146
}
213147
if (completionOpt) {
214-
// verify.completions(completionOpt);
215-
try {
216-
verify.completions(completionOpt);
217-
} catch (e) {
218-
console.log(e.message);
219-
console.log("please switch the code of src/services/completions.ts#getCompletionData");
220-
}
148+
verify.completions(completionOpt);
221149
}
222150
}
223151
});

0 commit comments

Comments
 (0)