8407 Commits

Author SHA1 Message Date
Giuseppe Penone
31b7a2d6ad updated language Italian 2016-01-24 21:59:56 +00: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
Enrico Tröger
632b215f77 Remove obsolete scripts/plugin_test.c
This script was used in the nightly builds to verify plugins will load
and have no undefined symbol references. Since the new way plugins
are built and linked, this is no longer necessary.
Additionally, this script won't work with new style geany_load_module()
plugins.
2016-01-23 15:29:03 +01:00
Thomas Martitz
43737733ac plugin api: convert StashGroup to GBoxed internally
Because the stash_group_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 stash_group_dup() is not exported (doesn't have to).
2016-01-19 17:08:59 +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
Thomas Martitz
a032ed506e scintilla: add scintilla_object_* to the plugin api
Analogous to their legacy counterparts. Also required for gir-bindings
generated via g-ir-scanner.
2016-01-19 17:05:30 +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
981320c3b8 Skip [] when performing scope autocompletion
In addition to skipping function parameters, we can also skip indexes so
in something like

foo[2].

we get autocompletion for foo's type members.
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
7a3d6a4ee1 Filter scope autocompletion list based on user input
When scope autocompletion list shows, start filtering it when
when the user types some more characters. As long as the list
is non-empty, don't switch to normal autocompletion and show
only the scope autocompletion results.
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
99938dd821 Update Scintilla to version 3.6.3
Includes improvements for Lua 5.3 and Perl 5.22.
2016-01-18 04:22:26 +01:00
Daniel Șuteu
f3a5dd609a Add file-extensions for Clojure
The extensions are from Wikipedia: https://en.wikipedia.org/wiki/Clojure

Closes #842.
2016-01-18 03:43:35 +01:00
Colomban Wendling
bfd5587f4f Merge pull request #852 from b4n/reflow-hang
Fix hang in reflow command (and small improvements around)
2016-01-18 03:40:56 +01:00
Colomban Wendling
50212093ba Merge pull request #831 from b4n/cuda/tags
CUDA: Use C++ ctags parser
2016-01-18 03:34:02 +01:00
Colomban Wendling
a7ce20dc59 Merge pull request #826 from kugel-/doxygen-fixes2
Doxygen API fixes and cleanup.
2016-01-18 03:19:15 +01:00
Thomas Martitz
9f6f6cfb78 gir: keybindings: adhere to user_data naming convention
This helps g-ir-scanner recognizing the data parameter as context storage,
allowing object methods to be used as callback (via wrappers). It goes even
so far that g_object_unref is propery passed as destroy func to
keybindings_set_item_full() and plugin_set_key_group_full().
2016-01-17 14:13:45 +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
Colomban Wendling
6e0d4ac6ec Merge pull request #581 from techee/symbollist_sort
Make it possible to define default symbol_list_sort_mode
2016-01-13 17:43:03 +01:00
Thomas Martitz
740ecb00fb doxygen: fix doxygen warnings about filetypes_array references. 2016-01-12 07:15:54 +01:00
Jiří Techet
1ea072e125 Make it possible to define default symbol_list_sort_mode
Both sorting by name and appearance makes sense for most languages. Some
users may prefer sorting by appearance so make it configurable in
preferences (the possibility to override the settings for specific
filetypes is preserved).

Thanks to Colomban Wendling for lots of improvements of this patch.

Fixes #313.
2016-01-11 23:36:50 +01:00
Colomban Wendling
e7429d4cdb Merge branch 'gb-new'
Nothing to see here, is there :)
2016-01-11 02:31:01 +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
4bc5f4a7e4 Popup scope autocompletion dialog in more cases
* for PHP and Rust scope separator ::
* when there's more than one whitespace between the identifier and operator
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
Jiří Techet
e13aac0dea Remove unused tm_workspace_find_namespace_members()
The implementation of this function is almost the same like the original
m_workspace_find_scoped_members() and there's nothing interesting here
we wouldn't be able to recreate trivially.
2016-01-10 12:31:46 +01:00
Jiří Techet
809a9a7ea5 Merge add_member() and find_scope_members_tags()
By comparing the file pointer in the loop we can speed it up a bit
because we can avoid the strcmp() (this function is the slowest part of
the scope completion based on profiling).

Also move the pointer array creation to this function and return it which
is a bit cleaner.
2016-01-10 12:31:46 +01:00
Jiří Techet
8ff8cbc3a3 Sane implementation of find_scope_members_tags()
Disclaimer: I have absolutely no idea how the original function works.
After gazing into the code for one hour, I just gave up and wrote my own
version of it based on what I think the function should do
but maybe I'm just missing something what justifies the original
implementation's insanity.
2016-01-10 12:31:46 +01:00
Jiří Techet
140a7b6617 When extracting members, get them from single file only
The previous commit fixed the situation when e.g. anon_struct_0 was in the
current file by checking the current file first.

In the case the struct type definition isn't found in the current file,
at the moment we get all members from all anon_struct_0 which can be a
really long list. This list isn't very helpful to users because all the
members from all the structs are mixed. Moreover, not all possible members
are in the list because there are e.g. just members from anon_struct_0 but
not from anon_struct_1 etc. which from the point of view of this function
is a different type.

Instead, restrict the returned members to just a single file (anonymous
structs have unique name per file so it means there will be just one
from the file). Of course the picked file can be wrong and the returned
members might be from a different struct the user wanted but at least
the list will make more sense to users.
2016-01-10 12:31:46 +01:00
Jiří Techet
b6b93036f6 Get scope members only from corresponding tag arrays
At the moment it can happen that even though a member is found in the
currently edited file, the search at the end of the function finds
the type inside another file. This typically happens for anonymous
structs so e.g. for anon_struct_0{...} from the current file we get
members from anon_struct_0{...} from all open documents plus gloabl tags.

Search in an increasing "circle" - start with current file only (trying
all possible types of the variable), continue with workspace array and
finally, if not found, search in the global tags.
2016-01-10 12:31:02 +01:00
Colomban Wendling
4d4573c5d8 Merge pull request #855 from techee/changelog
Concatenate ChangeLog.pre-0-17 and ChangeLog.pre-1-22
2016-01-09 20:18:29 +01:00
Colomban Wendling
28f7c169fc Merge pull request #652 from b4n/kb/file-properties
Allow to set a keybinding for File->Properties
2016-01-09 20:07:23 +01:00
Colomban Wendling
8099fddd92 Remove leftover references to SVN
Closes #856.
2016-01-09 19:59:09 +01:00