9943 Commits

Author SHA1 Message Date
Frank Lanitz
e59a2412f9
Merge pull request #3094 from nomadbyte/po/uk
PO:(uk) Update translation
2022-10-02 18:41:43 +02:00
Frank Lanitz
263a9897eb
Merge pull request #3251 from hugok79/patch-1
Update Portuguese translation
2022-10-02 18:26:09 +02:00
Frank Lanitz
3e72f637c8
Merge pull request #3276 from melhiors/master
Update of Latvian translation
2022-10-02 18:25:41 +02:00
Ben Young
b9891f2912
Added error_regex to filetypes.rust (#3300) 2022-09-22 13:10:03 +10:00
Jiří Techet
740377e6d0
Merge pull request #3203 from techee/cxx_mem_leak
cxx: use a trashbox for deleteing tokens allocated for anonymous parameters
2022-09-21 23:36:07 +02:00
Jiří Techet
0bc92b0f54
Merge pull request #3172 from techee/flat_tree
Add option to show symbols in symbol tree without root groups
2022-09-21 23:32:58 +02:00
Jiří Techet
3952182724
Merge pull request #3275 from techee/local_python
Enable local variable and parameter tag reporting for various languages
2022-09-21 23:32:25 +02:00
Enrico Tröger
3698462af9
Merge pull request #3011 from dolik-rce/fix-context-menus-on-wayland
Fix context menus on wayland (#3009)
2022-09-17 10:04:02 +00:00
Enrico Tröger
465e60bef6
Remove native file and color dialogs on Windows (#3219)
Their implementation was buggy, use very old Windows APIs and require
double implementation and maintenance efforts for us
The GTK dialogs work well for all other users already, so they probably
will also for Windows users.

Closes #3209.
2022-09-17 09:57:33 +00:00
Jiří Techet
6809d3a8ea Add option to show symbols in symbol tree without root groups
While the current way of grouping symbols under various categories
like "Functions", "Structures", "Macros" etc. may be useful in some
situations, it doesn't allow true sorting by name or sorting by line
number because this sorting is only valid within the group and not
globally which makes it sometimes hard to find some symbol.

This patch adds the option to switch between two views of the symbol tree
by using a new checkbox called "Group by Type" to the context menu:

- checked - the original view used by Geany
- unchecked - view with a single root element "Symbols" in which
  all symbols are rooted and all of them either sorted by line number
  or alphabetically

The core of the implementation is rather simple - there's always the
"Symbols" root present at position 0 in tv_iters and when categorized
view is selected, this root is used for all the tags. (We still need
to keep the category roots in this situation to copy the icons for
the tags from them but they are always empty and hidden).

The rest is some UI stuff for creating entries in the context menu, I also
added a config preference so this settings is remembered across Geany
re-launches. I made this option global for all open files because
I would find it annoying to apply this setting manually for every open
file. So the code also checks whether the view type changed for the
given file when switching tabs and re-creates the tree with the new
setting.
2022-09-14 00:22:23 +02:00
Jan Dolinar
3bffc4518d Refactor context menu code to ui_menu_popup 2022-09-11 17:38:44 +02:00
Enrico Tröger
563d94d856
Merge pull request #3265 from kugel-/fix-rightclick
Fix intermittent, erratic right-click behavior on documents sidebar page
2022-09-11 13:50:26 +00:00
Thomas Martitz
6b5e711c76
Properly fallback to geany.conf for session data (#3264)
The fallback was not applied for loading the user session files (i.e.
the opened files) but only for other session config.

Fixes #3236
2022-09-08 23:23:51 +02:00
Jiří Techet
2884b02fac
Merge pull request #3204 from techee/separate_parsing
Don't use temporary file when creating tag files without running preprocessor
2022-09-04 22:33:43 +02:00
Jiří Techet
5b12e286ae
Merge pull request #3268 from techee/local_tags
Ignore local tags for autocompletion in other files
2022-09-04 22:28:41 +02:00
Enrico Tröger
2b424581dc
Merge pull request #3273 from techee/anon_rename_fix3
Fix renaming tag type containing anonymous type
2022-09-04 13:20:08 +00:00
Ingmārs Dīriņš
b0e11d7847 Update of Latvian translation 2022-09-03 22:04:18 +03:00
Jiří Techet
06e8bdc1b3 Enable local variable and parameter tag reporting for various languages
This patch enables local variable and function parameter reporting for
Python, GDScript, PHP, and Typescript.

Because these are dynamic languages and Geany scope autocompletion
relies on static type information, scope completion doesn't work for
these languages. However, at least we get non-scope autocompletion
for local variables and function parameters.

Local variables in GDScript were previously mapped to tm_tag_other_t
and were displayed in the sidebar. We don't display these tags for
C/C++ in the sidebar and they should also be mapped to
tm_tag_local_var_t which is why there is a diff in unit tests removing
these variables from the output.

The python parser generates a slightly different output when function
parameter parsing is enabled (whitespace only change) which causes
the change of the output of some python unit tests.
2022-09-03 00:08:51 +02:00
Jiří Techet
41b40120ea Update python parser to the latest version from uctags
This version contains fixes related to parsing function parameters.
2022-09-03 00:07:37 +02:00
Jiří Techet
b8754a7a32 Fix renaming tag type containing anonymous type
The current code assumes that the whole var_type string consists of the
anonymous type name. This works for simple cases like

struct {} X;

where X is of the type __anonXXXX but not for cases like

struct {} X[2];

where X is of type __anonXXXX[].

For these cases checking for equality of var_tag->var_type, orig_name isn't
sufficient and we have to check whether orig_name is a substring
of var_tag->var_type and replace this substring with the new anon name.

This problem can be seen for instance in the symbol tree tooltip of
the symbols_icons variable inside symbols.c
2022-09-01 23:05:29 +02:00
Jiří Techet
10fba80d84 Ignore local tags for autocompletion in other files
ctags sets the tag's "local" flag to true for tags whose visibility is
limited to the current file only. These are for instance "static" functions
in C.

We can ignore these tags for autocompletion in other files than the
tag's file which reduces the number of irrelevant tags in the
autocompletion popup.
2022-08-29 19:35:46 +02:00
Jiří Techet
8c7081c652 Don't use temporary file when creating tag files without running preprocessor
The tm_workspace_create_global_tags() function generates tags for
two cases:

1. Source files pre-processed by C pre-processor. It first generates
a file combining the parsed header files by creating a temporary
file in which all the header files are included and this file is passed
to the pre-processor. The result of the pre-processed file is then
parsed by the ctags parser.
2. Source files directly parsed by the ctags parser. In this case all
the source files are concatenated to a single file which is then parsed
by the ctags parser.

This patch leaves (1) more or less unchanged; however, the creation of
the temporary file in (2) is unnecessary - the individual files can
be parsed directly, the tags from all the parses can be combined, sorted
and pruned without creating the temporary file.

The temporary file is a problem for unit tests where some languages
use the file name as the name of module in which the tags are defined
and by using a different name, the unit test generates a different tag
file every time it's run.

Note the changed output of the process_order unit test caused by this
change. The test parses two files, one containing

enum {
	I1_E1,
	I1_E2,
};

the other contining

enum {
	I2_E1,
	I2_E2,
};

Previously, because the files were concatenated the enums were different
tags and the anonnymous tag renaming function renamed them to anon_enum_1
and anon_enum_2. Because now the files are parsed separately, the
enum from the first file gets renamed to anon_enum_1 and when parsing
the second file, we get the name anon_enum_1 as well for the second enum.
This however isn't a problem - we don't display global tags in the
symbol tree, autocompletion, and they are also ignored in scope completion
so this shouldn't matter much.
2022-08-28 23:21:46 +02:00
Jiří Techet
30f5514465 Rename variables in tag file writing functions to make things clearer
The code was probably originally written for c/c++ only and all the
mentions of "include files" mean "source files" for other languages.
2022-08-28 20:40:11 +02:00
Thomas Martitz
5cdfe35cf2
Merge PR #3185
Enable local variables for C/C++ and improve autocompletion
2022-08-28 13:38:27 +02:00
Jiří Techet
a91a9c6ca1 Update documentation related to scope autocompletion 2022-08-28 00:44:50 +02:00
Jiří Techet
db1c862d5e Remove unnecessary "lang" parameter of various functions
In functions where we pass the current file as an argument, we can get
the used language from the file and this extra parameter is unnecessary.
2022-08-28 00:44:50 +02:00
Jiří Techet
4f45f7014b Sort non-scope autocompletion results by locality
To present more relevant results at the top of the list, sort them in
the following order:

local variables
tags from current file
workspace tags
global tags

and alphabetically within a single group.

In addition, we need to remove duplicates from the list of displayed names.

Finally, since the entries are not sorted alphabetically, we need to call

SSM(sci, SCI_AUTOCSETORDER, SC_ORDER_CUSTOM, 0);

so Scintilla knows it shouldn't sort the list alphabetically.
2022-08-28 00:44:50 +02:00
Jiří Techet
2a5da2225f Rewrite member_at_method_scope() to handle more situations
When performing scope completion for

void A::foo() {
    bar.  // <--
}

we need to determine what 'bar' is. It could be a global variable, in which
case we should look for variable tags, it could however also be a member
of A in which case we should look for member tags.

To determine this, the previous code checked whether there's a tag
named 'bar' with the same scope as the method tag. One drawback of this
approach is that it doesn't take namespace manipulation functions
like 'using namespace' into account so for header

namespace X {
    class A {
        Baz bar;
    };
};

and source

using namespace X;

void A::foo() {
    bar.  // <--
}

it wouldn't find 'bar' because ctags reports foo() to have scope A
and bar to have scope X::A.

Another drawback of this approach is that it doesn't take inheritance
into account so it wouldn't find 'bar' when defined in a super-class,
such as

class B {
    Baz bar;
};

class A : B {
    void foo();
}

To avoid these problems, this patch rewrites member_at_method_scope()
(and renames it to member_accessible()) so it gets the class name from
the scope of the method in which we are (A in the above example) and
returns all members of A (including the super-classes members).
Afterwards, it checks if one of the members is really the member tag
we are interested in ('bar' in the above example).
2022-08-28 00:44:50 +02:00
Jiří Techet
e4f2ed7452 Support (multiple) inheritance by scope completion
The code simply checks for inherited classes, strips unneeded stuff
like templates, etc. from inherited classes, detects multiple inheritance
by splitting the string using "," and calling tm_workspace_get_parents()
recursively on every parent class and collecting the returned tags.
The code limits the recursion depth to 10 to avoid possible inheritance
cycles and infinite recursion.

Also remove #if 0'd old code from TM implementing inheritance that we
kept for reference as we now have a better implementation.
2022-08-28 00:44:50 +02:00
Jiří Techet
2cf2e87bda Strip more things from variable type
We are interested in pure type name and ctags returns types including
pointers, references, arrays, template parameters and keywords such as
"const" or "struct". Strip all those.

Also move strip_type() above so it's usable by other functions.
2022-08-28 00:44:50 +02:00
Jiří Techet
13bdb37cf7 Update goto symbol definitions to take into account local variables
We only want to use local variables within the current function for
the goto. This means we want to filter out local variable tags that:
1. Are from a different file
2. Are declared later in the file than where the current cursor is
3. Have different scope than the current function scope

Fundamentally the same requirements as for (non-scope) autocompletion.
2022-08-28 00:44:12 +02:00
Jiří Techet
25f150931e Update scope completion to take into account local variables
The code removes invalid local variables from other functions and behind
current position. In addition, it sorts the found tags corresponding
to the name in the editor for which we perform scope completion so
local variables are searched first for their members, followed by tags
from the current file, followed by workspace tags and finally using
global tags.
2022-08-28 00:44:12 +02:00
Jiří Techet
9e4ef229a6 Update (non-scope) autocompletion to take into account local variables
We have to ignore local variables that:
1. Are from a different file
2. Are declared later in the file than where the current cursor is
3. Have different scope than the current function scope
2022-08-28 00:43:14 +02:00
Jiří Techet
86cefe6a26
Merge pull request #3195 from techee/anon_rename_fix
Fix anonymous tag renaming when interleaved by scopeless macros
2022-08-28 00:33:56 +02:00
Jiří Techet
fe4c0738eb Fix anonymous tag renaming when interleaved by scopeless macros
This problem can be seen on

scintilla/src/Document.cxx

where not all anonymous tags are renamed because of macros. Fix that
by not breaking the rename loop for macros for C-like languages.
2022-08-28 00:22:29 +02:00
Jiří Techet
d5cc1d05fb Enable local tag generation for C/C++
Enable generating these tags both for local variables and function
parameters - those are more or less identical for what we will be using
local tags for so they can be mapped to the same type.

Local tags aren't interesting for tag files so filter them out when
generating these (but this also means that we cannot create unit tests
for them).
2022-08-27 23:57:50 +02:00
Jiří Techet
8ff56a5c77 Rename tm_tag_file_t to tm_tag_local_var_t
tm_tag_file_t is unused in Geany (and we'll probably never need tags
for files) so let's use it for local variable tags.
2022-08-27 23:57:50 +02:00
Thomas Martitz
6db1b3a7bd Fix intermittent, erratic right-click behavior documents sidebar page
Sometimes right-click to open a the popup menu in the document sidebar
wouldn't change the selection before showing the popup. Then the
popup wasn't related to the document that was clicked.

This was especially bad with middle-click to close. It closed anything
but the clicked document (or folder in case of tree view).

This was caused by some unexpected calls to the "activate" signal handler
for the "openfiles_path_mode" menu items. The handler might re-create
the document list which in turn invalidates the current selection.

Now the signal handler has some protection against unexpected calls and
the selection properly updates upon right-click before spawing the popup.
2022-08-27 22:27:24 +02:00
Jan Dolinar
85de03686c fix context menus on wayland (#3009) 2022-08-16 14:24:31 +02:00
Hugo Carvalho
b7ecec1f11
Update portuguese translators credits 2022-08-12 12:07:54 +01:00
Hugo Carvalho
69e6328b1e
Update/improve Portuguese translation
Minor corrections
2022-08-12 12:06:07 +01:00
Nilankan Betal
34ce1724a5
Remove extra parentheses
Fixes #3238
2022-08-09 17:46:05 +10:00
Enrico Tröger
fef873d485
Merge pull request #3051 from techee/display_tags
Add human-readable representation of tags to unit test results
2022-06-15 19:33:59 +02:00
Jiří Techet
aba66f07cc Update unit tests to use the pretty-printed format 2022-06-13 00:31:22 +02:00
Jiří Techet
ad304cf79a Use the formatting script when running unit tests 2022-06-13 00:31:22 +02:00
Jiří Techet
4753344ce8 Add script for pretty-printing geany tags files
This script reads  Geany binary tags files from stdin and writes
to stdout a file where each of the tags is followed by a line where
the tag is printed in the following human-readable form:

tag_type:   return_value scope :: tag_name(arglist)   additional_stuff

Especially the tag_type is currently hard to understand when looking at
unit tests and easy to miss if there's a problem.
2022-06-13 00:31:16 +02:00
Thomas Martitz
def1600a5b
Merge PR #1813
This adds a tree view mode to the document list in the sidebar and enables it by default.

Based on previous work by Pavel Roschin <roshin@scriptumplus.ru>, see #259
2022-06-08 14:47:23 +02:00
Thomas Martitz
8932304f67 Add item to NEWS for tree view of open documents 2022-06-08 07:54:00 +02:00
Thomas Martitz
20bd9c44ea Add a unit test program to check the new sidebar documents tree view
The test program checks if open documents are grouped correctly by
their parent directory. The older modes (plain document list and two-level
tree) also get a distinct test. For this to work some symbols
must become visible from libgeany.

The test uses g_strv_length() which is relatively new.
Autoconf and meson checks are added as needed.
2022-06-08 07:54:00 +02:00
Thomas Martitz
9e1c79079b Refactor GTK-related autoconf checks
- Move to separate file geany-gtk.m4
- Merge gthread checks into the main gtk ones
2022-06-08 07:53:59 +02:00