Skip to content

Commit

Permalink
fix(#66): Remove returnType when the type is void
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Dec 1, 2019
1 parent 4fa2c09 commit 25c64d1
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
17 changes: 17 additions & 0 deletions autoload/doge/preprocessors/javascript.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let s:save_cpo = &cpoptions
set cpoptions&vim

" A callback function being called after the tokens have been extracted. This
" function will adjust the input if needed.
function! doge#preprocessors#javascript#tokens(tokens) abort
if has_key(a:tokens, 'returnType')
if a:tokens['returnType'] ==# 'void'
let a:tokens['returnType'] = ''
elseif a:tokens['returnType'] ==# ''
let a:tokens['returnType'] = '!type'
endif
endif
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo
17 changes: 17 additions & 0 deletions autoload/doge/preprocessors/typescript.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
let s:save_cpo = &cpoptions
set cpoptions&vim

" A callback function being called after the tokens have been extracted. This
" function will adjust the input if needed.
function! doge#preprocessors#typescript#tokens(tokens) abort
if has_key(a:tokens, 'returnType')
if a:tokens['returnType'] ==# 'void'
let a:tokens['returnType'] = ''
elseif a:tokens['returnType'] ==# ''
let a:tokens['returnType'] = '!type'
endif
endif
endfunction

let &cpoptions = s:save_cpo
unlet s:save_cpo
8 changes: 4 additions & 4 deletions ftplugin/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ call add(b:doge_patterns, {
\ '%(async| * @{async})%',
\ ' * @function {funcName|}',
\ '%(parameters| * {parameters})%',
\ ' * @return {{returnType|!type}} !description',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down Expand Up @@ -131,7 +131,7 @@ call add(b:doge_patterns, {
\ '%(static| * @static)%',
\ '%(async| * @async)%',
\ '%(parameters| * {parameters})%',
\ ' * @return {{returnType|!type}} !description',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down Expand Up @@ -169,7 +169,7 @@ call add(b:doge_patterns, {
\ '%(async| * @async)%',
\ ' * @function {className}#{funcName}',
\ '%(parameters| * {parameters})%',
\ ' * @return {{returnType|!type}} !description',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down Expand Up @@ -224,7 +224,7 @@ call add(b:doge_patterns, {
\ '%(async| * @async)%',
\ ' * @function {funcName|}',
\ '%(parameters| * {parameters})%',
\ ' * @return {{returnType|!type}} !description',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down
9 changes: 4 additions & 5 deletions ftplugin/typescript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ call add(b:doge_patterns, {
\ '%(async| * @{async})%',
\ ' * @function {funcName|}',
\ '%(parameters| * {parameters})%',
\ ' * @return {{returnType|!type}} !description',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down Expand Up @@ -90,7 +90,6 @@ call add(b:doge_patterns, {
\ 'jsdoc': [
\ '/**',
\ ' * !description',
\ ' *',
\ '%(parentClassName| * @extends {parentClassName})%',
\ '%(interfaceName| * @implements {interfaceName})%',
\ ' */',
Expand Down Expand Up @@ -135,7 +134,7 @@ call add(b:doge_patterns, {
\ '%(static| * @static)%',
\ '%(async| * @async)%',
\ '%(parameters| * {parameters})%',
\ ' * @return {{returnType|!type}} !description',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down Expand Up @@ -173,7 +172,7 @@ call add(b:doge_patterns, {
\ '%(async| * @async)%',
\ ' * @function {className}#{funcName}',
\ '%(parameters| * {parameters})%',
\ ' * @return {{returnType|!type}} !description',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down Expand Up @@ -228,7 +227,7 @@ call add(b:doge_patterns, {
\ '%(async| * @async)%',
\ ' * @function {funcName|}',
\ '%(parameters| * {parameters})%',
\ ' * @return {{returnType|!type}} !description',
\ '%(returnType| * @return {{returnType|!type}} !description)%',
\ ' */',
\ ],
\ },
Expand Down
1 change: 0 additions & 1 deletion playground/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,6 @@ class Child extends Parent {
*
* @param {number} arg0 - [TODO:description]
* @param {string} arg1 - [TODO:description]
* @return {void} [TODO:description]
*/
public funcA(arg0: number, arg1?: string): void {

Expand Down
1 change: 0 additions & 1 deletion test/filetypes/javascript/functions.vader
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ Expect javascript (generated comment with a description, @param and @return tags
* [TODO:description]
*
* @param {string} something - [TODO:description]
* @return {void} [TODO:description]
*/
public printSomething(something?: string): void {}

Expand Down

0 comments on commit 25c64d1

Please sign in to comment.