Commit Graph

185 Commits

Author SHA1 Message Date
Eike Ziller
242579099a CppTools: Fix QStringRef and QSharedPointer related issues with Qt6
Task-number: QTCREATORBUG-24098
Change-Id: I97347ac3fb397fea8eee655e3cc4ee252c511885
Reviewed-by: hjk <hjk@qt.io>
2020-09-15 13:57:32 +00:00
David Schulz
dba4bff703 TextEditor: use Utils::FilePath as file member in AssistInterface
Change-Id: I3bf9b013b9350411f918efdb9d1a36a2c22bf972
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-09-04 10:14:21 +00:00
Christian Kandeler
760d91665f TextEditor: Make threshold for automatic completion configurable
Fixes: QTCREATORBUG-19920
Change-Id: Id6be79485b1fb8c2ab4cce2706816949ae5e217b
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-13 13:49:44 +00:00
hjk
7ab6783e24 Standardize on int for line and column values
Recently tons of warnings show up for presumably "problematic"
singned <-> unsigned and size conversions.

The Qt side uses 'int', and that's the biggest 'integration surface'
for us, so instead of establishing some internal boundary between
signed and unsigned areas, push that boundary out of creator core code,
and use 'int' everywhere.

Because it reduces friction further, also do it in libcplusplus.

Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-26 09:23:48 +00:00
Nikolai Kosjar
975173af11 CodeAssist: Ensure perfect match for keywords
...as otherwise the completion windows stays open and gets in the way.

Fixes: QTCREATORBUG-21767
Change-Id: Ib0a841b9d9de52109439f067c466478744361814
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-05-23 08:08:30 +00:00
Nikolai Kosjar
12f4b1ee86 CppTools: Modernize
Change-Id: I78af9cd4ccddfa4ed744dce96b772ae5644c89d2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-02-08 08:43:32 +00:00
Alessandro Portale
1d3d18a969 CppTools: modernize
Change-Id: Iaf02e4d026f1ac8b216833d83cd7a735e21ff60a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-01-21 09:00:18 +00:00
Ivan Donchevskii
8469e317c9 Utils: Adjust column numbers affected by convertPosition change
convertPosition change was introduced in 931ec39f64.
It changed 0-based column to 1-based which is how it
naturally is in Qt Creator.

This fixed some usages but broke many more. This is an
attempt to fix the remaining use cases.

Fixes CppEditor auto-tests.

Change-Id: Ia8d14da0ebb035cd2fdd6da4ff6ec89c1c5121a8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-09 08:51:21 +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
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
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
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
David Schulz
a4b5fc00a8 CodeAssist: use shared pointer to pass around proposal models
Task-number: QTCREATORBUG-17752
Change-Id: Ia41f169b86ead209830e6f15764062389ced2b67
Reviewed-by: hjk <hjk@qt.io>
2018-02-27 12:32:36 +00:00
Ivan Donchevskii
80a472740d TextEditor: move convenience from texteditor to utils
Allows to use this header without texteditor dependency.

Change-Id: I706f42799c3ea42473a716fa9ef9f3cfbef6fdd4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-22 12:59:35 +00:00
Marco Bubke
b6e12f4a1c Convert macros from plain QByteArray to a vector of structs
The old code model expected the macros as C++ formatted text
("#define Foo 42) but newer targets like the Clang codemodel expect key
value arguments like "-DFoo=42". So instead of parsing the text again and
again we use an abstract data description.

Task-number: QTCREATORBUG-17915
Change-Id: I0179fd13c48a581e91ee79bba9d42d501c26f19f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-09-14 15:23:56 +00:00
Ivan Donchevskii
287ae7ae61 Completion: improve complete in the middle
Apply clang fix to the old code model
Do not replace the text after cursor if
the proposal does not contain it or
if proposal matches 100% the text after it

Task-number: QTCREATORBUG-18471
Change-Id: I662cb6e48a9e0ee14065594f5c823f114fff2474
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-07-10 13:52:18 +00:00
Nikolai Kosjar
3e203e1208 CppTools: Fix uninitialized values warnings
...from coverity scan.

Change-Id: I7f4c3de39279cfffab2246aa84ae2ac13916bd1e
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
2017-06-01 13:33:27 +00:00
Nikolai Kosjar
535cc76cac Clang: Avoid dot-arrow-correction if dot is gone
Change-Id: Iba23a17ba9345ed4f08e16faad02054903c04afc
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-23 17:26:06 +00:00
hjk
3f5caf4cdc Utils: Wrap MimeDatabase into static functions
To avoid repeating the 'MimeDatabase mdb; mdb.something(); ' mantra
all over the place.

Change-Id: I4bfef62e73275a991455141671d6071162788e9d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-03-03 07:57:54 +00:00
Nikolai Kosjar
e4e6572661 CppTools: Allow interpreting ambiguous headers as C headers
...instead of C++ headers.

For the Clang Code Model this results in using "-x c-header" instead of
"-x c++-header".

This introduces a new option in Options > C++ > "Code Model" to
configure this.

Change-Id: I8a0ce8fa6155f5ef58743ebc7f1d0b500fbf6599
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2017-01-16 10:17:50 +00:00
Nikolai Kosjar
602c873d3e CppTools: Reparse editor documents after active project change
Change-Id: I010709c866291bf59c27f4a05765e1ab0efd28af
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-16 13:56:31 +00:00
Nikolai Kosjar
bd66d5ac05 CppTools: Remove some duplication
Change-Id: I8c84660b28c3e76b2cedd08ff3b44a38583f38a0
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-16 13:56:26 +00:00
Nikolai Kosjar
566ab175b3 CppTools: Prioritize project parts from active project
...when selecting one for the editor document.

Change-Id: I85066aaa0862870cb2db2fb2cb40c2b2c23b2cac
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-16 13:56:16 +00:00
David Schulz
6750607244 Editor: Skip auto completed character only if it was recently inserted.
This means you can skip automatically inserted characters as long as you
don't explicitly move the text cursor and the editor doesn't lose the
focus. This will be visualized by highlighting the automatically
inserted character as long as you can perform the skipping.

This will reduce unexpected skipping in the case a cursor was explicitly
placed before an closing brace and a closing brace is typed.

Change-Id: I28e29e79ba10c9c48e8bc8817405fea630cca9bd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-21 11:56:56 +00:00
Nikolai Kosjar
a717e980e7 C++: Guard against parent binding loop
Task-number: QTCREATORBUG-16146
Change-Id: Ib2a790954517859acd7ca5f16c7d889d28208fb0
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2016-04-27 11:42:21 +00:00
Alessandro Portale
984a6eca73 cplusplus: Make functions of Icons static
This avoids multiple instatiations and reloading of the same image files.

Change-Id: I4d0bb955e23c1cb817671c25bff4e74fb7b3d0f4
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-04-06 08:48:32 +00:00
Nikolai Kosjar
334e3edd18 C++: Extract base startOfOperator()
...in order to remove some duplication.

Change-Id: Ie974b6ed9418967ad80b4604088b0e1c293b59d0
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-03-31 09:30:37 +00:00
Nikolai Kosjar
4b3a987c39 C++: Equalize startOfOperator()
There are two versions of startOfOperator:
    * InternalCppCompletionAssistProcessor::startOfOperator
    * ClangCompletionAssistProcessor::startOfOperator

The latter started as a copy of the former, but the former got some bug
fixes in the meantime.  Adjust both versions to each other, so it's easy
to diff them and to extract the duplication in a follow-up change.

Change-Id: Icf48386bf1ad0fa473bec476c5412be9b1890139
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-03-31 08:01:58 +00:00
Nikolai Kosjar
4de62a7349 C++: Fix completion for doxygen tags I
There are three cases that must be handled:

 1. Completion in C++ style comment
 2. Completion in first line of a C style comment
 3. Completion in non-first line of a C style comment

This change fixes case 1 + 2. Case 3 will be addressed in a follow-up
change, same goes for the duplication.

Task-number: QTCREATORBUG-15143
Change-Id: I449711f965ddcbbe6158870a8a5ae33218e0d238
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-03-31 06:51:34 +00:00
Christian Stenger
26c7afdfb7 TextEditor: Fix compile with gcc 4.7.3
Change-Id: I59b401c4d7a75398fddc8f6e3a0671fc49f0cb47
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-02-02 14:40:14 +00:00
Marco Bubke
f41c6b0c4b Clang: Remove TextEditorWidget from AssistProposalItemInterface
Change-Id: I0ac924f88c1347d1b0027c47118b7ed21daf4869
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-02-02 11:26:58 +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
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
Marco Bubke
2b4cadf1fe CppTools: Move ProjectPart in its own header file
Also extracting inline HeaderPath class and change projects list in vector
because the size is  larger than a pointer.

Change-Id: I885fdff3fe9bccc877634d1615249755f5b674fd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-01-13 14:46:56 +00:00
Nikolai Kosjar
9abfd73204 CppTools/Clang: Remove InMemoryInfo
...nowadays we only need the working copy.

Change-Id: I30924b3c5dc68b428d6c10f6ba015b0640b476d2
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-16 13:29:21 +00:00
Nikolai Kosjar
0498fb68ff C++: Revert lookup to 3.4.2
...which was least buggy.

The bugs fixed by the changes we revert here (highlighting/completion
for code involving templates) were minor compared to ones we currently
have. Those bugs will be addressed by the clang code model anyway.

Relevant commits were collected via:

  $ cd ${QTC}/src/libs/cplusplus
  $ git log \
   --no-merges \
   --format=oneline \
   v3.4.2..HEAD \
   -- LookupContext.* ResolveExpression.* TypeResolver.* TypeOfExpression.* \
      ../../plugins/cpptools/cppcompletion_test.cpp

From this list the following were skipped due to irrelevance:

  88c5b47e53 # CppTools: Minor cleanup in completion tests
  e5255a1f5c # CppTools: Add a test for ObjC not replacing dot with arrow
  5b12c8d63a # CppTools: Support ObjC in member access operator tests
  9fef4fb9ca # CPlusPlus: Fix warnings about overriding visit(...) methods

There were only minor conflicts while reverting those.

This changes touches so many files because there were quite some
cleanups and renames after the 3.4.2 release.

Task-number: QTCREATORBUG-14889
Task-number: QTCREATORBUG-15211
Task-number: QTCREATORBUG-15213
Task-number: QTCREATORBUG-15257
Task-number: QTCREATORBUG-15264
Task-number: QTCREATORBUG-15291
Task-number: QTCREATORBUG-15329
Change-Id: I01f759f8f35ecb4228928a4f22086e279c1a5435
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-19 14:48:38 +00:00
Orgad Shaneh
81a4f6b970 CppTools: Do not read language features from document in completer
The correct value is set on construction. The document knows *less*.

Task-number: QTCREATORBUG-14583
Change-Id: I60973047e14ce0664c49e802124b51aa23444835
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-09-16 12:54:11 +00:00
Nikolai Kosjar
169556db2f C++: Fix crash after triggering completion and closing editor
Fix use-after-free for the following case:
  1. Open an editor
  2. Trigger a long processing completion
     (e.g. simulate with QThread::msleep in
      CppCompletionAssistInterface::getCppSpecifics)
  3. ...and immediately close the editor (e.g. with Ctrl+W)
  4. Wait until it crashes.

The completion thread relied on the BuiltinEditorDocumentParser object,
which is deleted once the editor is closed. Fixed by sharing the
ownership of that object between the *EditorDocumentProcessor and the
completion assist interface.

This case came up when doing tests for the bug report below.

Task-number: QTCREATORBUG-14991
Change-Id: I0b009229e68fc6b7838740858cdc41a32403fe6f
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2015-09-02 12:37:23 +00:00
Nikolai Kosjar
418fc32f6a Clang: Do not call DocumentManager::modifiedDocuments() from worker thread
This is unsafe.

Change-Id: I8ac075a7289afa0d84785e37b1325d186a153000
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-07-10 14:04:19 +00:00
Nikolai Kosjar
23b8a3b2e8 Clang: Use completion through backend process
This makes us independent of libclang crashes for completion.
Re-parsing for highlighting still happens in the Qt Creator process.

Run in verbose mode:
    qtc.clangcodemodel.ipc=true

Run tests:
    -test "ClangCodeModel"

Task-number: QTCREATORBUG-14108
Task-number: QTCREATORBUG-12819
Change-Id: Id3e95bd2afdb6508bbd1d35fddc69534a909b905
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-06-10 10:15:40 +00:00
Tobias Hunger
e5da3d8aeb cpptools: s/Q_DECL_OVERRIDE/override/g
Change-Id: I1b239a666b6605035e0f9c140d940e8c260bafd3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-04 12:25:51 +00:00
Nikolai Kosjar
25c63444af CppTools: Remove QTC_ASSERT in completeQtMethodClassName
SOFT ASSERT: "klass" in file src/plugins/cpptools/
cppcompletionassist.cpp, line 1916

...can occur during Qt5 signal/slot completion if the object type can't
be looked up, e.g.:

    Foo *foo; // Foo is used by not defined
    connect(foo, &<TRIGGER COMPLETION HERE>

Change-Id: I0fafd328635e1db57d700d531af0fee819cca8fa
Reviewed-by: hjk <hjk@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-05-19 15:02:09 +00:00
Eike Ziller
4058ff6fe9 Merge remote-tracking branch 'origin/3.4'
Conflicts:
	src/libs/extensionsystem/pluginview.cpp

Change-Id: I410156c1003d5dc81e915110c6d432bcd71da010
2015-05-07 14:42:46 +02:00
Nikolai Kosjar
f878da0ea8 CppTools: Offer "override" and "final" as completion items
These are special identifiers and were thus not included in the 'add all
keywords' handling.

Change-Id: I7f65df5711193e945bfa955dcb70a6ab454606b5
Task-number: QTCREATORBUG-11341
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-04-24 08:33:56 +00:00
Nikolai Kosjar
cea5d886d8 CppTools: Fix global completion after "/// text."
Like for other comments, don't try member completion if the doxygen
comment ends with a dot.

Task-number: QTCREATORBUG-8597
Change-Id: I2d5204ba8f45fc9ee94e285a907364cc722e62c7
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-04-24 08:30:51 +00:00
Orgad Shaneh
cb350bfeb2 C++: Rename ClassOrNamespace -> LookupScope
Change-Id: Ide74482b133dd1fec40a725d9aa81bd749385f37
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-04-20 14:51:56 +00:00
Nikolai Kosjar
f368294251 CppTools: Fix global completion after '&'
Regression introduced by

        commit 9fb5b0be15
        CppTools: Add basic completion support for qt5 style signals/slots

Change-Id: I0a8e5ef31c1394512a51a26ed08b0f445add5acd
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-04-13 10:55:44 +00:00
Tobias Hunger
fb6d7ce91b Remove some duplicate includes
Change-Id: If7bae084cd34c6fb0fe77f9227d9848517c0e691
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2015-03-20 14:45:04 +00:00
Friedemann Kleint
fb80206f3c Clean exported headers of the CppTools plugin.
Change-Id: I0144ac33e88980c431c54a6d69bbde28da4b1967
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-03-05 08:16:48 +00:00