Skip to content

Commit

Permalink
Revert "fix positioning of jsdoc comments (and block comments in gene…
Browse files Browse the repository at this point in the history
…ral) by prepending them with two backticks ``"

Revert "add test for jsdoc inside iife"

It's not waterproof, see jashkenas/coffeescript#5366 (comment)

This reverts commit 56b7982.
This reverts commit 03acf8f.
  • Loading branch information
phil294 committed May 20, 2022
1 parent 124b4b1 commit d52648e
Show file tree
Hide file tree
Showing 28 changed files with 48 additions and 80 deletions.
6 changes: 0 additions & 6 deletions server/src/services/transpileService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
4 changes: 2 additions & 2 deletions test/lsp/features/completion/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
17 changes: 2 additions & 15 deletions test/lsp/features/diagnostics/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'."
},
}
])
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
something_else = 1


#
### ###
{ abc } = abc: destructuring_with_comment_block_var_1: 123

Expand Down
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/inline-object-open-brace.coffee
Original file line number Diff line number Diff line change
@@ -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
8 changes: 5 additions & 3 deletions test/lsp/fixture/completion/inline-object-param-key.coffee
Original file line number Diff line number Diff line change
@@ -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,
# }}
Expand All @@ -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 }} _
Expand All @@ -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',
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/jsdoc-spacing.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#
###*
# @typedef {{
# obj_completion_with_jsdoc_spacing_prop_1 : number ,
Expand All @@ -7,7 +7,7 @@
# }} Obj_completion_with_jsdoc_spacing_interface
###


#
###* @type {Obj_completion_with_jsdoc_spacing_interface} ###
obj_completion_with_jsdoc_spacing =

4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/object-before-comment.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_before_comment_completion_prop_1: number,
# obj_before_comment_completion_prop_2: string
# }} Obj_before_comment_completion_interface
###


#
###* @type {Obj_before_comment_completion_interface} ###
obj_before_comment_completion =

Expand Down
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/object-before-statement.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_completion_before_statement_prop_1: number,
# obj_completion_before_statement_prop_2: string
# }} Obj_completion_before_statement_interface
###


#
###* @type {Obj_completion_before_statement_interface} ###
obj_completion_before_statement =

Expand Down
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/object-half-defined-above.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_halfdefined_above_completion_prop_1: number,
# obj_halfdefined_above_completion_prop_2: string
# }} Obj_halfdefined_above_completion_interface
###


#
###* @type {Obj_halfdefined_above_completion_interface} ###
obj_halfdefined_above_completion =

Expand Down
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/object-half-defined.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_halfdefined_completion_prop_1: number,
# obj_halfdefined_completion_prop_2: string
# }} Obj_halfdefined_completion_interface
###


#
###* @type {Obj_halfdefined_completion_interface} ###
obj_halfdefined_completion =
obj_halfdefined_completion_prop_1: 123
Expand Down
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/object-half-line-colon.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_half_line_colon_completion_prop_1: number,
# obj_half_line_colon_completion_prop_2: string
# }} Obj_half_line_colon_completion_interface
###


#
###* @type {Obj_half_line_colon_completion_interface} ###
obj_half_line_colon_completion =
obj_half_line_colon_completion_prop:
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_half_line_half_defined_above_completion_prop_1: number,
# obj_half_line_half_defined_above_completion_prop_2: string
# }} 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_
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_half_line_half_defined_completion_prop_1: number,
# obj_half_line_half_defined_completion_prop_2: string
# }} 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_half_line_with_braces_completion_prop_1: number,
# obj_half_line_with_braces_completion_prop_2: string
# }} 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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_half_line_with_open_brace_completion_prop_1: number,
# obj_half_line_with_open_brace_completion_prop_2: string
# }} 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
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/object-half-line.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_half_line_completion_prop_1: number,
# obj_half_line_completion_prop_2: string
# }} Obj_half_line_completion_interface
###


#
###* @type {Obj_half_line_completion_interface} ###
obj_half_line_completion =
obj_half_line_completion_prop
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/object-invalid-line.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_invalid_line_completion_prop_1: number,
# obj_invalid_line_completion_prop_2: string
# }} Obj_invalid_line_completion_interface
###


#
###* @type {Obj_invalid_line_completion_interface} ###
obj_invalid_line_completion =
obj_invalid_line_completion_p : ~~var
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/object.coffee
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

#
###*
# @typedef {{
# obj_completion_prop_1: number,
# obj_completion_prop_2: string
# }} Obj_completion_interface
###


#
###* @type {Obj_completion_interface} ###
obj_completion =

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#
###* @param val {'abc' | 'def'} ###
open_empty_string_as_function_param = (val) =>

Expand Down
2 changes: 1 addition & 1 deletion test/lsp/fixture/completion/open-string-2.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#
###* @type {"abc" | "def"} ###
open_string_var_2 = "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#
###* @param val {'abc' | 'def'} ###
open_string_as_function_param_2 = (val) =>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#
###* @param val {'abc' | 'def'} ###
open_string_as_function_param = (val) =>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

#
###* @param val {'abc' | 'def'} ###
open_string_as_function_no_brace_param = (val) =>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#@ts-check

#
###* @type {{abc:"def"|"ghi"}} ###
open_string_as_inline_obj_var = abc: "
Expand Down
2 changes: 1 addition & 1 deletion test/lsp/fixture/completion/open-string.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

#
###* @type {"abc" | "def"} ###
open_string_var = "
4 changes: 2 additions & 2 deletions test/lsp/fixture/completion/string.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#
###* @type {'constant'} ###
string_completion_const = ''

#
###* @type {'constant'} ###
string_completion_const2 = 'constan'
17 changes: 1 addition & 16 deletions test/lsp/fixture/diagnostics/ts.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d52648e

Please sign in to comment.