Commit Graph

22 Commits

Author SHA1 Message Date
Nikolai Kosjar
ca72c29462 Clang: Provide highlighting for identifier under cursor
Change-Id: I80ffe23cbcc84ab7323124581d9dd6afbe974fd0
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2017-06-14 12:49:05 +00:00
Nikolai Kosjar
9d55d8485c Clang: Show info bar for parse errors in header files
...because those errors can lead to a substantial performance/functional
regression.

The actual diagnostics (possibly with children) are shown as details in
the info bar.

The info bar can be hidden with the "Do Not Show Again" button.
Re-enabling the info bar is possible with the new editor tool bar
button.

Change-Id: I03394ff8e3c84127946b0b791930b28a385f5a46
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-11 14:01:14 +00:00
Nikolai Kosjar
1a426d9f01 Clang: Support second translation unit
A TranslationUnit is owned by TranslationUnits now. TranslationUnits
allows to add another TranslationUnit and to update/query the recently
and previously parsed translation unit.

This does not change any behavior yet.

Change-Id: I8a2f0cc05d3e51bf739dd5d7c4da14b54147f3ab
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-10-10 12:35:48 +00:00
Nikolai Kosjar
985e4436f2 Clang: Rename TranslationUnitCore to TranslationUnit
Change-Id: I03a59ae5d5073c812ad40c7623cfb1fdb80aad80
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-07 13:36:43 +00:00
Nikolai Kosjar
14b27183ce Clang: Rename TranslationUnit(s) to Document(s)
The "TranslationUnit parts" moved already to TranslationUnitCore.

Change-Id: I2bea7847e2b3e84fbfacc3d2dc43f180873349ac
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-09-07 12:36:19 +00:00
Nikolai Kosjar
38f72855b6 Clang: Process distinct documents concurrently
Speed ups the typical use cases that can profit from this:
 * Change a header file and switch then to source file
 * Open documents one after the other (Follow Symbol)
 * Change documents visible in splits (e.g. by refactoring action)
 * Restore a session with multiple splits

Fixes the test ClangIpcServer.GetCodeCompletionDependingOnArgumets.

Change-Id: Ia575bd59780df14146dfc091a4d48794e4a0543d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-28 09:42:31 +00:00
Nikolai Kosjar
90f94363db Clang: Extract TranslationUnitCore and (re)parse explicitly
Extract TranslationUnitCore, which is the API for the high-level
operations we need. TranslationUnit does not call any clang_* functions
anymore, except the one needed for disposing the CXTranslationUnit - for
now, we keep TranslationUnit the owner of TranslationUnitCore.

TranslationUnitCore will be passed on to the worker threads.

With this, the current "TranslationUnit" looses its meaning. We will
rename it to "Document" in a follow-up change.

                            ***

TranslationUnit::cxTranslationUnit does not implicitly
creates/parses/reparses anymore. We use more verbose update operations
now.

The test ClangIpcServer.GetCodeCompletionDependingOnArgumets fails now
because of this - CodeCompleter::completeHelper() does not recreate the
translation unit anymore, thus working on the old data.

This will be addressed in a follow-up change.

Change-Id: I6213d6f1609cd3c9a54666c84cb8b623b2fefe1c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-28 09:42:24 +00:00
Nikolai Kosjar
dc734f45fd Clang: Extract TranslationUnitUpdater
...in preparation for concurrent processing of documents.

Parsing and reparsing is handled by TranslationUnit. Since we will do
this in a different thread, extract the core logic into the new class
TranslationUnitUpdater, so that we can prepare the necessary data for
the run and then later incorporate the results of the parse/reparse.

Change-Id: Ic9d936d193ee6795a755f0cfc38c0b2a7bd402cc
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-28 09:42:18 +00:00
Nikolai Kosjar
606d41187c Clang: Prepare for multi-threading
* Make the necessary data implicitly shared since it might get
  accessed/modified from two different threads with follow-up changes.
  This applies for UnsavedFiles/UnsavedFile and ProjectPart::arguments().

* Avoid returning references.

Change-Id: I98842c1cb90ae0d344a15c63b72cbc89568722d3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-07-28 09:42:14 +00:00
Nikolai Kosjar
36e7f4541f Clang: Pass on file paths with native separators
libclang 3.8 seems to be sensitive to file paths separators [1]. On Windows,
this led to not updated document annotations and/or crashes after reparsing.

When passing file paths to libclang, convert to native separators.
When getting file paths from libclang, convert back.

This handles:
 * main file path
 * file paths of the unsaved files
 * -I<DIR> arguments, the resource path (for builtins) and the paths to the
   wrapped qt headers
 * included header files from libclang
 * source locations from libclang

Also, minimize the conversion in SourceLocation to a minimum by making
filePath() lazy.

[1] https://llvm.org/bugs/show_bug.cgi?id=28381

Change-Id: If5866f34a6fdc6b34b16c022d3988e8e6eae2a0a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-04 13:08:03 +00:00
Eike Ziller
0f94aa3f4d Merge remote-tracking branch 'origin/4.0'
Conflicts:
	src/plugins/debugger/debuggerruncontrol.cpp
	src/plugins/projectexplorer/projectwizardpage.cpp
	src/plugins/projectexplorer/xcodebuildparser.h
	src/plugins/qmldesigner/qmldesignerplugin.cpp
	src/tools/clangbackend/ipcsource/translationunits.cpp

Change-Id: Ibf0857cf8dbf95fc9ac13d5c2112b3f4a2ca7de6
2016-05-03 11:49:01 +02:00
Nikolai Kosjar
7b7b1823cb Clang: Avoid parse loop if libclang crashed or file vanished
Remember whether clang_parseTranslationUnit() or
clang_reparseTranslationUnit() failed the last time and do not trigger
parse/reparse again.

Also, check whether the main file exists before reparsing.

Task-number: QTCREATORBUG-16051
Task-number: QTCREATORBUG-16140
Change-Id: Ied39e66a18032854911229898573941fe2ada35b
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
2016-04-26 12:28:16 +00:00
Eike Ziller
a3880c4916 Merge remote-tracking branch 'origin/4.0'
Change-Id: If0ba896a083392a532f76bb26bec3540a7c17667
2016-04-25 13:27:14 +02:00
Nikolai Kosjar
28b6820026 Clang: Print error code on parse error
Change-Id: Idecb0e9b78cc14c603de09fc460bbf17f43bb451
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2016-04-22 13:30:17 +00:00
Marco Bubke
2349b13ae5 Clang: Rename HighlightingInformation to HighlightingMark
Change-Id: I3954c7c9abe593ea04092337f48ac2b153e883ba
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2016-03-07 12:06:40 +00:00
Nikolai Kosjar
da27ea4d42 Clang: Introduce UnsavedFile wrapper
This simplifies UnsavedFiles and makes TemporaryModifiedUnsavedFiles
useless.

Change-Id: I1896f971215ed22ce7aa7bf21b16381862b7469d
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-02-01 12:20:53 +00:00
Tobias Hunger
1b4321279f Update License according to agreement with Free Qt Foundation
* Update files in src/share* and src/tools

Change-Id: I78aa5d4a1d76212964e467de7676c1fcb2b777d6
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:48:57 +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
0985e67858 Clang: Reparse editor document on project change
Change-Id: If7dcdc370fd50fded996df80ab6c893b4ec1ad55
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-12-07 15:49:33 +00:00
Marco Bubke
514a96c75f Clang: Don't reparse before code completion
Task-number: QTCREATORBUG-15365
Change-Id: I37f623449fa95268f1a0a5d5e66d75df0582c183
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-11-30 15:49:19 +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
216f110385 Clang: Tests on MSVC2013: Fix file name clashes
The following files conflicted:

	src\tools\clangbackend\ipcsource\translationunit.cpp
	src\libs\3rdparty\cplusplus\TranslationUnit.cpp

	src\libs\3rdparty\cplusplus\Type.cpp
	src\tools\clangbackend\ipcsource\type.cpp

	src\libs\3rdparty\cplusplus\Symbol.cpp
    src\plugins\clangcodemodel\symbol.cpp

Change-Id: If7865570cd70e39e25cc8d508f771c8023288f0c
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-26 13:54:21 +00:00