702 Commits

Author SHA1 Message Date
Jiří Techet
bdee1336aa Keep a separate list of typenames for Scintilla syntax highlighting
Manage the list the same way as workspace tags_array by the fast tag removal
and merge. Thanks to this, typename tags don't have to be extracted from
tags_array periodically, which speeds up editing.
2014-10-30 22:08:17 +01:00
Jiří Techet
32a3dfab7f Use binary search when removing file tags
Even though the binary search requires expensive string comparisons,
there are just log(n) of them to find the tag in the workspace array
and the result is much faster than scanning the array linearly (this
of course works only under the condition that

len(source_file->tags_array) << len(workspace_array)

This is however satisfied for big projects (and doesn't matter for small
projects).

Also make the tm_tags_find() function more user friendly by returning
tagCount 0 when no tags found.
2014-10-30 22:08:17 +01:00
Jiří Techet
be131b00f9 Extend dedup() and merge() to unref the duplicate tag when needed 2014-10-30 22:08:17 +01:00
Jiří Techet
6ba3bb46a4 Don't pass arguments to search/sort functions using static variables
Instead of qsort() it's possible to use g_ptr_array_sort_with_data() with
similar performance. Unfortunately it seems there's no bsearch_with_data()
anywhere so the patch uses a modified bsearch() implementation from libc
(still probably cleaner than passing arguments using static variables).
2014-10-30 22:08:17 +01:00
Jiří Techet
15c90b63c9 Get rid of lazy initialization in TM
Lazy initializing various member pointers doesn't bring any real performance
improvement but it requires lots of additional NULL checks - get rid of
this.

Make some more cleanups on the way.

In addition, remove success/failure return values from tm_workspace_add_source_file()
and tm_workspace_remove_source_file() which have no real use.
2014-10-30 22:08:17 +01:00
Jiří Techet
43b8ab8d23 Only keep the minimal set of parameter in the TM API calls
Avoid "utility" parameters like do_free for which we already have API calls
and which actually don't perform any free if the source file isn't
in TM. Clarify when to set the update_workspace parameter.
2014-10-30 22:08:17 +01:00
Jiří Techet
0285ec28a5 Move tm_source_file_update() to tm_workspace.c
The placement of this function in tm_source_file is not right - by moving
it to the workspace we can make the source file unaware of the existence
of the workspace (no inclusion of tm_workspace.h in tm_source_file any
more). Also change tm_source_file_new() so it doesn't offer the source file
update.

After this change
* TMWorkspace knows TMSourceFile and TMTag
* TMSourceFile knows TMTag
* TMTag knows TMSourceFile
2014-10-30 22:08:17 +01:00
Jiří Techet
a183d9cb97 Move the refcount TMTag member up in the structure and don't document it for plugins 2014-10-22 16:58:38 +02:00
Jiří Techet
11866938cc Remove unused return value 2014-10-22 16:23:07 +02:00
Jiří Techet
6ef41c65a9 Various cleanups in the merge algorithm
Remove the continue statement and use if/else instead. Initialize the
val1 variable only with the value used for the chosen path (normal/fast).
2014-10-22 16:14:59 +02:00
Jiří Techet
9a2a55a252 Reinclude tm_tag.h in tm_workspace.c
To make Colomban happy.
2014-10-22 16:04:06 +02:00
Jiří Techet
d8b178e4cb Whitespace changes 2014-10-22 15:59:36 +02:00
Colomban Wendling
11ea0ed637 Remove some dead code 2014-10-22 15:06:14 +02:00
Colomban Wendling
a671c1e26d Fix signed vs unsigned comparisons 2014-10-22 15:05:35 +02:00
Jiří Techet
62332e19aa Since lang is now always part of TMTag, always set its value
This makes it less confusing for code accessing TMTag so it can always
find the language in tag->lang and there is no need to access it through
tag->file.lang.
2014-10-18 21:40:11 +02:00
Jiří Techet
54a9fd83ea Get rid of the nested members in TMTag
The only real change is the removal of struct and union in TMTag, the
rest is purely mechanical removal of "atts.entry." everywhere.
2014-10-18 21:40:11 +02:00
Jiří Techet
48725e4188 Get rid of the file struct in TMTag, preparation for the union removal
The union on TMTag is very confusing and rather dangerous. The fields
file/timestamp and line/lang overlap. Some implicit assumptions are made
in the code - timestamp is never set so when file is NULL, the file
struct should be used to get the lang member. Rather avoid using unions
and move the lang member to the entry struct together with the other
attributes.
2014-10-18 21:40:10 +02:00
Jiří Techet
a7c6e0733f Remove tm_tag_file_t and all its uses
File tags aren't used for anything in geany and neither the existing
global tag files seem to use them - remove this concept from geany.
2014-10-18 21:40:10 +02:00
Jiří Techet
0f9b778ae5 Fix division by 0 2014-10-18 21:40:10 +02:00
Jiří Techet
9eefdb0efc Where possible, convert functions to static in TM 2014-10-18 21:40:10 +02:00
Jiří Techet
034ef6d79d Remove the unused (and misleading) tm_tag_free()
It just calls unref() which might not actually free the tag if the refnum
is more than 1.
2014-10-18 21:40:10 +02:00
Jiří Techet
344eca0204 Add #if 0 around unused TM functions and move them to the end of the file
Similarly, add #if TM_DEBUG around various unused debugging functions.

The #if 0 surrounded functions are good candidate for future removal
if decided they are not needed any more.
2014-10-18 21:40:10 +02:00
Jiří Techet
2c09333b6a Remove unused tm_tags_custom_sort() and tm_tags_custom_dedup() and friends 2014-10-18 21:40:10 +02:00
Jiří Techet
4e98021689 Swap the merge arguments if len(small_array) > len(big_array) 2014-10-18 21:40:10 +02:00
Jiří Techet
fe98ea6156 Use the new merge implementation also for global tags 2014-10-18 21:40:10 +02:00
Jiří Techet
0470f45e0c TM: move function descriptions from headers to sources
To make it consistent with the rest of Geany.
2014-10-18 21:40:10 +02:00
Jiří Techet
4903d79dcc TM: use the same format of docstrings as in the rest of Geany 2014-10-18 21:40:10 +02:00
Jiří Techet
74706374eb Remove the unused inactive flag in TM
It is set only when read from a file but it never gets written to the file
with the TRUE value.
2014-10-18 21:40:10 +02:00
Jiří Techet
d686674eca On single file update only merge the file's tags into workspace tags
Since both the file tags and workspace tags are sorted, it is unnecessary
to completely resort the tags for the workspace - instead, remove the
tags belonging to the file from the workspace tags and merge the updated
file's tags into the workspace tags.

The merge is optimized for merging small number of tags into a large array.
For instance, the total number of tags in linux kernel is about 2300000
while the average number of tags per file is about 65 (35000 source files).
Most of the time merge won't be performed so we can avoid expensive
string comparisons and try to make bigger jumps to see if some merge is
needed or not (more details in the source file comments).
2014-10-18 21:40:10 +02:00
Jiří Techet
8c25ff871c Make tm_workspace_update() public 2014-10-18 21:40:10 +02:00
Jiří Techet
52076d19e8 Remove unused tm_file_entry.[ch] 2014-10-18 21:40:10 +02:00
Jiří Techet
26587454b0 Remove TmWorkObject and all the OO related stuff
In addition, rename all functions, parameters, comments etc. mentioning
work_object and remove unnecessary parameters of various functions.
Delete dead code paths.

Also move common functions like tm_get_real_path() from tm_work_object to
tm_source_file.
2014-10-18 21:40:10 +02:00
Jiří Techet
6242d19471 Add all headers to libtagmanager_a_SOURCES in tag manager makefile
So they become part of tarball.
2014-10-12 23:49:52 +02:00
Jiří Techet
dbcf67d449 Define the GEANY_PRIVATE macro for tag manager in makefile.win32 2014-10-12 23:37:00 +02:00
Jiří Techet
6d6dd7444b Fix doxygen warnings
Make documents_array public and accessible by doxygen and describe all
parameters of tm_source_file_new().
2014-10-12 23:33:51 +02:00
Jiří Techet
10a28b4191 Protect private definitions by the GEANY_PRIVATE macro in headers
In addition, this patch defines the GEANY_PRIVATE macro for the tag
manager library where it wasn't defined before, removes 2 tag manager
headers from distribution as they are not needed by plugins and
in the tag manager changes the docstrings to ordinary comments for
private definitions.
2014-10-09 20:51:32 +02:00
Nick Treleaven
c0a8a1a943 Fix Windows build 2014-10-07 14:50:07 +01:00
Jiří Techet
ce46f8f0b4 Remove unused tm_tagmanager.c 2014-10-05 22:40:15 +02:00
Jiří Techet
4646323878 Remove unused tm_symbol 2014-10-05 22:40:15 +02:00
Jiří Techet
b512aa0368 Remove unused tm_project and all its references in docstrings 2014-10-05 22:40:15 +02:00
Colomban Wendling
b7b34ec451 Rewrite the Txt2tags parser for better conformance and features
This fixes parsing indented titles and titles with embedded delimiter
characters, and adds support for title nesting information.

Syntax: http://txt2tags.org/rules.html

Closes [feature-requests:#690].
2014-08-19 16:11:23 +02:00
Colomban Wendling
8341228ffa JavaScript: fix handling of parentheses around an rvalue
Properly skip parentheses around an rvalue, and then properly recognize
the surrounded value.  This allows to properly recognize e.g. rvalue
`({...})` as an object, or `(function(){})` as a function.  As the
implementation is tolerant regarding garbage after the statement,
function expressions called straight away (`(function(){})()`) are
implicitly supported.

This however removes support for the following invalid JavaScript
syntax that was previously supported as a function/method declaration:

	var func = () {}

This syntax is not present in the ECMA standard nor is supported by
popular JavaScript engines.

See:
 * http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
   section 13, "Function Definition"
 * http://ecma262-5.com/ELS5_HTML.htm#Section_13
 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope#Defining_functions
2014-08-04 00:23:13 +02:00
Colomban Wendling
35e8fbbe28 JavaScript: fix handling of various missing semicolons in loops 2014-08-03 23:24:33 +02:00
Colomban Wendling
3ff01aeeb3 JavaScript: recognize assignation to a parenthesized expression 2014-08-03 19:07:59 +02:00
Colomban Wendling
b596aa14e8 JavaScript: don't choke when returning object literals 2014-08-03 16:57:26 +02:00
Colomban Wendling
bc9b2fa444 JavaScript: don't choke on array lists 2014-08-03 16:52:11 +02:00
Colomban Wendling
4cfe71a487 Merge branch 'tm/faster-current-tag'
This makes tm_get_current_tag() roughly 4.5 times faster.
2014-08-01 17:34:24 +02:00
Colomban Wendling
257de6597c fortran: Make sure not to index kinds out of bounds
This also makes recent GCC shut up about indexing below the bounds as
it detected the code checked for a negative index yet didn't guard the
actual access.  For now GCC doesn't understand the more comprehensive
check, but it might come back if GCC becomes smart enough.

Anyway, this makes the Assert() more correct, and addition of the
explicit kinds array size makes sure any future kind addition won't
miss its entry.
2014-08-01 16:05:09 +02:00
SiegeLord
5e469dc5ae Rust: Update comment parsing.
Rust now allows CRLF line endings in source files, which doesn't actually
change any lexing here but the comment was wrong.

Also, the hashbang initial comment has a special case where #![ doesn't count
as a comment (but instead an inner attribute that just happens to be on the
first line).
2014-07-29 11:10:14 -04:00
SiegeLord
756344d901 Rust: Parse character literals.
These were omitted by mistake. Caused bugs like '"' being interpreted as a
start/end of a string, '}' as the end of a block etc.
2014-07-29 10:51:36 -04:00