Commit Graph

17 Commits

Author SHA1 Message Date
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
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
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
05c1efd8ef Clang: Fix dot-arrow-correction for not-yet-parsed unsaved content
The issue was re-producible with e.g.:

    void g()
    {
        // Type 'foo.' as fast as possible in the next line

    }

This led to "foo->" with completion results as if there was no "foo." at
all in that line.

We relied on a correct position for
translationUnit.sourceLocationAtWithoutReparsing(), but the just typed
characters were not yet reparsed. And we do not want to reparse at that
point since takes too long. We already determine the utf8 position for
the dot character, so simply use that instead.

This completes commit 17c1325cc4.

Change-Id: I669888b5c17ee63b2aec7b16c9921f9d79e281f9
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
2016-06-24 08:31:28 +00:00
Nikolai Kosjar
17c1325cc4 Clang: Fix dot to arrow correction
The position of the dot character was determined on an outdated
translation unit.

We queried the translation unit for the source location of the dot
character, but apparently clang_codeCompleteAt() does not update the
source locations for the translation unit. And we do not want to reparse
since this is expensive. Thus, determine the byte position manually by
scanning over the document until the right line/column is reached.

Change-Id: I25e256bb81a83bb71c7e46a0fb3e927bf4031b16
Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-05-03 12:19:13 +00:00
Nikolai Kosjar
db8b9f9463 Clang: Fix variable name in test
Change-Id: Ief210920c62710786cf75fd6aea04897f4e2965e
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-02-01 15:17:11 +00:00
Nikolai Kosjar
57877cc14d Clang: Workaround dot detection for arrow correction
...by explicitly checking for the dot in the source.

Task-number: QTCREATORBUG-15654
Change-Id: I4172e88a7fbb3015ef391daf13ded1f0002aab9c
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2016-02-01 12:20:58 +00:00
Tobias Hunger
954569387c Update License according to agreement with Free Qt Foundation
* Update license information in tests directory

Change-Id: I311441dd37d053ca3175e44b284258e232ee93e0
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 16:01:06 +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
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
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
Nikolai Kosjar
6687b60a99 Clang: Tests on MSVC2013: Fix string literal concatenation
Change-Id: I1b1cefbace16cf0161bfe522d2ac37704e374713
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
2015-11-26 13:17:32 +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
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
0fd213357e Clang: Tests for code completion
Reparsing in Clang is broken in master. We need to test what is working
in which version.

Change-Id: I620acd4a0a5adc951951e0fc3c0a4096ac9844fe
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-08-04 16:16:45 +00:00
Marco Bubke
5df8085529 Clang: Remove the hint and snippet field from the CodeCompletion
It is not used and is producing overhead.

Change-Id: I1398b18a40c0f5c0b90fe4c058996d7eb109f9f2
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
2015-07-16 12:54:58 +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