mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 14:26:07 +00:00
Merge pull request #20545 from lewis6991/remove_cscope
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
#include "nvim/getchar.h"
|
||||
#include "nvim/help.h"
|
||||
#include "nvim/highlight_group.h"
|
||||
#include "nvim/if_cscope.h"
|
||||
#include "nvim/locale.h"
|
||||
#include "nvim/lua/executor.h"
|
||||
#include "nvim/mapping.h"
|
||||
@@ -1419,11 +1418,6 @@ static const char *set_context_by_cmdname(const char *cmd, cmdidx_T cmdidx, cons
|
||||
case CMD_highlight:
|
||||
set_context_in_highlight_cmd(xp, arg);
|
||||
break;
|
||||
case CMD_cscope:
|
||||
case CMD_lcscope:
|
||||
case CMD_scscope:
|
||||
set_context_in_cscope_cmd(xp, arg, cmdidx);
|
||||
break;
|
||||
case CMD_sign:
|
||||
set_context_in_sign_cmd(xp, (char *)arg);
|
||||
break;
|
||||
@@ -2063,7 +2057,6 @@ static int ExpandOther(expand_T *xp, regmatch_T *rmp, int *num_file, char ***fil
|
||||
{ EXPAND_HIGHLIGHT, (ExpandFunc)get_highlight_name, true, false },
|
||||
{ EXPAND_EVENTS, expand_get_event_name, true, false },
|
||||
{ EXPAND_AUGROUP, expand_get_augroup_name, true, false },
|
||||
{ EXPAND_CSCOPE, get_cscope_name, true, true },
|
||||
{ EXPAND_SIGN, get_sign_name, true, true },
|
||||
{ EXPAND_PROFILE, get_profile_name, true, true },
|
||||
#ifdef HAVE_WORKING_LIBINTL
|
||||
@@ -2883,11 +2876,6 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
xpc.xp_pattern_len = strlen(xpc.xp_pattern);
|
||||
}
|
||||
|
||||
if (xpc.xp_context == EXPAND_CSCOPE) {
|
||||
set_context_in_cscope_cmd(&xpc, (const char *)xpc.xp_pattern, CMD_cscope);
|
||||
xpc.xp_pattern_len = strlen(xpc.xp_pattern);
|
||||
}
|
||||
|
||||
if (xpc.xp_context == EXPAND_SIGN) {
|
||||
set_context_in_sign_cmd(&xpc, xpc.xp_pattern);
|
||||
xpc.xp_pattern_len = strlen(xpc.xp_pattern);
|
||||
|
@@ -88,7 +88,6 @@ return {
|
||||
cos={args=1, base=1, float_func="cos"},
|
||||
cosh={args=1, base=1, float_func="cosh"},
|
||||
count={args={2, 4}, base=1},
|
||||
cscope_connection={args={0, 3}},
|
||||
ctxget={args={0, 1}},
|
||||
ctxpop={},
|
||||
ctxpush={args={0, 1}},
|
||||
|
@@ -39,7 +39,6 @@
|
||||
#include "nvim/getchar.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/highlight_group.h"
|
||||
#include "nvim/if_cscope.h"
|
||||
#include "nvim/indent.h"
|
||||
#include "nvim/indent_c.h"
|
||||
#include "nvim/input.h"
|
||||
@@ -1132,29 +1131,6 @@ static void f_count(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
rettv->vval.v_number = n;
|
||||
}
|
||||
|
||||
/// "cscope_connection([{num} , {dbpath} [, {prepend}]])" function
|
||||
///
|
||||
/// Checks the existence of a cscope connection.
|
||||
static void f_cscope_connection(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
int num = 0;
|
||||
const char *dbpath = NULL;
|
||||
const char *prepend = NULL;
|
||||
char buf[NUMBUFLEN];
|
||||
|
||||
if (argvars[0].v_type != VAR_UNKNOWN
|
||||
&& argvars[1].v_type != VAR_UNKNOWN) {
|
||||
num = (int)tv_get_number(&argvars[0]);
|
||||
dbpath = tv_get_string(&argvars[1]);
|
||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||
prepend = tv_get_string_buf(&argvars[2], buf);
|
||||
}
|
||||
}
|
||||
|
||||
rettv->vval.v_number = cs_connection(num, (char_u *)dbpath,
|
||||
(char_u *)prepend);
|
||||
}
|
||||
|
||||
/// "ctxget([{index}])" function
|
||||
static void f_ctxget(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
{
|
||||
@@ -3565,7 +3541,6 @@ static void f_has(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||
"cmdwin",
|
||||
"comments",
|
||||
"conceal",
|
||||
"cscope",
|
||||
"cursorbind",
|
||||
"cursorshape",
|
||||
#ifdef DEBUG
|
||||
|
@@ -672,18 +672,6 @@ module.cmds = {
|
||||
addr_type='ADDR_UNSIGNED',
|
||||
func='ex_cc',
|
||||
},
|
||||
{
|
||||
command='cscope',
|
||||
flags=bit.bor(EXTRA, NOTRLCOM, XFILE),
|
||||
addr_type='ADDR_NONE',
|
||||
func='ex_cscope',
|
||||
},
|
||||
{
|
||||
command='cstag',
|
||||
flags=bit.bor(BANG, TRLBAR, WORD1),
|
||||
addr_type='ADDR_NONE',
|
||||
func='ex_cstag',
|
||||
},
|
||||
{
|
||||
command='cunmap',
|
||||
flags=bit.bor(EXTRA, TRLBAR, NOTRLCOM, CTRLV, CMDWIN, LOCK_OK),
|
||||
@@ -1404,12 +1392,6 @@ module.cmds = {
|
||||
addr_type='ADDR_OTHER',
|
||||
func='ex_cclose',
|
||||
},
|
||||
{
|
||||
command='lcscope',
|
||||
flags=bit.bor(EXTRA, NOTRLCOM, XFILE),
|
||||
addr_type='ADDR_NONE',
|
||||
func='ex_cscope',
|
||||
},
|
||||
{
|
||||
command='ldo',
|
||||
flags=bit.bor(BANG, NEEDARG, EXTRA, NOTRLCOM, RANGE, DFLALL),
|
||||
@@ -2421,12 +2403,6 @@ module.cmds = {
|
||||
addr_type='ADDR_NONE',
|
||||
func='ex_scriptencoding',
|
||||
},
|
||||
{
|
||||
command='scscope',
|
||||
flags=bit.bor(EXTRA, NOTRLCOM),
|
||||
addr_type='ADDR_NONE',
|
||||
func='ex_scscope',
|
||||
},
|
||||
{
|
||||
command='set',
|
||||
flags=bit.bor(BANG, TRLBAR, EXTRA, CMDWIN, LOCK_OK, SBOXOK),
|
||||
|
@@ -44,7 +44,6 @@
|
||||
#include "nvim/hardcopy.h"
|
||||
#include "nvim/help.h"
|
||||
#include "nvim/highlight_group.h"
|
||||
#include "nvim/if_cscope.h"
|
||||
#include "nvim/input.h"
|
||||
#include "nvim/keycodes.h"
|
||||
#include "nvim/locale.h"
|
||||
@@ -6589,10 +6588,6 @@ static void ex_tag_cmd(exarg_T *eap, char *name)
|
||||
cmd = DT_LAST; // ":tlast"
|
||||
break;
|
||||
default: // ":tag"
|
||||
if (p_cst && *eap->arg != NUL) {
|
||||
ex_cstag(eap);
|
||||
return;
|
||||
}
|
||||
cmd = DT_TAG;
|
||||
break;
|
||||
}
|
||||
|
@@ -182,8 +182,7 @@ Additionally uses the following environment variables:
|
||||
If set to 1 then all generated declarations receive a comment with file
|
||||
name and line number after the declaration. This may be useful for
|
||||
debugging gen_declarations script, but not much beyond that with
|
||||
configured development environment (i.e. with ctags/cscope/finding
|
||||
definitions with clang/etc).
|
||||
configured development environment (i.e. with with clang/etc).
|
||||
|
||||
WARNING: setting this to 1 will cause extensive rebuilds: declarations
|
||||
generator script will not regenerate non-static.h file if its
|
||||
|
2027
src/nvim/if_cscope.c
2027
src/nvim/if_cscope.c
File diff suppressed because it is too large
Load Diff
@@ -1,10 +0,0 @@
|
||||
#ifndef NVIM_IF_CSCOPE_H
|
||||
#define NVIM_IF_CSCOPE_H
|
||||
|
||||
#include "nvim/ex_cmds_defs.h" // for exarg_T
|
||||
#include "nvim/types.h" // for char_u and expand_T
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "if_cscope.h.generated.h"
|
||||
#endif
|
||||
#endif // NVIM_IF_CSCOPE_H
|
@@ -1,64 +0,0 @@
|
||||
#ifndef NVIM_IF_CSCOPE_DEFS_H
|
||||
#define NVIM_IF_CSCOPE_DEFS_H
|
||||
|
||||
// CSCOPE support for Vim added by Andy Kahn <kahn@zk3.dec.com>
|
||||
// Ported to Win32 by Sergey Khorev <sergey.khorev@gmail.com>
|
||||
//
|
||||
// The basic idea/structure of cscope for Vim was borrowed from Nvi.
|
||||
// There might be a few lines of code that look similar to what Nvi
|
||||
// has. If this is a problem and requires inclusion of the annoying
|
||||
// BSD license, then sue me; I'm not worth much anyway.
|
||||
|
||||
#if defined(UNIX)
|
||||
# include <sys/types.h> // pid_t
|
||||
#endif
|
||||
|
||||
#include "nvim/ex_cmds_defs.h"
|
||||
#include "nvim/os/fs_defs.h"
|
||||
#include "nvim/os/os_defs.h"
|
||||
|
||||
#define CSCOPE_SUCCESS 0
|
||||
#define CSCOPE_FAILURE -1
|
||||
|
||||
#define CSCOPE_DBFILE "cscope.out"
|
||||
#define CSCOPE_PROMPT ">> "
|
||||
|
||||
// See ":help cscope-find" for the possible queries.
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int (*func)(exarg_T *eap);
|
||||
char *help;
|
||||
char *usage;
|
||||
int cansplit; // if supports splitting window
|
||||
} cscmd_T;
|
||||
|
||||
typedef struct csi {
|
||||
char *fname; // cscope db name
|
||||
char *ppath; // path to prepend (the -P option)
|
||||
char *flags; // additional cscope flags/options (e.g, -p2)
|
||||
#if defined(UNIX)
|
||||
pid_t pid; // PID of the connected cscope process
|
||||
#else
|
||||
DWORD pid; // PID of the connected cscope process
|
||||
HANDLE hProc; // cscope process handle
|
||||
DWORD nVolume; // Volume serial number, instead of st_dev
|
||||
DWORD nIndexHigh; // st_ino has no meaning on Windows
|
||||
DWORD nIndexLow;
|
||||
#endif
|
||||
FileID file_id;
|
||||
|
||||
FILE *fr_fp; // from cscope: FILE.
|
||||
FILE *to_fp; // to cscope: FILE.
|
||||
} csinfo_T;
|
||||
|
||||
typedef enum { Add, Find, Help, Kill, Reset, Show, } csid_e;
|
||||
|
||||
typedef enum {
|
||||
Store,
|
||||
Get,
|
||||
Free,
|
||||
Print,
|
||||
} mcmd_e;
|
||||
|
||||
#endif // NVIM_IF_CSCOPE_DEFS_H
|
@@ -31,7 +31,6 @@
|
||||
#include "nvim/highlight.h"
|
||||
#include "nvim/highlight_group.h"
|
||||
#include "nvim/iconv.h"
|
||||
#include "nvim/if_cscope.h"
|
||||
#include "nvim/insexpand.h"
|
||||
#include "nvim/locale.h"
|
||||
#include "nvim/log.h"
|
||||
@@ -772,7 +771,6 @@ void getout(int exitval)
|
||||
ui_call_set_title(cstr_as_string((char *)p_titleold));
|
||||
}
|
||||
|
||||
cs_end();
|
||||
if (garbage_collect_at_exit) {
|
||||
garbage_collect(false);
|
||||
}
|
||||
|
@@ -4313,11 +4313,7 @@ static void nv_ident(cmdarg_T *cap)
|
||||
|
||||
case ']':
|
||||
tag_cmd = true;
|
||||
if (p_cst) {
|
||||
STRCPY(buf, "cstag ");
|
||||
} else {
|
||||
STRCPY(buf, "ts ");
|
||||
}
|
||||
STRCPY(buf, "ts ");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -471,15 +471,6 @@ EXTERN long p_ph; // 'pumheight'
|
||||
EXTERN long p_pw; // 'pumwidth'
|
||||
EXTERN char *p_com; ///< 'comments'
|
||||
EXTERN char *p_cpo; // 'cpoptions'
|
||||
EXTERN char *p_csprg; // 'cscopeprg'
|
||||
EXTERN int p_csre; // 'cscoperelative'
|
||||
EXTERN char *p_csqf; // 'cscopequickfix'
|
||||
#define CSQF_CMDS "sgdctefia"
|
||||
#define CSQF_FLAGS "+-0"
|
||||
EXTERN int p_cst; // 'cscopetag'
|
||||
EXTERN long p_csto; // 'cscopetagorder'
|
||||
EXTERN long p_cspc; // 'cscopepathcomp'
|
||||
EXTERN int p_csverbose; // 'cscopeverbose'
|
||||
EXTERN char *p_debug; // 'debug'
|
||||
EXTERN char *p_def; // 'define'
|
||||
EXTERN char *p_inc;
|
||||
|
@@ -495,58 +495,6 @@ return {
|
||||
varname='p_cpo',
|
||||
defaults={if_true=macros('CPO_VIM')}
|
||||
},
|
||||
{
|
||||
full_name='cscopepathcomp', abbreviation='cspc',
|
||||
short_desc=N_("how many components of the path to show"),
|
||||
type='number', scope={'global'},
|
||||
varname='p_cspc',
|
||||
defaults={if_true=0}
|
||||
},
|
||||
{
|
||||
full_name='cscopeprg', abbreviation='csprg',
|
||||
short_desc=N_("command to execute cscope"),
|
||||
type='string', scope={'global'},
|
||||
secure=true,
|
||||
expand=true,
|
||||
varname='p_csprg',
|
||||
defaults={if_true="cscope"}
|
||||
},
|
||||
{
|
||||
full_name='cscopequickfix', abbreviation='csqf',
|
||||
short_desc=N_("use quickfix window for cscope results"),
|
||||
type='string', list='onecomma', scope={'global'},
|
||||
deny_duplicates=true,
|
||||
varname='p_csqf',
|
||||
defaults={if_true=""}
|
||||
},
|
||||
{
|
||||
full_name='cscoperelative', abbreviation='csre',
|
||||
short_desc=N_("Use cscope.out path basename as prefix"),
|
||||
type='bool', scope={'global'},
|
||||
varname='p_csre',
|
||||
defaults={if_true=0}
|
||||
},
|
||||
{
|
||||
full_name='cscopetag', abbreviation='cst',
|
||||
short_desc=N_("use cscope for tag commands"),
|
||||
type='bool', scope={'global'},
|
||||
varname='p_cst',
|
||||
defaults={if_true=0}
|
||||
},
|
||||
{
|
||||
full_name='cscopetagorder', abbreviation='csto',
|
||||
short_desc=N_("determines \":cstag\" search order"),
|
||||
type='number', scope={'global'},
|
||||
varname='p_csto',
|
||||
defaults={if_true=0}
|
||||
},
|
||||
{
|
||||
full_name='cscopeverbose', abbreviation='csverb',
|
||||
short_desc=N_("give messages when adding a cscope database"),
|
||||
type='bool', scope={'global'},
|
||||
varname='p_csverbose',
|
||||
defaults={if_true=1}
|
||||
},
|
||||
{
|
||||
full_name='cursorbind', abbreviation='crb',
|
||||
short_desc=N_("move cursor in window as it moves in other windows"),
|
||||
|
@@ -1375,23 +1375,6 @@ char *did_set_string_option(int opt_idx, char **varp, char *oldval, char *errbuf
|
||||
coladvance(curwin->w_virtcol);
|
||||
}
|
||||
}
|
||||
} else if (varp == &p_csqf) {
|
||||
if (p_csqf != NULL) {
|
||||
p = p_csqf;
|
||||
while (*p != NUL) {
|
||||
if (vim_strchr(CSQF_CMDS, *p) == NULL
|
||||
|| p[1] == NUL
|
||||
|| vim_strchr(CSQF_FLAGS, p[1]) == NULL
|
||||
|| (p[2] != NUL && p[2] != ',')) {
|
||||
errmsg = e_invarg;
|
||||
break;
|
||||
} else if (p[2] == NUL) {
|
||||
break;
|
||||
} else {
|
||||
p += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (gvarp == &p_cino) { // 'cinoptions'
|
||||
// TODO(vim): recognize errors
|
||||
parse_cino(curbuf);
|
||||
|
241
src/nvim/tag.c
241
src/nvim/tag.c
@@ -24,7 +24,6 @@
|
||||
#include "nvim/fold.h"
|
||||
#include "nvim/garray.h"
|
||||
#include "nvim/help.h"
|
||||
#include "nvim/if_cscope.h"
|
||||
#include "nvim/input.h"
|
||||
#include "nvim/insexpand.h"
|
||||
#include "nvim/mark.h"
|
||||
@@ -132,16 +131,13 @@ static int tfu_in_use = false; // disallow recursive call of tagfunc
|
||||
/// type == DT_LAST: jump to last match of same tag
|
||||
/// type == DT_SELECT: ":tselect [tag]", select tag from a list of all matches
|
||||
/// type == DT_JUMP: ":tjump [tag]", jump to tag or select tag from a list
|
||||
/// type == DT_CSCOPE: use cscope to find the tag
|
||||
/// type == DT_LTAG: use location list for displaying tag matches
|
||||
/// type == DT_FREE: free cached matches
|
||||
///
|
||||
/// for cscope, returns true if we jumped to tag or aborted, false otherwise
|
||||
///
|
||||
/// @param tag tag (pattern) to jump to
|
||||
/// @param forceit :ta with !
|
||||
/// @param verbose print "tag not found" message
|
||||
bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
void do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
{
|
||||
taggy_T *tagstack = curwin->w_tagstack;
|
||||
int tagstackidx = curwin->w_tagstackidx;
|
||||
@@ -158,7 +154,6 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
int error_cur_match = 0;
|
||||
int save_pos = false;
|
||||
fmark_T saved_fmark;
|
||||
bool jumped_to_tag = false;
|
||||
int new_num_matches;
|
||||
char **new_matches;
|
||||
int use_tagstack;
|
||||
@@ -174,16 +169,15 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
|
||||
if (tfu_in_use) {
|
||||
emsg(_(recurmsg));
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef EXITFREE
|
||||
if (type == DT_FREE) {
|
||||
// remove the list of matches
|
||||
FreeWild(num_matches, matches);
|
||||
cs_free_tags();
|
||||
num_matches = 0;
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -219,8 +213,7 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
// new pattern, add to the tag stack
|
||||
if (*tag != NUL
|
||||
&& (type == DT_TAG || type == DT_SELECT || type == DT_JUMP
|
||||
|| type == DT_LTAG
|
||||
|| type == DT_CSCOPE)) {
|
||||
|| type == DT_LTAG)) {
|
||||
if (g_do_tagpreview != 0) {
|
||||
if (ptag_entry.tagname != NULL
|
||||
&& strcmp(ptag_entry.tagname, tag) == 0) {
|
||||
@@ -311,7 +304,6 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
|
||||
// remove the old list of matches
|
||||
FreeWild(num_matches, matches);
|
||||
cs_free_tags();
|
||||
num_matches = 0;
|
||||
tag_freematch();
|
||||
goto end_do_tag;
|
||||
@@ -360,7 +352,6 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
cur_match = count - 1; break;
|
||||
case DT_SELECT:
|
||||
case DT_JUMP:
|
||||
case DT_CSCOPE:
|
||||
case DT_LAST:
|
||||
cur_match = MAXCOL - 1; break;
|
||||
case DT_NEXT:
|
||||
@@ -454,9 +445,6 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
flags = TAG_NOIC;
|
||||
}
|
||||
|
||||
if (type == DT_CSCOPE) {
|
||||
flags = TAG_CSCOPE;
|
||||
}
|
||||
if (verbose) {
|
||||
flags |= TAG_VERBOSE;
|
||||
}
|
||||
@@ -509,10 +497,7 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
} else {
|
||||
bool ask_for_selection = false;
|
||||
|
||||
if (type == DT_CSCOPE && num_matches > 1) {
|
||||
cs_print_tags();
|
||||
ask_for_selection = true;
|
||||
} else if (type == DT_TAG && *tag != NUL) {
|
||||
if (type == DT_TAG && *tag != NUL) {
|
||||
// If a count is supplied to the ":tag <name>" command, then
|
||||
// jump to count'th matching tag.
|
||||
cur_match = count > 0 ? count - 1 : 0;
|
||||
@@ -536,8 +521,6 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
tagstack[tagstackidx].fmark = saved_fmark;
|
||||
tagstackidx = prevtagstackidx;
|
||||
}
|
||||
cs_free_tags();
|
||||
jumped_to_tag = true;
|
||||
break;
|
||||
}
|
||||
cur_match = i - 1;
|
||||
@@ -586,7 +569,6 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
|
||||
ic = (matches[cur_match][0] & MT_IC_OFF);
|
||||
if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP
|
||||
&& type != DT_CSCOPE
|
||||
&& (num_matches > 1 || ic)
|
||||
&& !skip_msg) {
|
||||
// Give an indication of the number of matching tags
|
||||
@@ -619,7 +601,7 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
set_vim_var_string(VV_SWAPCOMMAND, (char *)IObuff, -1);
|
||||
|
||||
// Jump to the desired match.
|
||||
i = jumpto_tag((char_u *)matches[cur_match], forceit, type != DT_CSCOPE);
|
||||
i = jumpto_tag((char_u *)matches[cur_match], forceit, true);
|
||||
|
||||
set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);
|
||||
|
||||
@@ -649,7 +631,6 @@ bool do_tag(char *tag, int type, int count, int forceit, int verbose)
|
||||
if (use_tagstack && tagstackidx > curwin->w_tagstacklen) {
|
||||
tagstackidx = curwin->w_tagstackidx;
|
||||
}
|
||||
jumped_to_tag = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -663,7 +644,7 @@ end_do_tag:
|
||||
postponed_split = 0; // don't split next time
|
||||
g_do_tagpreview = 0; // don't do tag preview next time
|
||||
|
||||
return jumped_to_tag;
|
||||
return;
|
||||
}
|
||||
|
||||
// List all the matching tags.
|
||||
@@ -1324,7 +1305,6 @@ static int find_tagfunc_tags(char_u *pat, garray_T *ga, int *match_count, int fl
|
||||
/// TAG_REGEXP use "pat" as a regexp
|
||||
/// TAG_NOIC don't always ignore case
|
||||
/// TAG_KEEP_LANG keep language
|
||||
/// TAG_CSCOPE use cscope results for tags
|
||||
/// TAG_NO_TAGFUNC do not call the 'tagfunc' function
|
||||
///
|
||||
/// @param pat pattern to search for
|
||||
@@ -1409,7 +1389,6 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
|
||||
int name_only = (flags & TAG_NAMES);
|
||||
int noic = (flags & TAG_NOIC);
|
||||
int get_it_again = false;
|
||||
int use_cscope = (flags & TAG_CSCOPE);
|
||||
int verbose = (flags & TAG_VERBOSE);
|
||||
int use_tfu = ((flags & TAG_NO_TAGFUNC) == 0);
|
||||
int save_p_ic = p_ic;
|
||||
@@ -1448,15 +1427,9 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
|
||||
hash_init(&ht_match[mtt]);
|
||||
}
|
||||
|
||||
STRCPY(tag_fname, "from cscope"); // for error messages
|
||||
|
||||
// Initialize a few variables
|
||||
if (help_only) { // want tags from help file
|
||||
curbuf->b_help = true; // will be restored later
|
||||
} else if (use_cscope) {
|
||||
// Make sure we don't mix help and cscope, confuses Coverity.
|
||||
help_only = false;
|
||||
curbuf->b_help = false;
|
||||
}
|
||||
|
||||
orgpat.len = (int)strlen(pat);
|
||||
@@ -1522,77 +1495,74 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
|
||||
|
||||
// Try tag file names from tags option one by one.
|
||||
for (first_file = true;
|
||||
use_cscope || get_tagfname(&tn, first_file, (char *)tag_fname) == OK;
|
||||
get_tagfname(&tn, first_file, (char *)tag_fname) == OK;
|
||||
first_file = false) {
|
||||
// A file that doesn't exist is silently ignored. Only when not a
|
||||
// single file is found, an error message is given (further on).
|
||||
if (use_cscope) {
|
||||
fp = NULL; // avoid GCC warning
|
||||
} else {
|
||||
if (curbuf->b_help) {
|
||||
// Keep en if the file extension is .txt
|
||||
if (is_txt) {
|
||||
if (curbuf->b_help) {
|
||||
// Keep en if the file extension is .txt
|
||||
if (is_txt) {
|
||||
STRCPY(help_lang, "en");
|
||||
} else {
|
||||
// Prefer help tags according to 'helplang'. Put the
|
||||
// two-letter language name in help_lang[].
|
||||
i = (int)STRLEN(tag_fname);
|
||||
if (i > 3 && tag_fname[i - 3] == '-') {
|
||||
STRCPY(help_lang, tag_fname + i - 2);
|
||||
} else {
|
||||
STRCPY(help_lang, "en");
|
||||
} else {
|
||||
// Prefer help tags according to 'helplang'. Put the
|
||||
// two-letter language name in help_lang[].
|
||||
i = (int)STRLEN(tag_fname);
|
||||
if (i > 3 && tag_fname[i - 3] == '-') {
|
||||
STRCPY(help_lang, tag_fname + i - 2);
|
||||
} else {
|
||||
STRCPY(help_lang, "en");
|
||||
}
|
||||
}
|
||||
|
||||
// When searching for a specific language skip tags files
|
||||
// for other languages.
|
||||
if (help_lang_find != NULL
|
||||
&& STRICMP(help_lang, help_lang_find) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// For CTRL-] in a help file prefer a match with the same
|
||||
// language.
|
||||
if ((flags & TAG_KEEP_LANG)
|
||||
&& help_lang_find == NULL
|
||||
&& curbuf->b_fname != NULL
|
||||
&& (i = (int)strlen(curbuf->b_fname)) > 4
|
||||
&& curbuf->b_fname[i - 1] == 'x'
|
||||
&& curbuf->b_fname[i - 4] == '.'
|
||||
&& STRNICMP(curbuf->b_fname + i - 3, help_lang, 2) == 0) {
|
||||
help_pri = 0;
|
||||
} else {
|
||||
help_pri = 1;
|
||||
for (s = p_hlg; *s != NUL; s++) {
|
||||
if (STRNICMP(s, help_lang, 2) == 0) {
|
||||
break;
|
||||
}
|
||||
help_pri++;
|
||||
if ((s = (char_u *)vim_strchr((char *)s, ',')) == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s == NULL || *s == NUL) {
|
||||
// Language not in 'helplang': use last, prefer English,
|
||||
// unless found already.
|
||||
help_pri++;
|
||||
if (STRICMP(help_lang, "en") != 0) {
|
||||
help_pri++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((fp = os_fopen((char *)tag_fname, "r")) == NULL) {
|
||||
// When searching for a specific language skip tags files
|
||||
// for other languages.
|
||||
if (help_lang_find != NULL
|
||||
&& STRICMP(help_lang, help_lang_find) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_verbose >= 5) {
|
||||
verbose_enter();
|
||||
smsg(_("Searching tags file %s"), tag_fname);
|
||||
verbose_leave();
|
||||
// For CTRL-] in a help file prefer a match with the same
|
||||
// language.
|
||||
if ((flags & TAG_KEEP_LANG)
|
||||
&& help_lang_find == NULL
|
||||
&& curbuf->b_fname != NULL
|
||||
&& (i = (int)strlen(curbuf->b_fname)) > 4
|
||||
&& curbuf->b_fname[i - 1] == 'x'
|
||||
&& curbuf->b_fname[i - 4] == '.'
|
||||
&& STRNICMP(curbuf->b_fname + i - 3, help_lang, 2) == 0) {
|
||||
help_pri = 0;
|
||||
} else {
|
||||
help_pri = 1;
|
||||
for (s = p_hlg; *s != NUL; s++) {
|
||||
if (STRNICMP(s, help_lang, 2) == 0) {
|
||||
break;
|
||||
}
|
||||
help_pri++;
|
||||
if ((s = (char_u *)vim_strchr((char *)s, ',')) == NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (s == NULL || *s == NUL) {
|
||||
// Language not in 'helplang': use last, prefer English,
|
||||
// unless found already.
|
||||
help_pri++;
|
||||
if (STRICMP(help_lang, "en") != 0) {
|
||||
help_pri++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((fp = os_fopen((char *)tag_fname, "r")) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_verbose >= 5) {
|
||||
verbose_enter();
|
||||
smsg(_("Searching tags file %s"), tag_fname);
|
||||
verbose_leave();
|
||||
}
|
||||
|
||||
did_open = true; // remember that we found at least one file
|
||||
|
||||
state = TS_START; // we're at the start of the file
|
||||
@@ -1676,9 +1646,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
|
||||
|
||||
// skip empty and blank lines
|
||||
do {
|
||||
eof = use_cscope
|
||||
? cs_fgets(lbuf, lbuf_size)
|
||||
: vim_fgets(lbuf, lbuf_size, fp);
|
||||
eof = vim_fgets(lbuf, lbuf_size, fp);
|
||||
} while (!eof && vim_isblankline((char *)lbuf));
|
||||
|
||||
if (eof) {
|
||||
@@ -1745,8 +1713,7 @@ line_read_in:
|
||||
// the tag file isn't sorted, the second loop will find it.
|
||||
// When "!_TAG_FILE_SORTED" found: start binary search if
|
||||
// flag set.
|
||||
// For cscope, it's always linear.
|
||||
if (linear || use_cscope) {
|
||||
if (linear) {
|
||||
state = TS_LINEAR;
|
||||
} else if (tag_file_sorted == NUL) {
|
||||
state = TS_BINARY;
|
||||
@@ -1797,7 +1764,7 @@ parse_line:
|
||||
// last-but-one byte (see vim_fgets()).
|
||||
// Has been reported for Mozilla JS with extremely long names.
|
||||
// In that case we need to increase lbuf_size.
|
||||
if (lbuf[lbuf_size - 2] != NUL && !use_cscope) {
|
||||
if (lbuf[lbuf_size - 2] != NUL) {
|
||||
lbuf_size *= 2;
|
||||
xfree(lbuf);
|
||||
lbuf = xmalloc((size_t)lbuf_size);
|
||||
@@ -1985,37 +1952,32 @@ parse_line:
|
||||
if (match) {
|
||||
size_t len = 0;
|
||||
|
||||
if (use_cscope) {
|
||||
// Don't change the ordering, always use the same table.
|
||||
mtt = MT_GL_OTH;
|
||||
} else {
|
||||
// Decide in which array to store this match.
|
||||
is_current = test_for_current((char *)tagp.fname, (char *)tagp.fname_end,
|
||||
(char *)tag_fname,
|
||||
buf_ffname);
|
||||
is_static = test_for_static(&tagp);
|
||||
// Decide in which array to store this match.
|
||||
is_current = test_for_current((char *)tagp.fname, (char *)tagp.fname_end,
|
||||
(char *)tag_fname,
|
||||
buf_ffname);
|
||||
is_static = test_for_static(&tagp);
|
||||
|
||||
// Decide in which of the sixteen tables to store this match.
|
||||
if (is_static) {
|
||||
if (is_current) {
|
||||
mtt = MT_ST_CUR;
|
||||
} else {
|
||||
mtt = MT_ST_OTH;
|
||||
}
|
||||
// Decide in which of the sixteen tables to store this match.
|
||||
if (is_static) {
|
||||
if (is_current) {
|
||||
mtt = MT_ST_CUR;
|
||||
} else {
|
||||
if (is_current) {
|
||||
mtt = MT_GL_CUR;
|
||||
} else {
|
||||
mtt = MT_GL_OTH;
|
||||
}
|
||||
mtt = MT_ST_OTH;
|
||||
}
|
||||
if (orgpat.regmatch.rm_ic && !match_no_ic) {
|
||||
mtt += MT_IC_OFF;
|
||||
}
|
||||
if (match_re) {
|
||||
mtt += MT_RE_OFF;
|
||||
} else {
|
||||
if (is_current) {
|
||||
mtt = MT_GL_CUR;
|
||||
} else {
|
||||
mtt = MT_GL_OTH;
|
||||
}
|
||||
}
|
||||
if (orgpat.regmatch.rm_ic && !match_no_ic) {
|
||||
mtt += MT_IC_OFF;
|
||||
}
|
||||
if (match_re) {
|
||||
mtt += MT_RE_OFF;
|
||||
}
|
||||
|
||||
// Add the found match in ht_match[mtt] and ga_match[mtt].
|
||||
// Store the info we need later, which depends on the kind of
|
||||
@@ -2098,16 +2060,11 @@ parse_line:
|
||||
hashitem_T *hi;
|
||||
|
||||
// Don't add identical matches.
|
||||
// Add all cscope tags, because they are all listed.
|
||||
// "mfp" is used as a hash key, there is a NUL byte to end
|
||||
// the part that matters for comparing, more bytes may
|
||||
// follow after it. E.g. help tags store the priority
|
||||
// after the NUL.
|
||||
if (use_cscope) {
|
||||
hash++;
|
||||
} else {
|
||||
hash = hash_hash((char_u *)mfp);
|
||||
}
|
||||
hash = hash_hash((char_u *)mfp);
|
||||
hi = hash_lookup(&ht_match[mtt], (const char *)mfp,
|
||||
strlen(mfp), hash);
|
||||
if (HASHITEM_EMPTY(hi)) {
|
||||
@@ -2121,23 +2078,16 @@ parse_line:
|
||||
}
|
||||
}
|
||||
}
|
||||
if (use_cscope && eof) {
|
||||
break;
|
||||
}
|
||||
} // forever
|
||||
|
||||
if (line_error) {
|
||||
semsg(_("E431: Format error in tags file \"%s\""), tag_fname);
|
||||
if (!use_cscope) {
|
||||
semsg(_("Before byte %" PRId64), (int64_t)vim_ftell(fp));
|
||||
}
|
||||
semsg(_("Before byte %" PRId64), (int64_t)vim_ftell(fp));
|
||||
stop_searching = true;
|
||||
line_error = false;
|
||||
}
|
||||
|
||||
if (!use_cscope) {
|
||||
fclose(fp);
|
||||
}
|
||||
fclose(fp);
|
||||
if (vimconv.vc_type != CONV_NONE) {
|
||||
convert_setup(&vimconv, NULL, NULL);
|
||||
}
|
||||
@@ -2154,23 +2104,18 @@ parse_line:
|
||||
stop_searching = true;
|
||||
}
|
||||
|
||||
if (stop_searching || use_cscope) {
|
||||
if (stop_searching) {
|
||||
break;
|
||||
}
|
||||
} // end of for-each-file loop
|
||||
|
||||
if (!use_cscope) {
|
||||
tagname_free(&tn);
|
||||
}
|
||||
tagname_free(&tn);
|
||||
|
||||
// stop searching when already did a linear search, or when TAG_NOIC
|
||||
// used, and 'ignorecase' not set or already did case-ignore search
|
||||
if (stop_searching || linear || (!p_ic && noic) || orgpat.regmatch.rm_ic) {
|
||||
break;
|
||||
}
|
||||
if (use_cscope) {
|
||||
break;
|
||||
}
|
||||
orgpat.regmatch.rm_ic = true; // try another time while ignoring case
|
||||
}
|
||||
|
||||
@@ -2559,7 +2504,7 @@ static char_u *tag_full_fname(tagptrs_T *tagp)
|
||||
///
|
||||
/// @param lbuf_arg line from the tags file for this tag
|
||||
/// @param forceit :ta with !
|
||||
/// @param keep_help keep help flag (false for cscope)
|
||||
/// @param keep_help keep help flag
|
||||
///
|
||||
/// @return OK for success, NOTAGFILE when file not found, FAIL otherwise.
|
||||
static int jumpto_tag(const char_u *lbuf_arg, int forceit, int keep_help)
|
||||
|
@@ -14,7 +14,6 @@
|
||||
#define DT_SELECT 7 // jump to selection from list
|
||||
#define DT_HELP 8 // like DT_TAG, but no wildcards
|
||||
#define DT_JUMP 9 // jump to new tag or selection from list
|
||||
#define DT_CSCOPE 10 // cscope find command (like tjump)
|
||||
#define DT_LTAG 11 // tag using location list
|
||||
#define DT_FREE 99 // free cached matches
|
||||
|
||||
@@ -23,7 +22,6 @@
|
||||
#define TAG_NAMES 2 // only return name of tag
|
||||
#define TAG_REGEXP 4 // use tag pattern as regexp
|
||||
#define TAG_NOIC 8 // don't always ignore case
|
||||
#define TAG_CSCOPE 16 // cscope tag
|
||||
#define TAG_VERBOSE 32 // message verbosity
|
||||
#define TAG_INS_COMP 64 // Currently doing insert completion
|
||||
#define TAG_KEEP_LANG 128 // keep current language
|
||||
|
@@ -1,344 +0,0 @@
|
||||
" Test for cscope commands.
|
||||
|
||||
source check.vim
|
||||
CheckFeature cscope
|
||||
CheckFeature quickfix
|
||||
|
||||
if !executable('cscope')
|
||||
throw 'Skipped: cscope program missing'
|
||||
endif
|
||||
|
||||
func CscopeSetupOrClean(setup)
|
||||
if a:setup
|
||||
noa sp samples/memfile_test.c
|
||||
saveas! Xmemfile_test.c
|
||||
call system('cscope -bk -fXcscope.out Xmemfile_test.c')
|
||||
call system('cscope -bk -fXcscope2.out Xmemfile_test.c')
|
||||
cscope add Xcscope.out
|
||||
set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-,a-
|
||||
else
|
||||
cscope kill -1
|
||||
for file in ['Xcscope.out', 'Xcscope2.out', 'Xmemfile_test.c']
|
||||
call delete(file)
|
||||
endfo
|
||||
endif
|
||||
endfunc
|
||||
|
||||
func Test_cscopeWithCscopeConnections()
|
||||
call CscopeSetupOrClean(1)
|
||||
" Test: E568: duplicate cscope database not added
|
||||
try
|
||||
set nocscopeverbose
|
||||
cscope add Xcscope.out
|
||||
set cscopeverbose
|
||||
catch
|
||||
call assert_report('exception thrown')
|
||||
endtry
|
||||
call assert_fails('cscope add', 'E560')
|
||||
call assert_fails('cscope add Xcscope.out', 'E568')
|
||||
call assert_fails('cscope add doesnotexist.out', 'E563')
|
||||
if has('unix')
|
||||
call assert_fails('cscope add /dev/null', 'E564:')
|
||||
endif
|
||||
|
||||
" Test: Find this C-Symbol
|
||||
for cmd in ['cs find s main', 'cs find 0 main']
|
||||
let a = execute(cmd)
|
||||
" Test where it moves the cursor
|
||||
call assert_equal('main(void)', getline('.'))
|
||||
" Test the output of the :cs command
|
||||
call assert_match('\n(1 of 1): <<main>> main(void )', a)
|
||||
endfor
|
||||
|
||||
" Test: Find this definition
|
||||
for cmd in ['cs find g test_mf_hash',
|
||||
\ 'cs find 1 test_mf_hash',
|
||||
\ 'cs find 1 test_mf_hash'] " leading space ignored.
|
||||
exe cmd
|
||||
call assert_equal(['', '/*', ' * Test mf_hash_*() functions.', ' */', ' static void', 'test_mf_hash(void)', '{'], getline(line('.')-5, line('.')+1))
|
||||
endfor
|
||||
|
||||
" Test: Find functions called by this function
|
||||
for cmd in ['cs find d test_mf_hash', 'cs find 2 test_mf_hash']
|
||||
let a = execute(cmd)
|
||||
call assert_match('\n(1 of 42): <<mf_hash_init>> mf_hash_init(&ht);', a)
|
||||
call assert_equal(' mf_hash_init(&ht);', getline('.'))
|
||||
endfor
|
||||
|
||||
" Test: Find functions calling this function
|
||||
for cmd in ['cs find c test_mf_hash', 'cs find 3 test_mf_hash']
|
||||
let a = execute(cmd)
|
||||
call assert_match('\n(1 of 1): <<main>> test_mf_hash();', a)
|
||||
call assert_equal(' test_mf_hash();', getline('.'))
|
||||
endfor
|
||||
|
||||
" Test: Find this text string
|
||||
for cmd in ['cs find t Bram', 'cs find 4 Bram']
|
||||
let a = execute(cmd)
|
||||
call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a)
|
||||
call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.'))
|
||||
endfor
|
||||
|
||||
" Test: Find this egrep pattern
|
||||
" test all matches returned by cscope
|
||||
for cmd in ['cs find e ^\#includ.', 'cs find 6 ^\#includ.']
|
||||
let a = execute(cmd)
|
||||
call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a)
|
||||
call assert_equal('#include <assert.h>', getline('.'))
|
||||
cnext
|
||||
call assert_equal('#include "main.c"', getline('.'))
|
||||
cnext
|
||||
call assert_equal('#include "memfile.c"', getline('.'))
|
||||
call assert_fails('cnext', 'E553:')
|
||||
endfor
|
||||
|
||||
" Test: Find the same egrep pattern using lcscope this time.
|
||||
let a = execute('lcs find e ^\#includ.')
|
||||
call assert_match('\n(1 of 3): <<<unknown>>> #include <assert.h>', a)
|
||||
call assert_equal('#include <assert.h>', getline('.'))
|
||||
lnext
|
||||
call assert_equal('#include "main.c"', getline('.'))
|
||||
lnext
|
||||
call assert_equal('#include "memfile.c"', getline('.'))
|
||||
call assert_fails('lnext', 'E553:')
|
||||
|
||||
" Test: Find this file
|
||||
for cmd in ['cs find f Xmemfile_test.c', 'cs find 7 Xmemfile_test.c']
|
||||
enew
|
||||
let a = execute(cmd)
|
||||
call assert_true(a =~ '"Xmemfile_test.c" \d\+L, \d\+B')
|
||||
call assert_equal('Xmemfile_test.c', @%)
|
||||
endfor
|
||||
|
||||
" Test: Find files #including this file
|
||||
for cmd in ['cs find i assert.h', 'cs find 8 assert.h']
|
||||
enew
|
||||
let a = execute(cmd)
|
||||
let alines = split(a, '\n', 1)
|
||||
call assert_equal('', alines[0])
|
||||
call assert_true(alines[1] =~ '"Xmemfile_test.c" \d\+L, \d\+B')
|
||||
call assert_equal('(1 of 1): <<global>> #include <assert.h>', alines[2])
|
||||
call assert_equal('#include <assert.h>', getline('.'))
|
||||
endfor
|
||||
|
||||
" Test: Invalid find command
|
||||
call assert_fails('cs find', 'E560:')
|
||||
call assert_fails('cs find x', 'E560:')
|
||||
|
||||
if has('float')
|
||||
" Test: Find places where this symbol is assigned a value
|
||||
" this needs a cscope >= 15.8
|
||||
" unfortunately, Travis has cscope version 15.7
|
||||
let cscope_version = systemlist('cscope --version')[0]
|
||||
let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
|
||||
if cs_version >= 15.8
|
||||
for cmd in ['cs find a item', 'cs find 9 item']
|
||||
let a = execute(cmd)
|
||||
call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);'], split(a, '\n', 1))
|
||||
call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);', getline('.'))
|
||||
cnext
|
||||
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
||||
cnext
|
||||
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
||||
cnext
|
||||
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
|
||||
" Test: leading whitespace is not removed for cscope find text
|
||||
let a = execute('cscope find t test_mf_hash')
|
||||
call assert_equal(['', '(1 of 1): <<<unknown>>> test_mf_hash();'], split(a, '\n', 1))
|
||||
call assert_equal(' test_mf_hash();', getline('.'))
|
||||
|
||||
" Test: test with scscope
|
||||
let a = execute('scs find t Bram')
|
||||
call assert_match('(1 of 1): <<<unknown>>> \* VIM - Vi IMproved^Iby Bram Moolenaar', a)
|
||||
call assert_equal(' * VIM - Vi IMproved by Bram Moolenaar', getline('.'))
|
||||
|
||||
" Test: cscope help
|
||||
for cmd in ['cs', 'cs help', 'cs xxx']
|
||||
let a = execute(cmd)
|
||||
call assert_match('^cscope commands:\n', a)
|
||||
call assert_match('\nadd :', a)
|
||||
call assert_match('\nfind :', a)
|
||||
call assert_match('\nhelp : Show this message', a)
|
||||
call assert_match('\nkill : Kill a connection', a)
|
||||
call assert_match('\nreset: Reinit all connections', a)
|
||||
call assert_match('\nshow : Show connections', a)
|
||||
endfor
|
||||
let a = execute('scscope help')
|
||||
call assert_match('This cscope command does not support splitting the window\.', a)
|
||||
|
||||
" Test: reset connections
|
||||
let a = execute('cscope reset')
|
||||
call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a)
|
||||
call assert_match('\nAll cscope databases reset', a)
|
||||
|
||||
" Test: cscope show
|
||||
let a = execute('cscope show')
|
||||
call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
|
||||
|
||||
" Test: cstag and 'csto' option
|
||||
set csto=0
|
||||
let a = execute('cstag TEST_COUNT')
|
||||
call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
|
||||
call assert_equal('#define TEST_COUNT 50000', getline('.'))
|
||||
call assert_fails('cstag DOES_NOT_EXIST', 'E257:')
|
||||
set csto=1
|
||||
let a = execute('cstag index_to_key')
|
||||
call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a)
|
||||
call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.'))
|
||||
call assert_fails('cstag DOES_NOT_EXIST', 'E257:')
|
||||
call assert_fails('cstag', 'E562:')
|
||||
let save_tags = &tags
|
||||
set tags=
|
||||
call assert_fails('cstag DOES_NOT_EXIST', 'E257:')
|
||||
let a = execute('cstag index_to_key')
|
||||
call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a)
|
||||
let &tags = save_tags
|
||||
|
||||
" Test: 'cst' option
|
||||
set nocst
|
||||
call assert_fails('tag TEST_COUNT', 'E426:')
|
||||
set cst
|
||||
let a = execute('tag TEST_COUNT')
|
||||
call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
|
||||
call assert_equal('#define TEST_COUNT 50000', getline('.'))
|
||||
let a = execute('tags')
|
||||
call assert_match('1 1 TEST_COUNT\s\+\d\+\s\+#define index_to_key', a)
|
||||
|
||||
" Test: 'cscoperelative'
|
||||
call mkdir('Xcscoperelative')
|
||||
cd Xcscoperelative
|
||||
let a = execute('cs find g test_mf_hash')
|
||||
call assert_notequal('test_mf_hash(void)', getline('.'))
|
||||
set cscoperelative
|
||||
let a = execute('cs find g test_mf_hash')
|
||||
call assert_equal('test_mf_hash(void)', getline('.'))
|
||||
set nocscoperelative
|
||||
cd ..
|
||||
call delete('Xcscoperelative', 'd')
|
||||
|
||||
" Test: E259: no match found
|
||||
call assert_fails('cscope find g DOES_NOT_EXIST', 'E259:')
|
||||
|
||||
" Test: this should trigger call to cs_print_tags()
|
||||
" Unclear how to check result though, we just exercise the code.
|
||||
set cst cscopequickfix=s0
|
||||
call feedkeys(":cs find s main\<CR>", 't')
|
||||
|
||||
" Test: cscope kill
|
||||
call assert_fails('cscope kill', 'E560:')
|
||||
call assert_fails('cscope kill 2', 'E261:')
|
||||
call assert_fails('cscope kill xxx', 'E261:')
|
||||
|
||||
let a = execute('cscope kill 0')
|
||||
call assert_match('cscope connection 0 closed', a)
|
||||
|
||||
cscope add Xcscope.out
|
||||
let a = execute('cscope kill Xcscope.out')
|
||||
call assert_match('cscope connection Xcscope.out closed', a)
|
||||
|
||||
cscope add Xcscope.out .
|
||||
let a = execute('cscope kill -1')
|
||||
call assert_match('cscope connection .*Xcscope.out closed', a)
|
||||
let a = execute('cscope kill -1')
|
||||
call assert_equal('', a)
|
||||
|
||||
" Test: 'csprg' option
|
||||
call assert_equal('cscope', &csprg)
|
||||
set csprg=doesnotexist
|
||||
call assert_fails('cscope add Xcscope2.out', 'E609:')
|
||||
set csprg=cscope
|
||||
|
||||
" Test: multiple cscope connections
|
||||
cscope add Xcscope.out
|
||||
cscope add Xcscope2.out . -C
|
||||
let a = execute('cscope show')
|
||||
call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
|
||||
call assert_match('\n 1 \d\+.*Xcscope2.out\s*\.', a)
|
||||
|
||||
" Test: test Ex command line completion
|
||||
call feedkeys(":cs \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||
call assert_equal('"cs add find help kill reset show', @:)
|
||||
|
||||
call feedkeys(":scs \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||
call assert_equal('"scs find', @:)
|
||||
|
||||
call feedkeys(":cs find \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||
call assert_equal('"cs find a c d e f g i s t', @:)
|
||||
|
||||
call feedkeys(":cs kill \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||
call assert_equal('"cs kill -1 0 1', @:)
|
||||
|
||||
call feedkeys(":cs add Xcscope\<C-A>\<C-B>\"\<CR>", 'tx')
|
||||
call assert_equal('"cs add Xcscope.out Xcscope2.out', @:)
|
||||
|
||||
" Test: cscope_connection()
|
||||
call assert_equal(cscope_connection(), 1)
|
||||
call assert_equal(cscope_connection(0, 'out'), 1)
|
||||
call assert_equal(cscope_connection(0, 'xxx'), 1)
|
||||
|
||||
call assert_equal(cscope_connection(1, 'out'), 1)
|
||||
call assert_equal(cscope_connection(1, 'xxx'), 0)
|
||||
|
||||
call assert_equal(cscope_connection(2, 'out'), 0)
|
||||
call assert_equal(cscope_connection(2, getcwd() .. '/Xcscope.out', 1), 1)
|
||||
|
||||
call assert_equal(cscope_connection(3, 'xxx', '..'), 0)
|
||||
call assert_equal(cscope_connection(3, 'out', 'xxx'), 0)
|
||||
call assert_equal(cscope_connection(3, 'out', '.'), 1)
|
||||
|
||||
call assert_equal(cscope_connection(4, 'out', '.'), 0)
|
||||
|
||||
call assert_equal(cscope_connection(5, 'out'), 0)
|
||||
call assert_equal(cscope_connection(-1, 'out'), 0)
|
||||
|
||||
call CscopeSetupOrClean(0)
|
||||
endfunc
|
||||
|
||||
" Test ":cs add {dir}" (add the {dir}/cscope.out database)
|
||||
func Test_cscope_add_dir()
|
||||
call mkdir('Xcscopedir', 'p')
|
||||
|
||||
" Cscope doesn't handle symlinks, so this needs to be resolved in case a
|
||||
" shadow directory is being used.
|
||||
let memfile = resolve('./samples/memfile_test.c')
|
||||
call system('cscope -bk -fXcscopedir/cscope.out ' . memfile)
|
||||
|
||||
cs add Xcscopedir
|
||||
let a = execute('cscope show')
|
||||
let lines = split(a, "\n", 1)
|
||||
call assert_equal(3, len(lines))
|
||||
call assert_equal(' # pid database name prepend path', lines[0])
|
||||
call assert_equal('', lines[1])
|
||||
call assert_match('^ 0 \d\+.*Xcscopedir/cscope.out\s\+<none>$', lines[2])
|
||||
|
||||
cs kill -1
|
||||
call delete('Xcscopedir/cscope.out')
|
||||
call assert_fails('cs add Xcscopedir', 'E563:')
|
||||
|
||||
call delete('Xcscopedir', 'd')
|
||||
endfunc
|
||||
|
||||
func Test_cscopequickfix()
|
||||
set cscopequickfix=s-,g-,d+,c-,t+,e-,f0,i-,a-
|
||||
call assert_equal('s-,g-,d+,c-,t+,e-,f0,i-,a-', &cscopequickfix)
|
||||
|
||||
call assert_fails('set cscopequickfix=x-', 'E474:')
|
||||
call assert_fails('set cscopequickfix=s', 'E474:')
|
||||
call assert_fails('set cscopequickfix=s7', 'E474:')
|
||||
call assert_fails('set cscopequickfix=s-a', 'E474:')
|
||||
endfunc
|
||||
|
||||
func Test_withoutCscopeConnection()
|
||||
call assert_equal(cscope_connection(), 0)
|
||||
|
||||
call assert_fails('cscope find s main', 'E567:')
|
||||
let a = execute('cscope show')
|
||||
call assert_match('no cscope connections', a)
|
||||
endfunc
|
||||
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
@@ -46,7 +46,6 @@ static const char *command_complete[] =
|
||||
[EXPAND_COLORS] = "color",
|
||||
[EXPAND_COMMANDS] = "command",
|
||||
[EXPAND_COMPILER] = "compiler",
|
||||
[EXPAND_CSCOPE] = "cscope",
|
||||
[EXPAND_USER_DEFINED] = "custom",
|
||||
[EXPAND_USER_LIST] = "customlist",
|
||||
[EXPAND_USER_LUA] = "<Lua function>",
|
||||
|
@@ -138,7 +138,6 @@ enum {
|
||||
EXPAND_USER_LIST,
|
||||
EXPAND_USER_LUA,
|
||||
EXPAND_SHELLCMD,
|
||||
EXPAND_CSCOPE,
|
||||
EXPAND_SIGN,
|
||||
EXPAND_PROFILE,
|
||||
EXPAND_BEHAVE,
|
||||
|
Reference in New Issue
Block a user