Commit Graph

14 Commits

Author SHA1 Message Date
Ivan Donchevskii
8922fbf4be Clang: change global completions order
Give CamelCase completions lower priority

Task-number: QTCREATORBUG-18319
Change-Id: I812d22616e8ab0e3d186bcf7a6a569de22be2a07
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-06-09 14:28:16 +00:00
Nikolai Kosjar
4ae368ddbb Clang: Set limit for sorting completion items
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>
2016-07-27 08:30:30 +00:00
Nikolai Kosjar
9d5705a755 Clang: Stop trying to remove duplicate completion items
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>
2016-07-26 11:49:17 +00:00
Marco Bubke
c903f4974f TextEditor: Introduce AssistProposalItemInterface
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>
2016-02-01 14:01:35 +00:00
Nikolai Kosjar
06a99af0f6 Revert "Clang: Fix text format for completion details" from 3.6
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>
2016-01-27 16:31:10 +00:00
Tobias Hunger
397e7f4843 Update License according to agreement with Free Qt Foundation
* Update files in src/plugins

Change-Id: Ia5d77fad7d19d4bb3498e78661982f68729adb22
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:57:01 +00:00
Eike Ziller
98257617e9 Merge remote-tracking branch 'origin/3.6'
Conflicts:
	src/plugins/clangcodemodel/clangassistproposalmodel.cpp
	src/plugins/clangcodemodel/clangassistproposalmodel.h

Change-Id: Iba30d2f4d95fa0f551afe58890d15f5835dfb715
2016-01-19 16:41:17 +01:00
Nikolai Kosjar
1a6b62a2b0 Clang: Fix text format for completion details
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&amp;".

Task-number: QTCREATORBUG-15630
Change-Id: Ia58d65ee542730e4823c69150d452cdde98112f8
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-01-19 13:27:30 +00:00
Nikolai Kosjar
8d6549fa74 Clang: Correct member access operator if possible
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>
2016-01-19 13:20:35 +00:00
Nikolai Kosjar
a5a0864741 Clang: Fix warnings about unused members
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>
2015-12-01 12:07:57 +00:00
Marco Bubke
bb549770a8 Clang: Remove unused function
Change-Id: Iee4a6a4e8197db9520ad188fa872840305bca1b1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-07-13 10:30:40 +00:00
Marco Bubke
eb5afed10f Clang: Add sorting by priority
The priority is adjusted too provide a better completion list.

Change-Id: I1ebed1996f660046843e0c5249a91e8c2b1eeb88
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-07-08 12:29:27 +00:00
Marco Bubke
5467fc25ea Clang: Make ClangAssistProposalModel members private
Change-Id: Ib8089f4afdb72840d97e5286d8be631387e4d2c5
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-07-06 12:41:05 +00:00
Marco Bubke
ed27414f48 Clang: Split clangcompletion.[h|cpp]
First step for refactor them.

Change-Id: If9de084e39ddf31317035ccbbc1fd57d7797d193
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-07-06 12:41:01 +00:00