Skip to content

Commit 72f19f7

Browse files
committed
Fix private,public bug.
1 parent 3155ac5 commit 72f19f7

File tree

5 files changed

+58
-14
lines changed

5 files changed

+58
-14
lines changed

autoload/jsdoc.vim

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: jsdoc.vim
22
" Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
33
" Modifyed: Shinya Ohyanagi <[email protected]>
4-
" Version: 0.10.0
4+
" Version: 0.10.1
55
" WebPage: http://github.com/heavenshell/vim-jsdoc/
66
" Description: Generate JSDoc to your JavaScript file.
77
" License: BSD, see LICENSE for more details.
@@ -106,13 +106,13 @@ let s:regexs = {
106106
\ 'arrow': '^.\{-}\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\)\s*[:=]\s*(\s*\([^)]*\)\s*)\s*=>.*$',
107107
\ 'return_type': ')\(:\|:\s\|\s*:\s*\)\([a-zA-Z]\+\).*$',
108108
\ 'interface': '^.\{-}\s*interface\s*\([a-zA-Z_$][a-zA-Z0-9_$]*\).*$',
109-
\ 'access': '^\(public\|protected\|private\)',
109+
\ 'access': '^\s*\(public\|protected\|private\)',
110110
\ 'implements': '^.\{-}\s*implements\s*\(\([^{]*\)\).*$',
111111
\ 'extends': '^.\{-}\s*extends\s*\([^\s*]\)'
112112
\ }
113113

114114
function! s:trim(value)
115-
return substitute(a:value, '\s', '', '')
115+
return substitute(a:value, '\s', '', 'g')
116116
endfunction
117117

118118
" If someday Vim support lambda use lambda.
@@ -123,15 +123,12 @@ function! s:parse_type(args)
123123
let args = split(arg, ':')
124124
let val = args[0]
125125
if val =~# s:regexs['access']
126-
"let val = substitute(split(val, s:regexs['access'])[0], '\s', '', '')
127126
let val = s:trim(split(val, s:regexs['access'])[0])
128127
endif
129128

130-
"let type = substitute(args[1], '\s', '', '')
131129
let type = s:trim(args[1])
132130
" Split keywaord args.
133131
if type =~# '='
134-
"let type = substitute(split(type, '=')[0], '\s', '', '')
135132
let type = s:trim(split(type, '=')[0])
136133
endif
137134
call add(results, {'val': val, 'type': type})
@@ -387,12 +384,16 @@ function! jsdoc#insert() abort
387384
" either @access public/private
388385
" or @public/private
389386
let l:access_tag = g:jsdoc_access_descriptions == 1
390-
\ ? ' * @access '
391-
\ : ' * @'
387+
\ ? ' * @access '
388+
\ : ' * @'
389+
if l:line =~ s:regexs['access']
390+
let l:access = s:trim(matchstr(l:line, s:regexs['access']))
391+
else
392392

393-
let l:access = g:jsdoc_underscore_private == 1 && l:funcName[0] ==# '_'
394-
\ ? 'private'
395-
\ : 'public'
393+
let l:access = g:jsdoc_underscore_private == 1 && l:funcName[0] ==# '_'
394+
\ ? 'private'
395+
\ : 'public'
396+
endif
396397

397398
call add(l:lines, l:space . l:access_tag . l:access)
398399
endif

doc/jsdoc.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
*jsdoc.txt* Generate JSDoc to your JavaScript code.
22

3-
Version: 0.10.0
3+
Version: 0.10.1
44
Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
55
Modifyed: Shinya Ohynagi <[email protected]>
66
Repository: http://github.com/heavenshell/vim-jsdoc/
@@ -279,6 +279,9 @@ g:jsdoc_tags *g:jsdoc_tags*
279279
280280
==============================================================================
281281
CHANGELOG *jsdoc-changelog*
282+
2016-09-11
283+
- Fix private, public bug.
284+
282285
2016-08-30
283286
- Add typed params and return type, such as TypeScript, support
284287

ftplugin/javascript/jsdoc.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: jsdoc.vim
22
" Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
33
" Modifyed: Shinya Ohyanagi <[email protected]>
4-
" Version: 0.10.0
4+
" Version: 0.10.1
55
" WebPage: http://github.com/heavenshell/vim-jsdoc/
66
" Description: Generate JSDoc to your JavaScript file.
77
" License: BSD, see LICENSE for more details.

ftplugin/typescript/jsdoc.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: jsdoc.vim
22
" Author: NAKAMURA, Hisashi <https://github.com/sunvisor>
33
" Modifyed: Shinya Ohyanagi <[email protected]>
4-
" Version: 0.10.0
4+
" Version: 0.10.1
55
" WebPage: http://github.com/heavenshell/vim-jsdoc/
66
" Description: Generate JSDoc to your JavaScript file.
77
" License: BSD, see LICENSE for more details.

test/test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
function foo(foo: string = 'foo', bar: number = 1): string {
2+
return 'foo'
3+
}
4+
5+
function bar() : any {
6+
}
7+
8+
function _baz() :number{
9+
return 1
10+
}
11+
12+
function union(): number | string {
13+
return 'foo'
14+
}
15+
16+
interface IFoo {
17+
}
18+
19+
class Foo {
20+
}
21+
22+
class Bar extends Foo implements IFoo {
23+
constructor(private arg1: string, public arg2: string) {
24+
super()
25+
}
26+
private foo(arg1: string, arg2: number = 0): void {
27+
}
28+
public _bar(): void {
29+
}
30+
}
31+
32+
class Baz extends Foo implements IFoo {
33+
}
34+
35+
function ifoo(): IFoo {
36+
return new Bar('foo', 'bar')
37+
}
38+
39+
function list(args: Array<Bar>): void {
40+
}

0 commit comments

Comments
 (0)