Commit Graph

843 Commits

Author SHA1 Message Date
Jacob Dufault
8a7dfb017f Validate no files are consumed by import pipeline 2018-01-06 20:27:50 -08:00
Fangrui Song
299e687d37 WIP serializers/msgpack.h 2018-01-06 20:10:08 -08:00
Fangrui Song
aa139a4b65 Serialize Config::cacheFormat 2018-01-06 18:56:15 -08:00
Fangrui Song
5809d0c436 Make Serialize accept argument SerializeFormat format
Rename `const char* GetString()` to GetCString and add `std::string GetString()`
WIP on serializers/msgpack.h
2018-01-06 18:01:36 -08:00
Jacob Dufault
76a3fe8400 Reenable tests 2018-01-06 17:12:57 -08:00
Jacob Dufault
8debcf1d9d Usage initializer_list 2018-01-06 17:11:34 -08:00
Jacob Dufault
a1423a39a0 Fix build 2018-01-06 16:51:55 -08:00
Fangrui Song
315ec292f1 Add WIP serializers/msgpack.h 2018-01-06 16:44:49 -08:00
Fangrui Song
fe0313f0b5 Add a parameter (number of __VA_ARGS__) to REFLECT_MEMBER_START
rapidjson StartArray StartObject do not need the number of fields, but msgpack-c does.
2018-01-06 16:42:22 -08:00
Jacob Dufault
d22f994d8a Don't implicitly return data for TestIndexer. 2018-01-06 16:30:57 -08:00
Jacob Dufault
476a3f1797 Add a couple more import pipeline tests, introduce fixture. 2018-01-06 16:30:41 -08:00
Jacob Dufault
a9a905b0d2 Delete previous QueueManager instance if creating multiple. 2018-01-06 16:30:26 -08:00
Jacob Dufault
5d4e0a5020 Enable simple sanity test for import pipeline.
- Add FakeCacheManager
- Add IIndexer so we don't call out to clang
2018-01-06 16:20:37 -08:00
Jacob Dufault
e09ed35a8d Forward declare Project 2018-01-06 16:04:51 -08:00
Fangrui Song
3f1cb5c072 Add submodule https://github.com/msgpack/msgpack-c and make Serialize/Deserialize aware of SerializeFormat 2018-01-06 15:29:53 -08:00
Fangrui Song
734f9b6380 Add serializers/json.h 2018-01-06 14:59:05 -08:00
Fangrui Song
02a457f65d Make Reader/Writer abstract classes instead of type aliases of rapidjson classes
Added src/serializers/json.h (which includes rapidjson)
2018-01-06 14:47:43 -08:00
Fangrui Song
007bc5362c Fix null pointer dereference of param.primary_file 2018-01-06 14:47:24 -08:00
Jacob Dufault
181b405c54 Remove some debug code 2018-01-06 12:32:58 -08:00
Fangrui Song
4758b70d00 Reorder Reflect functions 2018-01-06 11:26:41 -08:00
Joel Hock
0c9f572637 freeze state of WorkingFiles to insulate them from async changes
before shipping unsaved state off to clang
2018-01-06 11:26:09 -08:00
scturtle
991b27899f Show error on include position. (#243) 2018-01-06 09:28:55 -08:00
Fangrui Song
516b94e982 Change VarClass::cls to ClangSymbolKind::kind
ClangSymbolKind is ported from clang::index::SymbolKind
2018-01-05 22:43:12 -08:00
Jacob Dufault
cf2103b521 Always normalize --sysroot=.
Clang does not respect -working-dir for this argument.
2018-01-05 13:41:38 -08:00
Fangrui Song
af600d4b90 Recognize clang-4.0 as commands 2018-01-05 11:10:58 -08:00
Jacob Dufault
0657de7ef9 Make exact workspace symbol search use detailed_name.
This enables lookup by typing fully qualified names, ie, myns::MyClass.
2018-01-05 10:06:15 -08:00
Jacob Dufault
bbe11e32eb Prefer WriteToFile over manual std;:ofstream usage. 2018-01-05 10:02:53 -08:00
Jacob Dufault
327958dbe0 Log error instead of asserting if writing file fails.
Also remove some unused code.
2018-01-05 09:58:38 -08:00
Fangrui Song
08e856b85a Use nullptr for main source filename in clang_parseTranslationUnit2FullArgv and rely on -working-directory for relative filename resolution 2018-01-05 09:45:46 -08:00
yshui
2a7b593a80 Use gnu11 standard when none is specified (#231)
Reference:

1. https://clang.llvm.org/docs/UsersManual.html#differences-between-various-standard-modes
2. https://gcc.gnu.org/onlinedocs/gcc/Standards.html
2018-01-04 11:10:40 -08:00
yshui
e2ce134e1f Check __GLIBC__ for malloc_trim instead of __linux__ (#230) 2018-01-04 10:55:11 -08:00
Jacob Dufault
22ef88045f Write cache to disk in binary format. Otherwise some escaping may occur. 2018-01-03 22:13:33 -08:00
Jacob Dufault
0c839d19fc [ci]: Do not wait for input after failing a test.
This adds --ci command line flag which disables waiting for user input when running an index test (ie, test expectations are not updated).
2018-01-03 18:43:58 -08:00
Jacob Dufault
31c7fddf3d More work to fix AppVeyor 2018-01-03 18:32:15 -08:00
Jacob Dufault
f5f3887dd3 Add newline after warning about not running obj-c tests 2018-01-03 18:12:39 -08:00
Jacob Dufault
2a17f66792 Write test using binary, otherwise \n will become \r\n leading to double \r\r\n. 2018-01-03 18:12:39 -08:00
Chao Shen
d9b9e5e227 fix appveyor 2018-01-03 18:12:21 -08:00
Daniel Martín
7e2c19d792 Format with predefined_style when a style cannot be obtained 2018-01-03 13:29:54 -08:00
Fangrui Song
5f8e1935a6 Use cursor extent instead of cursor spelling range for CXCursor_MemberRefExpr #174
Members of non-concrete template types do not have useful spelling ranges (likely unexposed).

C<int> f; f.x // .x produces a MemberRefExpr which has a spelling range of `x`.

C<T> e; e.x // .x produces a MemberRefExpr which has a spelling range of `e` (weird).

To make `e.x` (MemberRefExpr with empty spelling name) able to find
definition, We use cursor extent (larger than spelling range) `e.x`. It
would be better if we could restrict the ranges to `.x` or just `x`.
Nevertheless, larger ranges are less specific, and should do no harm
because they will be overriden by more specific variable references `e`.
2018-01-03 11:02:28 -08:00
Jacob Dufault
4514e2f9ce Silence unhandled namespace declaration warnings 2018-01-03 08:05:52 -08:00
scturtle
66af432946 Fix completion order: Sort after cache. 2018-01-03 07:58:59 -08:00
Fangrui Song
1109c486c6 Help Riatre
clang_getNumArgTypes may return -1 for unexposed types.
2018-01-03 00:08:18 -08:00
Fangrui Song
74be57c334 Set variable_type of lambda parameters
Now a lambda parameter is listed in $cquery/vars of its type
2018-01-03 00:00:03 -08:00
Fangrui Song
a63297b002 Add type names to non-type template parameters 2018-01-02 22:52:40 -08:00
Fangrui Song
1220463efe Make GetPath less hacky for #215 2018-01-02 18:59:47 -08:00
Fangrui Song
3e1a068c19 Make implicit calls spanning one more column to the left/right
This is hacky but useful. e.g. textDocument/definition on the space/semicolon in `A a;` or `return 42;` will take you to the constructor.
2018-01-02 16:30:08 -08:00
Chao Shen
c157445ef3 fix ci 2018-01-02 09:11:34 -06:00
Fangrui Song
a14ddc69ac Split MultiQueueWaiter into {querydb,indexer,stdout}waiter to solve thundering herd problem (#217)
See https://github.com/jacobdufault/cquery/pull/213#issuecomment-354706992
2018-01-01 23:40:36 -08:00
Jacob Dufault
0b53c871dc Remove platform specific mutex/shared memory 2018-01-02 01:37:39 -06:00
Fangrui Song
f68e70f5b7 Replace MultiQueueWaiter timeout with condition_variable_any on multiple mutexes
Inspired by https://github.com/jacobdufault/cquery/pull/213
2018-01-01 16:19:58 -08:00
Fangrui Song
6fa92f7968 Compare hover & comments in {Func,Type,Var}DefDefinitionData::operator==
So that the changes populate to querydb.
Also expand two std::set_difference calls to save one scan
2018-01-01 12:36:08 -08:00
Fangrui Song
0539e4249b The Little Match Ray On New Year's Eve 2017 2018-01-01 00:06:25 -08:00
Fangrui Song
cef47b13f7 Remove ResolveSpelling 2017-12-31 23:34:00 -08:00
Fangrui Song
02246a5c4b Add ClangCursor::get_spelling_range and change some ResolveSpelling calls to get_spelling_range 2017-12-31 23:27:33 -08:00
Fangrui Song
a6496a0f8f [indexer] Add template parameters in parameter-list to their uses and index template template parameters 2017-12-31 22:54:52 -08:00
Fangrui Song
a4847181fa Fix formatting 2017-12-31 20:17:31 -08:00
Fangrui Song
86768b7d36 [formatting] textDocument/rangeFormatting 2017-12-31 20:03:43 -08:00
Fangrui Song
12ad0303be [formatting] Add textDocument/rangeFormatting 2017-12-31 19:41:47 -08:00
Fangrui Song
aca8e42033 Use --bundled-clang=5.0.1 in appveyor (#212) 2017-12-31 17:21:35 -08:00
Daniel Martín
c5610b8d76 Default to Chromium's format style if cquery cannot obtain it (#211)
Set the tab configuration (tab, spaces, amount) to the information
provided by the LSP client.
2017-12-31 16:35:37 -08:00
Fangrui Song
f9aa0ef66d [formatting] Refrain from std::make_unique until migration to C++14 or C++17 2017-12-31 15:56:02 -08:00
Fangrui Song
cd2f3c1e45 [formatting] Rename formattingOptions to options
LanguageClient-neovim `:call LanguageClient_formatting()` works now
2017-12-31 15:46:28 -08:00
Fangrui Song
c97bc5dbac [formatting] Add missing cases 2017-12-31 14:52:06 -08:00
Fangrui Song
9d04446d48 Merge branch 'document-formatting' of https://github.com/danielmartin/cquery into danielmartin-document-formatting 2017-12-31 14:17:39 -08:00
Daniel Martín
f389d294b7 Protect formatting code inside USE_CLANG_CXX 2017-12-31 23:15:03 +01:00
Fangrui Song
f32d3a6851 Use -working-directory
This is in preparation for https://github.com/jacobdufault/cquery/pull/94
-working-directory allows us to remove relative filename resolution later on.
2017-12-31 14:00:50 -08:00
Fangrui Song
73ba3f0d6f Move -x & -std= options just after compiler driver 2017-12-31 13:37:59 -08:00
Daniel Martín
4fdc81ae6d Manage Expected in formatting APIs 2017-12-31 13:30:34 +01:00
Daniel Martín
05e9bf3966 Add missing includes 2017-12-31 13:30:34 +01:00
Daniel Martín
0e16899b81 Move formatting structs to text_document_formatting.cc 2017-12-31 13:30:34 +01:00
Daniel Martín
aa4e5e7e5b Implement .clang-format style management
If we can't find a .clang-format file for the given file, default to
Chromium style with the tab/spaces configuration that was provided by
the client.
2017-12-31 13:30:34 +01:00
Daniel Martín
19341c18cd Basic implementation of document formatting
Still some important TODOs to address:

- Improve the algorithm that converts between offsets and line/column
  pairs. Right now it's extremely naive.
- Add proper support for a .clang-format file that specifies
  the coding style.
2017-12-31 13:30:34 +01:00
Daniel Martín
abc2edf05f Add structures to support document formatting 2017-12-31 13:24:58 +01:00
scturtle
4c2dff39ef Response "being indexed" instead of "not found". 2017-12-30 19:39:10 -08:00
Fangrui Song
77e9ea1b77 Use cursor extents for is_implicit function calls
cursor extents have larger ranges and less specific, thus making
them overridable by more specific (with smaller range) symbols.
Thus we do not need to hide them in query.cc:BuildFileDef

For example, the left paren in `A a(3)` jumps to the constructor.
the left paren in `A a = f()` jumps to the copy/move constructor.
2017-12-30 15:42:08 -08:00
Fangrui Song
95126bff61 In detailed_name, remove space between * and name 2017-12-30 13:11:55 -08:00
Fangrui Song
947a80ecc8 [comments] Add a minimalist approach to skip Doxygen comment markers 2017-12-30 10:56:34 -08:00
Chao Shen
829b2fe18c Better order of the completion items. 2017-12-30 15:15:46 +08:00
Fangrui Song
11aa09fac2 Don't reject macro definitions in system headers
Before, an assert() macro expansion jumps to __assert_fail but not
assert. This is because OnIndexReference finds a reference to __assert_fail
but VisitMacroDefinitionAndExpansions rejects the expansion.
2017-12-29 19:18:42 -08:00
Fangrui Song
48e88950e1 Complete CompletionItemKind 2017-12-29 16:32:43 -08:00
Fangrui Song
b015b03405 Fix platform_posix.cc on FreeBSD 2017-12-29 14:46:21 -08:00
Fangrui Song
66d4926e41 Remove <sys/prctl.h> and set thread name on BSD & __APPLE__ 2017-12-29 14:35:20 -08:00
Fangrui Song
720266e97a Support equal signs in options, e.g. --log-file=a.log 2017-12-29 14:00:02 -08:00
Fangrui Song
43ea2fcc53 Clean up type printer 2017-12-29 12:58:11 -08:00
Fangrui Song
daaf3a701b Clean type printer 2017-12-29 12:30:05 -08:00
romix
f897c46122 A more robust way of producing function signatures with parameter names 2017-12-29 12:02:33 -08:00
Fangrui Song
8592df7cf6 Use --bundled-clang=5.0.1 by default (instead of 4.0.0) 2017-12-29 10:40:29 -08:00
Jacob Dufault
f85659713e Fix compile 2017-12-29 10:28:11 -08:00
Jacob Dufault
6048eb6237 Move LoadCachedFileContents into ICacheManager 2017-12-29 12:19:39 -06:00
Jacob Dufault
71591d7805 Index_Request::contents is no longer optional 2017-12-29 12:00:52 -06:00
Jacob Dufault
a10bb50f51 Begin cache restructure so it can be tested 2017-12-29 12:00:52 -06:00
Jacob Dufault
3c0b2ff042 Move most of import_pipeline.cc into anonymous namespace 2017-12-29 12:00:52 -06:00
Jacob Dufault
c596e55dcc Cleanup some includes. 2017-12-29 12:00:52 -06:00
Jacob Dufault
48f3c75053 Add using declaration to optional.h, include STL optional if available or fallback to third-party one. 2017-12-29 12:00:52 -06:00
Jacob Dufault
b6071004df Rename IndexMain to Indexer_Main 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
Jacob Dufault
59e79b3c42 Move entry_points.h into import_pipeline.h 2017-12-29 09:52:43 -06:00
Jacob Dufault
36e7fa9a76 More work on e2e tests 2017-12-29 09:39:10 -06:00
Jacob Dufault
ad193b2ace Initialize ImportPipelineStatus::num_active_threads 2017-12-29 09:39:10 -06:00
Fangrui Song
6636617b4d [comments] Import mpark/variant and make MarkedString a variant (#200) 2017-12-28 15:21:40 -08:00
Fangrui Song
34052fbf27 [indexer] Index some references in ClassTemplate 2017-12-28 10:53:13 -08:00
Jacob Dufault
719c6c9ae9 Enhance index test selection filtering 2017-12-28 09:55:17 -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
Jacob Dufault
7939aec743 Remove WorkThread::Result.
WorkThread::StartThread is now a more typical main function.
2017-12-28 09:20:21 -08:00
Jacob Dufault
8468ef09c3 Reduce verbosity of index tests. Make it easier to identify failures. 2017-12-28 09:15:46 -08:00
Jacob Dufault
5ace7e7062 Remove logging 2017-12-28 09:03:35 -08:00
Jacob Dufault
243630ca2e wip 2017-12-28 08:55:46 -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
scturtle
32bcac38af Simplify LruCache a little bit. (#199) 2017-12-27 23:27:42 -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
9dde5041cb Always use -fparse-all-comments 2017-12-27 07:56:17 -08:00
Jacob Dufault
ef4af128fc Exit early if unit tests fail 2017-12-27 07:54:46 -08:00
Jacob Dufault
b8e7a5bcb3 Format code 2017-12-27 07:54:46 -08:00
Chao Shen
a84c863e5e Filter some completion results based on the input. 2017-12-27 09:34:24 -06:00
Fangrui Song
3df71f4145 [hover] Change the first MarkedString's language to "text" 2017-12-25 21:48:28 -08:00
Fangrui Song
5a22a5cc66 [hover] Return comments and hover as two MarkedString's
Inspired by @romix's https://github.com/jacobdufault/cquery/pull/187
2017-12-25 21:31:01 -08:00
Fangrui Song
23bbe81b92 Un-indent extracted comments (#191) 2017-12-25 11:20:47 -08:00
Fangrui Song
20c156f71d Make lsTextDocumentContentChangeEvent::{range,rangeLength} optional. fix #185 (#189)
Also make lsVersionedTextDocumentIdentifier::version optional per specification
2017-12-25 00:58:26 -08:00
Fangrui Song
bfccac525c Add experimental command line option --enable-comments to index comments and display them on textDocument/hover (#188) 2017-12-24 18:47:39 -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
Fangrui Song
b52ec9070c [workspace/symbol] Use short_name for sorting and detailed_name for displaying results 2017-12-23 21:27:01 -08:00
Fangrui Song
24f428c670 [workspace/symbol] Sort candidates with a fuzzy matching algorithm (#182) 2017-12-23 19:23:29 -08:00
Jacob Dufault
dce1365eb6 Move import pipeline into import_pipeline.cc 2017-12-23 17:30:55 -08:00
scturtle
f10521372b Initilize var.def.cls to unknown. 2017-12-23 19:29:32 -06:00
scturtle
cb7ccbe543 Change var.def.is_* to enum. 2017-12-23 19:29:32 -06:00
Jacob Dufault
f6d84cd68c Merge IpcManager and QueueManager 2017-12-23 16:25:18 -08:00
Jacob Dufault
27b5816a7f Small doc updates 2017-12-23 15:42:54 -08:00
Jacob Dufault
64f094d347 Move BuildWorkspaceEdit to text_document_rename.cc 2017-12-23 15:41:09 -08:00
Jacob Dufault
2bc44d59f2 Add --wait-for-input.
Previous on Windows when running index tests cquery would wait for the user to
press enter. This breaks AppVeyor CI.
2017-12-23 17:25:18 -06:00
Fangrui Song
af5ae31c34 Don't emit more diagnostics after hitting -ferror-limit 2017-12-23 15:20:13 -08:00
Fangrui Song
c04c9fa750 Don't emit more diagnostics after hitting -ferror-limit 2017-12-23 15:08:47 -08: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