752 Commits

Author SHA1 Message Date
Jiří Techet
27e4455502 Drop g_list_reverse()
Since the original include list is already reordered by the hash table,
it makes no sense to reverse the resulting list as it's in a different
order anyway.
2016-06-09 10:30:07 +02:00
Jiří Techet
379eefa831 Use '\0' for non-existent tag kind instead of '-'
Shouldn't collide with real tag kind symbols and a non-visible character
is more probably unused by ctags than a visible one.
2016-06-09 10:24:47 +02:00
Jiří Techet
6e89ee5ebe Check for fclose() success 2016-05-06 22:00:14 +02:00
Jiří Techet
b959801d8f Rename append_to_temp_file() to combine_include_files() 2016-05-06 21:56:47 +02:00
Jiří Techet
7fe549d480 Make sure not to leak tmp_errfile if only outf creation fails 2016-05-06 21:47:04 +02:00
Jiří Techet
084c23bbb1 Use g_strdup() instead of strdup() 2016-05-06 21:43:50 +02:00
Jiří Techet
bd9d26a0d1 Fix crash in lookup_includes()
Right now

geany -g foo.c.tags \"

makes Geany crash.
2016-05-06 21:42:13 +02:00
Jiří Techet
9ae93e34a0 Check return value of write_tag()
If we were strict, we should check every single fprintf() int write_tag()
but it's highly improbable that some of the middle fprintf()s fail and
the last one doesn't so the current implementation of write_tag() is
probably sufficient.
2016-05-06 21:08:24 +02:00
Jiří Techet
8c27ea1042 Remove invalid part of a comment 2016-05-06 17:34:26 +02:00
Jiří Techet
c05e3eabf1 Split tm_ctags_callback into two
One to inform about a new tag, the other informing about a start of a new
pass.
2016-05-06 17:29:54 +02:00
Jiří Techet
9b188a20ef Use g_error() instead of g_warning() in parser type verification 2016-05-06 17:06:57 +02:00
Colomban Wendling
f147f36daf Reduce some repetitions in tag type mapping code
* Use a streamlined name for each map, `map_LANGUAGE`, where `LANGUAGE`
  is the CTags parser name from tm_parser.h.  This allows some further
  automation.
* Make sure the maps are referenced at the correct index in
  `parser_map`, even if they were not in the same order as in the
  `TMParserType` enumeration by using explicit sub-object initializers.
* As explicit sub-object initialization might lead to a missing
  initializer for a non-last index going unnoticed, add a check for
  uninitialized entries to properly reject them even for regex parsers.
2016-05-06 17:02:32 +02:00
Colomban Wendling
0833974e1e Convert parser map size check to a static assertion 2016-05-06 16:52:54 +02:00
Colomban Wendling
4036d7d18a Remove not useless tm_source_file_ctags_init() indirection 2016-05-06 16:51:38 +02:00
Colomban Wendling
fdc4510864 Don't use char array subscript as it may be signed 2016-05-06 16:48:04 +02:00
Colomban Wendling
056e53c2c5 Make our convenience libraries more self-contained
Make each convenience library depend on the ones it requires, which is
pretty straightforward for us as they each only depend on a single
other one, avoiding any worry about double linking of static objects.
2016-05-04 19:11:13 +02:00
Colomban Wendling
7411f9b5cf Remove an unused variable 2016-05-04 19:11:13 +02:00
Colomban Wendling
2bdc96776c Use proper C prototypes 2016-05-04 19:11:13 +02:00
Jiří Techet
5d9376ea80 Add explicit mapping of ctags tag types to Geany tag types
At the moment tag types are changed in ctags to match the types Geany
uses internally. This introduces differences between the parsers used
in ctags and the ones used in Geany.

Instead, perform the "ctags tag type"->"geany tag type" mapping explicitly
in TM and leave the tag types in individual parsers identical to ctags.
For parsers which are present in ctags (and which don't seem to be
completely different from the parsers used in Geany) revert the tag type
change in the parsers so the parser tag definitions match universal-ctags.
This patch doesn't do anything with the tag types of parsers not present
in universal-ctags and leaves them as they are.

Parsers which previously had a mapping to an non-existent Geany type have
now the mapping explicitly set to tm_tag_undef_t. Since the mapping is now
made through the one-letter type, some of the parsers had to be adjusted
because they used single letter for multiple tag types (probably by
mistake).

Because the whole mapping process might be a bit fragile and error-prone
to changes in ctags parsers, the patch also performs some consistency
checks:

* whether the parser number in ctags/TM matches
* whether for the given language the tag type number is identical in TM
  mapping and ctags definition
* whether all tag types defined in ctags parser are mapped in TM and in
  reverse, whether all mapped tags in TM are defined in ctags parser
* whether there aren't duplicate tag types

Unfortunately the checks are possible only for parsers not using regex
because regex definitions are not exposed by ctags (TODO).

A bonus side effect of the changes is we can now use real tag types defined
for each languages in ctags when parsing ctags tag files instead of
using the hard-coded static values which mostly work just for C/C++.
2016-03-22 17:03:16 +01:00
Jiří Techet
aea7d78459 Remove some unused return values and unnecessary checks 2016-03-21 18:28:36 +01:00
Jiří Techet
b72b859634 Clean up messy tm_workspace_create_global_tags()
At the same time ignore tags of the type tm_tag_undef_t when parsing -
we cannot query them anyway and this eliminates the need to call

tm_tags_extract(source_file->tags_array, tm_tag_max_t);

when creating tags file.
2016-03-21 18:28:36 +01:00
Jiří Techet
1c4aaa0eb7 Add an API-like ctags layer
At the moment it is a bit hard to distinguish which of the functions
we are using belong to ctags. To make more explicit what we need
from ctags, wrap all ctags-related code and access ctags only using
this layer.

The interface from tm_ctags_wrappers.h can serve as a base for
proper ctags interface if ctags becomes a library.
2016-03-21 18:28:36 +01:00
Jiří Techet
103d2c5358 Move code related to various tag file formats into tm_source_file.c
This patch moves code related to reading/writing various tag file formats
into form TMTag and TMWorkspace to TMSourceFile. The benefits of this
change are:

* only tm_source_file.c interfaces with ctags after this change
* tagEntryInfo is removed from headers, no redefinitions needed any more
* source code is more evenly distributed among tm_source_file.c,
  tm_tag.c and tm_workspace.c after the change (tm_tag.c got smaller)
* all tag reading/writing is at a single place

Despite its size, this patch mostly just moves code. Notable changes are:

* tm_tag_new() now creates just an empty tag. The tag is filled by various
  init_* functions inside tm_source_file.c
* there are new functions tm_source_file_read_tags_file() and
  tm_source_file_write_tags_file() - these hide tags file
  reading/writing details from tm_workspace.c
* tm_source_file_write() debugging function got removed -
  tm_source_file_write_tags_file() does a similar thing and there's no
  need to keep around two functions doing the same.
2016-03-21 18:28:36 +01:00
Jiří Techet
4dcc829e72 Remove unused tm_tagmanager.h
Nobody uses it, the comment there doesn't provide any valuable
information and we don't need an umbrella TM header like this.
2016-03-21 18:28:36 +01:00
Jiří Techet
75c5cb6a9c Use G_BEGIN_DECLS/G_END_DECLS 2016-03-21 18:28:36 +01:00
Jiří Techet
1de139854f Improve ctags callback API
Communicate with ctags only using function calls and don't assign
ctags variables directly.
2016-03-21 18:28:36 +01:00
Jiří Techet
7be40f5832 Initialize ctags at a single place instead of four 2016-03-21 18:28:36 +01:00
Jiří Techet
f61a64be29 Remove the TagEntrySetArglistFunction hook
The direct python parser -> tagmanager callback is rather hacky
and unnecessary as we can do the same in the normal ctags callback
upon receiving a tag.
2016-03-21 18:28:36 +01:00
Masatake YAMATO
e46093d1fc Ruby: delete rspec related kinds
Close universal-ctags/ctags#453.

(This is about a bug spotted in universal-ctags/ctags#453 by @mislav and
 in universal-ctags/ctags#11 by @NewAlexandria.)

Kinds C and d are for Rspec.

Parts of code related to above kinds assume a ruby string
comes after Rspec keywords (describe or context).

This is a wrong assumption. A class name can be used there.

It is nice if ctags can handle these rspec code well, but we
don't have enough resource to make it now.

So in this commit I delete rspec related code temporary. I
just reserve a kind letter 'd' for rspec for the future. 'C'
is completely deleted because (1) describe and context have
the same meaning in rspec, and (2) we would like to assign
'C' for Ruby constant as ripper-tags does.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2016-03-14 19:49:47 +01:00
Colomban Wendling
885b994ec2 ruby: License under GPLv2+ as per Universal CTags
See https://github.com/universal-ctags/ctags/pull/578
2016-03-14 19:40:50 +01:00
Colomban Wendling
ab6a012119 ruby: Unify identifier character classification 2016-03-14 19:27:22 +01:00
Colomban Wendling
116c749cd9 ruby: Report singleton type inside anonymous classes at a class level
New test case contributed by @masatake in universal-ctags/ctags#456.

Closes universal-ctags/ctags#455 and universal-ctags/ctags#456.
2016-03-14 19:27:22 +01:00
Colomban Wendling
7d116cb482 ruby: Report proper scope type 2016-03-14 19:27:22 +01:00
Colomban Wendling
9e97746751 ruby: Use nestlevel instead of string lists
This will simplify some upcoming fixes.
2016-03-14 19:27:22 +01:00
Colomban Wendling
17606d8af7 ruby: Fix scope after anonymous classes 2016-03-14 19:27:22 +01:00
Colomban Wendling
1ed29f1d7b ruby: Fix parsing qualified identifiers
The implementation is a bit hacky, but avoids the need for complex
logic to pop several scopes at once.

Closes universal-ctags/ctags#452.
2016-03-14 19:27:22 +01:00
Colomban Wendling
eaf6c82af8 ruby: Fix keyword matching
After an identifier there can be anything but an identifier character.
2016-03-14 19:27:22 +01:00
Colomban Wendling
e003da2bea ruby: Properly skip documentation contents 2016-03-14 19:27:22 +01:00
Masatake YAMATO
e9e9b9988d ruby: handle singleton method including ?!= in its name(sf.bug:364)
This patch is intended a bug reported as sf.bug:364.
https://sourceforge.net/p/ctags/bugs/364/

Writing a test case is helped by Dmitry Gutov.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2016-03-14 19:27:22 +01:00
Masatake YAMATO
68322fcb54 ruby: fix wrong memory access in catMatch
fuzz target reports canMatch access wrong memory
area when php-anonymous_functions.d/input.php is
given as input.

This patch fixes it.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2016-03-14 19:27:21 +01:00
Masatake YAMATO
a71dbcbeca ruby: Use NULL for initialize an pointer variable
Suppress a warning reported by sparse.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2016-03-14 19:27:21 +01:00
Artem Nezvigin
e129043c98 Honor --ruby-kinds option in ruby.c
Fixes universal-ctags/ctags#49
2016-03-14 19:26:54 +01:00
Ram Singla
2269c42dde RSpec Code added. Courtesy: mortice 2016-03-14 15:18:14 +01:00
Thomas Martitz
d868130d78 tagmanager: make doxygen comments and typedefs gtkdoc generation friendly
Because of the missing "typedef struct TMFoo" it was missing from the gtkdoc
header (the struct listings are always without typedef). This is also
consistent with the rest of geany.

@gironly for TMParserType so it's picked up as well.
2016-03-09 22:49:51 +01:00
Colomban Wendling
6818ba6baf Avoid NULL dereference when typing a dot in a file without tags 2016-03-07 15:46:34 +01:00
solawing
bef06691b5 objc: fix property parser won't exit bug
Based on 21e74e6a019975045a7975bc611ae63f0917f976 from universal-ctags,
and update the tests accordingly, thanks to @JX7P.

Closes #940.

X-Universal-CTags-Commit-ID: 21e74e6a019975045a7975bc611ae63f0917f976
2016-03-07 12:50:52 +01:00
solawing
fec974687c objc: fix property Protocol type error
X-Universal-CTags-Commit-ID: 43330bfe114658726bd3926c8a48bfe1858352fa
2016-03-07 12:48:57 +01:00
Colomban Wendling
e3d066c203 Do not generate tags for disabled kinds
Closes universal-ctags/ctags#324.
X-Universal-CTags-Commit-ID: 4a95e4a55f67230fc4eee91ffb31c18c422df6d3
2016-03-07 12:46:36 +01:00
Masatake YAMATO
6180b10226 suppress the compiler warnings by adding static
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
X-Universal-CTags-Commit-ID: 9be84d26c1fd1653f20e9feda6a67484f7e86bd9
2016-03-07 12:44:50 +01:00
Masatake YAMATO
07a3772700 ObjectiveC: free memory blocks allocated at initialize method
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
X-Universal-CTags-Commit-ID: 882c5f8506159d77acd6c418239e33c5439bd290
2016-03-07 12:38:51 +01:00