From d52648e2fb683e4f8e2695bb47cff2646af9622b Mon Sep 17 00:00:00 2001 From: phil294 Date: Sat, 21 May 2022 00:38:41 +0200 Subject: [PATCH] Revert "fix positioning of jsdoc comments (and block comments in general) by prepending them with two backticks ``" Revert "add test for jsdoc inside iife" It's not waterproof, see https://github.com/jashkenas/coffeescript/issues/5366#issuecomment-1132090903 This reverts commit 56b7982a4af21e5ffc96a303d42d27c8b5a62cc5. This reverts commit 03acf8f95205cef9cd7a1ada7e9e024d863a236b. --- server/src/services/transpileService.ts | 6 ------ test/lsp/features/completion/basic.test.ts | 4 ++-- test/lsp/features/diagnostics/basic.test.ts | 17 ++--------------- .../destructuring-with-comment-block.coffee | 2 +- .../completion/inline-object-open-brace.coffee | 4 ++-- .../completion/inline-object-param-key.coffee | 8 +++++--- .../lsp/fixture/completion/jsdoc-spacing.coffee | 4 ++-- .../completion/object-before-comment.coffee | 4 ++-- .../completion/object-before-statement.coffee | 4 ++-- .../completion/object-half-defined-above.coffee | 4 ++-- .../completion/object-half-defined.coffee | 4 ++-- .../completion/object-half-line-colon.coffee | 4 ++-- .../object-half-line-half-defined-above.coffee | 4 ++-- .../object-half-line-half-defined.coffee | 4 ++-- .../object-half-line-with-braces.coffee | 4 ++-- .../object-half-line-with-open-brace.coffee | 4 ++-- .../fixture/completion/object-half-line.coffee | 4 ++-- .../completion/object-invalid-line.coffee | 4 ++-- test/lsp/fixture/completion/object.coffee | 4 ++-- ...ring-as-function-param-brace-indented.coffee | 2 +- .../lsp/fixture/completion/open-string-2.coffee | 2 +- ...ng-as-function-param-brace-indented-2.coffee | 2 +- ...ring-as-function-param-brace-indented.coffee | 2 +- ...pen-string-as-function-param-indented.coffee | 2 +- .../open-string-as-inline-object.coffee | 2 +- test/lsp/fixture/completion/open-string.coffee | 2 +- test/lsp/fixture/completion/string.coffee | 4 ++-- test/lsp/fixture/diagnostics/ts.coffee | 17 +---------------- 28 files changed, 48 insertions(+), 80 deletions(-) diff --git a/server/src/services/transpileService.ts b/server/src/services/transpileService.ts index 87858194..fe3b02fa 100644 --- a/server/src/services/transpileService.ts +++ b/server/src/services/transpileService.ts @@ -83,12 +83,6 @@ function preprocess_coffee(coffee_doc: TextDocument) { logger.logDebug(`transform a:b\nc\n to a:b\nc:c\n ${coffee_doc.uri}`) return match + ':' + key }) - // Comment blocks ordering are often messed up without some workaround (issue #1) - // This also inserts `` before closing block comments but JSDoc doesn't seem to care - .replaceAll(/^(\s*)###($|[^#])/mg, (_, ws, c) => { - logger.logDebug(`transform ^### to ^\`\`### ${coffee_doc.uri}`) - return ws + '``###' + c - }) // Trailing spaces = `↯:↯`. Something to make the line not error, and object to get autocomplete with params // inline object keys, both as new obj param and as new entry to an existing object param. // These characters are again removed in postprocess_js and gets special handling in doComplete(). diff --git a/test/lsp/features/completion/basic.test.ts b/test/lsp/features/completion/basic.test.ts index dad91f7d..2a789432 100644 --- a/test/lsp/features/completion/basic.test.ts +++ b/test/lsp/features/completion/basic.test.ts @@ -226,8 +226,8 @@ describe('Should autocomplete', () => { [40, 11, ['oi7', 'oi8'], true], [42, 21, 'oi2'], [43, 8, ['oi1', 'oi2'], true], - [45, 7, ['oi11', 'oi12'], true], - [47, 19, 'oi15'], + [46, 7, ['oi11', 'oi12'], true], + [49, 19, 'oi15'], ] as const for(const check of checks) { await testCompletion({ diff --git a/test/lsp/features/diagnostics/basic.test.ts b/test/lsp/features/diagnostics/basic.test.ts index 3f8466be..d522d6f2 100644 --- a/test/lsp/features/diagnostics/basic.test.ts +++ b/test/lsp/features/diagnostics/basic.test.ts @@ -32,23 +32,10 @@ describe('Should find diagnostics', () => { }, // be5e704: JSDoc errors shown at the next possible source code section { - range: sameLineRange(11, 0, 26), + range: sameLineRange(12, 0, 26), severity: vscode.DiagnosticSeverity.Error, message: "Cannot find name 'ThisTypeDoesNotExist'." - }, - // Issue #1: Keep multiple var/comment block combination in the right order - { - range: sameLineRange(14, 0, 16), - severity: vscode.DiagnosticSeverity.Error, - message: "Type 'string' is not assignable to type 'number'." - }, - // Also dependent on the backtick `` block quote fix because the typedef - // is otherwise being dragged *into* the IIFE with a missing newline which messes everything up - { - range: sameLineRange(26, 8, 36), - severity: vscode.DiagnosticSeverity.Error, - message: "Type 'string' is not assignable to type 'number'." - }, + } ]) }) diff --git a/test/lsp/fixture/completion/destructuring-with-comment-block.coffee b/test/lsp/fixture/completion/destructuring-with-comment-block.coffee index d5589e23..e237e1d6 100644 --- a/test/lsp/fixture/completion/destructuring-with-comment-block.coffee +++ b/test/lsp/fixture/completion/destructuring-with-comment-block.coffee @@ -1,6 +1,6 @@ something_else = 1 - +# ### ### { abc } = abc: destructuring_with_comment_block_var_1: 123 diff --git a/test/lsp/fixture/completion/inline-object-open-brace.coffee b/test/lsp/fixture/completion/inline-object-open-brace.coffee index 214ff63d..dcc02238 100644 --- a/test/lsp/fixture/completion/inline-object-open-brace.coffee +++ b/test/lsp/fixture/completion/inline-object-open-brace.coffee @@ -1,10 +1,10 @@ - +# ###* # @typedef {{ # inline_obj_open_brace_prop_1: number # }} inline_obj_open_brace_interface ### - +# ###* @type {inline_obj_open_brace_interface} ### inline_obj_open_brace = { inline_obj_open_brace_prop \ No newline at end of file diff --git a/test/lsp/fixture/completion/inline-object-param-key.coffee b/test/lsp/fixture/completion/inline-object-param-key.coffee index dff90b46..f84dfef5 100644 --- a/test/lsp/fixture/completion/inline-object-param-key.coffee +++ b/test/lsp/fixture/completion/inline-object-param-key.coffee @@ -1,7 +1,7 @@ +# ###* # @param one {{ -# obj_inline_param_key_prop_1: number -# }} +# obj_inline_param_key_prop_1: number }} # @param two {{ # obj_inline_param_key_prop_2: number, # }} @@ -16,12 +16,12 @@ obj_inline_param_key_method obj_inline_param_key_method {}, # # - ###* # @param {{ oi1: string, oi2: string }} _ # @param {{ oi3: string, oi4: string }} _ ### oi5 = ({ oi1, oi2 }, { oi3, oi4 }) => +# ###* # @param {string} oi6 # @param {{ oi7: string, oi8: string }} _ @@ -42,7 +42,9 @@ oi9 'op8', do => oi5 oi1: 'op10', oi5 +# ###* @type {{ oi11: string, oi12: string }} ### oi13 = +# ###* @type {{ oi14: string, oi15: string }} ### oi15 = oi14: '123', \ No newline at end of file diff --git a/test/lsp/fixture/completion/jsdoc-spacing.coffee b/test/lsp/fixture/completion/jsdoc-spacing.coffee index fc2d0f7c..4836979d 100644 --- a/test/lsp/fixture/completion/jsdoc-spacing.coffee +++ b/test/lsp/fixture/completion/jsdoc-spacing.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_completion_with_jsdoc_spacing_prop_1 : number , @@ -7,7 +7,7 @@ # }} Obj_completion_with_jsdoc_spacing_interface ### - +# ###* @type {Obj_completion_with_jsdoc_spacing_interface} ### obj_completion_with_jsdoc_spacing = \ No newline at end of file diff --git a/test/lsp/fixture/completion/object-before-comment.coffee b/test/lsp/fixture/completion/object-before-comment.coffee index 7c42b615..096821aa 100644 --- a/test/lsp/fixture/completion/object-before-comment.coffee +++ b/test/lsp/fixture/completion/object-before-comment.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_before_comment_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_before_comment_completion_interface ### - +# ###* @type {Obj_before_comment_completion_interface} ### obj_before_comment_completion = diff --git a/test/lsp/fixture/completion/object-before-statement.coffee b/test/lsp/fixture/completion/object-before-statement.coffee index 0f281fb6..0ab9c030 100644 --- a/test/lsp/fixture/completion/object-before-statement.coffee +++ b/test/lsp/fixture/completion/object-before-statement.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_completion_before_statement_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_completion_before_statement_interface ### - +# ###* @type {Obj_completion_before_statement_interface} ### obj_completion_before_statement = diff --git a/test/lsp/fixture/completion/object-half-defined-above.coffee b/test/lsp/fixture/completion/object-half-defined-above.coffee index ad0b431a..07ae3dea 100644 --- a/test/lsp/fixture/completion/object-half-defined-above.coffee +++ b/test/lsp/fixture/completion/object-half-defined-above.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_halfdefined_above_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_halfdefined_above_completion_interface ### - +# ###* @type {Obj_halfdefined_above_completion_interface} ### obj_halfdefined_above_completion = diff --git a/test/lsp/fixture/completion/object-half-defined.coffee b/test/lsp/fixture/completion/object-half-defined.coffee index 535db8fe..eeddf904 100644 --- a/test/lsp/fixture/completion/object-half-defined.coffee +++ b/test/lsp/fixture/completion/object-half-defined.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_halfdefined_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_halfdefined_completion_interface ### - +# ###* @type {Obj_halfdefined_completion_interface} ### obj_halfdefined_completion = obj_halfdefined_completion_prop_1: 123 diff --git a/test/lsp/fixture/completion/object-half-line-colon.coffee b/test/lsp/fixture/completion/object-half-line-colon.coffee index 23f60508..390bc135 100644 --- a/test/lsp/fixture/completion/object-half-line-colon.coffee +++ b/test/lsp/fixture/completion/object-half-line-colon.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_half_line_colon_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_half_line_colon_completion_interface ### - +# ###* @type {Obj_half_line_colon_completion_interface} ### obj_half_line_colon_completion = obj_half_line_colon_completion_prop: \ No newline at end of file diff --git a/test/lsp/fixture/completion/object-half-line-half-defined-above.coffee b/test/lsp/fixture/completion/object-half-line-half-defined-above.coffee index 15cfd22d..a1bcda91 100644 --- a/test/lsp/fixture/completion/object-half-line-half-defined-above.coffee +++ b/test/lsp/fixture/completion/object-half-line-half-defined-above.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_half_line_half_defined_above_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_half_line_half_defined_above_completion_interface ### - +# ###* @type {Obj_half_line_half_defined_above_completion_interface} ### obj_half_line_half_defined_above_completion = obj_half_line_half_defined_above_completion_prop_ diff --git a/test/lsp/fixture/completion/object-half-line-half-defined.coffee b/test/lsp/fixture/completion/object-half-line-half-defined.coffee index f9055b98..b0256f28 100644 --- a/test/lsp/fixture/completion/object-half-line-half-defined.coffee +++ b/test/lsp/fixture/completion/object-half-line-half-defined.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_half_line_half_defined_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_half_line_half_defined_completion_interface ### - +# ###* @type {Obj_half_line_half_defined_completion_interface} ### obj_half_line_half_defined_completion = obj_half_line_half_defined_completion_prop_1: 123 diff --git a/test/lsp/fixture/completion/object-half-line-with-braces.coffee b/test/lsp/fixture/completion/object-half-line-with-braces.coffee index 3ceb3e8e..3a3580ed 100644 --- a/test/lsp/fixture/completion/object-half-line-with-braces.coffee +++ b/test/lsp/fixture/completion/object-half-line-with-braces.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_half_line_with_braces_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_half_line_with_braces_completion_interface ### - +# ###* @type {Obj_half_line_with_braces_completion_interface} ### obj_half_line_with_braces_completion = { obj_half_line_with_braces_completion_prop diff --git a/test/lsp/fixture/completion/object-half-line-with-open-brace.coffee b/test/lsp/fixture/completion/object-half-line-with-open-brace.coffee index 7d66e4d0..812e3718 100644 --- a/test/lsp/fixture/completion/object-half-line-with-open-brace.coffee +++ b/test/lsp/fixture/completion/object-half-line-with-open-brace.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_half_line_with_open_brace_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_half_line_with_open_brace_completion_interface ### - +# ###* @type {Obj_half_line_with_open_brace_completion_interface} ### obj_half_line_with_open_brace_completion = { obj_half_line_with_open_brace_completion_prop \ No newline at end of file diff --git a/test/lsp/fixture/completion/object-half-line.coffee b/test/lsp/fixture/completion/object-half-line.coffee index 88874a80..50b78db3 100644 --- a/test/lsp/fixture/completion/object-half-line.coffee +++ b/test/lsp/fixture/completion/object-half-line.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_half_line_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_half_line_completion_interface ### - +# ###* @type {Obj_half_line_completion_interface} ### obj_half_line_completion = obj_half_line_completion_prop \ No newline at end of file diff --git a/test/lsp/fixture/completion/object-invalid-line.coffee b/test/lsp/fixture/completion/object-invalid-line.coffee index 6e2b12e8..4c7aee66 100644 --- a/test/lsp/fixture/completion/object-invalid-line.coffee +++ b/test/lsp/fixture/completion/object-invalid-line.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_invalid_line_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_invalid_line_completion_interface ### - +# ###* @type {Obj_invalid_line_completion_interface} ### obj_invalid_line_completion = obj_invalid_line_completion_p : ~~var \ No newline at end of file diff --git a/test/lsp/fixture/completion/object.coffee b/test/lsp/fixture/completion/object.coffee index 6782cffd..e58e32b9 100644 --- a/test/lsp/fixture/completion/object.coffee +++ b/test/lsp/fixture/completion/object.coffee @@ -1,4 +1,4 @@ - +# ###* # @typedef {{ # obj_completion_prop_1: number, @@ -6,7 +6,7 @@ # }} Obj_completion_interface ### - +# ###* @type {Obj_completion_interface} ### obj_completion = \ No newline at end of file diff --git a/test/lsp/fixture/completion/open-empty-string-as-function-param-brace-indented.coffee b/test/lsp/fixture/completion/open-empty-string-as-function-param-brace-indented.coffee index 126b872d..3b8d9614 100644 --- a/test/lsp/fixture/completion/open-empty-string-as-function-param-brace-indented.coffee +++ b/test/lsp/fixture/completion/open-empty-string-as-function-param-brace-indented.coffee @@ -1,4 +1,4 @@ - +# ###* @param val {'abc' | 'def'} ### open_empty_string_as_function_param = (val) => diff --git a/test/lsp/fixture/completion/open-string-2.coffee b/test/lsp/fixture/completion/open-string-2.coffee index a2b07af1..64d521f2 100644 --- a/test/lsp/fixture/completion/open-string-2.coffee +++ b/test/lsp/fixture/completion/open-string-2.coffee @@ -1,4 +1,4 @@ - +# ###* @type {"abc" | "def"} ### open_string_var_2 = " diff --git a/test/lsp/fixture/completion/open-string-as-function-param-brace-indented-2.coffee b/test/lsp/fixture/completion/open-string-as-function-param-brace-indented-2.coffee index 0b4133d7..12ff846e 100644 --- a/test/lsp/fixture/completion/open-string-as-function-param-brace-indented-2.coffee +++ b/test/lsp/fixture/completion/open-string-as-function-param-brace-indented-2.coffee @@ -1,4 +1,4 @@ - +# ###* @param val {'abc' | 'def'} ### open_string_as_function_param_2 = (val) => diff --git a/test/lsp/fixture/completion/open-string-as-function-param-brace-indented.coffee b/test/lsp/fixture/completion/open-string-as-function-param-brace-indented.coffee index 19bc689a..67657a6e 100644 --- a/test/lsp/fixture/completion/open-string-as-function-param-brace-indented.coffee +++ b/test/lsp/fixture/completion/open-string-as-function-param-brace-indented.coffee @@ -1,4 +1,4 @@ - +# ###* @param val {'abc' | 'def'} ### open_string_as_function_param = (val) => diff --git a/test/lsp/fixture/completion/open-string-as-function-param-indented.coffee b/test/lsp/fixture/completion/open-string-as-function-param-indented.coffee index 9ca56d4c..2e34a17b 100644 --- a/test/lsp/fixture/completion/open-string-as-function-param-indented.coffee +++ b/test/lsp/fixture/completion/open-string-as-function-param-indented.coffee @@ -1,4 +1,4 @@ - +# ###* @param val {'abc' | 'def'} ### open_string_as_function_no_brace_param = (val) => diff --git a/test/lsp/fixture/completion/open-string-as-inline-object.coffee b/test/lsp/fixture/completion/open-string-as-inline-object.coffee index 182d2e50..f6463de3 100644 --- a/test/lsp/fixture/completion/open-string-as-inline-object.coffee +++ b/test/lsp/fixture/completion/open-string-as-inline-object.coffee @@ -1,5 +1,5 @@ #@ts-check - +# ###* @type {{abc:"def"|"ghi"}} ### open_string_as_inline_obj_var = abc: " diff --git a/test/lsp/fixture/completion/open-string.coffee b/test/lsp/fixture/completion/open-string.coffee index c4cf08e8..90b88b3c 100644 --- a/test/lsp/fixture/completion/open-string.coffee +++ b/test/lsp/fixture/completion/open-string.coffee @@ -1,3 +1,3 @@ - +# ###* @type {"abc" | "def"} ### open_string_var = " \ No newline at end of file diff --git a/test/lsp/fixture/completion/string.coffee b/test/lsp/fixture/completion/string.coffee index 30c234fe..dc347533 100644 --- a/test/lsp/fixture/completion/string.coffee +++ b/test/lsp/fixture/completion/string.coffee @@ -1,6 +1,6 @@ - +# ###* @type {'constant'} ### string_completion_const = '' - +# ###* @type {'constant'} ### string_completion_const2 = 'constan' \ No newline at end of file diff --git a/test/lsp/fixture/diagnostics/ts.coffee b/test/lsp/fixture/diagnostics/ts.coffee index 9cb61955..e357f895 100644 --- a/test/lsp/fixture/diagnostics/ts.coffee +++ b/test/lsp/fixture/diagnostics/ts.coffee @@ -6,23 +6,8 @@ diagnostics_ts = '1' ts_check_func = (###* @type {string} ### param1) => ts_check_func 123 +# ###* # @type {ThisTypeDoesNotExist} ### ts_type_does_not_exist_var = 123 - -###* @type {number} ### -diagnostics_ts_2 = '1' - -###* -# @typedef {{ -# obj_jsdoc_inside_iife_prop_1: number -# }} obj_jsdoc_inside_iife_interface -### -do => - ###* @type {number} ### - something_else = 123 - ###* @type {obj_jsdoc_inside_iife_interface} ### - obj_jsdoc_inside_iife = - obj_jsdoc_inside_iife_prop_1: '123' - something_else_again \ No newline at end of file