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>
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>
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>
...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>
...so we can rehighlight if it's requested by the editor. This is e.g.
necessary if the font size changes.
Task-number: QTCREATORBUG-11502
Change-Id: I608921899fc37fcf1394db9ff041e6b378196bdd
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
...in order to be able to full-rehighlight on the next turn.
The following sequence was problematic:
1. recalculateSemanticInfoDetached(true)
* e.g. triggered by opening the document
2. recalculateSemanticInfoDetached(false)
* e.g. triggered by moving the cursor
* cancels 1. and leads to incompletely parsed/checked document - OK
3. startHighlighting()
* triggered by 1.; starts highlighting on incomplete document - OK
4. startHighlighting()
* gets a completely parsed/checked document - OK
* not forced, so just compare revisions; they are the same, so
skip/return - a partly highlighted document is left behind.
Task-number: QTCREATORBUG-11367
Change-Id: Ic56e00e862ec4a1ffa197b2fc8b48be56a3562de
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
e.g. changing cursor position or editing text.
CPPEditorWidget::updateUses() does not depend on the highlighter, but
only on the semantic info update.
Task-number: QTCREATORBUG-11367
Change-Id: Ia9f5ed7c2adc6899995a5d966a20e45b2f87d9e3
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
As the name function name suggests, true should be returned if the
declaration should be processed. Otherwise false.
Change-Id: I8d266d99c579b331fee8772bde47aa1a466dae9c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
In case the editor is hidden before semantic highlighting started
(because semantic parsing hasn't finished yet).
Just disable the logic that tries to optimize that for now, since it is
not working, and fixing it will require more work (that's done later
anyhow).
Task-number: QTCREATORBUG-11367
Change-Id: I7ef3cc558e514968f90d2ea56b2df362606d879a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
For some reason it doesn't like signals with QFutures. Going back to
pointers, but copying the future from there when it's used.
Change-Id: I8dea0817b4e59ede6874ab8be01f22a92e7402a0
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
The CPPEditorWidget retained two futures, as did the attached future
watchers retained them too. Together, each future and the watcher held
on to a complete snapshot that would only get released when another
future was set. This could result into retaining old snapshots in
editors that were invisible/unused for long.
Change-Id: I1133e857c620437b4a69b9dad468f6bd458304b8
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
The m_snapshotUpdater may never be accessed directly.
Change-Id: Id773a291f66e93a48ae46f2b1c04417af2f26763
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
To differentiate it from the byte array based IDocument::setContents
Change-Id: Icc9600732c2742fb79254a0697870bacce3a59ee
Reviewed-by: David Schulz <david.schulz@digia.com>
Possible when the highlighter does not need semantic info to run, and is
started through onDocumentUpdated() and updateDocumentNow().
Change-Id: I720299730213ac196143a273fb60cee8e43111f1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
We need to wait for the document parser, otherwise the CppModelManager
object might get destroyed first and will be referenced later in
CppEditorSupport::parse().
Change-Id: I1b591640c1da3e63e49ac0b4b8af41aae31b3d43
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
If parse() is called in another thread the CppToolsEditorSupport might be
already destructed.
Task-number: QTCREATORBUG-10548
Change-Id: Ie4215937eb1847b51bce8b080aca4925c0bee39f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Since commit 566be09 we might reparse the current document if the
current editor changes. This is fine as long as the current document has
a file path, which is not always true, especially for the documents
created in the FakeVim tests.
Task-number: QTCREATORBUG-10767
Change-Id: Ibe00ef8bb6a144e2ba09b311025d238c2dcde112
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
The document was not always updated in time.
Change-Id: Iac89985d39a8784e3cbf63dfd42b1c5150775068
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
- 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>
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>
On duplication of an editor onMimeTypeChanged() of CppToolsEditorSupport
was not triggered, thus not completion provider was set.
Task-number: QTCREATORBUG-10284
Change-Id: Ia1da7f59b19e042f65b068a993f0d5c04b0778e0
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
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>
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>
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>
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>
That is what it actually is, wrt how Qt API calls it.
Change-Id: Ied02055debf6aad75556b0d9d22e8ba2f72be555
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
When a reloading operation was in progress, CppEditorSupport::contents()
could return a partly reloaded file to the code model leading to parse
errors and incomplete highlighting.
Fixed by checking if the file is currently being reloaded.
Task-number: QTCREATORBUG-9382
Change-Id: Iee97e10444763c0cbf481132afa4617c5cdbd15c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
For a new split/editor no CppHighlightingSupport was set since
onMimeTypeChanged was not called.
Now the CppHighlightingSupport is set again in the constructor. This
reverts partly
commit 033ad887
C++: handle file type changes for choosing highlighters
Task-number: QTCREATORBUG-9382
Change-Id: Ie79d357d570bec4920366fbd56fb67859be9b37a
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
If the file type (mime type) of an editor changes, it might need a
different kind of highlighter/highlighting-support.
Change-Id: I470dbf69e71856c9593d201416c4d4bd2958aaec
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
If Creator switched to the Project mode on startup, the highlighting was
not started because the editor widget was not visible. Now we check if
the editor itself is or would be visible in the edit mode, which is
indepedent of the current mode.
Task-number: QTCREATORBUG-9260
Change-Id: I72373e09965fd1cded034ae4711df48798e7f0d8
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Now recalculateSemanticInfoNow is called only once instead of three
times when a new editor is opened/created.
Change-Id: Ife84fc9ca90cdbf2a417123e6a2b9e1e068dfdc4
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Case: Opening a file that is not yet in the Snapshot
recalculateSemanticInfoNow() emitted the same SemanticInfo until the
indexer processed the document (Snapshot::contains()). That signal
caused CppEditorWidget::updateSemanticInfo() to call
semanticRehighlight() because of unequal revisions. That triggered
recalculateSemanticInfo() again.
Change-Id: I8fb7d7c42aad3d6a89876e743cd4e3c7aff643bf
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>