... rather than the one from the LLVM that Qt Creator was compiled
against.
Task-number: QTCREATORBUG-27120
Change-Id: I4f211345ed547cd13f0b0774b99bc0f199a9cd44
Reviewed-by: David Schulz <david.schulz@qt.io>
We needlessly re-evaluated the same compiler options again and again for
all files in a project part.
Now we only do the actual file-related work per file. Along the way, we
dissolved some unneeded classes and made CompilerOptionsBuilder non-
polymorphic.
Change-Id: I9710d641a57032936cc0812515974dbc91676c8c
Reviewed-by: David Schulz <david.schulz@qt.io>
... for clangd.
Putting it in the build directory seems sensible in principle, but that
can be problematic for in-source builds. So introduce another level of
nesting to prevent conflicts.
Fixes: QTCREATORBUG-26431
Change-Id: Id66aa0852d206695f2fc2ec42292b1cecefe2b59
Reviewed-by: David Schulz <david.schulz@qt.io>
Neither we nor clangd can afford to watch all source files, which means
that after e.g. a branch switch we can easily end up in an inconsistent
state.
We alleviate this problem by restarting clangd if at least one open file
was changed externally.
Change-Id: I7e0d14835e3afbd7a64c3233614f2161282dddc0
Reviewed-by: David Schulz <david.schulz@qt.io>
There was no proper separation of responsibilities between these
plugins. In particular, CppTools had lots of editor-related
functionality, so it's not clear why it was separated out in the first
place.
In fact, for a lot of code, it seemed quite arbitrary where it was put
(just one example: switchHeaderSource() was in CppTools, wheras
switchDeclarationDefinition() was in CppEditor).
Merging the plugins will enable us to get rid of various convoluted
pseudo-abstractions that were only introduced to keep up the artificial
separation.
Change-Id: Iafc3bce625b4794f6d4aa03df6cddc7f2d26716a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
All members were already const, but this makes it clear at all points of
use that these data structures are immutable.
Change-Id: Iea615c090bde462c445d15223caccc561b0c713d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
ProjectInfo, ProjectPart and ProjectUpdateInfo used to carry pointers
to Project and/or Toolchain, even though they were used in contexts
where these pointers were either unsafe to access or not guaranteed to
be valid anymore, which made their use difficult and error-prone.
We turn these classes into pure value types by copying in all relevant
information before the first async operation takes place.
Fixes: QTCREATORBUG-25678
Change-Id: I1914b0dbda6c7dfba6c95e5e92f2d69977755590
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Note that we lose the highlighting for virtual function calls. We need
to amend clangd to add the respective information to its semantic tokens
message.
Also, Qt properties are no longer highlighted as class members. We'll
investigate how to best restore this feature.
Change-Id: I403712aada3d7a8e1c7b7c1277f43f7f64f8450b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Note that we temporarily lose the ability to hover over an include and
get the full path of the header file. This is a valuable feature that we
need to restore, preferably by fixing clangd itself.
Fixing the remaining few test failures would likely require more
complicated code as well as additional LSP round-trips, and as of now
I'm not convinced it is worth the effort.
Change-Id: I08c72c4bd1268bbd67baeb57bbfd29d9b11303a5
Reviewed-by: David Schulz <david.schulz@qt.io>
These are the tests from clangbackend, so we are now up to par coverage-
wise.
Change-Id: I7b8a63109bff17745782a646f684fd795f732672
Reviewed-by: David Schulz <david.schulz@qt.io>
... with "Find Usages", as we do in the built-in code model.
Note 1: This is very slow, so it's for now only enabled if the
search results come from a small number of files.
Possible ways of speeding up the operation
to be investigated.
Note 2: All test cases from the old code model also pass here,
but checking with non-trivial real-world projects
shows a lot of mis-categorizations.
Well will fix them one by one.
Note 3: This functionality requires clangd >= 13.
Change-Id: Ib3500b52996dbbf9d7d9712d729179bcbd3262fc
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
If the user has enabled clangd (default is off), we start up one instance
per project when it is opened/changed (including build config switches),
and trigger background indexing.
So far, the index is used to provide results for locators and "Find
Usages".
Per-document functionality such as semantic highlighting and completion
is still provided by libclang.
Change-Id: I12532fca1b9c6278baab560e7238cba6189cde9f
Reviewed-by: David Schulz <david.schulz@qt.io>
... by the customary ::Internal.
It adds only noise on the user side and conflicts regularly with
the top-level ::Utils namespace.
Remove a (now) duplicated definition of setLastSentDocumentRevision().
Plus minor namespace related fixes.
There are still minor conflicts between Utils::Text and
ClangCodeModel::Text
Change-Id: I2e8df6b3c6c3599192774032822ee7e778355bba
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
For some reason, Q_UNUSED includes already a semicolon, adding one
on the user side creates an additional empty statement.
Change-Id: I9c5e8fac381345a60792cb75e2938fd53958d3b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Refactor much of the code from Environment* classes to NameValue* classes
to share it with the preprocessor macro settings.
Change-Id: Ica4ee817aa338230c422b30d91240d266248d226
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Qt 6 API will move away from it.
Use QVector for API and some std container for internal things.
Change-Id: Iff14d48a47d5ac52ade875d9c8c84ad8a4f577d8
Reviewed-by: hjk <hjk@qt.io>
We must tell users where we generated the file, and also inform them
about errors.
Change-Id: I6383655e2f731f41b9121b2a6a31bba551d1c1de
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
For example CMake puts compile_commands.json into the build
directory and it makes sense because it uses some target-specific
command line options.
Change-Id: I92a5b391f35e3f75bbcf41b8efff448f197895bb
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This helps to deal with many diagnostics.
Error diagnostics precede warning diagnostis to have them on top.
If no CppEditor is active, no diagnostics are displayed.
Previously one had to scroll the document up and down to locate the
diagnostics. Now they are in a list and can be easily navigated with
F6/Shift-F6. Also, at least for some diagnostics "Get Help Online" from
the context menu seems to provide useful results. For example,
triggering the action on clang tidy issues will open the web browser
with some good hits explaining the issues.
Change-Id: Idabe30b0961d893bee39ccee431e92aeeda1cc26
Reviewed-by: David Schulz <david.schulz@qt.io>
Moving defaultToolTip and color from TextMarkRegistry to TextMark.
Allowing every instance of a TextMark object to define these
information.
Change-Id: Iec1794372cf902b34d343402074e3999e7f9faf7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* The QtTest include is not available in release builds.
* Make the batch file mode only available in debug/test builds as that
one uses test utilities that are only available in debug builds.
Change-Id: I441c51ec00b14b81a396ad0199882cf46fff10b0
Reviewed-by: David Schulz <david.schulz@qt.io>
This allows to start Qt Creator in batch processing mode:
$ export QTC_CLANG_BATCH=/path/to/file
$ export QT_LOGGING_RULES=qtc.clangcodemodel.batch=true
$ ./qtcreator -load ClangCodeModel
The batch file will be executed and Qt Creator will exit. Advanced
logging output can be activated as stated above.
Note that it is required that the project was already configured/set up
properly with the used settingspath, otherwise the wrong configuration
will be taken or a pop-up dialog will block the execution.
A small example follows that covers all the understood and so far needed
batch file commands in order to train libclang for profile guided
optimization. ${PWD} expands to the directory of the batch file.
openProject "${PWD}/calendarwidget.pro"
# Initial parsing
openDocument "${PWD}/window.cpp"
closeAllDocuments
openDocument "${PWD}/window.cpp"
# Reparse
setCursor 478 1
insertText " "
insertText " "
insertText " "
# Completion
complete
complete
complete
# Member completion
insertText "comboBox->"
complete
complete
complete
# Wait in order to inspect the result
processEvents 3000
Change-Id: I7dc5dddc6752272ecc2fb4f30497b17cee3f9a9f
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This reverts commit 07f4ae6227,
which broke compilation
clangbatchfileprocessor.cpp:170:27: error: ambiguous overload for
'operator==' (operand types are 'const QChar' and 'char')
and only worked in QT_TEST=1 cases.
Change-Id: I089427359958221882cb4e4369c4b88d71779acf
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This allows to start Qt Creator in batch processing mode:
$ export QTC_CLANG_BATCH=/path/to/file
$ export QT_LOGGING_RULES=qtc.clangcodemodel.batch=true
$ ./qtcreator -load ClangCodeModel
The batch file will be executed and Qt Creator will exit. Advanced
logging output can be activated as stated above.
Note that it is required that the project was already configured/set up
properly with the used settingspath, otherwise the wrong configuration
will be taken or a pop-up dialog will block the execution.
A small example follows that covers all the understood and so far needed
batch file commands in order to train libclang for profile guided
optimization. ${PWD} expands to the directory of the batch file.
openProject "${PWD}/calendarwidget.pro"
# Initial parsing
openDocument "${PWD}/window.cpp"
closeAllDocuments
openDocument "${PWD}/window.cpp"
# Reparse
setCursor 478 1
insertText " "
insertText " "
insertText " "
# Completion
complete
complete
complete
# Member completion
insertText "comboBox->"
complete
complete
complete
# Wait in order to inspect the result
processEvents 3000
Change-Id: Ib30526036f999e530f0c01d42a196a1e311e2c4c
Reviewed-by: David Schulz <david.schulz@qt.io>
The default tool tip should describe the general purpose
of the mark which is displayed in the UI when no tool tip
is explicitly set for the text mark.
Change-Id: I27aff26cf0f3458d454428e805a9b323191dc393
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
The existing solution with the special-style horizontal
kit selector comes from a time when there was typically
one, at most four targets. Today's setup can easily
reach half a dozen targets with several toolchain versions
each and can't be sensibly handled with the overflowing
horizontal bar.
This here replaces the horizontal kit selector bar as
well as the top level project "tab bar" with a normal
tree view. All targets are visible (but possibly disabled)
at once, and can be enabled/disabled using the context
menu on the tree items.
Change-Id: I1ce7401ca96109bf34bc8c0ae19d265e5845aa88
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This removes also the need to close editor documents.
Change-Id: I96c68105bceb37841053f3dbd8a264e059a02cb8
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
...for consistency and to avoid future file name clashes.
Change-Id: If595c8debfa1ceb01a1bb0ed34649fa513660503
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
Related to
commit c47079f97f7d42db0c581525a2ce6fddbc0995f2
Clang: Activate the code model with a check box
Change-Id: Ief11768ba0dd27788032e2dd3ad9b7ae39a8f52b
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>