Commit Graph

299 Commits

Author SHA1 Message Date
Nikolai Kosjar
36ce1dbb84 Designer/CppTools: Fix flaky test_gotoslot_withoutProject
The document was not always updated in time.

Change-Id: Iac89985d39a8784e3cbf63dfd42b1c5150775068
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
2013-11-14 08:34:45 +01:00
Erik Verbruggen
566be0995d C++: Release more documents.
- fix memory leak in find-usages
- do not retain snapshot in search history
- when an editor is invisible for more than 2 minutes, release the
  backing snapshot

Retaining snapshots will retain their documents, and if done for too
long, the memory consumption might grow. This is especially the case
when switching to a different kit (Qt version): in that case, the new
versions of headers will be indexed, while the old ones stay around.

Task-number: QTCREATORBUG-5583
Task-number: QTCREATORBUG-7645
Task-number: QTCREATORBUG-9842

Change-Id: I045eda1565e0a3fa702baeffaab9c12662f90289
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-11-12 09:24:13 +01:00
Nikolai Kosjar
b8dbac0b9c Rename "[Mm]ethod(s)" to "[Ff]unction(s)"
Only methods as programming functions are affected. Besides renaming
some actions like "Switch Between Function Declaration/Definition" this
mostly touches (api) code comments.

This is a follow-up patch to commit 872bfb7.

Change-Id: Icb65e8d73b59a022f8885b14df497169543a3b92
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-10-10 15:56:12 +02:00
Nikolai Kosjar
90130f4596 CppTools: Tests: Fix crash in test_modelmanager_gc_if_last_cppeditor_closed
The project that was referenced at cppeditor.cpp:711 was already
deleted. CppModelManager::m_fileToProjectParts contained outdated
information. Now it is updated if a project is closed.

Exposed by commit d411c07.

Change-Id: I6fee93a02c72a045dd44a05723ab39a1eeec616e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-10-09 15:02:45 +02:00
Erik Verbruggen
ba2d7a4fa7 C++: Only parse with appropriate defines for open editors.
If two files from different (sub-)projects include the same header file,
and the defined macros differ for both files, the header file will be
parsed with only the appropriate macros for the including file.

Task-number: QTCREATORBUG-9802
Task-number: QTCREATORBUG-1249

Change-Id: I560490afa287b3bb1e863bce1bb4f57af36ad56e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-10-01 10:33:51 +02:00
Erik Verbruggen
c9f5a14bdd C++: add code-model settings to choose one by mime-type.
The model-manager now supports multiple code models for semantic
highlighting and code completion, and will choose one based on the
mime-type of the editor.

The settings page is currently disabled. It will get enabled when a
second plug-in lands that has a ModelManagerSupport class.

Change-Id: I10023f52322ed6860397da15dba1c231e80e6517
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-09-13 14:37:48 +02:00
Erik Verbruggen
f7c68f6baf C++: change working-copy to work on UTF-8 encoded QByteArrays.
These not only take less space than UTF-16 encoded QStrings, but due to
the caching in the CppEditorSupport also take less time to build.

This patch also fixes a number of possible encoding issues, where files
and constant strings were (falsely) assumed to be UTF-8.

Change-Id: Ib6f91c9a94ebed5b5dfbd4eb2998825c62c72784
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-09-11 09:43:14 +02:00
Erik Verbruggen
3a5d3a2fe9 C++: unify highlighting/code-completion support "factories".
Both semantic highlighting and code-completion go hand-in-hand, so now
the ModelManagerSupport class acts as a "factory" for the model manager.
Depending on the mime-type of the document in the editor, the model
manager will return the appropriate highlighter or code-completion
engine. If none is registered, the built-in fall-back is used.

Change-Id: I3e5dbb0e3b58e077dd5eda9aecb2ce5d448ac0b8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-09-10 11:45:38 +02:00
Erik Verbruggen
87a3aac18f C++: add fallback project part querying
When a file is not part of any other project part, this project part can
be used to get at least some compiler flags, defines, etc. to use. This
can happen when either a file outside a project is opened, or when the
project description is incomplete.

Change-Id: I5d595fae7195e8b61dbad14368b6cae9eb15c21b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-09-10 07:36:25 +02:00
Erik Verbruggen
b4a1bd415f C++: clean-up CppCompletionAssist.
This is step 1 of 2 for merging the various provider factories into a
single class. Merging has the advantage that selecting based on editor
(content) mime-type only has to select one class, instead of re-doing
the selection for each class separately.

Change-Id: I11f815151bd4769ae6028b636793d6a80d02e202
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-09-09 11:59:14 +02:00
Erik Verbruggen
7516ef4969 TextEditor: get CompletionAssistProvider from editor.
And not from the global object pool. This way, the editors that have
different highlighters for various language dialects, or editors that
support multiple languages in a single editor, can decide themselves on
what CompletionAssistProvider to provide.

Change-Id: Ieebc4a8e7b3de6470fdb8103035aa3b8b2ba6598
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-09-09 10:15:55 +02:00
hjk
aadb6f16af SessionManager: Apply 'static' pattern
Change-Id: I370f72fcf7a24216ee189979ce6b5c8bfc5f4140
Reviewed-by: David Schulz <david.schulz@digia.com>
2013-09-05 12:28:12 +02:00
hjk
98917598d3 ProjectManager: Use Core::Id for progress types
Change-Id: I72993fda50ad70ad2d7c2f449923ac6e34b9e737
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-09-04 14:59:06 +02:00
hjk
df36184371 Core: Static pattern for ProgressManager, clean up all users
Change-Id: I4af8793ca69a3af9e99baeb7c31dad3864266f91
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-09-02 12:41:47 +02:00
Erik Verbruggen
073e5d6632 C++: optionally let the highlighter handle ifdefed-out blocks.
Change-Id: I38cc0e55348cac0245d2ab8f3e39c68de76e3e6d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-08-19 13:01:07 +02:00
Nikolai Kosjar
8ea14767af CppTools: Rework handling of ProjectInfo changes
(a) The code model manager figures out by itself which files were added
    or removed from the project.

    If this was done successfully, check also the timestamp of the
    common files and reindex if necessary.

(b) A full reindexing is only triggered if the project configuration
    changes (defines, includes, framework paths).

(c) If project files were removed, the garbage collector is called.

Task-number: QTCREATORBUG-9730
Change-Id: Ib855614b070880576233a3525813617c967a72f3
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
2013-08-13 14:13:33 +02:00
Nikolai Kosjar
2665a1249b CppTools: Do not garbage collect files in the working copy
...except the configuration file if no projects are open. For this case
there is no need to keep the configuration file around.

Task-number: QTCREATORBUG-9829

Change-Id: I51b01b30c17cbc1ced491ef2c47c338dae6ed983
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-08-08 12:12:31 +02:00
Nikolai Kosjar
7583039b87 CppTools: Do not call GC() more than necessary
Currently GC() is invoked if
   - 5 CppEditors were closed or the last CppEditor was closed
   - a project is about to be removed
   - a session is about to be unloaded

Thus, for the following use cases, too much GC() calls (can) happen:
    - File > Close All
    - Close All Projects and Editors
    - Changing the session

Fixed by introducing a timer.

Change-Id: I9c984d9de735fc8c6ee77a518e9fb5b63dba5881
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-08-08 12:12:08 +02:00
Tobias Hunger
5422b2c4da Introduce Project::projectFilePath()
Use it instead of retrieving this information from the document.

Change-Id: I809fcb2daf59021cf503c371a5d40d75d7448796
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-08-01 11:42:41 +02:00
Nikolai Kosjar
fdaddec7d1 CppTools: Clean up CppModelManager(Interface)
* Const correctness
* Better variable names
* Sort order of includes and forward declarations
* Comment fixes
* Cosmetic/Whitespace changes

Change-Id: Ieb137266ac7eddedb00c37f8b2cc8677d67e4bdd
Reviewed-by: David Schulz <david.schulz@digia.com>
2013-07-31 14:34:08 +02:00
Oswald Buddenhagen
6896546ba5 Merge remote-tracking branch 'origin/2.8'
Conflicts:
	src/plugins/cpptools/cppmodelmanager.cpp

Change-Id: I0e69dfad951eb81d8008f5ca05e8fb6999ae2c8a
2013-07-25 13:18:31 +02:00
Nikolai Kosjar
e2ce17ef00 CppTools: Fix "! condition" coding style
Change-Id: Ic7e634e4249fb64edbc2daceb65ec8e9b5f0f8b9
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
2013-07-25 13:11:34 +02:00
Nikolai Kosjar
072b7c5718 CppTools: Check if project has changed before reparsing
This introduces an API change for the project managers. Those are not
expected to call updateSourceFiles() anymore.

Task-number: QTCREATORBUG-9581
Change-Id: I77befd29fb851c9acf87204d571da00183c9cd05
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-07-22 08:33:52 +02:00
Nikolai Kosjar
c84e3a27d6 CppTools: Garbage collect if the last CppEditor is closed
Task-number: QTCREATORBUG-9828

Change-Id: Ie0ef9757cedb772702e49542b58d5b589506aa9e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-07-17 14:54:10 +02:00
Nikolai Kosjar
bc4fa63f84 CppTools: Move GC() call from CppEditorWidget to CppModelManager
There is no need to have that logic in CppEditorWidget. The
CppModelManager knows how many editors are open and can therefore call
GC() by itself.

Change-Id: I2ed4051ad7b8c87615014d73e29291027d49d2ab
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-07-17 14:54:01 +02:00
Eike Ziller
dd43d9908f Rename IDocument::fileName --> filePath
That is what it actually is, wrt how Qt API calls it.

Change-Id: Ied02055debf6aad75556b0d9d22e8ba2f72be555
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-07-09 13:51:42 +02:00
Erik Verbruggen
afa66ab9c7 C++: fix potential deadlock when closing an editor
When the editor is closed, the CppEditorSupport waits for the
highlighting and semantic info futures to finish. These futures might
access the CppEditorSupport through the CppModelManager, causing a
deadlock on the m_editorSupportMutex.

Change-Id: Ifeb3864ed3bc2666d83607ef50d7bfee8f3d118f
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-07-02 15:27:54 +02:00
Nikolai Kosjar
1fad00f999 CppTools: Fix snapshot in case another project is opened
When a second project was opened the snapshot was reset. That resulted
in all kinds of problems since from then on the code model effectively
was not aware of the files of the first project.

The regression was introduced by commit a0d6df7b.

Change-Id: I1ccc9de68177205b49a4ba8ead2bc8abe4592b32
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
2013-06-28 17:54:53 +02:00
Nikolai Kosjar
26fbefb26c CppTools: Allow to force a "Parsing" notification
Task-number: QTCREATORBUG-9597

Change-Id: I726a818c7d4af35dcb4863f74b08cd639a189bdd
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
2013-06-24 13:10:51 +02:00
Leena Miettinen
41411165ba Doc: use standard wording in \brief commands
QDoc does some magic with the \class and \namespaces
and \brief commands, so the following wording must be used:
"The xxx class yyy ..."

Change-Id: Id231f30e8464898b776888d5423523de404aae34
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-06-20 11:22:47 +02:00
Erik Verbruggen
18dcac7ad0 C++: fix encoding/conversion of built-in macros
Task-number: QTCREATORBUG-9404

Change-Id: I732b729e64b065b4ac75c547d9370cbc64918a31
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-06-17 08:14:39 +02:00
Erik Verbruggen
10725c086b C++: fix Q_CREATOR_RUN macro handling
Moved it from the handleIfDefDirective to the pre-defined macros, so
that #if defined() can also see it.

Task-number: QTCREATORBUG-9322
Change-Id: Icbecad5c885dd2374b559969c99631c3ddc73844
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-06-03 15:41:54 +02:00
Erik Verbruggen
feff33827c C++: fix crash when failing to open non-existing file.
Change-Id: Ie7bd3b36139ab7fac1186cefa7222dff7277eb53
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-24 14:17:47 +02:00
Erik Verbruggen
09ea0d235a C++: moved the CppPreprocessor into its own file.
Change-Id: I399d667a1fccb376fadbd6ab8fbba243e86d8f4b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-26 13:56:08 +02:00
Erik Verbruggen
ecacaab7a4 C++: model-manager clean-ups.
Change-Id: I59fdb898e270af0fcc18e79ae922e119504ef10e
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-26 13:00:43 +02:00
Erik Verbruggen
0c27b27658 C++ Detach the CppEditor from code-model internals.
- Moved document update handling into CppTools.
- Moved semantic info calculation into CppTools.
- Moved semantic highlighting into CppTools.

Change-Id: I253861bf074a64b1f657f7a4a8e6583871b5285f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-26 12:47:06 +02:00
Nikolai Kosjar
52825a91f9 C++: Preprocessor: Do not add configurationFileName() to the seen files
After processing configurationFileName() the first time, it was added to
the already seen files (m_included). Thus, on parsing further files, it
was ignored and with that all the project defines.

Task-number: QTCREATORBUG-9107
Change-Id: Ia4817dfa3b30ed27d142f7f3eeb6f099d0653441
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-26 09:55:32 +02:00
Erik Verbruggen
cd581ecd0b C++: do not run GC when exiting.
This operation is quite costly if a lot of files are involved, and in
case of exiting Creator, it's also useless.

Change-Id: I97d178d47a3a2f6b214f7ebc45c871edd26b8286
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-04-22 10:08:55 +02:00
hjk
fb72d5324e C++: Also cache result of misses in resolveFile()
Change-Id: Ib501bbe16548b194ff5028a1b3ab74c5f0e3230d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-16 12:36:00 +02:00
Erik Verbruggen
a0d6df7bd8 C++: also refresh files not in the project when project changes.
System headers and other file which are not explicitly mentioned in the
project must be reparsed when the project changes.

Task-number: QTCREATORBUG-9056
Change-Id: I32f1206d241a078a4d9b15fac5813f365a1ba303
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-16 11:56:18 +02:00
Erik Verbruggen
c388c05b86 C++: fix the quick-exit for already parsed files.
When the preprocessor is asked to process a file which it has already
seen before, it can skip it, but it still has to add the file to the
list of included files for the current document.

Task-number: QTCREATORBUG-9107
Change-Id: I30cac61c1da20da7fe925168ecccb429584e9746
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-11 12:15:07 +02:00
Friedemann Kleint
4b0bafd615 Clean headers in CppTools.
Ran script to remove inludes on a trial-and-error basis and
manually corrected it.

Change-Id: Ic8464ea084ca1ab401e9f4a7d0183b92b4038902
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-10 10:55:14 +02:00
Erik Verbruggen
82e347095c C++: Untangle include file resolving from loading.
Change-Id: Iacf8cb12dd623c908538d80ee2595297a9bdde71
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-09 11:56:02 +02:00
Tobias Hunger
ea23948efb CppTools: Use namespace CppTools consistently
There were quite a few classes using CPlusPlus namespace in the
CppTools plugin. Rename them and do some other small namespace
related coding style fixups.

Change-Id: I093fc1f3fc394fd9923e3f18d5f66522e288f21d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-08 13:21:31 +02:00
Oswald Buddenhagen
7923032022 fix include style relating to cplusplus libraries
... and adjust INCLUDEPATH accordingly.

while i'm at messing with include statements, also re-order the include
blocks according to policy and sort them within bigger blocks.

Change-Id: I7762abfd7c4ecf59432b99db2f424e4fa25733a5
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-04-03 13:40:39 +02:00
Sergey Shambir
f29902d33a CppTools: fixed bugs in change 49602
Change-Id: I14e9bbfea1bca58cdc49212b7ad1d880ab908ec8
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-03-27 10:36:13 +01:00
Sergey Shambir
63fe568b9b CppTools: improved languages support in ProjectPart
Please, read blueprint here:
http://qt-project.org/wiki/Blueprint-for-language-specs-system

Removed feature from QbsProjectManager: it not longer splits project on
separate C and C++ parts, because Qt version used only by clang parser
(not native) and can be ignored for pure C and Objective-C without C++.

Change-Id: I1c561f7f9f915cc6cb8579d19db74e8352f54c1e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
2013-03-21 17:22:18 +01:00
Friedemann Kleint
cb08f959b9 Fix Krazy warnings about includes/header guards in Cpp-Editor.
Change-Id: I00a68d7f2b509e3934c3248765a78e9b47749127
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-03-12 16:18:59 +01:00
Erik Verbruggen
b36a53cd19 C++: use QMutexLocker everywhere in the model manager.
Change-Id: Iab4dee2a607d453b3e80fe591b70329ab48d27a9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-03-08 15:00:14 +01:00
Friedemann Kleint
934bccbc7e Fix Krazy-warnings in CppTools.
- values or keys iteration
- non-const ref iterator

Change-Id: I6bb58793b3155243e0fbfaf33ee43ce60edea8d1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-03-08 10:56:12 +01:00