724 Commits

Author SHA1 Message Date
Colomban Wendling
5a1a22d930 javascript: Properly handle nested unknown blocks
Properly match open curly braces when parsing a statement not to
possibly get fooled by unexpected nested blocks, e.g. after a
`switch`'s `case` or a label.

This mostly reverts c54c3ad5e815d16e3b48f3c477465627808aadee and
replaces it with a more correct and complete solution.
2014-11-24 02:41:57 +01:00
Colomban Wendling
f158f5d362 javascript: Fix scope after some constructs 2014-11-24 02:41:17 +01:00
dfishburn
f886f7084a Javascript parser: Removed warning of unused variable is_inside_class and cleanUp
git-svn-id: https://svn.code.sf.net/p/ctags/code/trunk@815 c5d04d22-be80-434c-894e-aa346cc9e8e8
2014-11-24 02:00:24 +01:00
dfishburn
c54c3ad5e8 Added new method findMatchingToken() to skip over blocks of code. Updated parseSwitch() to use the new method.
Updated tests/ctags/ui5.ui.controller.js with code that broke the switch statement.

git-svn-id: https://svn.code.sf.net/p/ctags/code/trunk@809 c5d04d22-be80-434c-894e-aa346cc9e8e8
2014-11-24 01:48:04 +01:00
dfishburn
52d2d73527 Udated jscript to be able to parse SAPUI5 controller and view files.
Added test case tests/ctags/ui5.controller.js

git-svn-id: https://svn.code.sf.net/p/ctags/code/trunk@808 c5d04d22-be80-434c-894e-aa346cc9e8e8
2014-11-24 01:39:36 +01:00
Colomban Wendling
f765463af0 Import new CSS parser from fishman-ctags
Some highlights:
* Fixes handling of comments
* Adds support for attribute and namespace selectors
* Adds support for @supports blocks
* Fixes tag type for many selectors
* Adds support for pseudo-classes with arguments
2014-11-11 02:01:41 +01:00
Colomban Wendling
6a0673f4ae TM: Don't allow passing NULL to tm_workspace API 2014-11-08 18:32:41 +01:00
Colomban Wendling
b38f1f99d5 TM: Use gsize everywhere for the memory buffer size 2014-11-08 18:13:13 +01:00
Jiří Techet
f441a121d3 Parse file from buffer only if the file isn't too big
By loading e.g. a huge DB dump into memory we could run out of memory.
Check the size of the file and determine whether to use file parsing
or buffer parsing.

Give up early if LANG_IGNORE set - there's no need to read the file in
this case.
2014-11-06 11:39:40 +01:00
Jiří Techet
0ad85aee04 Fix comment wording 2014-11-05 21:50:07 +01:00
Jiří Techet
a95fc1a994 Don't expose the source file update function to plugins 2014-11-05 21:50:07 +01:00
Jiří Techet
90944c77b0 Unify tag sorting and simplify tag comparison function
Use the same (or compatible) sorting criteria everywhere.

Add tm_tag_attr_line_t to sort options so even after merging file tags
into workspace tags, the same tags defined at different lines are preserved
and not removed as duplicates.

Sort type before scope because it's cheaper to compare (string vs int comparison).

For some reason, the above changes make the sorting performance worse.
Simplify the tag comparison function a bit and reorder the case statements
in the switch to match the sort order. This (again not sure why), makes the
performance like before.
2014-11-05 21:50:07 +01:00
Jiří Techet
29000cf104 Always parse buffer instead of file
This brings the linux kernel parsing time from about 20s to 12s on my machine.
2014-11-05 21:50:07 +01:00
Jiří Techet
448f1fd20e Make sure gboolean tm_source_file_parse() returns the right value
Previously, after finishing the while loop TRUE was returned - this is
wrong because the while was running because parsing was unsuccessful.
Make it work the same way as in ctags (parser() always succeeds,
parser2() returns whether to retry or not).

(The return value actually isn't used, it's just to make sure we know
what we are doing.)
2014-11-05 21:50:07 +01:00
Jiří Techet
f35d0b9c0c Move tm_get_current_tag() from tm_workspace to tm_tag
This function has nothing to do with the workspace so it rather belongs
to tm_tag.
2014-11-02 11:40:05 +01:00
Jiří Techet
71cc1ecb20 Cleaner and safer TMWorkspace API
With the previous TMWorkspace API it was possible to make the workspace
inconsistent by e.g. removing source files and forgetting to update
workspace. This could lead to non-obvious and not immediately visible
crashes.

The new set of the public (but also Geany private) API calls always
updates the workspace accordingly and neither of the calls can lead
to an inconsistent state of the workspace.

In addition, perform some minor cleanups and simplifications - unify
parsing from buffer and from file, support "parsing" of 0-sized buffers
and improve documentation.
2014-11-02 11:39:57 +01:00
Colomban Wendling
48718f4b79 Remove an unused parameter 2014-10-31 20:25:59 +01:00
Colomban Wendling
013c47c6e3 TM: Fix various integer signedness issues 2014-10-31 20:25:13 +01:00
Colomban Wendling
61ee7de86e Return an unisgned tag count in tm_tags_find()
There is no reason to return a signed value an it help unifying
caller's types.
2014-10-31 20:20:25 +01:00
Colomban Wendling
42a9603f4a Use TMTagType everywhere to hold tag types 2014-10-31 20:07:27 +01:00
Jiří Techet
d7ed48f86b Fix a problem in tm_tags_remove_file_tags() when more tags of the same name exist 2014-10-31 02:03:13 +01:00
Jiří Techet
cb9e4bbf74 Microoptimization in merge
Improves performance by about 10%.
2014-10-30 22:08:17 +01:00
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