Skip to content

Commit

Permalink
fix(#67): Allow protected and private function data modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Dec 2, 2019
1 parent 25c64d1 commit c2f427a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ftplugin/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ call add(b:doge_patterns, {
"
" function pluck<T, K extends keyof T>(o: T, names: K[]): T[K][] {}
call add(b:doge_patterns, {
\ 'match': '\m^\%(\%(export\|public\)\s\+\)*\(static\s\+\)\?\(async\s\+\)\?\%(function\*\?\s*\)\?\%([[:alnum:]_$]\+\)\?\s*\%(<[[:alnum:][:space:]_,]*>\)\?\s*(\([^>]\{-}\))\%(\s*:\s*(\?\([[:alnum:][:space:]_[\].,|<>]\+\))\?\)\?\s*[{(]',
\ 'match': '\m^\%(\%(export\|public\|private\|protected\)\s\+\)*\(static\s\+\)\?\(async\s\+\)\?\%(function\*\?\s*\)\?\%([[:alnum:]_$]\+\)\?\s*\%(<[[:alnum:][:space:]_,]*>\)\?\s*(\([^>]\{-}\))\%(\s*:\s*(\?\([[:alnum:][:space:]_[\].,|<>]\+\))\?\)\?\s*[{(]',
\ 'match_group_names': ['static', 'async', 'parameters', 'returnType'],
\ 'parameters': {
\ 'match': s:parameters_match_pattern,
Expand Down
2 changes: 1 addition & 1 deletion ftplugin/typescript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ call add(b:doge_patterns, {
"
" function pluck<T, K extends keyof T>(o: T, names: K[]): T[K][] {}
call add(b:doge_patterns, {
\ 'match': '\m^\%(\%(export\|public\)\s\+\)*\(static\s\+\)\?\(async\s\+\)\?\%(function\*\?\s*\)\?\%([[:alnum:]_$]\+\)\?\s*\%(<[[:alnum:][:space:]_,]*>\)\?\s*(\([^>]\{-}\))\%(\s*:\s*(\?\([[:alnum:][:space:]_[\].,|<>]\+\))\?\)\?\s*[{(]',
\ 'match': '\m^\%(\%(export\|public\|private\|protected\)\s\+\)*\(static\s\+\)\?\(async\s\+\)\?\%(function\*\?\s*\)\?\%([[:alnum:]_$]\+\)\?\s*\%(<[[:alnum:][:space:]_,]*>\)\?\s*(\([^>]\{-}\))\%(\s*:\s*(\?\([[:alnum:][:space:]_[\].,|<>]\+\))\?\)\?\s*[{(]',
\ 'match_group_names': ['static', 'async', 'parameters', 'returnType'],
\ 'parameters': {
\ 'match': s:parameters_match_pattern,
Expand Down
26 changes: 24 additions & 2 deletions test/filetypes/javascript/functions.vader
Original file line number Diff line number Diff line change
Expand Up @@ -224,18 +224,26 @@ Expect javascript (generated comment with @async, @param and @return tags):
async function* myFunc($p1 = 'value', p2 = [], p3, p4) {}

# ==============================================================================
# Class with a public function with parameters and return type.
# Class with functions with parameters and return type.
# ==============================================================================
Given javascript (class with a public function with parameters and return type):
Given javascript (class with functions with parameters and return type and differrent data modifiers):
export class Test {

public printSomething(something?: string): void {}

protected printSomething(something?: string): void {}

private printSomething(something?: string): void {}

}

Do (trigger doge):
:3\<CR>
\<C-d>
:10\<CR>
\<C-d>
:17\<CR>
\<C-d>

Expect javascript (generated comment with a description, @param and @return tags):
export class Test {
Expand All @@ -247,4 +255,18 @@ Expect javascript (generated comment with a description, @param and @return tags
*/
public printSomething(something?: string): void {}

/**
* [TODO:description]
*
* @param {string} something - [TODO:description]
*/
protected printSomething(something?: string): void {}

/**
* [TODO:description]
*
* @param {string} something - [TODO:description]
*/
private printSomething(something?: string): void {}

}

0 comments on commit c2f427a

Please sign in to comment.