Commit Graph

253 Commits

Author SHA1 Message Date
Jacob Dufault
c596e55dcc Cleanup some includes. 2017-12-29 12:00:52 -06:00
Fangrui Song
d4ce12bb9a Add --use-clang-cxx to waf and move type printer to src/type_printer.cc
src/type_printer.cc demonstrates how to leverage clang C++ API.
It includes clang/**/*.h headers and CXTranslationUnit.h which resides
in clang/tools/libclang/ but is not exposed in clang/include/clang-c/

These libclang/ header files are stable and provide some struct definitions used by clang-c/ header files.
A copy of them from clang source tree is checked into libclang/ .

If you want to an early adopter,
CXXFLAGS='-std=c++11 -fno-rtti -D_GLIBCXX_USE_CXX11_ABI=0 -g' ./waf configure --variant=cxx-debug --bundled-clang=5.0.1 --use-clang-cxx

Some clang/**/*.h are unstable and should be used with caution,
in addition, Windows pre-built binaries on https://releases.llvm.org/download.html do not include C++ header files.
Thus `--use-clang-cxx` defaults to False.
2017-12-29 09:51:26 -08:00
Fangrui Song
34052fbf27 [indexer] Index some references in ClassTemplate 2017-12-28 10:53:13 -08:00
Jacob Dufault
4781e9a53d Move tests to index_tests 2017-12-28 09:42:55 -08:00
Jacob Dufault
3ab2f2e2b7 Update formatting 2017-12-28 09:22:26 -08:00
Fangrui Song
56135f615c [template] Attribute template parameter references to the parameter declaration. Class templates still do not work 2017-12-28 00:37:10 -08:00
Fangrui Song
cff432a223 [template] Index references to non-type template parameters 2017-12-27 23:42:56 -08:00
Fangrui Song
d7d8b820ac [template] Index template parameter references 2017-12-27 22:58:07 -08:00
Fangrui Song
f86de0b544 function signature: blacklist "typeof " 2017-12-27 19:51:16 -08:00
Fangrui Song
6fa08b2b90 Refactor function signatures: fix infinite loop processing constructors 2017-12-27 18:51:19 -08:00
romix
8bdce31789 Produce detailed function signatures which include parameter names 2017-12-27 15:49:26 -08:00
Jacob Dufault
b8e7a5bcb3 Format code 2017-12-27 07:54:46 -08:00
romix
03b50ea3cc Serialize decl comments and use them in GetHoverForSymbol 2017-12-24 18:01:38 -08:00
Fangrui Song
2ffc068760 Handle function calls from templates. fix #174 2017-12-24 15:12:52 -08:00
Fangrui Song
dced34dd58 Reopen #174 2017-12-24 13:28:53 -08:00
Fangrui Song
4b9bc342f5 Fix called_id 2017-12-24 10:43:32 -08:00
Fangrui Song
6a8537c2bf Handle function references in templates. fix #174 (#184) 2017-12-24 10:27:17 -08:00
Fangrui Song
dd4044998d Add TemplateVisitor to handle CXCursor_OverloadedDeclRef in templates 2017-12-24 00:35:38 -08:00
Fangrui Song
cdcf75ac84 Raise maxWorkspaceSearchResults to 500 and sort results even if the max number has been reached 2017-12-23 22:49:45 -08:00
scturtle
cb7ccbe543 Change var.def.is_* to enum. 2017-12-23 19:29:32 -06:00
Fangrui Song
646d154b9b Better heuristics, noexcept specifier and C11 _Atomic specifier 2017-12-23 09:57:12 -08:00
Fangrui Song
156d4891c3 [hover] Better heuristics to insert function name right before the paren pair enclosing parameters (#178) 2017-12-23 09:29:13 -08:00
Jacob Dufault
fb491e6c6d Format using clang format 4.0.0 2017-12-23 08:33:26 -08:00
Jacob Dufault
4aeb6acf04 Test improvements:
- Update files with \r\n newlines.
- Require clang 4.0.0 for running tests.
2017-12-23 07:51:34 -08:00
Chao Shen
0985613d16 Add is_global and is_member. 2017-12-23 01:00:46 -06:00
Fangrui Song
2056e44d22 Insert qualified name right before matching paren ( of last ) in function's type spelling
Before, function<int(int)> and (anon) mess up the function signature
2017-12-22 15:48:30 -08:00
Fangrui Song
c3c0feecb2 [indexer] Make hover optional (#176)
On textDocument/hover requests, return `detailed_name` if `hover` is unavailable
Don't include leading `type_name` in `detailed_name` for CXIdxEntityEnumConstant, i.e. `Foo Foo::a` -> `Foo::a`
2017-12-22 14:48:55 -08:00
Fangrui Song
ba4a5e91cb [indexer] Remove IsLocalSemanticContainer check in qualified names 2017-12-22 09:21:53 -08:00
Jacob Dufault
fd7c01796c Do not include path in lambda detail/hover string 2017-12-22 08:59:37 -08:00
Fangrui Song
043e9a4d44 [indexer] Fix hover info of class member functions 2017-12-21 22:46:45 -08:00
Fangrui Song
ba1ca37326 [indexer] Make $cquery/base find correct overriden functions (#169) 2017-12-20 23:18:48 -08:00
Fangrui Song
6aefa9b114 [indexer] Handle unnamed namespaces 2017-12-20 19:52:34 -08:00
Fangrui Song
ee78b527ae [indexer] Treat empty short_name as implicit call which should not be included in all_symbols
std::vector<int> a = f(); // besides f, there is an implicit move constructor vector(vector<T>&&)
We expect finding references on `f` takes us to `f`, not to `vector(vector<T>&&)`
2017-12-20 07:46:43 -08:00
Fangrui Song
cf4603c6fa Add FileContentsWithOffsets 2017-12-18 23:05:12 -08:00
Jacob Dufault
8098e4f01d Support multiple base functions. 2017-12-18 22:15:46 -08:00
Jacob Dufault
be961fc4f2 Add hover (instead of reusing detailed_name) 2017-12-18 21:20:00 -08:00
Fangrui Song
8897bcc54d [indexer] Display declaration line for typedef/using. fix #141
GetDocumentContentInRange calls clang_tokenize, which is not easy to
handle multi-line declarations. Only display declaration lines for
one-line `typedef`/`using` now.
2017-12-18 19:30:49 -08:00
Walter Erquinigo
cb098cbfc3 test 2017-12-18 16:26:58 -08:00
Walter Erquinigo
a6cb98945e Add obj-c support in the indexer 2017-12-18 16:26:58 -08:00
Fangrui Song
5600989a42 [indexer] Treat explicit destructor call as not is_implicit (#159)
Also fixed an unused warning.
2017-12-18 13:48:32 -08:00
Fangrui Song
9fd35db034 [indexer] Index references to system headers 2017-12-17 21:16:40 -08:00
Jacob Dufault
c0c3fc41a4 Do not emit an include in the indexer if we failed to resolve the file. Also add -resource-dir to tests. 2017-12-15 21:24:31 -08:00
Walter Erquinigo
5238c50027 objc 2017-12-15 12:02:32 -08:00
Fangrui Song
17cac3d30a [indexer] Change macro's IndexVar::def::detail_name to its approximate definition
For `#define foo 3`,
Before this commit, `detail_name` was `foo` (displayed for textDocument/hover reqeusts).
It is now shown as `#define foo 3`
2017-12-13 09:35:44 -08:00
Jacob Dufault
1467526bad Be less aggressive about indexing potential lambdas 2017-12-12 09:49:52 -08:00
Fangrui Song
17f23bf3bf In OnIndexDeclaration, get_type_description() may return the name of a typedef and there is no (, causing insert failing 2017-12-12 00:14:25 -08:00
Jacob Dufault
9b909b3a13 Move usr out of *Def and into Query*/Index* types.
I'd like to make the *Def structures optional in the future, and usr is always non-optional.
2017-12-11 23:57:44 -08:00
Jacob Dufault
2751f51956 Format 2017-12-11 21:21:03 -08:00
Fangrui Song
fb902a29b7 Add missing definition and reference info to lambda paramaters. fix #120 2017-12-11 21:06:55 -08:00
Fangrui Song
479c0c59bc More idiomatic 2017-12-10 19:53:17 -08:00
Jacob Dufault
5d1fd4ce4d Remove a bunch of std::cerr in favor of LOG_S 2017-12-01 17:04:39 -08:00
Jacob Dufault
fa240e3132 Small code cleanup in src/indexer.cc. 2017-12-01 09:57:03 -08:00
Jacob Dufault
9b44bf7901 Run ./format.sh 2017-12-01 09:55:41 -08:00
Jacob Dufault
066166ba40 Add --clang-sanity-check.
Does a simple index test to verify expected libclang API behavior.
2017-12-01 09:46:40 -08:00
topisani
c4ada3e9df Don't highlight operators as functions (#104)
* Don't highlight operators as functions

* address comments
2017-12-01 17:08:19 +01:00
topisani
63d2b5fa10 nitpick fixing 2017-11-30 14:12:41 -08:00
topisani
4e153784f6 Index language as enum instead of string 2017-11-30 14:12:41 -08:00
topisani
e6bcd05a7e markdown compliant language identifiers 2017-11-30 14:12:41 -08:00
topisani
28ad5b1ed1 Index file language and send it on hover 2017-11-30 14:12:41 -08:00
Jacob Dufault
601af73ca9 Move all libclangmm/* files into src/* directory 2017-11-11 11:41:09 -08:00
Jacob Dufault
348b4a2e4e Move libclangmm/Cursor.* to clang_cursor.* 2017-11-11 11:31:05 -08:00
Jacob Dufault
9d376a47d5 Do not index is_constructor and parameter_type_descriptions. 2017-11-08 19:59:11 -08:00
Jacob Dufault
96894ae996 Index std::make_unique and similar functions as constructor calls. 2017-11-08 19:55:13 -08:00
Jacob Dufault
e7de24764e Increase indexed file version 2017-11-07 01:01:37 -08:00
Jacob Dufault
510594cdcd Add is_constructor to indexer 2017-11-07 01:00:59 -08:00
Jacob Dufault
9cb4008023 Index type description for function parameters. 2017-11-07 00:57:08 -08:00
Jacob Dufault
6d2af96c16 Remove TranslationUnit::document_cursor() 2017-11-04 16:11:52 -07:00
Jacob Dufault
7d549f3fdf Move libclangmm/Utility.h into clang_utils.h 2017-11-04 16:02:39 -07:00
Jacob Dufault
7734943620 Format all code in src/ 2017-10-31 12:49:19 -07:00
Jacob Dufault
3e9cffcc62 Cleanup clang::TranslationUnit API so callers have to handle failures. 2017-10-22 22:07:50 -07:00
Jacob Dufault
7531a0b4e5 Real-time indexing as you type. 2017-09-26 23:03:43 -07:00
Jacob Dufault
f5314b62b1 Reformat to Chromium style. 2017-09-21 18:14:57 -07:00
Jacob Dufault
d9143f065d Fix indexer crash when indexing MSVC STL. 2017-09-12 22:51:13 -07:00
Jacob Dufault
7901653698 Make sure file exists before importing it. 2017-08-15 22:39:50 -07:00
Jacob Dufault
7faedfdf00 Do not import empty dependencies 2017-08-15 20:28:52 -07:00
Jacob Dufault
3ab4d0455d Fix delta update.
Previous file was being loaded after the current file is written to disk.
2017-08-15 00:46:21 -07:00
Jacob Dufault
1f3f69b221 Reuse loaded file contents in indexer; clear large state before caching. 2017-07-30 11:31:41 -07:00
Jacob Dufault
ee20d79dcc wip 2017-07-29 21:24:02 -07:00
Jacob Dufault
00e452272f Do not use clang_Location_isInSystemHeader for diagnostics; causes crashes 2017-07-12 15:02:48 -07:00
Jacob Dufault
6ab8a27313 Mark macros in index. 2017-06-28 23:28:29 -07:00
Jacob Dufault
a005cc627d Generate diagnostics when indexing a file, even if non-interactive. 2017-06-19 18:52:25 -07:00
Jacob Dufault
7328d138e3 Fix linker error on clang (issue #2) 2017-06-14 20:12:52 -07:00
Jacob Dufault
0e5312790e Add more detailed logging for failed unique file id 2017-06-13 20:08:31 -07:00
Jacob Dufault
dec484ed0d Only report diagnostics from code completion document parse.
Also use shared_ptr, hopefully fix memory crashes.
2017-06-09 21:13:16 -07:00
Jacob Dufault
8c50324576 Small fixes for osx 2017-05-30 17:54:19 -07:00
Jacob Dufault
1d67d1ee37 Add additional metadata to function declarations. 2017-05-27 18:53:22 -07:00
Jacob Dufault
3469850c98 Change how function declarations are serialized so parameter info can be added. 2017-05-27 14:09:20 -07:00
Jacob Dufault
b7f7987cb8 Use cached location 2017-05-27 13:10:06 -07:00
Jacob Dufault
5415f4be50 Don't count the '~' in type usages for destructors. 2017-05-27 13:02:49 -07:00
Jacob Dufault
dcc71f2470 More cleanup in indexer 2017-05-27 12:56:39 -07:00
Jacob Dufault
e431dbd793 Some renames in indexer. Fix warning for namespace alias. 2017-05-27 12:33:18 -07:00
Jacob Dufault
e9025104cb Rename some variables in the indexer. 2017-05-27 10:03:49 -07:00
Jacob Dufault
b66f015a4a Some small cleanup when indexing function declaration/definition. 2017-05-27 09:57:52 -07:00
Jacob Dufault
968b6c0966 Remove HasInterestingState().
These don't serve any real purpose since the multi-file indexer tests.
2017-05-27 00:47:03 -07:00
Jacob Dufault
8bbd9b7694 Revert change to use CXTranslationUnit_Incomplete when indexing. It broke tests. 2017-05-24 20:06:05 -07:00
Jacob Dufault
32940e2c88 Experiment with caching CXIndex across multiple sessions 2017-05-24 19:04:19 -07:00
Jacob Dufault
2e4c5474da Index implicit function calls. 2017-05-22 23:47:27 -07:00
Jacob Dufault
c66c927c1f Fix some more warnings from clang 2017-05-21 16:48:21 -07:00
Jacob Dufault
8910d0a13e Fix warnings (almost all numeric cast-related) 2017-05-21 16:22:00 -07:00
Jacob Dufault
864ff122d8 Scan include directories for include completion candidates. 2017-05-21 12:51:15 -07:00
Jacob Dufault
41e1dff4c9 Goto definition for includes 2017-05-20 20:47:20 -07:00
Jacob Dufault
529f309c45 Index macros (treat them like variables) 2017-05-20 18:58:54 -07:00
Jacob Dufault
d3bd31604e Code lens improvements
- Hide declaration from list of refs on types and variables (so now they will show as '0 refs')
- Let the user hide code lens on parameter and function-local variables
2017-05-20 18:26:50 -07:00
Jacob Dufault
44153f94e8 Fix auto variable type deduction when auto is a pointer. 2017-05-20 17:19:32 -07:00
Jacob Dufault
b79b98f464 Darken/fade code disabled by preprocessor. 2017-05-20 14:45:46 -07:00
Jacob Dufault
b3d5327342 Real-time diagnostics via clang_codeCompleteAt 2017-05-19 23:35:14 -07:00
Jacob Dufault
2b407e0bce Basic performance data tracking during indexing 2017-05-17 00:08:45 -07:00
Jacob Dufault
f2d46e86b7 Don't force index updates on primary translation unit when updating dependency indexes. 2017-05-16 23:09:53 -07:00
Jacob Dufault
f907d1d1b9 When indexing make sure we use the correct contents.
Hopefully this will make overlapping saves more robust.
2017-05-16 00:38:15 -07:00
Jacob Dufault
ff421723a5 Renames and fix some operator < implementations 2017-05-11 23:08:15 -07:00
Jacob Dufault
202ab60ede Added diagnostics. 2017-05-09 23:13:13 -07:00
Jacob Dufault
49c687663e Rework some of the command line flag parsing logic. Hopefully make it more robust. 2017-04-25 21:03:22 -07:00
Jacob Dufault
839f3d9968 Try parsing with full argv. Also hide system diagnostics. 2017-04-25 19:57:36 -07:00
Jacob Dufault
91b5614c7e Optimize import pipeline.
Previous implementation was slower at reindexing if loading from cache because primary cc files would be reindexed for every dependency that changed.
2017-04-23 18:01:51 -07:00
Jacob Dufault
489f54e538 Remove most of libclangmm 2017-04-22 00:43:48 -07:00
Jacob Dufault
bb25640d91 Rename instantiations to instances. 2017-04-21 00:03:33 -07:00
Jacob Dufault
14b47de1db Cleanup import pipeline, store arguments in indexed file.
We no longer store any runtime state (ie, file arguments) in project.cc; we store it and then query it from the cached index file.
2017-04-20 21:06:15 -07:00
Jacob Dufault
7326b861ac Simplify dependency management when updating index for a file. 2017-04-20 01:05:19 -07:00
Jacob Dufault
1f6da81009 Preserve dependencies across multiple index runs. 2017-04-20 00:53:33 -07:00
Jacob Dufault
4d9567a0c2 Fix reindexing for header files 2017-04-20 00:25:38 -07:00
Jacob Dufault
b4fb350140 Include file modification time in index 2017-04-19 21:57:44 -07:00
Jacob Dufault
20864e422a Fix recursion when loading cache and indexing are both enabled.
Also added config options to disable indexing, disable cache writing, and disable cache reading from settings file.
2017-04-19 00:32:59 -07:00
Jacob Dufault
cd50eb9e35 Positions are now 32 bits (down from 96ish) 2017-04-18 22:38:39 -07:00
Jacob Dufault
95b567838c Remove concept of 'interesting' usage.
It never worked well enough. Showing variable instantations for the type will be more useful.
2017-04-18 22:28:33 -07:00
Jacob Dufault
85734278d8 Misc fixes 2017-04-18 17:05:14 -07:00
Jacob Dufault
2e8e3d29c5 Indexer spelling lookup cannot fail 2017-04-18 16:49:55 -07:00
Jacob Dufault
c615535d33 vscode settings can now include an additional set of clang arguments to apply. 2017-04-17 21:06:01 -07:00
Jacob Dufault
c6dead848e Remove some TODOs, reduce output sleep from 10ms to 2ms 2017-04-16 16:57:31 -07:00
Jacob Dufault
741e357053 Remove clang-c dependency from command_line.cc 2017-04-16 14:51:47 -07:00
Jacob Dufault
c946fd1b8e Simplify code for building detailed_name 2017-04-14 22:02:03 -07:00
Jacob Dufault
f4e16067b7 Rename qualified_name to detailed_name. 2017-04-14 21:58:07 -07:00
Jacob Dufault
07c984d6c7 - Add type information to qualified_name, remove hover.
- Allow tests to automatically update their expecatations
2017-04-14 21:53:10 -07:00
Jacob Dufault
f263524b19 Fix another threading crash 2017-04-14 17:54:22 -07:00
Jacob Dufault
337c1f0b12 Fix multithread crash 2017-04-14 15:58:07 -07:00
Jacob Dufault
031c0c2011 Include variable type and function signature in qualified name (better outline and workspace symbol search). Also add WIP rename provider. 2017-04-14 01:21:03 -07:00
Jacob Dufault
4f770befee Support textDocument/hover (ie, hover over symbol to see type) 2017-04-13 22:18:02 -07:00
Jacob Dufault
d6123bd861 Every function usage is now considered a call of that function.
This means we will now report function calls that happen in the global scope (previously, those would only show up for find all refs).
2017-04-13 00:47:47 -07:00
Jacob Dufault
d5e5d96a9e - Slightly more robust file parsing
- Make memory ownership slightly clearer in indexer
2017-04-12 23:01:42 -07:00
Jacob Dufault
94090b7b50 index stl declarations 2017-04-12 00:57:12 -07:00
Jacob Dufault
abbc6380f4 Fix indexing function call when there is implicit ctor call 2017-04-12 00:36:17 -07:00
Jacob Dufault
12a0db7d10 Don't call NormalizePath in core indexing logic; syscall dominates indexing time 2017-04-12 00:04:06 -07:00
Jacob Dufault
215a9a80fb - Show code lens for calls to parent and derived methods
- Don't show local variables in global symbol search
2017-04-11 00:29:36 -07:00
Jacob Dufault
76b6a3d4fd Store indexed dependencies so we can reload all files when restoring from cache. Also slightly improve goto definition source range 2017-04-10 22:26:27 -07:00
Jacob Dufault
527439b7c2 WIP on updating index; locations still broken 2017-04-09 17:08:54 -07:00
Jacob Dufault
c25fac0919 Make Resolve location never fail 2017-04-08 16:16:30 -07:00
Jacob Dufault
56f0b3a90a Auto-index header files 2017-04-08 15:54:36 -07:00
Jacob Dufault
460a428ced Parse now returns a vector of unique_ptrs 2017-04-08 13:00:08 -07:00
Jacob Dufault
f0e8d0110c Add call refs from ctor context 2017-04-08 11:36:32 -07:00
Jacob Dufault
fffb3d3fcc Migrate QueryableFuncDef to indices 2017-04-08 01:04:38 -07:00
Jacob Dufault
d61cc7a077 QueryableLocation now stores a file index 2017-04-08 00:21:00 -07:00