From 9d6c40c1f78eb67326aa09866e6415901b7edbda Mon Sep 17 00:00:00 2001 From: Marcin Bednarek Date: Sun, 28 Apr 2013 14:32:12 +0100 Subject: [PATCH 1/5] Cygwin support added. Using cygpath to get actual path for Cygwin. --- syntax_checkers/java/javac.vim | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/syntax_checkers/java/javac.vim b/syntax_checkers/java/javac.vim index 5380f2e5..4e4c0c3e 100644 --- a/syntax_checkers/java/javac.vim +++ b/syntax_checkers/java/javac.vim @@ -40,6 +40,8 @@ endif if !exists("g:syntastic_java_javac_temp_dir") if has('win32') || has('win64') let g:syntastic_java_javac_temp_dir = $TEMP."\\vim-syntastic-javac" + elseif has('win32unix') + let g:syntastic_java_javac_temp_dir=substitute(system("cygpath -m /tmp/vim-syntastic-javac"), '\%x00', '', 'g') else let g:syntastic_java_javac_temp_dir = '/tmp/vim-syntastic-javac' endif @@ -87,7 +89,7 @@ function! s:AddToClasspath(classpath,path) return a:classpath endif if a:classpath != '' && a:path != '' - if has('win32') || has('win64') + if has('win32') || has('win32unix') || has('win64') return a:classpath . ";" . a:path else return a:classpath . ":" . a:path @@ -150,7 +152,7 @@ function! s:GetMavenClasspath() let class_path_next = 0 for line in mvn_classpath_output if class_path_next == 1 - let mvn_classpath = line + let mvn_classpath = substitute(line, ' ', '', 'g') break endif if match(line,'Dependencies classpath:') >= 0 @@ -214,21 +216,26 @@ function! SyntaxCheckers_java_javac_GetLocList() endif if javac_classpath != '' - let javac_opts .= ' -cp ' . fnameescape(javac_classpath) + let javac_opts .= ' -cp "' . fnameescape(javac_classpath) . '"' endif - " path seperator - if has('win32') || has('win64') + if has('win32') || has('win32unix') || has('win64') let sep = "\\" else let sep = '/' endif + let fname = fnameescape(expand ( '%:p:h' ) . sep . expand ( '%:t' )) + + if has('win32unix') + let fname = substitute(system("cygpath -m " . fname), '\%x00', '', 'g') + endif + let makeprg = syntastic#makeprg#build({ \ 'exe': g:syntastic_java_javac_executable, \ 'args': javac_opts, - \ 'fname': fnameescape(expand ( '%:p:h' ) . sep . expand ( '%:t' )), + \ 'fname': fname, \ 'tail': '2>&1', \ 'subchecker': 'javac' }) From aecbf445683c5eb34b7551fc83fd2100a62a7e33 Mon Sep 17 00:00:00 2001 From: Marcin Bednarek Date: Sun, 28 Apr 2013 21:06:39 +0100 Subject: [PATCH 2/5] ^M changed to \r - carriage return. --- syntax_checkers/java/javac.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax_checkers/java/javac.vim b/syntax_checkers/java/javac.vim index 4e4c0c3e..6a633118 100644 --- a/syntax_checkers/java/javac.vim +++ b/syntax_checkers/java/javac.vim @@ -152,7 +152,7 @@ function! s:GetMavenClasspath() let class_path_next = 0 for line in mvn_classpath_output if class_path_next == 1 - let mvn_classpath = substitute(line, ' ', '', 'g') + let mvn_classpath = substitute(line, '\r', '', 'g') break endif if match(line,'Dependencies classpath:') >= 0 From 82177875439707aa53c931209bd29ac90a22846b Mon Sep 17 00:00:00 2001 From: Marcin Bednarek Date: Mon, 29 Apr 2013 21:26:33 +0100 Subject: [PATCH 3/5] target/test-classes added to classpath. --- syntax_checkers/java/javac.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/syntax_checkers/java/javac.vim b/syntax_checkers/java/javac.vim index 6a633118..66b9121c 100644 --- a/syntax_checkers/java/javac.vim +++ b/syntax_checkers/java/javac.vim @@ -160,6 +160,7 @@ function! s:GetMavenClasspath() endif endfor let mvn_classpath = s:AddToClasspath(mvn_classpath,'target/classes') + let mvn_classpath = s:AddToClasspath(mvn_classpath,'target/test-classes') let g:syntastic_java_javac_maven_pom_cwd = getcwd() let g:syntastic_java_javac_maven_pom_ftime = getftime('pom.xml') let g:syntastic_java_javac_maven_pom_classpath = mvn_classpath From 2f89733f3e43f4d74c93decf58468e3a686cc571 Mon Sep 17 00:00:00 2001 From: Marcin Bednarek Date: Mon, 6 May 2013 12:24:15 +0100 Subject: [PATCH 4/5] Cygwin support added. --- syntax_checkers/java/checkstyle.vim | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/syntax_checkers/java/checkstyle.vim b/syntax_checkers/java/checkstyle.vim index bdc9fa75..e03df5d3 100644 --- a/syntax_checkers/java/checkstyle.vim +++ b/syntax_checkers/java/checkstyle.vim @@ -27,19 +27,44 @@ function! SyntaxCheckers_java_checkstyle_IsAvailable() return executable('java') endfunction +function! s:CygwinPath(path) + return substitute(system("cygpath -m ".a:path), '\%x00', '', 'g') +endfunction + +function! s:RemoveCarriageReturn(line) + return substitute(a:line, '\r', '', 'g') +endfunction + +function! s:RemoveCarriageReturns(errors) + for error in a:errors + let error['text'] = s:RemoveCarriageReturn(error['text']) + endfor +endfunction + function! SyntaxCheckers_java_checkstyle_GetLocList() + + let fname = fnameescape(expand ( '%:p:h' ) . '/' . expand ( '%:t' )) + + if has('win32unix') + let fname = s:CygwinPath(fname) + endif + let makeprg = syntastic#makeprg#build({ \ 'exe': 'java', \ 'args': '-cp ' . g:syntastic_java_checkstyle_classpath . ' com.puppycrawl.tools.checkstyle.Main -c ' . g:syntastic_java_checkstyle_conf_file, - \ 'fname': expand ( '%:p:h' ) . '/' . expand ( '%:t' ), + \ 'fname': fname, \ 'tail': '2>&1', \ 'subchecker': 'checkstyle' }) " check style format let errorformat = '%f:%l:%c:\ %m,%f:%l:\ %m' + let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + if has('win32unix') + call s:RemoveCarriageReturns(errors) + endif + return errors endfunction call g:SyntasticRegistry.CreateAndRegisterChecker({ From 5bd761984cb11a1f6d827a2e92f8d70d523951cf Mon Sep 17 00:00:00 2001 From: Marcin Bednarek Date: Mon, 6 May 2013 12:25:19 +0100 Subject: [PATCH 5/5] Using standard output directories for maven project. --- syntax_checkers/java/javac.vim | 50 ++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/syntax_checkers/java/javac.vim b/syntax_checkers/java/javac.vim index 66b9121c..cc1b03f6 100644 --- a/syntax_checkers/java/javac.vim +++ b/syntax_checkers/java/javac.vim @@ -37,11 +37,15 @@ if !exists("g:syntastic_java_javac_delete_output") let g:syntastic_java_javac_delete_output = 1 endif +function! s:CygwinPath(path) + return substitute(system("cygpath -m ".a:path), '\%x00', '', 'g') +endfunction + if !exists("g:syntastic_java_javac_temp_dir") if has('win32') || has('win64') let g:syntastic_java_javac_temp_dir = $TEMP."\\vim-syntastic-javac" elseif has('win32unix') - let g:syntastic_java_javac_temp_dir=substitute(system("cygpath -m /tmp/vim-syntastic-javac"), '\%x00', '', 'g') + let g:syntastic_java_javac_temp_dir=s:CygwinPath('/tmp/vim-syntastic-javac') else let g:syntastic_java_javac_temp_dir = '/tmp/vim-syntastic-javac' endif @@ -72,6 +76,16 @@ if !exists("g:syntastic_java_javac_maven_pom_classpath") let g:syntastic_java_javac_maven_pom_classpath = '' endif +function! s:RemoveCarriageReturn(line) + return substitute(a:line, '\r', '', 'g') +endfunction + +function! s:RemoveCarriageReturns(errors) + for error in a:errors + let error['text'] = s:RemoveCarriageReturn(error['text']) + endfor +endfunction + " recursively remove directory and all it's sub-directories function! s:RemoveDir(dir) if isdirectory(a:dir) @@ -152,7 +166,7 @@ function! s:GetMavenClasspath() let class_path_next = 0 for line in mvn_classpath_output if class_path_next == 1 - let mvn_classpath = substitute(line, '\r', '', 'g') + let mvn_classpath = s:RemoveCarriageReturn(line) break endif if match(line,'Dependencies classpath:') >= 0 @@ -174,6 +188,23 @@ function! SyntaxCheckers_java_javac_IsAvailable() return executable(g:syntastic_java_javac_executable) endfunction +function! s:MavenOutputDirectory() + if filereadable('pom.xml') + let output_dir = getcwd() + if match(expand( '%:p:h' ), "src.main.java") >= 0 + let output_dir .= '/target/classes' + endif + if match(expand( '%:p:h' ), "src.test.java") >= 0 + let output_dir .= '/target/test-classes' + endif + + if has('win32unix') + let output_dir=s:CygwinPath(output_dir) + endif + return output_dir + endif +endfunction + function! SyntaxCheckers_java_javac_GetLocList() let javac_opts = g:syntastic_java_javac_options @@ -212,6 +243,10 @@ function! SyntaxCheckers_java_javac_GetLocList() endfor if g:syntastic_java_javac_autoload_maven_classpath + if !g:syntastic_java_javac_delete_output + let maven_output_dir = s:MavenOutputDirectory() + let javac_opts .= ' -d ' . maven_output_dir + endif let maven_classpath = s:GetMavenClasspath() let javac_classpath = s:AddToClasspath(javac_classpath,maven_classpath) endif @@ -230,7 +265,7 @@ function! SyntaxCheckers_java_javac_GetLocList() let fname = fnameescape(expand ( '%:p:h' ) . sep . expand ( '%:t' )) if has('win32unix') - let fname = substitute(system("cygpath -m " . fname), '\%x00', '', 'g') + let fname = s:CygwinPath(fname) endif let makeprg = syntastic#makeprg#build({ @@ -246,11 +281,16 @@ function! SyntaxCheckers_java_javac_GetLocList() if g:syntastic_java_javac_delete_output silent! call mkdir(output_dir,'p') endif - let r = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + let errors = SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) + + if has('win32unix') + call s:RemoveCarriageReturns(errors) + endif + if g:syntastic_java_javac_delete_output call s:RemoveDir(output_dir) endif - return r + return errors endfunction