Commit Graph

1594 Commits

Author SHA1 Message Date
Erik Verbruggen
a870c29a71 C++: use a global string table for SearchSymbols.
This string table uniques strings, so that multiple identical strings
share their contents. It is used by the locator and the symbol searcher,
and will later be used by the class view.

Change-Id: Ib8b50f69bbf994d0d7a39b66dc8caf1a3d9bfb42
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-28 15:54:38 +02:00
Erik Verbruggen
76fd01d428 C++: clean up name generation for symbol searching.
This does less calls, and less string concatenations for anonymous
scopes.

Change-Id: Ief07cdcd7daa5710628990abe1486b52a2896d05
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-27 14:17:25 +02:00
Orgad Shaneh
c5af948623 CppTools: Optimize test for electric char in context
Change-Id: I34a03ec9e781656fd4f24a719fb2c2da2efa4681
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:53:55 +02:00
Nikolai Kosjar
b35686b968 CppTools: Move some static functions into the *.cpp
...since they are not referenced.

Change-Id: Ibe5906de6a3dcb9d6d69cade948eba98964e9a66
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:46:04 +02:00
Nikolai Kosjar
06e810767c CppTools: Remove qHash() and operator==() for ProjectPart
These days we rather use ProjectPart::Ptr.

Change-Id: I069ad47fe9dd62901e7ac7d43a1850af8cb15f5d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:45:32 +02:00
Nikolai Kosjar
a8690b61fe Cpp{Tools,Editor}: Tests: Use CppModelManager::document()
...instead CppModelManager::snapshot().document().

Change-Id: If79bc03d062d309bbf6d4b229255ba281cddf8d5
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:43:54 +02:00
Nikolai Kosjar
acbc4b9f07 C++: Get rid of {Name,Type}::isEqualTo()
...since it's superseded by the class Matcher.

For consistency, rename FullySpecifiedType::isEqualTo() to match().

Change-Id: I07640f9218d814e0350265de45f05929e5d595a9
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:43:30 +02:00
Nikolai Kosjar
c6358e5d38 C++: Add utf16 indices to Macro and Document::MacroUse
In most cases we need to work with the utf16 indices. Only in
cppfindreferences the byte interface is still needed since there we read
in files and work on a QByteArray to save memory.

Change-Id: I6ef6a93fc1875a8c9a305c075d51a9ca034c41bb
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:34:01 +02:00
Nikolai Kosjar
bb7da966b8 Cpp{Tools,Editor}: Respect multi-QChar code points when handling identifiers
* Consolidate code dealing with C++ identifiers into cpptoolsreuse.h
* Handle code points that are represented with two QChars

Change-Id: I4fb4435aa539f65d88598cac0b50629f33f32440
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:33:34 +02:00
Nikolai Kosjar
bea8fc8e6a Cpp{Tools,Editor}: Expect UTF-8 encoded literals
Change-Id: I9843c4163aad3fa3f1bfa33060c76328fc2dc25a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:24:23 +02:00
Nikolai Kosjar
cadc4b42ba Cpp{Tools,Editor}: Tests: Use QString instead of QByteArray
This is necessary in order to add tests with multi-byte UTF-8 code
points. Otherwise the initial and target source code marker positions
will be calculated on the QByteArray (test code) but used with a QString
(editor document).

Change-Id: I108961b13d32912a4d3193cf26eb59f65d296f57
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:24:10 +02:00
Nikolai Kosjar
41aa2cb3bd C++: Use Token::utf16chars{Begin,End} where appropriate
...especially in CppTools/CppEditor where the offsets are used with a
QString/QTextDocument.

Change-Id: Ic6d18fbc01fb9cc899a9bd2d7424cd2edae487f1
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:23:51 +02:00
Nikolai Kosjar
57ff992961 C++/CppTools: Pass UTF-8 encoded source to Lexer
The Lexer can handle it now.

Task-number: QTCREATORBUG-7356
Change-Id: I8c4b03a247656e013d44c3cedca4835e133d4036
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:23:41 +02:00
Nikolai Kosjar
587eb49c4e C++: TranslationUnit::getPosition takes utf16char offsets
...and not byte offsets anymore. This is necessary in order to calculate
the line and column numbers correctly with respect to unicode code
points.

Change-Id: I5d79857b3eaefeb8d563b4f1e3938a64debc5e08
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-23 14:23:24 +02:00
Orgad Shaneh
589535c120 CppTools: Pass some const variables by reference
Change-Id: I3e703c923f6e1a14a89c76f394a070184db0c7bf
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-21 15:50:10 +02:00
Orgad Shaneh
28f5c46cc0 CppTools: Deduplicate null validation
Change-Id: I291fd7d755f08a533bb2686024858b11fabd9bed
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-21 15:50:01 +02:00
Orgad Shaneh
904a1d78f4 CppTools: Fix indentation of stream operators after string
Task-number: QTCREATORBUG-12053
Change-Id: Ia34165d860bd7fd371a84a8349bed7a3fe1c01a9
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-16 15:59:56 +02:00
Nikolai Kosjar
126e69137a C++: Clarify units of a Token
This will avoid confusion when later more length and indices methods are
added.

In Token:
    length() --> bytes()
    begin() --> bytesBegin()
    end() --> bytesEnd()

Change-Id: I244c69b022e239ee762b4114559e707f93ff344f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-15 15:55:38 +02:00
Orgad Shaneh
efe316f811 CppTools: Define '<' and '>' as electrical characters
Required for auto-indenting stream operations. For example:

std::cout << foo
          << bar;

without explicitly invoking the indenter.

Change-Id: I3a88083af5295709dfecb384538078e236119b0b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-05-15 11:40:56 +02:00
hjk
6e584b5b49 DocumentModel: Make interface static
Move item model implementation to private, adjust user code.

Change-Id: Ifbe94e7c7b9b1e8be1b4c531958dbd7a9413af13
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-05-13 11:48:30 +02:00
Orgad Shaneh
519913e599 CppTools: Pass const QString by reference
Change-Id: I3ad42095b7029cb58223a7bb7f9ce21dda29f50f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-13 04:20:10 +02:00
Orgad Shaneh
038f59836b CppTools: Minor cleanup
Replace repetitive condition with switch-case statement.

Change-Id: Ib022d6970257d054f47229b70c1c0db4b6f2e80c
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-05-13 04:18:17 +02:00
Daniel Teske
3c413fc358 Rewrite ::getObjects usage to use predicate version
This makes the code easier to read and shorter.

Change-Id: I6d582bd9861aa0208565301f61f098e9313b6c89
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-05-12 14:54:46 +02:00
Tobias Hunger
8d5e4b32a8 Project: Use Utils::FileName as return type for projectFilePath()
Change-Id: If304d5e95cd9ac714100abaae35d60e3e1050eb2
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
2014-05-06 11:30:45 +02:00
Eike Ziller
0fb641c90e Merge remote-tracking branch 'origin/3.1'
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/libs/qmljs/qmljsmodelmanagerinterface.cpp
	src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp

Change-Id: Ie216b715d6f87a6d72d3b8fe3d4e777e561579f9
2014-05-02 10:00:20 +02:00
Nikolai Kosjar
3f835d3925 CppTools: Fix race conditions in CppEditorSupport
...when accessing m_lastSemanticInfo by introducing semanticInfo() and
setSemanticInfo(), which lock the appropriate mutex.

Task-number: QTCREATORBUG-11367
Change-Id: If8ac6b8e6d576dfd1869c98a7ff7952ec97f530e
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-04-30 14:28:34 +02:00
Eike Ziller
063b95d970 Use more descriptive progress bar titles
Change-Id: I70450a2aa675d69f820de48dd75909f36051efe0
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2014-04-28 14:32:25 +02:00
Eike Ziller
8c1c106a4f Merge remote-tracking branch 'origin/3.1' 2014-04-14 16:53:23 +02:00
Nikolai Kosjar
9b2672cb05 CppTools: Fix data race when accessing the editor revision
Addresses the following findings of QTCREATORBUG-12030:
 * qtc.helgrind.plugintests.txt#2
 * qtc.helgrind.usingEditors1.txt#1

Helgrind report (truncated):

Possible data race during write of size 4 at 0x23679618 by thread #1
Locks held: none
   at 0x6819003: ???
   by 0x681D713: ???
   by 0x68200DE: ???
   by 0x684B8F8: QTextCursor::insertText(QString const&, QTextCharFormat const&)
   by 0x684BCB9: QTextCursor::insertText(QString const&)
   by 0x139DA06C: TextEditor::BaseTextEditorWidget::keyPressEvent(QKeyEvent*) (basetexteditor.cpp:1866)
   by 0x184C999F: CppEditor::Internal::CPPEditorWidget::keyPressEvent(QKeyEvent*) (cppeditor.cpp:1416)

This conflicts with a previous read of size 4 by thread #18
Locks held: none
   at 0x680BC54: QTextDocument::revision() const
   by 0x159047F3: CppTools::CppEditorSupport::editorRevision() const (cpptoolseditorsupport.cpp:198)
   by 0x158E39BF: CppTools::Internal::CppModelManager::buildWorkingCopyList() (cppmodelmanager.cpp:525)
   by 0x158E3D5B: CppTools::Internal::CppModelManager::workingCopy() const (cppmodelmanager.cpp:544)
   by 0x1589FF6F: CppTools::Internal::CppCompletionAssistInterface::getCppSpecifics() const (cppcompletionassist.cpp:1957)
   by 0x158A1158: CppTools::Internal::CppCompletionAssistInterface::snapshot() const (cppcompletionassist.h:200)
   by 0x1589707C: CppTools::Internal::CppCompletionAssistProcessor::startCompletionInternal(QString, unsigned int, unsigned int, QString const&, int) (cppcompletionassist.cpp:1212)
   by 0x15893CC7: CppTools::Internal::CppCompletionAssistProcessor::startCompletionHelper() (cppcompletionassist.cpp:970)

---

Possible data race during write of size 4 at 0x24C8AD18 by thread #1
Locks held: none
   at 0x684AF23: QTextCursor::beginEditBlock()
   by 0x139D7D05: TextEditor::BaseTextEditorWidget::keyPressEvent(QKeyEvent*) (basetexteditor.cpp:1578)
   by 0x184C999F: CppEditor::Internal::CPPEditorWidget::keyPressEvent(QKeyEvent*) (cppeditor.cpp:1416)
   ...
   by 0x40F15A: main (main.cpp:533)

This conflicts with a previous read of size 4 by thread #11
Locks held: none
   at 0x680BC54: QTextDocument::revision() const
   by 0x159048D3: CppTools::CppEditorSupport::editorRevision() const (cpptoolseditorsupport.cpp:198)
   by 0x158E3A9F: CppTools::Internal::CppModelManager::buildWorkingCopyList() (cppmodelmanager.cpp:525)
   by 0x158E3E3B: CppTools::Internal::CppModelManager::workingCopy() const (cppmodelmanager.cpp:544)
   by 0x1590741E: parse(QFutureInterface<void>&, QSharedPointer<CppTools::SnapshotUpdater>) (cpptoolseditorsupport.cpp:299)

Task-number: QTCREATORBUG-12030
Change-Id: Idf0aa47f1f6bfd6814a961fe39d3b19b98f934f5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-04-14 10:29:57 +02:00
Nikolai Kosjar
291b80cb33 CppTools: Remove invalid optimization for highlighting
The optimization in question could lead to an empty source and thus to
no highlighting. Checking for 'force' and the revisions is at this point
not enough since later the semantic info calculcation can be aborted, so
that a subsequent recalculation would get an empty document.

contents() itself is already optimized (uses caching).

Task-number: QTCREATORBUG-11367
Change-Id: If31a8ab0c848e4babd38104961fb9812f077a2be
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-04-14 10:28:37 +02:00
Nikolai Kosjar
e7904caf0b CppTools: Do not wait in GUI thread for the parsed document
...when collecting data for the semantic highlighting recalculation.

Task-number: QTCREATORBUG-11037

Change-Id: Ibed73a2916df0a91aedef166de2c8c6bb5df309c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-04-14 10:27:53 +02:00
Nikolai Kosjar
ec13e65d95 CppTools: Avoid using old incomplete semantic info document
Task-number: QTCREATORBUG-11367
Change-Id: I8b02c30a43a57c547bc07d796f4b29725beca793
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-04-11 16:22:47 +02:00
Nikolai Kosjar
697ec70037 Revert "C++: nested class with enclosing template class"
This reverts commit 5d76b4339a since it
might lead to an infinite loop.

Task-number: QTCREATORBUG-11999
Change-Id: I12c7f3afc4aa53a83ddc2bf2d33eb76c29b747ee
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2014-04-09 17:32:04 +02:00
Eike Ziller
b687658663 Merge remote-tracking branch 'origin/3.1'
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/plugins/cpptools/cppcompletion_test.cpp

Change-Id: Ic5e75b3ef164de664a1449ffa8579beaf5b02521
2014-04-08 11:18:40 +02:00
Nikolai Kosjar
5506919233 CppTools/Editor: Make sure test code is free of diagnostic messages
...where applicable.

Change-Id: Ie42e1012598adf124e5f66b6a53eda01724dfb71
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2014-04-04 16:07:19 +02:00
Przemyslaw Gorszkowski
5d76b4339a C++: nested class with enclosing template class
The parent of instantiation of nested class of template class
should be the instantiation of enclosing template class.

Task-number: QTCREATORBUG-11752
Change-Id: I8875c738848b85731f5ea88a60da190b4b0ad18f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-04-04 12:11:19 +02:00
Przemyslaw Gorszkowski
faca3333b5 C++: fix typedef resolving
Fix a case:
struct A
{
  int a;
};

typedef A B;
typedef B* Bptr;
Bptr b;
b->

Task-number: QTCREATORBUG-10021
Change-Id: Ibf5ca801dbdb72744416924c0b8fc03daad5948a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-04-04 12:11:02 +02:00
Nikolai Kosjar
4409873281 CppTools: Fix tooltip for 'Add leading asterisks'
Task-number: QTCREATORBUG-11748
Change-Id: I4d773528bd749510041d71411cf125879cfd3080
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
2014-04-03 14:33:10 +02:00
Eike Ziller
cab8e4aa03 Merge remote-tracking branch 'origin/3.1'
Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/plugins/qtsupport/qtversionmanager.cpp
	src/shared/qbs

Change-Id: If7a93fb018799fe6ada76e79c24ab5b43dfa6fc2
2014-04-02 13:24:34 +02:00
Orgad Shaneh
530332c255 CppTools: Replace Method with Function
Change-Id: I6405c4dfa07eba1ea09ba23fe20667769eaca748
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-03-31 19:59:39 +02:00
Orgad Shaneh
aeb2cfbc4f CppTools: Fix indentation for concatenated strings
Change-Id: I801a56804e7873be75a9ebc085dc3f4a2d64ea35
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-03-31 18:18:42 +02:00
Nikolai Kosjar
00c0fcf353 CppTools: Resolve absolute files in working copy always successfully
...since we can always provide the contents for such files.

This fixes the soft assert

    SOFT ASSERT: "document()" in file
	src/plugins/cpptools/cppsnapshotupdater.cpp, line 199

that occurs if you Follow Symbol on an include directive of the type
"ui_*.h" file that is not yet generated on disk.

Change-Id: I1e40db95a648a0570c6ccbcf5475691094097e18
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-27 15:41:15 +01:00
Nikolai Kosjar
5e7a27dbe7 CppTools: Fix highlighting of ui_*.h files
Editor revisions start with 1, not 0.

There are some more problems in that area which are not addressed by
this patch. E.g. the synchronization of the AbstractEditorSupport
revision and the QTextDocument revision.

Task-number: QTCREATORBUG-11774
Change-Id: I4b0f41b2436ecedcd10dc0e3e39e5f185f990e05
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-27 15:04:40 +01:00
Christian Kandeler
080bd0df07 CppTools: Fix qbs build.
Change-Id: Iaf68f0c9b491454faebd7a232189152d97064c42
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-03-27 09:49:45 +01:00
Nikolai Kosjar
fd5de10f2f CppTools: Encode more information in log file of CppCodeModelInspector
Among others the timestamp and if provided, some extra id.

Change-Id: I017c2af197023347c88f2547e7bda8f22b3d00c4
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-26 15:57:58 +01:00
Nikolai Kosjar
b5f8309610 CppTools: Use CppCodeModelInspector::Dumper
...if dumping from updateProjectInfo().

Change-Id: I0db5f29605e5cae30e339f246fe2b67e5949fb2d
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-26 15:57:48 +01:00
Nikolai Kosjar
4b99d218d5 CppEditor: Dump also merged entities if invoking CppCodeModelInspector
Change-Id: I6a167b47363fb14452bd8ba3dc9d4242d17c25b6
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-26 15:57:41 +01:00
Nikolai Kosjar
25be7e087d CppEditor: Extract CodeModelInspector::Dumper
Change-Id: I58acfb2d049dd4239a3f41b0a5795bfaab7b4f2f
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-26 15:57:27 +01:00
Nikolai Kosjar
0d84603c41 CodeModel(s): Unify name/values of accessed environment variables
Format: QTC_*=(1|0).

Now it's easier to change them in the Run Configuration of Qt Creator.

Change-Id: Ifc45cecb89b33a31942b4c3e2d03851a1d72d0bf
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-26 15:57:21 +01:00
Przemyslaw Gorszkowski
6bf75acac7 C++: fix support for nested anonymous class
The case when anonymous class is inside function. Fixed:
* highlighting
* completion

Task-number: QTCREATORBUG-11711
Change-Id: Ic8fc5fdfb1aed62a74bf148ab7ed449d08214dda
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-03-26 09:56:54 +01:00