Skip to content

Commit

Permalink
fourslash test (Temporary code
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffy-g committed Apr 4, 2020
1 parent dd10253 commit 0bcf716
Show file tree
Hide file tree
Showing 2 changed files with 155 additions and 35 deletions.
1 change: 1 addition & 0 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ namespace ts.Completions {
}
else {
const lineStart = getLineStartPositionForPosition(position, sourceFile);
// or !/[^/\s\*]/.test(sourceFile.text.substring(lineStart, position))
if (!(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/))) {
return { kind: CompletionDataKind.JsDocTag };
}
Expand Down
189 changes: 154 additions & 35 deletions tests/cases/fourslash/completionsJsdocTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,97 @@
//// * /**/
//// */

// cannot run fourslash test these cases because it doesn't recognize the marker
//** /*invalidMarker1*/*/
//
//** /*invalidMarker2*/*/
//

// jsdoc tags are listed when there is more than one whitespace after "*"
// 1x - jsdoc tags are listed when there is more than one whitespace after "*"
/////**
//// * /*1*/
//// * /*10*/
//// */
////
/////**
//// * link to {/*2*/
//// * /*11*/
//// */
////

// before the fix, jsdoc tag names was listed (but no longer appears
// jsdoc tag names are still listed after the fix.
// however this behavior does not by getCompletionData.insideComment.hasDocComment clause
/////**@/*3*/ */
// 2x - also, if there is more than one whitespace at the beginning of the line.
/////**
//// /*20*/
//// */
////
/////**
//// * @type {@/*4*/
//// /*21*/
//// */
////
/////**
//// *@/*5*/
//// /*22*/
//// */
////

// before the fix, jsdoc tags was listed but no longer appears
// 3x - jsdoc tag names will be listed
/////** @/*30*/ */
////
/////** @/*31*/ */
////
/////**
//// +/*6*/
//// * @/*32*/
//// */
////
/////**
//// */*7*/
//// * @/*33*/
//// */
////
/////**
//// @/*34*/
//// */
////
/////**
//// @/*35*/
//// */
////
/////**
//// * @pa/*36*/
//// */
////

// jsdoc tag names will be listed
// 4x - jsdoc tag name completions should not occur
/////**@/*40*/ */
////
/////**
//// *@/*41*/
//// */
////
/////**
//// * @/*8*/
//// * @type {@/*42*/
//// */
////
/////**
//// +@/*43*/
//// */
////
/////** some description @/*44*/ */
////
/////**
//// * ### jsdoc @/*45*/
//// */
////

// 5x - jsdoc tag completions should not occur
/////**
//// */*50*/
//// */
////

// before the fix, jsdoc tag names was listed but no longer appears
// also, can support the inline jsdoc tags
/////**
//// +@/*9*/
//// * link to {/*70*/
//// */
////
/////**
//// * ### jsdoc @/*10*/
//// * link to {@/*71*/
//// */
////

Expand All @@ -64,39 +107,115 @@ verify.completions({ marker: "", includes: { name: "@property", text: "@property
//
test.markerNames().forEach(marker => {
if (marker) {
let completionOpt: FourSlashInterface.CompletionsOptions;
const n = +marker;
switch (n) {
case 1:
// case 2:
verify.completions({ marker, includes: ["@abstract", "@access"] });
/* https://coderwall.com/p/zbc2zw/the-comment-toggle-trick
// - - - - - -
// before fix
// - - - - - -
// jsdoc tags will be listed when there is more than one whitespace after "*"
case 10: case 11:
// also, if there is more than one whitespace at the beginning of the line.
case 20: case 21: case 22:
// 5x - jsdoc tag completions should not occur
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// jsdoc tags will be listed but this does not the expected behavior
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case 50:
completionOpt = { marker, includes: ["@abstract", "@access"] };
break;
case 3:
// case 4:
case 5:
verify.completions({
// 3x - jsdoc tag names will be listed
case 30: case 31: case 32: case 33: case 34: case 35: case 36:
// 4x - jsdoc tag name completions should not occur
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// jsdoc tag names will be listed but this does not the expected behavior
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case 40: case 41: case 42: case 43: case 44: case 45:
// does not the expected behavior... because ts.JsDoc@jsDocTagNames is missing inline jsdoc tag name
// In other words, inline jsdoc tag is interpreted as not intending to support
case 71:
completionOpt = {
marker,
triggerCharacter: "@",
includes: ["abstract", "access"]
});
includes: ["package", "param"]
};
break;
case 6: case 7:
verify.completions({ marker, exact: [] });
/*/

// - - - - - -
// after fix
// - - - - - -

// jsdoc tags will be listed when there is more than one whitespace after "*"
case 10: case 11:
// also, if there is more than one whitespace at the beginning of the line.
case 20: case 21: case 22:

// // also, can support the inline jsdoc tags
// case 70:
completionOpt = { marker, includes: [
"@abstract", "@access",
// "@link"
]};
break;
case 8:
verify.completions({

// 3x - jsdoc tag names will be listed
case 30: case 31: case 32: case 33: case 34: case 35:

// 4x - jsdoc tag name completions should not occur
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// this behavior does not by getCompletionData.insideComment.hasDocComment clause
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case 40: case 41: case 42:

// // also, can support the inline jsdoc tags
// case 71:
completionOpt = {
marker,
triggerCharacter: "@",
includes: ["abstract", "access"]
});
};
break;
case 9: case 10:
verify.completions({

// 4x - jsdoc tag name completions should not occur
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// before the fix, jsdoc tag names was listed but no longer appears
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case 43: case 44: case 45:
completionOpt = {
marker,
triggerCharacter: "@",
exact: []
});
};
break;

// 5x - jsdoc tag completions should not occur
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// before the fix, jsdoc tags was listed but no longer appears
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case 50:
completionOpt = { marker, exact: [] };
break;
default: break;
//*/

default:
break;
}
if (completionOpt) {
// verify.completions(completionOpt);
try {
verify.completions(completionOpt);
} catch (e) {
console.log(e.message);
console.log("please switch the code of src/services/completions.ts#getCompletionData");
}
}
}
});

0 comments on commit 0bcf716

Please sign in to comment.