Commit Graph

88 Commits

Author SHA1 Message Date
Eike Ziller
5aa8a63f90 CppEditor: Fix potential crash
The m_snapshotUpdater may never be accessed directly.

Change-Id: Id773a291f66e93a48ae46f2b1c04417af2f26763
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-01-07 12:22:30 +01:00
Friedemann Kleint
dc6b28366c Avoid value-list creation when iterating over maps.
Change-Id: I704ba93d01ffababb405bc801f07a845631930cc
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
2013-12-16 16:03:16 +01:00
Eike Ziller
890f72160c Rename QString ITextEditorDocument::contents --> plainText
To differentiate it from the byte array based IDocument::setContents

Change-Id: Icc9600732c2742fb79254a0697870bacce3a59ee
Reviewed-by: David Schulz <david.schulz@digia.com>
2013-12-10 09:11:30 +01:00
Erik Verbruggen
af2900ce72 C++: prevent possibly highlighting a document twice
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>
2013-12-04 10:40:02 +01:00
Nikolai Kosjar
067ae2439b CppTools: Fix crash on shutdown
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>
2013-11-20 11:30:12 +01:00
Nikolai Kosjar
3b5e84e650 CppTools: Fix race condition when closing files
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>
2013-11-19 13:12:00 +01:00
Nikolai Kosjar
d8077db3fb CppTools: Fix crash for documents without file paths
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>
2013-11-14 11:21:26 +01:00
Nikolai Kosjar
36ce1dbb84 Designer/CppTools: Fix flaky test_gotoslot_withoutProject
The document was not always updated in time.

Change-Id: Iac89985d39a8784e3cbf63dfd42b1c5150775068
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
2013-11-14 08:34:45 +01:00
Erik Verbruggen
566be0995d C++: Release more documents.
- 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>
2013-11-12 09:24:13 +01:00
Nikolai Kosjar
b8dbac0b9c Rename "[Mm]ethod(s)" to "[Ff]unction(s)"
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>
2013-10-10 15:56:12 +02:00
Nikolai Kosjar
cd4c4218e4 CppTools: Fix completion in other editor
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>
2013-10-02 12:13:31 +02:00
Erik Verbruggen
507452f097 CppTools: honor pre-compiled headers in the code-model.
Task-number: QTCREATORBUG-476

Change-Id: I82ed92acdcda551d2c6a9ca221832ac20117a08f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-10-01 13:02:45 +02:00
Orgad Shaneh
e4f762deec Fix compilation with Qt4
Change-Id: I486198c9d7e27159445411c38037d315b90cd67a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-10-01 12:40:15 +02:00
Erik Verbruggen
ba2d7a4fa7 C++: Only parse with appropriate defines for open editors.
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>
2013-10-01 10:33:51 +02:00
Nikolai Kosjar
87e793d089 CppTools: Initialize pointer to 0
Change-Id: I55ec2d98b5fe72936ae7073e211fc6297334daba
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com>
2013-09-11 15:47:49 +02:00
Erik Verbruggen
f7c68f6baf C++: change working-copy to work on UTF-8 encoded QByteArrays.
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>
2013-09-11 09:43:14 +02:00
Erik Verbruggen
b4a1bd415f C++: clean-up CppCompletionAssist.
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>
2013-09-09 11:59:14 +02:00
Erik Verbruggen
7516ef4969 TextEditor: get CompletionAssistProvider from editor.
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>
2013-09-09 10:15:55 +02:00
hjk
4a24df38a3 EditorManager: Use static pattern, adjust surrounding code
Change-Id: I3255a0150cd9a730336456c5a9f986eb74fefbff
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-08-30 11:22:56 +02:00
Erik Verbruggen
073e5d6632 C++: optionally let the highlighter handle ifdefed-out blocks.
Change-Id: I38cc0e55348cac0245d2ab8f3e39c68de76e3e6d
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-08-19 13:01:07 +02:00
Nikolai Kosjar
e2ce17ef00 CppTools: Fix "! condition" coding style
Change-Id: Ic7e634e4249fb64edbc2daceb65ec8e9b5f0f8b9
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
2013-07-25 13:11:34 +02:00
Orgad Shaneh
ad9e7ccab6 Fix coding style for else statements
Change-Id: I1309db70e98d678e150388c76ce665e988fdf081
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-07-17 11:11:25 +02:00
Eike Ziller
dd43d9908f Rename IDocument::fileName --> filePath
That is what it actually is, wrt how Qt API calls it.

Change-Id: Ied02055debf6aad75556b0d9d22e8ba2f72be555
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-07-09 13:51:42 +02:00
Nikolai Kosjar
6df66e883f CppTools: Do not hand over partly reloaded files to the code model
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>
2013-06-24 11:13:35 +02:00
Nikolai Kosjar
5cb22e5021 CppEditor: Fix highlighting in new split if file is changed externally
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>
2013-06-17 10:36:39 +02:00
Erik Verbruggen
033ad8875b C++: handle file type changes for choosing highlighters.
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>
2013-05-15 15:05:58 +02:00
Nikolai Kosjar
934cea560d CppEditor: Fix crash when closing editors fast
Task-number: QTCREATORBUG-9250

Change-Id: I15bcaf5d0e55c7e3cc731755fc48df2d1181f3da
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-05-08 10:29:10 +02:00
Nikolai Kosjar
5b30509a99 CppEditor: Fix highlighting if there are unconfigured projects
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>
2013-05-07 11:45:59 +02:00
Nikolai Kosjar
cacd66195c CppEditor: Avoid premature calls to recalculateSemanticInfoNow
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>
2013-05-07 11:45:46 +02:00
Nikolai Kosjar
7313203c29 CppEditor: Reduce calls to recalculateSemanticInfo()
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>
2013-05-07 11:43:53 +02:00
Erik Verbruggen
364c95476e C++: fix possible null-pointer derefs.
Change-Id: Ie6a2398f3a9e5c26a9af1578e512da53a01d15f5
Reviewed-by: Sergey Shambir <sergey.shambir.auto@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-05-03 08:41:13 +02:00
Nikolai Kosjar
d47aed5201 CppEditor: Tests: Remove superfluous reference to CppEditorSupport
Also remove the introduced functions in CppEditorSupport. We can just
wait until the document is "Full Checked" via Document::checkmode().

Change-Id: I31d23016f5aa5d3c37e8e05078436ab901bfb2d7
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-05-02 15:50:56 +02:00
Nikolai Kosjar
e6e30c3fd3 CppEditor: Tests: Add initial Follow Symbol Under Cursor tests
Test cases are examples from

    Working Draft, Standard for Programming Language C++
    Document Number: N3242=11-0012

Change-Id: I624c315943d6a00e821abb52eef6e0ff4a40f0d7
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: David Schulz <david.schulz@digia.com>
2013-04-30 15:00:07 +02:00
Orgad Shaneh
a8ff5e8343 Fix link error with MSVC
CppTools.lib(CppTools.dll) : error LNK2005: "public: virtual __thiscall
  QFutureInterface<class TextEditor::HighlightingResult>::~QFutureInterface<class TextEditor::HighlightingResult>(void)"
  (??1?$QFutureInterface@VHighlightingResult@TextEditor@@@@UAE@XZ) already defined in moc_cppeditor.obj
   Creating library ..\..\..\lib\qtcreator\plugins\QtProject\CppEditor.lib and object
   ..\..\..\lib\qtcreator\plugins\QtProject\CppEditor.exp..\..\..\lib\qtcreator\plugins\QtProject\CppEditor.dll :
   fatal error LNK1169: one or more multiply defined symbols found

Change-Id: Id53a0f8a99dbd18a9cbdf2af57b4f3970f5c41a3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-29 08:38:02 +02:00
Erik Verbruggen
0c27b27658 C++ Detach the CppEditor from code-model internals.
- Moved document update handling into CppTools.
- Moved semantic info calculation into CppTools.
- Moved semantic highlighting into CppTools.

Change-Id: I253861bf074a64b1f657f7a4a8e6583871b5285f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-04-26 12:47:06 +02:00
Eike Ziller
b450b3071e TextEditors: Separate away methods that actually work on a document
Introduces ITextEditorDocument. This is part of a more general "use
documents instead of editors whereever possible". It will allow to move
to e.g. ITextEditor::openedTextDocumentContents() instead of
ITextEditor::openedTextEditorsContents().

Change-Id: I5ebceaa257a0d2c3e8ac4ac51b9b08b6faa42487
Reviewed-by: David Schulz <david.schulz@digia.com>
2013-04-19 16:21:30 +02:00
Friedemann Kleint
4b0bafd615 Clean headers in CppTools.
Ran script to remove inludes on a trial-and-error basis and
manually corrected it.

Change-Id: Ic8464ea084ca1ab401e9f4a7d0183b92b4038902
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-04-10 10:55:14 +02:00
Oswald Buddenhagen
7923032022 fix include style relating to cplusplus libraries
... and adjust INCLUDEPATH accordingly.

while i'm at messing with include statements, also re-order the include
blocks according to policy and sort them within bigger blocks.

Change-Id: I7762abfd7c4ecf59432b99db2f424e4fa25733a5
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-04-03 13:40:39 +02:00
Friedemann Kleint
cb08f959b9 Fix Krazy warnings about includes/header guards in Cpp-Editor.
Change-Id: I00a68d7f2b509e3934c3248765a78e9b47749127
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-03-12 16:18:59 +01:00
Oswald Buddenhagen
1fda2111d4 Merge remote-tracking branch 'origin/2.6'
Conflicts:
	src/plugins/autotoolsprojectmanager/AutotoolsProjectManager.pluginspec.in
	src/plugins/debugger/qtmessageloghandler.cpp
	src/plugins/debugger/qtmessagelogwindow.cpp
	src/plugins/madde/maemodeployconfigurationwidget.cpp
	src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp
	src/plugins/qmldesigner/designercore/include/widgetqueryview.h
	src/plugins/qmldesigner/designercore/metainfo/metainfoparser.cpp
	src/plugins/qmldesigner/designercore/model/modelnodecontextmenu.cpp
	src/plugins/qmldesigner/designercore/model/modelnodecontextmenu.h
	src/plugins/qmlprojectmanager/qmlprojectapplicationwizard.cpp
	src/plugins/qnx/bardescriptormagicmatcher.h
	src/plugins/qt4projectmanager/profilekeywords.cpp
	src/plugins/remotelinux/deployablefilesperprofile.cpp
	src/plugins/remotelinux/deployablefilesperprofile.h
	src/plugins/remotelinux/deploymentinfo.cpp
	src/plugins/remotelinux/deploymentsettingsassistant.cpp
	src/plugins/remotelinux/profilesupdatedialog.cpp
	tests/auto/icheckbuild/ichecklib.cpp
	tests/auto/icheckbuild/parsemanager.cpp
	tests/auto/icheckbuild/parsemanager.h

Change-Id: Ie465a578446a089e1c502d1cb1096e84ca058104
2013-01-31 16:25:33 +01:00
Robert Loehning
298531e370 Incremented year in copyright info
Change-Id: Ic6a9ff0359625021ebc061d22db6811814534205
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
2013-01-29 16:27:03 +01:00
Orgad Shaneh
29a93998df Remove braces for single lines of conditions
#!/usr/bin/env ruby

Dir.glob('**/*.cpp') { |file|
  # skip ast (excluding paste, astpath, and canv'ast'imer)
  next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
  s = File.read(file)
  next if s.include?('qlalr')
  orig = s.dup
  s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
    res = $&
    if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
      res
    else
      res.gsub!('} else', 'else')
      res.gsub!(/\n +} *\n/m, "\n")
      res.gsub(/ *{$/, '')
    end
  }
  s.gsub!(/ *$/, '')
  File.open(file, 'wb').write(s) if s != orig
}

Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 10:48:18 +01:00
Orgad Shaneh
be443b8edb CppTools: Compile with QT_NO_CAST_FROM_ASCII
Change-Id: I31a6117c2b4be3f8603c16a9f98b6937a0b9aeb2
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
2012-11-22 09:40:14 +01:00
Erik Verbruggen
9246e78d23 C++: started to make indexing plug-able.
Change-Id: Iff35840d73882a212dd77b54e4223c0b4111ac1c
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2012-10-23 09:26:19 +02:00
hjk
386ca7c8dd Adjust license headers
Change-Id: Ice592c6de9951ee3b2c4cb52ed0bb3b6770e0825
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2012-10-05 17:12:56 +02:00
Eike Ziller
e0e8cf3ada Contact -> qt-project.org
Change-Id: I7134d7de30bcf9f9dcfad42520dd45ee083a852d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
2012-07-19 13:23:21 +02:00
Erik Verbruggen
6fe6f5cdb1 C++: make highlighting/completion plugable.
Change-Id: I990fdf5411153041c6b4c62f31b453342d59de53
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
2012-02-20 14:21:22 +01:00
Eike Ziller
d66acb51d0 Rename IFile->IDocument and FileManager->DocumentManager
And adapt the other API respectively.

Change-Id: I1e04e555409be09242db6890f9e013396f83aeed
Reviewed-by: Bill King <bill.king@nokia.com>
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
2012-02-20 13:32:49 +01:00
Erik Verbruggen
3fa55b7ab9 Removed module names from #include directives.
Getting the #include directives ready for Qt5. This includes the
new-project wizards.

Change-Id: Ia9261f1e8faec06b9285b694d2b7e9a095978d2b
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
2012-02-15 16:24:46 +01:00
Erik Verbruggen
dbc3332b8e C++: Moved completion/highlighting into the model manager.
This way the editor does not need to know all the details of
instantiating or maintaining classes for highlighting and/or completion,
it can just ask the model manager. The change also enables different
highlighting- or completion-engines without changes to the cppeditor.

Change-Id: I8000d9d9fe446b292defddb2295493cf77d0f14a
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
2012-02-08 14:30:14 +01:00