Skip to content

Add support for C++ #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ SQL can be used from a variety of languages. Each development language (PHP, Pe
different filetypes, so that it can understand and correctly parse a SQL statement.

The current supported languages are:
PHP, Java, JSP, JavaScript, JProperties, Perl, SQL, Vim
PHP, Java, JSP, JavaScript, JProperties, C++, Perl, SQL, Vim

For example assume you had the following Java code:
String mySQL =
Expand Down
14 changes: 10 additions & 4 deletions autoload/dbext.vim
Original file line number Diff line number Diff line change
Expand Up @@ -6580,11 +6580,11 @@ function! dbext#DB_auBufDelete(del_buf_nr) "{{{
silent! exec cur_buf.'buffer'

" Switch back value of 'bufhidden' and syntax
if !empty(cur_bufhidden)
"if !empty(cur_bufhidden)
exec "setlocal bufhidden=".cur_bufhidden
exec "setlocal syntax=".cur_syntax
exec "setlocal filetype=".cur_filetype
endif
"endif
endif
endfunction "}}}
"}}}
Expand Down Expand Up @@ -7367,7 +7367,8 @@ function! dbext#DB_parseQuery(query)
\ matchstr( l:filetype, "cs" ) == "cs" ||
\ matchstr( l:filetype, "jsp" ) == "jsp" ||
\ matchstr( l:filetype, "html" ) == "html" ||
\ matchstr( l:filetype, "javascript" ) == "javascript"
\ matchstr( l:filetype, "javascript" ) == "javascript" ||
\ matchstr( l:filetype, "cpp" ) == "cpp"
let query = s:DB_parseJava(a:query)
return s:DB_parseHostVariables(query)
elseif matchstr( l:filetype, "jproperties" ) == "jproperties"
Expand Down Expand Up @@ -7869,9 +7870,14 @@ function! s:DB_parsePHP(query)
endfunction
"}}}

" Java, JSP, JavaScript Parser {{{
" Java, JSP, JavaScript, C++ Parser {{{
function! s:DB_parseJava(query)
let query = a:query

" Strip stand alone quotes at the begin and end (string continuation in
" C++)
let query = substitute(query, '\v"\s*\n\s*"', ' ', 'g')

" Remove any newline characters
let query = substitute(query, "\n", ' ', 'g')

Expand Down