Commit Graph

100 Commits

Author SHA1 Message Date
Ivan Donchevskii
1184792fe7 CppTools: remove ambiguity in Usages class name
Usages class is used in findUsages and globalRename in further changes.

Change-Id: I2f314e4ebe7828e59fcc3cae824893c96eb21cab
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-24 10:18:27 +00:00
Ivan Donchevskii
b10f8484c7 CppTools: merge CompilerOptionsBuilder with Clang one
Since it's never used for other compilers.

Change-Id: I9512692d1dc9f9a701ea2453b7d50005478bed5d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-23 12:46:34 +00:00
Ivan Donchevskii
a959fe59da C++: remove builtin RefactoringEngine dependency from CppEditor
Move CppRefactoringEngine to CppTools and builtin member
ownership to model manager.

Change-Id: I3e72308559fd2928229f9f25d4dd09beb3f56c34
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-22 12:59:20 +00:00
Ivan Donchevskii
55a5ffc1ec C++: remove builtin FollowSymbol dependency from CppEditor
Move FollowSymbolUnderCursor to CppTools and
builtin member ownership to internal model manager.

Change-Id: I97a4f744ec1709ccc0b34fb67b58680973ef566f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-22 12:59:05 +00:00
Nikolai Kosjar
656b9f9185 Clang: Restrict warning options edit to single line
...to avoid confusion.

Use a customized QPlainTextEdit instead of a QLineEdit because the
latter does not allow wrapping of long lines. Horizontal scrolling in a
QLineEdit for long/many options is inconvenient.

Change-Id: I15b5f034e04920d0ca955c4f822d882b05e9c235
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-09-19 06:58:34 +00:00
Ivan Donchevskii
a137b08eaa CppEditor: refactor FollowSymbol
Create an interface to get the ability to use
another FollowSymbol implementation

Change-Id: I5802f62523ff3ee47b8a14e487adf43edcb6c9b1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-15 14:14:01 +00:00
Ivan Donchevskii
76d12dc2d5 CppEditor: add default RefactoringEngine
..and use it when we don't have refactoring plug-in

Change-Id: Ibe317a9728d439b9c5e05271d92a330d22eaacb9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-15 14:13:48 +00:00
Nikolai Kosjar
d3d3e2ace5 CppTools: Simplify/Modernize SemanticInfo
Change-Id: I7bef1dee81678f77f5c0d8a6d22488aa63f981e7
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2017-06-15 15:11:48 +00:00
Nikolai Kosjar
fdf0a104ec CppEditor: Generalize CppUseSelectionsUpdater
Let CppUseSelectionsUpdater delegate the work to
*EditorDocumentProcessor so that the clang code model can also provide
results.

Change-Id: I6872afbfeea1a5c4a64fdf19fcb1992f134dde08
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 12:24:59 +00:00
Nikolai Kosjar
6174cca5a0 Move CanonicalSymbol from CppEditor to CppTools
Needed for a follow-up change.

Change-Id: Ibb4815f3411f0d63deac8c32583178470668f67b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2017-05-29 06:42:09 +00:00
Nikolai Kosjar
8c90998fff CppTools/ProjectManagers: Reduce ui blocking when loading projects
${AnyProject}::updateCppCodeModel() did two potentially not that cheap
operations in the ui thread:
 (1) Querying the MimeDatabase for the mime type for the source files of
     the project. In 99.9% of the cases no files need to be read for
     this as the file extension will resolve the type. The expensiveness
     comes from the sheer number of files that can occur.
 (2) Calling compilers with the "(sub)project's compiler command line"
     to determine the macros. While the caches avoid redundant calls,
     the number of the unique compiler calls makes this still a
     ui-freezing experience.

These two operations are moved into a worker thread. For this, the
expensive compiler calls are encapsulated in thread safe lambdas
("runners") in order to keep the "mutexed" data minimal. The original
API calls of the toolchains are implemented in terms of the runners.

While adapting the project managers, remove also the calls to
setProjectLanguage(). These are redundant because all of the project
managers already set a proper value in the constructor. Also, currently
there is no need (client) to report back detection of C sources in
project parts. This also keeps CppProjectUpdater simple.

There is still room for improvement:
 * Run the compiler calls in parallel instead of sequence.
 * Ensure that the mime type for a file is determined exactly once.

Change-Id: I2efc4e132ee88e3c8f264012ec8fafe3d86c404f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-20 09:18:13 +00:00
Nikolai Kosjar
c0f2bc254e C++: Sort source files in *.qbs
This makes the diff smaller when adding new files with the wizards.

Change-Id: Iabd35afc32f363c465c8d9b36c45d480ea666627
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2017-02-13 11:13:11 +00:00
Nikolai Kosjar
0b8df41387 CppTools: Provide hints about chosen project part for editor document
Parse issues can have multiple reasons (invalid kit, not a project file,
actual parse issue) and we should be able to tell them apart. With this
change, we can distinguish between the fallback project part and a
ambiguous project part.

Follow up changes will use this to display more accurate diagnostics.

Change-Id: Icc8767607cc17dc14d6227b07f34e81ba5525a96
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-01-24 14:41:48 +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
ce1c6b2258 CppTools: Extract ProjectPartChooser
...and put it under tests.

Change-Id: Id4bd2391abd1dfdc23640e871453558566cb0693
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-16 13:40:23 +00:00
Marco Bubke
1e3f2eec8d Clang: Consolidate all ClangCompilerOptionsBuilder into one implementation
We used the same code in different but don't shared it. From a bug fixing
perspective it's actually not that smart.

Change-Id: Iaaffc883229e259ff77f95b5cf0a8f0d8b5117df
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2016-12-15 10:18:15 +00:00
Nikolai Kosjar
602ad72d42 CppTools: Refactor ProjectPartBuilder
...and add some basic tests.

Introduce the abstractions ProjectInterface and ToolChainInterface in
order to break the dependency to the ProjectExplorer. Also, some simple
logic can go there to simplify the (Base)ProjectPartBuilder.

Change-Id: I6c50a1804ce62098b87109931eb171f5c2542937
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-13 08:33:04 +00:00
Nikolai Kosjar
4580e88cbe CppTools: Extract ProjectFileCategorizer
Change-Id: Ib7a5c3c61b0ea172cbc6a3ac7c94e77ffabc0db4
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-08 08:35:34 +00:00
Christian Kandeler
e1e203598d qbs build: Final steps to support building plugins "out of source".
- Use the entire Export block when creating a module, not just the
  Depends items. Adapt references to the product source directory
  and the "share" directory so that they point to the respective
  locations in the install tree.
- Install dev headers for some more plugins.
- Bug fixes & polishing.

Create a "dev installation" like this:
$ qbs qtc.make_dev_package:true qbs.installRoot:<install root>

Then build your plugin against it like this:
$ qbs qtc.make_dev_package:true qbs.installRoot:<install root>
project.qbsSearchPaths:<install root>/qbs-resources
(Using qbs from 1.5 branch; 1.5.1 requires a trivial wrapper project.)

That's all. Successfully tested with all commercial plugins on Linux.

Change-Id: Ie39c4717dafcd431c533421a15f2f898783d8521
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-06-15 12:35:55 +00:00
Christian Kandeler
a0f956f050 qbs build: Introduce new module "qtc".
The qtc module gathers properties that used to live in the top-level
project file. This is the first step towards making it possible to build
plugins against an installed Qt Creator ("out of source build").

Change-Id: Ia1514cc9c888e80be01b308e908de48980fcbdb8
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2016-06-08 08:46:00 +00:00
David Schulz
c422b81316 Move completion settings page to TextEditor plugin.
Change-Id: I12b7828d23d599e5903237d0cc2a3c0440e1b07d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2016-05-30 07:15:03 +00:00
Nikolai Kosjar
8cfef9657a Clang: Introduce switching/adding of warning configurations
A warning configuration is a list of command line (warning) options for
libclang. Three non-editable built-in configurations are provided by
default. The user can copy a configuration to customize it.

This is still a global setting and it changes take effect after
re-opening a document. Both issues will be addressed in follow-up
changes.

Change-Id: I86667d7dc39ad31b88666454220e6da563797740
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-03-01 11:21:36 +00:00
Alexandru Croitor
bed88818ce C++: Implement context-aware expand / shrink selection actions.
Implement selection expanding / shrinking, that is aware of C++
semantics, thus giving smart selection changing.

Change-Id: I1386a20597fa6bb85c3aa0d8ddfb87cdb3fd7c38
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-02-29 08:15:03 +00:00
Ulf Hermann
2e3e060520 Generalize support for extra compilers
Allow for different extra compilers which may get called to generate
additional code for the code model. The build system is expected to
know what files are generated from which source file and the extra
compilers know how to generate the content of those files, without
touching the build directory. the uic adapter is refactored to be
the first such extra compiler.

The extra compiler is run when an editor for its source document
loses focus, or after a timeout of 1s when the source document has
been changed.

Change-Id: I13c110c61120c812f02639a3684144daf8979b37
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-02-16 12:53:05 +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
Marco Bubke
68bd9a881f CppTools: Moving CompilerOptionsBuilder in its own header file
Change-Id: I503ffd72a98db6668f6449ce95e695e035a79a29
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-01-13 14:47:20 +00:00
Marco Bubke
1ae509541c CppTools: Moving ProjectPartBuilder in its own header
Change-Id: I0aa65ec6c80dcd437f13ff70021388b0da57ccfd
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-01-13 14:47:11 +00:00
Marco Bubke
da1f8e66e5 CppTools: Move ProjectInfo in its own header file
Change-Id: I0fc4c73553a29585d4ff7c8d6593acb6975d1607
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-01-13 14:47:04 +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
Marco Bubke
6fe9b0ccc4 CppTools: Add CppToolsBridge
We broke the dependency of
BaseEditorDocumentProcessor *BaseEditorDocumentProcessor::get(const QString &filePath)

It's hiding static calls and it is much easier to do it that way than to
provide a reference to every user. It's also possible to exchange it with
different implementations for different test cases.

Change-Id: Ic74699b45948e8b48f7efb6a1b295ba2641b8951
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-01-12 10:21:30 +00:00
Nikolai Kosjar
6b6ad446eb CppTools: Make FollowSymbol respect projects
Finding the class definition for a forward declaration or finding the
function definition from its declaration is mostly determined by the
file iteration order. Documents with the most common path prefix are
checked first.

This works fine as long as the files of your project have a common
ancestor. If that's not the case, FollowSymbol might take you to the
definition within another project.

Fix that issue by considering the project part id when constructing the
file iteration order. Since the cached file iteration order now depends
on the projects, ensure to clear it if projects are added, changed or
removed.

Task-number: QTCREATORBUG-15116
Change-Id: I529166bac363959c9fee0b946747fd0370a88809
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-10-12 15:08:24 +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
Eike Ziller
9790d8aa00 Merge remote-tracking branch 'origin/3.4' 2015-03-24 07:40:21 +01:00
Orgad Shaneh
044eeacde5 Load only tested plugins when invoked with -test
By default, a clean settings path is used for test environment.

All the default plugins are loaded, although they're not needed.

This change significantly improves loading time for tests.

Change-Id: I24254f3e538e3f0e6d233d0989738dc1ce238209
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-03-24 06:22:03 +00:00
Nikita Baryshnikov
3cd0463f32 Remove aggregation dependency from project files
Change-Id: Idfd3941f47b71d6b84306d88604b744e3585e4af
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-03-09 14:25:34 +00:00
Nikolai Kosjar
93e82d731e CppEditor: Move CppEditorOutline to CppTools
Change-Id: I75768f548f8f914e76fbdeaf3c318c207782fe1b
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-01-26 18:15:29 +01:00
Nikolai Kosjar
df1bbb07d1 CppTools: Extract base class CppCompletionAssistProcessor
As as side effect, this also brings some more pragma completions for the
builtin-in completion engine, e.g. "pragma once" or "pragma omp atomic".

Change-Id: If3ef22076c331c653b78a87cfff836c1da38c8fb
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
2015-01-21 12:19:12 +01:00
Eike Ziller
bae5782166 Add locator filter for all included files.
Collects all included files from any file of any project or
that is open in an editor. It has the same shortcut as the
files from any project filter and is also enabled by default.

Task-number: QTCREATORBUG-280
Change-Id: I7cd89ee68d2f8ec4e0ea03de0c11671f489c47dc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-01-12 15:06:20 +01:00
Christian Kandeler
9d677e3302 qbs build: Remove unneeded import statements.
The respective items are available without it.

Change-Id: Idc840cf08e7bec84f561c096afe8de25b1fb8468
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
2014-11-10 15:45:14 +01:00
hjk
b26a17f30d CppTools: Change CppModelManager implementation pattern
Replace the CppModelManagerInterface/derived CppModelManager
combo by a more common CppModelManager/CppModelManagerPrivate
pimpl pattern.

Change-Id: Ia4582845ed94d5ef60b8571bab9b2260c6290287
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-09-19 13:17:55 +02:00
Tobias Hunger
57cc272770 CppTools: Add some methods to the JsExpander.
Make some C++ related methods available to the JsExpander. These
are concerned with namespace handling, etc.

Change-Id: I2fc3807cf421b817bb103b727606a78aee290652
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-09-18 14:38:30 +02:00
Nikolai Kosjar
89bd4ee3c4 C++: Base parsing on editor document instead of widget
This mainly takes CppEditorSupport apart.

* Parsing is now invoked by CPPEditorDocument itself by listening to
  QTextDocument::contentsChanged().

* Upon construction and destruction CPPEditorDocument creates and
  deletes an EditorDocumentHandle for (un)registration in the model
  manager. This handle provides everything to generate the working copy
  and to access the editor document processor.

* A CPPEditorDocument owns a BaseEditorDocumentProcessor instance that
  controls parsing, semantic info recalculation and the semantic
  highlighting for the document. This is more or less what is left from
  CppEditorSupport and can be considered as the backend of a
  CPPEditorDocument. CPPEditorDocument itself is quite small.

    * BuiltinEditorDocumentProcessor and ClangEditorDocumentProcessor
      derive from BaseEditorDocumentProcessor and implement the gaps.

    * Since the semantic info calculation was bound to the widget, it
      also calculated the local uses, which depend on the cursor
      position. This calculation got moved into the extracted class
      UseSeletionsUpdater in the cppeditor plugin, which is run once the
      cursor position changes or the semantic info document is updated.

    * Some more logic got extracted:
	- SemanticInfoUpdater (logic was in CppEditorSupport)
	- SemanticHighlighter (logic was in CppEditorSupport)

    * The *Parser and *Processor classes can be easily accessed by the
      static function get().

* CppHighlightingSupport is gone since it turned out to be useless.

* The editor dependency in CompletionAssistProviders is gone since we
  actually only need the file path now.

Change-Id: I49d3a7bd138c5ed9620123e34480772535156508
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-08-25 13:06:01 +02:00
Nikolai Kosjar
7d35212f60 CppTools: Rename SnapshotUpdater to BuiltinEditorDocumentParser
Change-Id: I554b5e9e3f1ef7c167fa45b5cd0c230fdf63073b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-08-20 11:12:48 +02:00
Nikolai Kosjar
27e343b970 CppTools: Extract BaseEditorDocumentParser out of SnapshotUpdater
Change-Id: If89e81eec6d600d3d39cc09203cf434d0768c1b4
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-08-20 10:29:21 +02:00
Nikolai Kosjar
6b5298faf9 CppTools: Move Project{Part,Info} to new cppprojects.{h,cpp}
Change-Id: Ieff216017b9da1e6a12121688ea9572bdd81fd9b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-08-20 10:28:35 +02:00
Nikolai Kosjar
b8a6a4dd4e CppTools: Move WorkingCopy to new cppworkingcopy.{h,cpp}
Change-Id: I447acf28849bffb52c1e6b6eafdde221ec0b179e
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-08-20 10:26:47 +02:00
Nikolai Kosjar
995d1f777f C++: Add basic LocalSymbols test
Change-Id: I199e912203f329ec9b8bed2eb105e4a56f729e7d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-07-04 12:35:05 +02:00
Erik Verbruggen
17febac88b C++: Rename ModelItemInfo to IndexInfo.
And move it into its own header and source files.

Change-Id: I37401badd819e028e1d767425759dc0ff27afe31
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-06-16 12:08:12 +02:00
Nikolai Kosjar
ec97d967e6 CppTools: Rename CppPreprocessor to CppSourceProcessor
...since it does quite a bit more than only preprocessing, as the name
suggests. We use that class to process source files in general. The
output is not a preprocessed source, but a set of CPlusPlus::Documents
with symbols.

Change-Id: I787d0f22f9f042ddf0c99e8c2f0bdb9aa7001735
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-06-04 16:28:35 +02:00
Alessandro Portale
6facb4391a CppTools: Move setting category icon from Core to CppTools
This image is used exclusively in the CppTools plugin,
thus belong into CppTools resources.

Change-Id: I8bbc553fb16897b74487ad27a941776b83f14d77
Reviewed-by: Alessandro Portale <alessandro.portale@digia.com>
2014-06-03 10:50:01 +02:00