Having *some* limit is reasonable since sorting happens in the UI thread
and given enough includes/symbols it will freeze sooner or later.
The strategy is now: Stop sorting at all if there are more than 30.000
completion items to process.
The limit is a guess made on the following measurements. The goal is to
keep below 100ms.
test | items | before | now
-----+-----------------------
Cpp1 | 6394 | 172ms | 15ms |
Win1 | 44739 | 125ms | 56ms |
Qtc1 | 9648, | 16ms | 15ms |
Qtc2 | 10210 | 20ms | 16ms |
Qtc3 | 51044 | 141ms | 63ms |
Qt1 | 62953 | 172ms | 78ms |
Windows.h alone pulls in about 44.000 completion items.
Used test procedure
-------------------
For each test below, do:
1. Start Qt Creator in release mode
2. Open/create the project with a MSVC2015 Kit
3. Open the mentioned file
4. Strg+Space in the mentioned function
Measured with a timer in IpcReceiver::codeCompleted.
Test projects:
Cpp1: stdc++11-includes.pro, main.cpp, main()
Win1: Create project from wizard, *.cpp file including windows.h, completion
in some added function
Qtc1: qtcreator.pro, texteditor.cpp, BaseTextEditor::duplicate()
Qtc2: qtcreator.pro, fakevimhandler.cpp, FakeVimHandler::jumpToLocalMark
Qtc3: qtcreator.pro, botan.cpp, version_string()
Qt1: qt-essential-includes.pro, main.cpp, main()
Change-Id: I6fbd65d14f6086f289be7dd6c24385996e4bde83
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
We assume that libclang does not return any duplicates, at least we
never noticed any so far. For the concrete test below no duplicates were
removed.
Function overloads are not problematic because they are folded into one
ClangAssistProposalItem (addOverload()).
To the completion items from libclang we add the Qt Creator snippets as
items. Those might have the same text in the completion list view, but
their icon is different (e.g. consider the keyword completion "class"
and the Qt Creator snippet "class"), thus the user can still tell them
apart.
Test:
1. Open src/plugins/clangstaticanalyzer/unit-tests/qt-essential-includes.pro
2. Open main.cpp
3. Complete in the main function
Measured with a timer in IpcReceiver::codeCompleted.
On Linux, for 20637 completion items:
Before: 74ms (avg)
Now: 66ms (avg)
Gain: 11%
Change-Id: I524eaa09f8d9e07c78dc9efcc77f7e021c6f37f7
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
For unit test we need to break every dependency to the TextEditor
Widget etc.. With an abstract interface we can implement it in clang
without relying on unwanted dependencies. It makes it also easier to
compute the values deferred.
Change-Id: I1b313a1625f4e80bd324ab4bf1a7c4f6b690abe9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This reverts commit c5f70a3bad1ee2457741459cafb6419c67c417ad.
We will set the rich text unconditionally in a follow-up change to
simplify things.
Change-Id: I59aad8e33011ef68aa7c32ec80bb02edfd29c6a6
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
The tooltip text right to the completion list item is prepared for rich
text (html) interpretation, but the QLabel the text will finally be
displayed with has no explicit text format set and thus defaults to auto
detection. The auto detection works fine for e.g. "<i>int optionalArg</
i>" but fails for "const Foo&".
Task-number: QTCREATORBUG-15630
Change-Id: Ia58d65ee542730e4823c69150d452cdde98112f8
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
1 struct Foo { int member; };
2 void f(Foo *foo)
3 {
4 foo.<REQUEST COMPLETION> // correct '.' to '->' and provide results
5 }
The preferred approach would be to check if "foo" in line 4 is of
pointer type, but there is no suitable cursor (only CompoundStmt) at
that position since the code is usually not yet parsed and thus invalid.
Thus, just run the completion as is. If there are not any results for a
dot completion, re-run the completion with "." exchanged by "->". This
approach is inherently slower than the preferred approach implemented in
the built-in code model.
The following rare cases are not handled:
1) Requesting completion after white space:
Works: foo.<COMPLETE HERE>
Fails: foo. <COMPLETE HERE>
2) Opening a file and requesting completion (ctrl+space) without prior
editing. No editing before triggering completion means that no
unsaved file is generated on the backend side, which is a
requirement for the correction.
Task-number: QTCREATORBUG-11581
Change-Id: I6bc8e8594778774ab342755fdb01a8a3e5c52ba0
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
Remove the unused members and remove also
ClangAssistProposalModel::[m_]replaceDotForArrow, which is a needled
indirection.
Change-Id: If6e0f65678b05fabd5fa16823a7a4c634b9fbdef
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
The priority is adjusted too provide a better completion list.
Change-Id: I1ebed1996f660046843e0c5249a91e8c2b1eeb88
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>