Commit Graph

37 Commits

Author SHA1 Message Date
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
Marco Bubke
ddd1d4c9cc CppTools: Remove cpptools/cppprojects.[h|cpp]
Change-Id: Ida0e8552d371972c141cf561b28667f4428c6fff
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-01-13 14:47:27 +00:00
Nikolai Kosjar
ca63359386 CppTools/Clang: Clean-up of includes
Change-Id: I0ba340dcf0ee23e61588f17262d07e7088751836
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-16 13:15:38 +00:00
Nikolai Kosjar
475b11aad1 Clang: Fix recovering on clangbackend crash
The translation unit was updated, but not re-registered.

Handle the editor documents this way:
  1. Reset all ClangEditorDocumentProcessors (this will send an
     unregister message, but that's not problematic).
  2. For the visible editor documents, run their processors so that the
     translation units will be re-registered.
  3. For the invisible editor documents, mark them dirty. Once the user
     makes an invisible document visible again, the processor will run
     and also re-register the translation unit.

Change-Id: I23693ac197bd34a183f3a0020eb5372268636599
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-02 16:04:31 +00:00
Marco Bubke
a08336fcc2 Clang: Don't send multiple completions for the same position
If we send already a completion we should test if there is already one
sent for the same position.

Change-Id: Ie88f89bff0e1da1c5e747827a45154c7ccaecabc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-02 16:01:54 +00:00
Marco Bubke
ff913b83ae Clang: Use revision from file container
Change-Id: Ie084677fb910fc6e415afcdf7533369150162f8f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-12-02 13:46:10 +00:00
Marco Bubke
493a2a6189 Clang: Fix slowness of code completion after opening the file
Task-number: QTCREATORBUG-15429
Change-Id: I9a8a582fb3c59a960425f83eb8e7b436f15d1c1a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-12-02 12:37:25 +00:00
Marco Bubke
d579608e8a Clang: Prioritize current and visible translation units
We reparse first the current and then the visible translation units before
we reparse all other units.

The signals connections are queued to wait for the visible editor update.

Change-Id: I5e2b8bc80568450268ca24e26720b3f5af640995
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-12-01 11:14:39 +00:00
Nikolai Kosjar
a12a8c95f9 Clang: Request diagnostics/highlighting only if needed
Most of the time, the updated diagnostics/highlightings will be send by
the backend on translation unit update.

The other use case is changing the font settings (e.g. color), here we
need to request the highlightings explicitly.

Change-Id: I17a574eaf972c8bef12900241e7b33fe6ffd9dbd
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-30 16:50:49 +00:00
Nikolai Kosjar
5f98b8ec24 Clang: Remove PchManager
...which is the last dependency to libclang from the plugin.

Change-Id: I173ee7e9621912ec88706b4cf62db2b1dbcf7610
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-11-30 11:03:51 +00:00
Marco Bubke
7ce9ef9db4 Clang: Integrate highlighting results from backend
Change-Id: I2c3fb69aabfe075bde76d63eafc2ca370f17493c
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-26 15:19:27 +00:00
Nikolai Kosjar
641abf3e56 Clang: Update the fallback project part
Change-Id: I1dfbb32246798a402a1efe18529e95d6199ba942
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-11-09 12:11:35 +00:00
Nikolai Kosjar
787b386ecc Clang: Use the fallback project part
...for project-less files.

Change-Id: I02d7e26bdd40dfce3b0663a07b591ee6beb2f6b7
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-11-06 11:55:28 +00:00
Nikolai Kosjar
23fa5a7efd Clang: Provide the language option to the backend
Provide the language option (e.g. "-x c++-header") when registering a
translation unit for the editor.

Task-number: QTCREATORBUG-14787
Change-Id: Ie06f9fdab302f1b21ba72cdb65b6aabf9f7bc04c
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-11-06 11:54:16 +00:00
Nikolai Kosjar
8f2ad8d246 Clang: Remove dead code
Change-Id: Ic81768748bb998d73906dcfc599a52f8c363f5b8
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-11-06 11:32:53 +00:00
Nikolai Kosjar
582494e68f Clang: Fix misleading function name
Change-Id: I60934867db6b61c8309a712db8a189d458a73ea7
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-11-06 11:32:47 +00:00
Marco Bubke
250c8d662b Clang: Add UpdateTranslationUnitsForEditorMessage
If an editor is changing all translation units independent of their project
part they must be updated too. So we introduce a new message to update all
translation units with the same file path.

Change-Id: I70d0ea2bbca9fa880111ff7219573e54f3277026
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-10-13 14:03:11 +00:00
Marco Bubke
bc89baa6e8 Clang: Request new diagnostics after reload
Diagnostics should be not computed after a file change but after creator
is requesting them. Now we wait for the dialog if the file should be
reloaded.

Change-Id: Id0d51874b95e0f8743002a91511d07e0ed47ecdc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-10-12 15:32:03 +00:00
Marco Bubke
d6d5d9ac8c Clang: Improve IpcCommunicator::requestDiagnostics
Add logging and don't send if sendMode is IgnoreSendRequests.

Change-Id: Ia3df9fd2c1c75cfec720233518401fc9df5e0017
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-10-01 13:05:13 +00:00
Nikolai Kosjar
514efee682 Clang: Fix typo in function name
Change-Id: I6f3dd4cb41f52df440ce9d133cc199f6c66b742c
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-09-30 14:33:52 +00:00
Marco Bubke
c5941f9fec Clang: Call updateTranslationUnit for reloaded files
If a file is reloaded it should update every translation unit.

Change-Id: Ib61d933e95fcd9fe4d32363ddc06f5edcca55e35
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-09-30 14:29:29 +00:00
Marco Bubke
b412eb81ea Clang: Add revision and completion management
Reparsing a document is expensive so we should avoid it by all means. In
this patch we prevent that the same document is send again. It isn't send
too in advance of a code completion if there was no changes before the
the completion position.

Change-Id: I0bb786ba1d4e7ce08611a518cb32f8cf8f4d0037
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-09-28 15:46:15 +00:00
Marco Bubke
a272d93fcd Clang: Change name to registerCurrentCppDocuments
registerCurrentUnsavedFiles was misleading.

Change-Id: I5a2444d81d141ced4b8a0fae7236484c9e919d8d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-09-21 13:28:35 +00:00
Marco Bubke
7eee8061f6 Clang: Add unsaved files messages
We have auto generated buffers from ui files which are not open but have no
file representation. So we need to provide them as unsaved files only.

Change-Id: I48a426c18e06eeda2fa707864f32f293e17ac651
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 15:02:19 +00:00
Marco Bubke
6e14eb6940 Clang: Rename ForCodeCompletion in ForEditor
It reflects that the translation units and projects have a tied
relationship with an editor.

Change-Id: I3c01d5776980fe079af1fdef82feded83fdf5463
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 15:02:02 +00:00
Marco Bubke
f2b7371af1 Clang: Reparse only if files are changed
Includes are now watched by a file watcher. Unsaved file changes are
watched too. If they are changed the translation units which depend on
them are set to a state which require a reparse. Later the diagnostics
of this units are collected and send back to creator.

Change-Id: I2fb5c7dd6644687f22399edd8d18edd6215c9505
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 15:00:07 +00:00
Marco Bubke
b278dc87ca Clang: Add diagnostics
Diagnostics are now moved to the clang backend process. Fixits are
supported too.

Change-Id: I20faacf466bbf78dec479220c3d7b336a47bc453
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-31 14:59:16 +00:00
Marco Bubke
ec4d002857 Clang: Rename command in message
Change-Id: I1e2671d15b0db3c670b86dd0d4bed5ee09e866f1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-25 12:54:27 +00:00
Nikolai Kosjar
93e0ffa942 Clang: Increase backend alive timeout
...the backend is not yet multithreaded and on very slow machines on
heavy load this can sum up.

Change-Id: Ia7f456e8558d60aacbe6a689e884342b466063fa
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-08-06 12:43:36 +00:00
Nikolai Kosjar
b783bcea60 Clang: Allow to time high-level functions
...by enabling the logging rule:

    qtc.clangbackend.timers=true

Change-Id: I085c6bbebc0343b74bcb90119d1ebb80ad49518d
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-07-29 08:53:24 +00:00
Nikolai Kosjar
5643a45a83 Clang: Fallback to global completion if function call completion fails
We can not offer proper constructor completion with libclang <= 3.6, so
fall back to normal/global completion.

Change-Id: I90bb8d981ae20ed4c228f829ad4267221b92f8a1
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-07-23 11:18:55 +00:00
Nikolai Kosjar
889237f962 Clang: Mini refactorings in ClangCompletionAssistProcessor
The renames will improve the readability of the follo-up change.

Change-Id: If1f5ae2a2798c13ce7268e436dae1b3963f01d5e
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-07-23 11:18:50 +00:00
Nikolai Kosjar
420bc69739 CppTools: Use project part ids instead of file paths
File paths are not unique since e.g. each qbs group in a file is mapped
to a project part.

Change-Id: I7df3f224dd23046b869f2588b8a34eb26cfc0b1a
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-07-20 09:49:14 +00:00
Nikolai Kosjar
e8041f2254 Clang: Update class name in assert
Change-Id: Ib7aa42fbe8cc66fa8629cf9079e81fd0449fe14d
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-07-17 11:33:38 +00:00
Nikolai Kosjar
83d1aa0d72 Clang: Avoid heap-use-after-free in IpcCommunicator
...on shutdown.

Now the slot will be disconnected on destruction.

Change-Id: Ie511bf5400c41eee3245879ea355293e7bb5c7cd
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-07-14 10:19:17 +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
Marco Bubke
1402c067b1 Clang: Rename CodeModelBackEnd in ClangBackEnd
Change-Id: I13e8a458634110456375956d4d4da7239c86957f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-06-16 13:29:27 +00:00