711 Commits

Author SHA1 Message Date
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
Colomban Wendling
be29bad098 Merge pull request #906 from techee/scope_fallout
Scope completion fallout patches
2016-03-04 20:06:10 +01:00
Colomban Wendling
3fda6988b3 Merge pull request #890 from kugel-/gtkdoc-hdr
Generated and ship a GtkDoc header suitable for GObject Introspection.
2016-03-01 18:53:08 +01:00
Jiří Techet
86cb9aeac0 Make the use of TMParserType private
Or semi-private by removing the docstring.
2016-02-26 01:40:37 +01:00
Jiří Techet
833921e6ee Install tm_parser.h
Included now in other headers and needed for successful plugin compilation.
2016-02-26 01:29:50 +01:00
Jiří Techet
292383c197 Some more uses of TMParserType instead of int 2016-02-26 01:11:53 +01:00
Jiří Techet
00cb498ebc Don't use ctags types inside Geany
We should isolate ctags from Geany completely and use separate types. At
the moment langType is shared by both Geany and ctags. For Geany redefine
it as TMParserType (which was currently used as the name of the enum and
was unused) and use everywhere in Geany. At the same time convert some
ints to TMParserType where they denote the parser.

This is strictly speaking an API change but no plugin uses langType at the
moment so its renaming doesn't cause any problems.

The only remaining visible ctags type is tagEntryInfo - it is however
used only inside tagmanager (and can be later removed quite easily too
by slightly reorganizing TM source files).
2016-02-26 01:10:00 +01:00
Jiří Techet
cb307e5b92 Use the langs_compatible() function when passing typenames to scintilla
This requires making the function public and tm_tag.c seems to be a better
place for the function than tm_workspace so move there and add the prefix.
2016-02-26 01:09:59 +01:00
Jiří Techet
5030f7f3da Cleanup NONE/AUTO filetype definitions
At the moment the Geany code uses arbitrary combination of the following
synonyms

TM_PARSER_NONE / LANG_IGNORE / -2
TM_PARSER_AUTO / LANG_AUTO / -1

Especially using just the numbers makes things very confusing.

In the Geany code this patch replaces all occurrences of -2 and LANG_IGNORE
with TM_PARSER_NONE. It also removes LANG_IGNORE from the header which
isn't needed any more.

In addition, TM_PARSER_AUTO/LANG_AUTO shouldn't be used at all. We want
filetype detection based on Geany's definitions and not based on the
hard-coded ctags definitions. Remove it completely.

Finally, as it's clearer now what the constants mean, the patch fixes the
implementation of langs_compatible() (tag or file can never be of type
AUTO but we should rather check for NONE filetypes which we should
consider incompatible between each other).
2016-02-26 01:09:59 +01:00
Jiří Techet
77f6e98de8 Add scope completion for namespaces
Pop up scope completion dialog for namespaces too; e.g. for

boost::

show all symbols defined in the namespace. Determine whether the namespace
scope completion should be used based on whether user typed a scope
separator. If so, perform completion for namespaces before normal scope
completion - this seems to work better e.g. for Scintilla where

Scintilla::

would otherwise pop up the varible sci instead of showing everything
in the namespace (might be more questionable for languages where
the scope separator is identical to the dereference operator like
Java's "." but we have to make some choice anyway).

The performance seems to be reasonable - for the completion all tags
have to be walked but after testing with big C++ projects like
boost and Mozilla, the completion takes only something like 0.2s
which is acceptable as the delay happens only on typing the scope
completion separator and feels kind of expected.

Also tested with linux kernel sources which normally lack any scope
information by hacking TM a bit and injecting 10-character scope for
each tag - then the completion takes something over 0.5s.
2016-02-26 01:09:59 +01:00
Colomban Wendling
a775da0714 Merge pull request #862 from techee/tm_workspace_find_cleanup3
Rewrite scope completion v3.

Closes #488 and #505.
2016-02-11 15:30:09 +01:00
Colomban Wendling
e38c7e3b67 Merge pull request #879 from b4n/c/cxx11-raw-strings
c++: Fix parsing of C++11 raw string literals.
2016-02-11 15:26:32 +01:00
Thomas Martitz
bfa0946420 doxygen: various doxygen-related fixes in preparation for gtkdoc generation 2016-02-07 17:50:23 +01:00
Jiří Techet
6b2e99d067 Remove scope prefix of variable types
We only perform search based on variable name so if a variable is e.g. of
the type std::Foo, we can drop the std:: prefix and search only for the
Foo type.
2016-01-27 01:06:56 +01:00
Colomban Wendling
748137bd1d C, C++, C#, D: Improve return type and var type recognition
This is far from perfect and contains a lot of guessing.  It showed
good results based on our tests cases, fixing several issues and not
introducing any more issues (admittedly, after working around a subtle
one regarding D static ifs).

Closes #845.
2016-01-26 16:18:11 +01:00
Colomban Wendling
496d51210c Merge pull request #839 from kugel-/gboxed-types
GBoxed types
2016-01-25 23:10:37 +01:00
Colomban Wendling
b40d1f255b Use explicit character literal instead of numerical value 2016-01-25 22:22:51 +01:00
Colomban Wendling
5a279f0bf6 c++: Fix parsing of prefixed C++11 raw string literals
See http://en.cppreference.com/w/cpp/language/string_literal
2016-01-24 17:33:32 +01:00
Colomban Wendling
cdabbecd37 read: Avoid possible NULL dereference in getNthPrevCFromInputFile()
Also, don't perform subtractions to check pointer bounds, to avoid
unsigned value wraparound.  This is very unlikely as it would either
mean a very large `nth` value or a very small value for the current
line pointer, but better safe than sorry.
2016-01-24 17:29:38 +01:00
Colomban Wendling
67f3add7c7 read: Move logic for getting a previous character into a read function
This ties related logic together, making it less of a hack and easier
to maintain, as well as accessible by all parsers if needed.
2016-01-24 17:25:12 +01:00
Colomban Wendling
a14aa908c5 c++: Fix parsing of C++11 raw string literals
See http://en.cppreference.com/w/cpp/language/string_literal

Closes #877.

---

This contains a pretty ugly hack to fetch the previous character, in
order not to get fooled by string concatenation hidden behind a macro,
like in `FOUR"five"`, which is not a raw string literal but simply the
identifier `FOUR` followed by the string `"five"`.

While this may sound uncommon, it is not and lead to complaints [2][3]
when Scintilla [1] broke this when they introduced C++11 raw string
literal support themselves.

The implementation here still contains a bug with line continuations: a
raw literal of the form:

```c
const char *str = R\
"xxx(...)xxx";
```

is not properly recognized as such, although it's perfectly valid (yet
probably very uncommon).  For the record, Scintilla has also suffers
from this but nobody complained about it yet.

[1] http://scintilla.org/
[2] https://sourceforge.net/p/scintilla/bugs/1207/
[3] https://sourceforge.net/p/scintilla/bugs/1454/
2016-01-23 21:52:40 +01:00
Thomas Martitz
9a38b7ac20 plugin api: convert TMSourceFile to GBoxed internally
Because the tm_source_file_new() is an exported API, it has to be at least a
boxed type to be usable for gobject introspection. The boxed type uses
reference counting as opposed to memory duplication.

The obligatory tm_source_file_dup() is not exported (doesn't have to).
2016-01-19 17:08:56 +01:00
Jiří Techet
c653741a3c Fix member scope completion with nested members
First, the search for existing type with the given scope should be done
also for namespaces.

Second, with the string operations we get no scope as empty string ""
but the rest of TM functions expect scope to be set to NULL in such
case. Fix that.
2016-01-19 00:40:06 +01:00
Jiří Techet
f10747ae5a Remove duplicate names from scope search popup
There may be duplicate tag names in the list e.g. when performing namespace
search and overloaded methods are found.
2016-01-18 23:00:19 +01:00
Jiří Techet
cd1a58f0a5 Use language-specific context separator instead of hard-coded "::"
This makes it possible to popup scope completion dialog for more languages.
2016-01-18 22:56:10 +01:00
Jiří Techet
f38068f04e Skip typedef resolution in namespace search if not needed
When we already have a struct-like type in namespace search,
we don't need any extra resolution - we already have the
right type. Skip the whole typedef resolution in this case.
2016-01-18 22:56:10 +01:00
Jiří Techet
5801844d7e Improve anonymous type handling
Make sure the anonymous types are from the same file as the
variable of that type (or, when performing typedef resolution, from
the same file as the typedef).

On the way, simplify find_scope_members() a bit and fix some minor
problems.
2016-01-18 22:56:10 +01:00
Jiří Techet
5cd5734642 Minor cleanup
Make the unused code compile and remove unused tm_get_current_function()
(we have similar symbols_get_current_function() and there's no reason
to keep it)
2016-01-18 22:56:10 +01:00
Jiří Techet
ad77ee15da Add a "prefix" search for non-scope autocompletion
The main reason for separating m_workspace_find() into two parts is the
fact that when matching only the prefix, the result may contain too
many results and we need to go through all of them, return them and at the
end discard most of them.

For instance, when considering the linux kernel project with 2300000 tags
and when autocompletion is set to be invoked after typing a single character,
we get on average something like 100000 results (tag_num/alphabet_size).
But from these 100000 results, we get only the first 30 which we display
in the popup and discard the rest which means going through the list of
the 100000 tags and comparing them for no reason.

Thanks to using binary search for the start and the end of the sequence of
matching tags (added in a separate patch), we can get the start of the
sequence and the length of the sequence very quickly without going through
it.

For the prefix search we can limit the number of tags we are interested
in and go through at most this number of returned tags (to be precise,
times two, because we need to go both through the workspace array and
global tags array and remove the extras only after sorting the two).

It would be possible to combine both tm_workspace_find() and
tm_workspace_find_prefix() into a single function but the result is a bit
hard to read because some of the logic is used only in tm_workspace_find()
and some only in tm_workspace_find_prefix() so even though there is some
code duplication, I believe it's easier to understand this way.
2016-01-18 22:56:10 +01:00
Jiří Techet
5b4c6f96b2 Don't use anon_struct_* and similar members unless we are sure it's the right one
We can only be sure it's the right one if we previously resolved a
typedef to it and the typedef was in the same file.
2016-01-18 22:56:10 +01:00
Jiří Techet
02105d77d7 Simplify tag type specifications in scope search
Consider types with members to have the same properties everywhere (this
might differ language to language but this assumption should behave
reasonably for any language).

Don't check member type in find_scope_members_tags() - we already check
scope which should be sufficient and will work even if some language
uses function/variable instead of method/member/field.
2016-01-18 22:56:10 +01:00
Jiří Techet
67916dc403 Use only binary search to find first/last element in a row of equal tags
The linear part may become expensive when there are many equal tags
which can happen when partial search, used for non-scope completion,
is used.
2016-01-18 22:56:10 +01:00
Jiří Techet
2682d7973f Remove anon_* elements when performing namespace search
These correspond to anonymous structs, enums, etc. but they don't have
any name so the name shouldn't be listed.
2016-01-18 22:56:10 +01:00
Jiří Techet
932dc71fe2 Don't use struct/class/... member types when the edited text isn't a member
For instance, consider

class A {
    int a;
    int b;
}

class B {
    A c;
    void foo() {
        c.    //<---- (3)
    }
}

int main() {
    c.    //<---- (1)
    foo.c.    //<---- (2)
}

Consider cases (1) and (2) first - in the case (1) scope completion
shouldn't be performed because c isn't a global variable; however,
in case (2) it should be performed because c is a member.

To fix this, we can check whether the typed variable ('c' in this case)
is preceeded by another dot - if it is, use member tags for scope
completion; otherwise don't use them.

There's one exception from this rule - in the case (3) we are accessing
a member variable from a member function at the same scope so the
function should have access to the variable. For this we can use the
scope at the position of the cursor. It should be

B::foo

in this case, more generally ...::class_name::function_name. We need
to check if class_name exists at the given scope and if the member
variable we are trying to access is inside ...::class_name - if so,
scope completion can be performed using member tags (without explicit
invocation on a member).
2016-01-18 22:55:02 +01:00
Colomban Wendling
1c4a9d8dd3 C++: Fix parsing of global scope qualifiers in base class lists
See also https://sourceforge.net/p/ctags/bugs/194/

I didn't use the exact upstream patch only altering the C++ code path,
because as far as I know no c.c language recognize two consecutive
colons separated by whitespace as a single token, so there's no point
in carrying on mistakes from the past.
2016-01-17 04:03:24 +01:00
Colomban Wendling
440a736018 C++, C#: Properly set scope on namespaces
Closes #871.
2016-01-17 03:30:06 +01:00
Jiří Techet
e0122592d9 Perform scope autocompletion based on function return types
We just need to skip the (...) and perform autocompletion as before.

Shift pos by 1 in the whole function so we don't have to look 2 characters
back (makes the function easier to read).

Functions contain pointers in their return values - remove them before
searching for the type.

Also restrict the searched variable/function/type tags a bit only to
types which make sense for the search.
2016-01-10 12:36:08 +01:00
Jiří Techet
c4b1cd4938 Perform "namespace" search (autocomplete for A:: where A is a type)
In principle this is very similar to the normal scope search. If the
provided name belongs to a type that can contain members (contrary to a
variable in scope search), perform the namespace search. With namespace
search show all possible members that are at the given scope.

Since we perform the scope search at file level, don't perform the
namespace search for tags that can span multiple files otherwise we get
incomplete results which could be confusing to users. This involves
namespaces and packages.
2016-01-10 12:36:05 +01:00
Jiří Techet
1281d0c942 Get members from the same file as the type/struct/union
Rethink how to extract members from the struct types. Inspired by
the patch using the same file as the typedef to search for structs,
we can do the same to extract the members only from the file
containing the struct and not the whole workspace. This makes
this operation fast enough so we don't have to keep the extracted
members in a special array (this will become especially useful
for namespace search because for it we would have to extract
all tags and then the extracted array would have the same
size as the workspace so we'd lose the performance gain).

Since the above works only for tags having the file information,
that is, not the global tags, we'll lose some performance
when searching the global tags. I think people don't create
the tag files for complete projects but rather for header files
which contain less tags and still the performance should be
better than before this patch set because we go through the
global tag list only once (was twice before).

On the way, clean up the source a bit, add more comments and move
some code from find_scope_members() to find_scope_members_tags().
2016-01-10 12:33:40 +01:00
Jiří Techet
30fa28bac7 Don't use enums for scoped search
Even though enums contain members, their members are accessed in a
different way than members of classes and structs. E.g. consider:

typedef enum {A, B, C, D} MyEnum;

Variable of this type is declared as

MyEnum myVar;

myVar can be assigned a value from MyEnum; however, we don't access myVar
over the dot operator so we don't need the list of all members after
typing

myVar.

This patch eliminates some false positives after typing .
2016-01-10 12:31:47 +01:00
Jiří Techet
bf17c90bd6 Improve tag searching for "typedef struct {...}" cases
When resolving typedef, search for the subsequent type in the file where
the typedef was defined. For more info see the comment in the patch.
2016-01-10 12:31:47 +01:00
Jiří Techet
13755122f2 Move symbols_get_context_separator() implementation to TM
This way we can use it inside TM.
2016-01-10 12:31:47 +01:00