Commit Graph

1332 Commits

Author SHA1 Message Date
Ivan Donchevskii
039a34a369 Clang: Adapt priorities for the same method/constructor overloads
CXXMethod and CXXConstructor may have different priorities
depending ony their origin and attributes. To keep them together
in the sorted list we adapt their priorities to have the same
value if their names match.
To continue keeping ClassCompletion before ConstructorCompletion
change the order of the completion kinds for the sort purposes.

Change-Id: I36efe5d5dbaa77d604a54b1dafe07d67f44db4c9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-10-25 07:10:12 +00:00
Ivan Donchevskii
353cc0e5f3 Clang: Fix the completion fix-it wording
Change-Id: Ifc3ab9946caf3716681a1bffd590f0780b796176
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2018-10-24 09:45:23 +00:00
Robert Loehning
a81f8dd0e1 Clang: Use multi-arg version of arg()
Change-Id: Iaaf95ea7a8057a66f044ece79c9b40ecd825d59c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-24 08:41:50 +00:00
Nikolai Kosjar
cfbf2559f4 Clang: Fix naming conventions for *ModelManagerSupport* classes
We use "Builtin" and "Clang" as prefixes, not suffixes.

Change-Id: I6926aeb8f005176ef420c4421c257e3df61ee0b7
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-10-23 06:12:29 +00:00
Ivan Donchevskii
3f613d25a1 Clang: Move text cursor utility methods into ClangCodeModel
These 3 are only used in ClangCodeModel.

Change-Id: Id7c2cead40473bcb746e4b105aa36cb7d51a2740
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-18 09:13:35 +00:00
Ivan Donchevskii
239c15b5e2 Fixes: Clang: Sort the initial list of includes for the code completion
Task-number: QTCREATORBUG-6242
Change-Id: Icdd5671801079a547a08b1276a6dbc76fed4bd30
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-17 08:09:59 +00:00
Ivan Donchevskii
f8e6ba916c Clang: Fix abandoning the parentheses for function
Was introduced in 0f96f735f0 because the the incorrect
move to the '&' character.

Task-number: QTCREATORBUG-21305
Change-Id: I55d79e68795f55b758aa95072fca10bc00d49037
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-17 07:31:05 +00:00
Nikolai Kosjar
d67ddfb5d1 Clang: Avoid starting backend jobs for inactive app and during VCS operations
...to reduce file locking on Windows caused by clangbackend's
parse/reparse jobs.

Considering inactive application state should help for external VCS
operations, e.g. on the command line. However, activating Qt Creator
while such a VCS operation runs might still lead to undesired behavior,
but this should be the less common case.

VCS operations started from within Qt Creator should see less locking
conflicts as we know when they start and finish. However, we just avoid
starting new jobs - there might be still jobs running.

Pending or new jobs will be started once Qt Creator is activated again
and all VCS operations finished.

Task-number: QTCREATORBUG-15449
Change-Id: I5f04c34f006e66162368efbdd58bd822a706f35e
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-16 06:40:43 +00:00
Nikolai Kosjar
bd6f30da70 Clang: Improve debug log message
Change-Id: I82b8f4fc72614f6671815e3b1dbfad87a062ae98
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-10-15 07:28:22 +00:00
Orgad Shaneh
bdc2b4b59f Remove hard-coded disabling of debug logs
Instead, set the default level of all logs to QtWarningMsg.

The call to setFilterRules overrides the user preferences in qtlogging.ini.

Change-Id: Id5f6cd550d14ff7f45ae04c5d3110e0bafb0f072
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-10-13 16:36:58 +00:00
Nikolai Kosjar
d8768c0c6d Clang: Remove explicit ClangHoverHandler::ClangHoverHandler
Change-Id: I131504e8f31210a928a802ad7c5dc069ac11b2f3
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-11 07:43:56 +00:00
Marco Bubke
77b5907c57 Don't remove __cplusplus
For the indexing we need all tool chain macros. Originally it was a fix
because the C++ version of the project part and __cplusplus could be
different but now they should be the same. They will be now removed in the
compiler options builder.

Change-Id: I7ae8721a29632473e76ecedb411a6c9001e5e199
Task-number: QTCREATORBUG-21265
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-10 12:25:30 +00:00
Nikolai Kosjar
6aa11eb75e CppTools/ProjectExplorer: Remove enum duplication
... between CppTools::ProjectPart and ProjectExplorer::ToolChain.

Change-Id: I8b448747e454adbed77547460383b8515462cc81
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-10-08 12:34:57 +00:00
Ivan Donchevskii
3858c7d3b9 Clang: Fix the crash in function overload completion
Check that the completions container is not empty.

Change-Id: I399b8cce42995d758013441d2d3d9f3d8156dc06
Reviewed-by: hjk <hjk@qt.io>
2018-10-05 13:57:09 +00:00
Ivan Donchevskii
66e5d2f492 Clang: Fix C++ method code completion
Clang returns no result type when the virtual method
from the base class is called in the same method override
in the derived class.

This is not a problem for us because it's not a method definition
and therefore it does not require special handling.

Change-Id: I736989165c1f031dc1937c7935e26da8236d9e9e
Reviewed-by: hjk <hjk@qt.io>
2018-10-05 13:57:00 +00:00
Ivan Donchevskii
efc39304a1 Clang: Move the majority of completion items sorting to ClangBackend
With this change ClangCodeModel only needs to sort completions by prefix.

Also some other optimization have become possible and are implemented here:
1. Getting completions after '{' for constructor overloads by replacing
   it with '(' inside usaved file.
2. Checking for all overloads requires only previous item check because
   all Class completions are already sorted to go before all CXXConstructor
   completions. Since they are not mixed no extra search is required.

Change-Id: Ie0187ad96a20857a63c1d71ddec74606b803f572
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-02 12:29:23 +00:00
Ivan Donchevskii
931ec39f64 Clang: Change the way completion fix-its are shown
Move the completion information to the tooltip and
show fix-it icon on the right of such item.

Change-Id: I7eff410384104387e547695171e4864760c07fb9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-10-02 12:26:18 +00:00
Nikolai Kosjar
aa290912b8 Clang: Remove project tracking on clangbackend side
...as it is not needed. Just provide the compilation arguments as part
of the Document.

As a side effect, re-initializing the backend after a crash is cheaper
and will not freeze the UI anymore (referenced bug).

Task-number: QTCREATORBUG-21097
Change-Id: I866e25ef1fd5e4d318df16612a7564469e6baa11
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-26 10:45:41 +00:00
Eike Ziller
18ffdbb12e Merge remote-tracking branch 'origin/master' into 4.8
Change-Id: Iaad349302545619f5299fbab26aff11790ca122e
2018-09-26 09:37:07 +02:00
Orgad Shaneh
57af3f1f3d Clang: Fix compile commands generation for large projects
...such as Qt Creator.

Avoid storing the entire JSON in-memory. Instead, write as you go.

Change-Id: Ie298af546b25d80813a75d8dc09f3244488b8658
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-25 12:44:43 +00:00
Nikolai Kosjar
5a6a348d21 Clang: Remove unused function
Change-Id: I78743489c6b5dc617c4a9966e83d3bf987707bc9
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-09-24 14:11:33 +00:00
Orgad Shaneh
439bc225e1 Clang/CppTools: Replace Q_DECL_NOEXCEPT with noexcept
Change-Id: I105a5ed5e4a5c647f947a413ae8123d02bfdae3f
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-20 08:36:45 +00:00
Ivan Donchevskii
641c9f7db9 Clang: Add compiler name to each compilation database entry
In all examples there's a compiler as a first argument.

Change-Id: I37ec4073254d68f29357e9b2447a035a1b15e02f
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-19 13:07:54 +00:00
Eike Ziller
dd0347d1ee Merge remote-tracking branch 'origin/4.7'
Conflicts:
	src/plugins/qnx/qnxrunconfiguration.cpp

Change-Id: I6069e6a644c6d50c3d2821d51c368129b6957017
2018-09-19 08:27:51 +02:00
Ivan Donchevskii
9c7d546c14 Clang: Fix possible out of bounds access in ClangFollowSymbol
Change-Id: I80132dca9c26a54059f2c1ba872b102df8e6e0d7
Reviewed-by: hjk <hjk@qt.io>
2018-09-18 12:49:56 +00:00
Ivan Donchevskii
eeece5b5ad Clang: Skip built-in includes when exporting the compilation database
We don't want to have compiler-specific paths there.

Change-Id: If26434ea3760d4f2ca4c25bbcf0340f4ea781072
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-17 13:13:16 +00:00
Tobias Hunger
c763d4d787 ProjectExplorer: Remove HeaderPath::isFrameworkPath
None of the other types has a query function, so remove this one, too.

Change-Id: I936d162e092c8f9361b0e3bb86676e68905d2f4b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-13 11:32:59 +00:00
Tobias Hunger
1df553a683 ProjectExplorer: Rename IncludePathType to HeaderPathType
It is the type used by the HeaderPath class, so reflect that in
the name.

I also considered to rename HeaderPath to IncludePath, but
that name is reflected in a lot of users, which would also need
to be adjusted for consistency. That would blow up the patch size
for little value IMHO.

Change-Id: I51421dbd3ab8b2874dc32fc82dc394c9b93ce5e9
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-13 11:32:31 +00:00
Ivan Donchevskii
50e5aacb02 Highlighting: Add highlighting style for punctuation
Currently only operators have their own style but not
punctuation tokens. Make possible to highlight both.

Task-number: QTCREATORBUG-20666
Change-Id: I9533e0f1bef65b86c4e4f5c9756571103584124b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-13 11:15:05 +00:00
Ivan Donchevskii
ad5336a028 Clang: Enable follow symbol for 'auto' keyword
It will follow to the Type which is deduced from auto
or to the pointee type if auto is deduced to pointer.

Task-number: QTCREATORBUG-17191
Change-Id: I57db3f9b68c3da861691ab148fe39774ad5fceec
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-12 10:44:44 +00:00
Marco Bubke
3abaf647d0 Add system include path to HeaderPath and merge ProjectPartHeaderPath
System include paths are appended after other includes by the compiler. So
we should set them as system includes and not as normal includes. Otherwise
we change the include order. Headers in system include paths are not
cluttering the screen with unwanted warning and by the way improve
performance too.

ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them.

Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-09-10 09:31:32 +00:00
Ivan Donchevskii
8b6a16c95b Clang: Fix completion after '{'
Follow-up fix for 8d0391a4f9.

Do not complete after '{' coming not after an identifier.
Take constructor completions only for '{' and function
completions only for '('. Filter constructor completions by
class/struct type.

Task-number: QTCREATORBUG-21004
Change-Id: I7ae2d6bee23cf907648c42b93eb12742942833f6
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-30 13:36:52 +00:00
Ivan Donchevskii
4a6ad6c849 Clang: Do not replace class completion with constructor completion
Both completion kinds have the same name. Do not merge them
together when looking for constructor overloads.

Task-number: QTCREATORBUG-21010
Change-Id: I4c851033d63ad4e242b6179491f1fba00af466f6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-08-29 11:54:34 +00:00
Ivan Donchevskii
1b4f5c0670 Clang: Fix include paths order
C++ include paths should come before Clang include
folder. Therefore parse all options for include/c++/v1,
include/c++/{version}, include/g++ and /usr/local/include.

Task-number: QTCREATORBUG-20231
Change-Id: I22c41f07d241e1e564069bb192d4fe637ff05e87
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-27 11:35:02 +00:00
Ivan Donchevskii
8d0391a4f9 Clang: Treat brace initialization as constructor completion
Try to complete constructor after left brace with fallback
to normal completion.

Task-number: QTCREATORBUG-20957
Change-Id: I6c33790a3ee1e623a3d8abe9a44cfd821b6f3106
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-21 10:40:04 +00:00
Christian Kandeler
3336baad12 Fix references to the clang code model documentation file
Was forgotten in 7ab07a4e8f.

Change-Id: I2c6d21b79658e3946eb6ecdcf7b11992c0bf865e
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2018-08-20 11:58:18 +00:00
Ivan Donchevskii
5077bf379d Clang: Fix menu button text capitalization
Change-Id: I771cbaebbb801665e96cc3d6ea337ebe15872803
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2018-08-20 08:26:16 +00:00
Marco Bubke
7bae47642c Add optional system include to compiler option builder
System includes suppress warnings and prevent indexing of unwanted symbols.
Using system includes for all includes outside of the project can be
quite advantageous. The rootProjectDirectory() can be extended to be set
in the project settings. An automatic generation could be possible but
could create an unwanted path which includes files outside of the
perceived project.

Change-Id: Ib9d3158f14f41efe1f6657f962d5c4437bb324b2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-14 15:03:51 +00:00
Christian Stenger
f6b228842c Clang: Fix possible nullptr access
Change-Id: I8643912f02d127286b0a0ededbaf7d4f23347a5f
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-08-14 06:35:47 +00:00
Ivan Donchevskii
f60b035295 Clang: Add button to generate compile_commands.json
Change-Id: Iaabdcfc8d1b3463c3f6e5ce47536f9c52556eac0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-13 13:24:12 +00:00
Christian Kandeler
8cfd5b165a Fix qbs build when no llvm is present
Some defines were set conditionally, but accessed unconditionally, which
of course breaks the build.
Make sure the defines are always set. Also gather them in a module,
instead of copying the code all over the place.

Change-Id: Iac628da64fb3934872d912510936aeccd0e20247
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-08-10 09:57:38 +00:00
Ivan Donchevskii
86b8164a93 Clang: Use the same format for the current document filter and the symbol outline
Global variables and fields had different style of
the return value. Make it look the same.

Change-Id: Ie031a994b65991289103028234227950861e05d0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-08 14:09:28 +00:00
Ivan Donchevskii
62e776aa8e Clang: Provide include directory only for libclang
Only libclang has issues with the include directory
search therefore undefining include folders makes sense
only for libclang options builder.

Change-Id: Ie3f62f5f3a89503e6e0ab59e18889e92425c3abc
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-08 14:07:13 +00:00
David Schulz
141f19a652 Utils: move code model icons to utils
In preperation for the language server protocol support.

Change-Id: Iee4ccd53a86d9afdb357972ea62b75ace2edcb1d
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-08-06 13:22:47 +00:00
Ivan Donchevskii
843f31ae04 Clang: Better handle constructor overloads
Follow up for 0f96f735f0. Constructors have worse support
in Clang for their definitions but have proper overloads
for the references.

Change-Id: Ie002ae74b0d15f0fe00126042a7f61172b82946b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-06 10:38:34 +00:00
Ivan Donchevskii
0f96f735f0 Clang: Provide all overloads for function definition completion
When we complete a function definition with the parameter list
it is important to have multiple entries to select.

Change-Id: I25e94b58cfe4831387d66eecdec74712addb7ec5
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-02 12:47:17 +00:00
Ivan Donchevskii
810896936b Clang: Improve function definition completion
Insert argument list together with completion.

Task-number: QTCREATORBUG-20826
Change-Id: I4aa9faaa04bcd3ca014306aad27843c2b4419d3c
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-08-01 14:25:38 +00:00
Ivan Donchevskii
da4be3fdb7 Clang: Use new libclang code completion fix-its feature
Each completion coming from libclang now has it's own
list of fix-its which are required to be applied before
completion itself.

This saves one extra reparse cycle and gives an ability
to provide both kinds of completion (initial and corrected
one) for cases like shared_ptr, unique_ptr or any other
class with overloaded arrow operator.

Each of these extra fix-its is applied together with
corresponding completion dircetly before completion itself.

Change-Id: Ide37e45bb15fa2f1375cd6b86ecd43ced3593046
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-07-27 07:34:44 +00:00
Ivan Donchevskii
534aa02163 Clang: For definitions show their parent class qualification
Append methods and class members with the scope they belong to
extracting the parent name. It was like that in old code model.

Example:
namespace Foo {
void Bar::function() {}
}

Old result:
Foo
  function() -> void

New result:
Foo
  Bar::function() -> void

Change-Id: I9dad86a6738baafb1a210c5e1146d8de33828c44
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-07-09 09:24:35 +00:00
Ivan Donchevskii
91cbbd39ac Clang: Don't show template type parameters in Class View and Current Document filter
They do not bring any value.

Task-number: QTCREATORBUG-20716
Change-Id: I2876f0e1e3918cb33d133b4a65ccaefd9bd30ac8
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-07-09 09:24:19 +00:00