Skip to content

Commit

Permalink
feat: Add tests for java
Browse files Browse the repository at this point in the history
  • Loading branch information
kkoomen committed Jun 9, 2019
1 parent 352b1d0 commit c7eda6f
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ftplugin/java.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set cpoptions&vim
let b:doge_patterns = []

" ==============================================================================
" Matches regular function expressions and class methods.
" Matches class methods.
" ==============================================================================
"
" Matches the following scenarios:
Expand All @@ -22,7 +22,7 @@ let b:doge_patterns = []
"
" void MyParameterizedFunction(String param1, int param2, Boolean ...params) {}
call add(b:doge_patterns, {
\ 'match': '\m^\%(public\|private\|protected\)\?\s*\%(static\)\?\s*\%(final\)\?\s*\%(\([[:alnum:]_]\+\)\%(<[[:alnum:][:space:]_,]*>\)\?\)\s*\([[:alnum:]_]\+\)\s*(\(.\{-}\))\s*{',
\ 'match': '\m^\%(\%(public\|private\|protected\)\s*\)\?\%(static\s*\)\?\%(final\s*\)\?\%(\([[:alnum:]_]\+\)\?\%(<[[:alnum:][:space:]_,]*>\)\?\)\?\s\+\([[:alnum:]_]\+\)(\(.\{-}\))\s*{',
\ 'match_group_names': ['returnType', 'funcName', 'parameters'],
\ 'parameters': {
\ 'match': '\m\%(\([[:alnum:]_]\+\)\%(<[[:alnum:][:space:]_,]\+>\)\?\)\%(\s\+[.]\{3}\s\+\|\s\+[.]\{3}\|[.]\{3}\s\+\|\s\+\)\([[:alnum:]_]\+\)',
Expand All @@ -35,7 +35,7 @@ call add(b:doge_patterns, {
\ '/**',
\ ' * TODO',
\ ' * {parameters}',
\ '! * @return {returnType} TODO',
\ '! * @return {returnType|void} TODO',
\ ' */',
\ ],
\ },
Expand Down
17 changes: 16 additions & 1 deletion playground/test.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private ListResultBean<MstRelation> getAllRelation(int parentId) {
* @param int type TODO
* @return List TODO
*/
private List<ElementDto> createSortedList(Map<Integer, ElementDto> map, int type) {
private List<Element> createSortedList(Map<Integer, ElementDto> map, int type) {
//
}

Expand Down Expand Up @@ -88,3 +88,18 @@ void MyParameterizedFunction(String param1, int param2, Boolean ... params) {}
* @return void TODO
*/
void MyParameterizedFunction(String param1, int param2, Boolean ...params) {}

/**
* TODO
* @return List TODO
*/
List<Element> createSortedList() {}

/**
* TODO
* @param IndexSettings indexSettings TODO
* @param Environment env TODO
* @param String name TODO
* @param Settings settings TODO
*/
public UkrainianAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {}
78 changes: 78 additions & 0 deletions test/filetypes/java/class-methods.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# ==============================================================================
# Method without parameters.
# ==============================================================================
Given java (method without parameters):
class Test {
List<Element> createSortedList() {}
}

Do (trigger doge):
:2\<CR>
\<C-d>

Expect java (method with 'TODO' and a @return tag):
class Test {
/**
* TODO
* @return List TODO
*/
List<Element> createSortedList() {}
}

# ==============================================================================
# Methods without return type.
# ==============================================================================
Given java (mtehod without return type):
class Test {
public createSortedList() {}
}

Do (trigger doge):
:2\<CR>
\<C-d>

Expect java (method with 'TODO' and a @return tag containing 'void'):
class Test {
/**
* TODO
* @return void TODO
*/
public createSortedList() {}
}

# ==============================================================================
# Methods with parameters.
# ==============================================================================
Given java (method without return type):
class Test {
private static MstRelation MyParameterizedMethod(String param1, int param2, Boolean ...params) {}

ListResultBean<MstRelation> MyParameterizedMethod(String param1, int param2, Boolean... params) {}
}

Do (trigger doge):
:2\<CR>
\<C-d>
:11\<CR>
\<C-d>

Expect java (generated comment where the @return tag should be void):
class Test {
/**
* TODO
* @param String param1 TODO
* @param int param2 TODO
* @param Boolean params TODO
* @return MstRelation TODO
*/
private static MstRelation MyParameterizedMethod(String param1, int param2, Boolean ...params) {}

/**
* TODO
* @param String param1 TODO
* @param int param2 TODO
* @param Boolean params TODO
* @return ListResultBean TODO
*/
ListResultBean<MstRelation> MyParameterizedMethod(String param1, int param2, Boolean... params) {}
}

0 comments on commit c7eda6f

Please sign in to comment.