Commit Graph

2583 Commits

Author SHA1 Message Date
Nikolai Kosjar
5c8df5fa4e CppEditor/CppTools: Introduce Test{Case,Document}
Move common functionality of the 12 test classes into base classes.

Change-Id: If64d3cec876807ac6f991151189860a99b8ff4ca
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2014-01-07 14:19:13 +01:00
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
Erik Verbruggen
18ac68adb3 C++: add header chooser to codemodel settings page.
Change-Id: I2da9c4b382afcad2faad1817af266381a2f02b2a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2014-01-07 09:29:20 +01:00
Eike Ziller
5cf0fabb3b Fix missing completion options page
Task-number: QTCREATORBUG-11154

Change-Id: Ib763675e4b00408e2840eb3a672560ffdc8f99d4
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2014-01-07 08:40:19 +01:00
Orgad Shaneh
0ce3f3e68c C++: Ignore return type on function overrides comparison
Change-Id: I9933e1cc1fb996181e818e2ea0aff76f9255f849
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-28 22:02:01 +01:00
Orgad Shaneh
a625d9656c CppTools: Add completion tests for enums inside class/namespace
Change-Id: If088533d0b51d1750e3273d7ab732dffd110ec85
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-28 20:35:07 +01:00
Orgad Shaneh
f7e6c40094 CppTools: Uncomment a test and fix it
The bug was fixed long time ago, the test is missing a semicolon

Change-Id: I0236048d2da059fe208591469fb69541705463cf
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-28 19:17:58 +01:00
Orgad Shaneh
ed13ba2d0c CppTools: Replace comma with dot for test names
Comma is used to separate tests on command-line

Change-Id: I785d2137d54b0e1e4edbbd940042dc926719dcfc
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-28 19:17:52 +01:00
Orgad Shaneh
90265b7696 CppTools: Fix indentation for some completion tests
Change-Id: I9a5bf4705da5ca88776dec70057da2c64e4c1494
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 13:46:59 +01:00
Orgad Shaneh
0909c0295f CppTools: Make completion tests data-driven
Mostly done using the following Ruby script:

Fname = 'src/plugins/cpptools/cppcompletion_test.cpp'
s = File.read(Fname)
mod = s.gsub(/(?<declaration>void CppToolsPlugin::test_(?<test_name>[^(]+)\(\)\n\{)(?<body>.*?\n)\}/m) { |func|
  match = $~
  declaration = match['declaration']
  body = match['body']
  test_name = match['test_name'].sub('_data', '')
  final = body.gsub(/(?:completions.clear\(\);\s+)?(?: +)[^\n]* =\n(?<code>.*?);\s*(?<completions>(?:completions.append\(QLatin1String\("[^"]*"\)\);\s*)*)QTest::newRow\("case: (?<name>.+?)"\)\s*<< code << _\("(?<prefix>[^"]+)"\) << completions;/m) {
    m = $~
    res = "    QTest::newRow(\"#{test_name}: #{m['name']}\") << _(\n#{m['code'].rstrip}\n        ) << _(\"#{m['prefix']}\") << (QStringList()"
    m['completions'].scan(/completions.append\((.+)\);/) { |comp|
      res << "\n            << #{comp[0]}"
    }
    res + ');'
  }.gsub(/(?: +)[^\n]* =\n(?<code>.*?);\n\s*CompletionTestCase test\(.+?, "(?<prefix>.+?)"\);\s*QStringList expected;\s*(?<completions>(?:expected.append\(QLatin1String\("[^"]*"\)\);\s*)*)const QStringList completions = test.getCompletions\(\);\s*QCOMPARE\(completions, expected\);/m) {
    m = $~
    res = "    QTest::newRow(\"#{test_name}\") << _(\n#{m['code'].rstrip}\n        ) << _(\"#{m['prefix']}\") << (QStringList()"
    m['completions'].scan(/expected.append\((.+)\);/) { |comp|
      res << "\n            << #{comp[0]}"
    }
    res + ');'
  }.gsub(/(?: +)[^\n]* =\n(?<code>.*?);\n\s*CompletionTestCase test\(.+?(?:, (?<prefix>".+?"))?\);\s*(?:const )?QStringList completions = test.getCompletions\(\);\s*QCOMPARE\(completions.size\(\), \d+\);(?<completions>(?:\s*QVERIFY\(completions.contains\([^\n]+\);)*)\n/m) { |mm|
    m = $~
    res = "    QTest::newRow(\"#{test_name}\") << _(\n#{m['code'].rstrip}\n        ) << _(#{m['prefix']}) << (QStringList()"
    m['completions'].scan(/QVERIFY\(completions.contains\((.+?)\)\);/) { |comp|
      res << "\n            << #{comp[0]}"
    }
    res + ");\n"
  }.gsub(/(?: +)[^\n]* =\n(?<code>.*?);\n\s*CompletionTestCase test\(.+?(?:, (?<prefix>".+?"))?\);\s*bool replaceAccessOperator = false;\s*const QStringList completions = test.getCompletions\(\&replaceAccessOperator\);\s*QCOMPARE\(completions.size\(\), \d+\);(?<completions>(?:\s*QVERIFY\(completions.contains\([^\n]+\);)*)\s*QVERIFY\((?<replace>!?)[^)]*\);\n/m) { |mm|
    m = $~
    res = "    QTest::newRow(\"#{test_name}\") << _(\n#{m['code'].rstrip}\n        ) << _(#{m['prefix']}) << (QStringList()"
    m['completions'].scan(/QVERIFY\(completions.contains\((.+?)\)\);/) { |comp|
      res << "\n            << #{comp[0]}"
    }
    res + ")\n        << #{m['replace'].empty?};\n"
  }
  if final == body or final['QTest::addColumn']
    declaration + final + "}"
  else
    final
  end
}.gsub(/QTest::newRow\("([^"]+)"/) { |m|
  name = $1
  if name.size > 73
    space = name[0..73].rindex(/[ _]/)
    "QTest::newRow(\"#{name[0..space]}\"\n                  \"#{name[space+1..-1]}\""
  else
    m
  end
}.gsub(/\s+QTest::newRow/, "\n\n    QTest::newRow")
if mod != s
    File.open(Fname, 'wt').write(mod)
end

Change-Id: Id6bfb03cdf31ac27b36028fcdc861c340a5398f4
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 13:46:49 +01:00
Orgad Shaneh
ed2d98577a CppTools: Reorder completion tests
For reasonable diff on following commit

Change-Id: I97e121355279f9166cea2f500cf2d4df5fafaa32
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 13:41:52 +01:00
Orgad Shaneh
f53598a1ae CppTools: Braces cleanup in CppCompletionAssistant
Change-Id: I3dea8a8bdd4ae71b48926ec3332ef00cf5ad4303
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 13:41:35 +01:00
Orgad Shaneh
be31d8d08f CppTools: Minor optimization in CppCompletionAssistant
Change-Id: Ieb452713e9e09fce107520c4fd2a401007802e89
Reviewed-by: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 13:41:26 +01:00
Orgad Shaneh
b0c3a6bad8 CppTools: Generalize data-driven test_completion
Change-Id: I409a00b869a95dff2d69c9744da75c324c82776a
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 13:25:51 +01:00
Orgad Shaneh
0204f56628 CppTools: Cleanup completion tests #2
Change-Id: I3c5f42de464a5607f1caa6a48d881c5a4a113ec3
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 13:20:27 +01:00
Orgad Shaneh
7356987c41 CppTools: Remove superfluous comments from completion tests
Change-Id: I2526daeaf54f7f8d4b808cf556cff9242adaa391
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 12:51:38 +01:00
Orgad Shaneh
5713b85cb0 CppTools: Refix MSVC compilation
SemanticInfo has moved from CppEditor to CppTools and is now exported,
so this workaround is no longer needed (and it breaks linkage)

Change-Id: Ic9ba017bcb06be85fdccef27e63091415494bb21
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 12:00:34 +01:00
Orgad Shaneh
d3c606c001 CppTools: Fix MSVC compilation
Change-Id: I7b3c52a6eb70a0e2d7f2785fac71cb3ac68769d8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-23 09:25:02 +01:00
Erik Verbruggen
5beb74fd9d Add experimental clang code-model plug-in.
Previously known as the wip/clang branch.

Contributors (in alphabetical order):
- Christian Kamm <christian.d.kamm@nokia.com>
- Erik Verbruggen <erik.verbruggen@digia.com>
- Leandro Melo <leandro.melo@nokia.com>
- Peter Kuemmel <syntheticpp@gmx.net>
- Sergey Shambir <sergey.shambir.auto@gmail.com>

Change-Id: I4c3ff600a19b6732641c1d5ef28236bf2cc17737
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-12-20 17:05:09 +01:00
Eike Ziller
1adab4c4cc Merge BaseTextEditorWidget::editorDocument() and ::baseTextDocument()
Doesn't really make sense to have the additional IDocument *editorDocument()
method.

Change-Id: I0a7420eb1afaa76f63c3f7e9c4b373acf624ffb9
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-12-18 11:34:34 +01:00
Eike Ziller
e035ae6df1 Merge remote-tracking branch 'origin/3.0'
Conflicts:
	share/qtcreator/debugger/stdtypes.py
	src/plugins/qmlprofiler/qmlprofilereventsmodelproxy.cpp

Change-Id: I5d86746d58960e41e01e725ccb2a6c00890f0dfd
2013-12-18 11:02:16 +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
Nikolai Kosjar
a8e7b6bd38 CppEditor: Use the project part chosen with CppPreProcessorDialog
...otherwise the CppPreProcessorDialog is only semi-useful.

Change-Id: I6b80967b05e7c9a51cd78ae064a3d78170948e32
Reviewed-by: David Schulz <david.schulz@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-12-16 10:32:26 +01:00
Thiago Macieira
a60b89bff4 Remove trailing comma in an enum
qmljsconstants.h(53): warning #271: trailing comma is nonstandard
[and many more]

Change-Id: I2224b7fe6ae1954b27d2b2bfebd469e1ca472f7b
Reviewed-by: Kurt Pattyn <pattyn.kurt@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-12-12 10:17:22 +01:00
Nikolai Kosjar
9b41023b68 CppEditor/CppTools: Tests: Fix potential race condition
...when updating the code model.

Change-Id: Ifc55b7d0bb795b9cfd72465990991bc2cc907846
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-12-12 10:14:50 +01:00
Nikolai Kosjar
7f829b26e5 Clean up {classview,cppeditor,cpptools}.{pro,qbs}
Mostly reordering files alphabetically.

Change-Id: Ibad1fa75559218fe488d1b31c7200ba4ff6131fe
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-12-11 11:46:42 +01:00
Nikolai Kosjar
273192759b CppEditor/CppTools: Move FunctionHelper to CppTools
...and rename it to FunctionUtils.

Change-Id: If076ec01fd82e8ba728764bdeab7e87e8bc1ff3b
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-12-11 11:46:33 +01:00
Erik Verbruggen
d20dd06abb C++: remove superfluous forward defines.
Change-Id: I962e0fbafdb2281645b98779a421d1084d223570
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-10 16:03:54 +01:00
Nikolai Kosjar
e6b41d7e2f CppEditor: Use TypeHierarchyBuilder in FunctionHelper::overrides
...instead going the way over CppClass. This makes
FunctionHelper::overrides independent of the cppeditor plugin.

Change-Id: Ifaedb94da1f67b3876e06cce9e745aaf3c1050a7
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-12-10 15:07:34 +01:00
Eike Ziller
deb43b4c8a Preferences: Add default implementation for filtering
The default "matches" method now takes the widget and looks for all
child labels, checkboxes, push buttons and group boxes.
Because of that, the former "createWidget" method
can be called multiple times without creating a new widget
(-->widget()), and the "finished" method must ensure that the created
widget gets deleted, since not all widgets that were created are added
to the UI anymore.

Change-Id: Ia231c7c78dd8819146668e6447d36d22e7836904
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
2013-12-10 13:31:48 +01:00
Erik Verbruggen
ea1a92484a C++: split defines into project-defined and toolchain-defined.
So we can ignore possibly problematic toolchain-defines, while can still
unconditionally apply project-defines.

Change-Id: I7cb96f35a963d080011fe888ef71bfc098dd33ef
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-12-10 11:42:41 +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
jkobus
90b33316e4 Fix tooltips' texts.
Change-Id: I9f8681a8d975558e5e8626566df73ac8438c4cef
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
2013-12-04 15:36:58 +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
Eike Ziller
920d524d38 Merge remote-tracking branch 'origin/3.0' 2013-12-03 12:46:39 +01:00
Nikolai Kosjar
796fcaf1d2 Revert "C++: Fix highlighting for lines with predefined macros"
This takes too much memory. For qtcreator.pro the numbers are as
follows:

    Patch applied:  ~ 1600MB (RES)
    Patch reverted: ~  510MB (RES)

This reverts commit 4c2daa90ce.

Task-number: QTCREATORBUG-10973
Change-Id: I843bd7c1ea4a26a1ec55ddc14c2a34a98d040922
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Robert Loehning <robert.loehning@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-12-03 09:53:26 +01:00
Tobias Hunger
95306dbf65 CppTools: Add history completer to path choosers
Change-Id: Iaedd5eb2890d19761c342d248e600b50e43be979
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
2013-12-02 14:40:40 +01:00
Eike Ziller
f7397224ea Merge remote-tracking branch 'origin/3.0' 2013-11-29 16:36:13 +01:00
Nikolai Kosjar
4c2daa90ce C++: Fix highlighting for lines with predefined macros
This adds definitions for the macros __FILE__, __LINE__, __DATE__ and
__TIME__ on demand.

As a side effect, this also introduces highlighting for the uses of
these macros.

Task-number: QTCREATORBUG-8036
Change-Id: Ib7546c7d45d2eecbc50c7883fc684e3497154405
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: hjk <hjk121@nokiamail.com>
2013-11-29 15:11:27 +01:00
Eike Ziller
baf190ff4a Merge remote-tracking branch 'origin/3.0' 2013-11-27 12:18:12 +01:00
Nikolai Kosjar
51d91a6075 CppTools: Add revisions to AbstractEditorSupport
So far revisions for AbstractEditorSupport were not needed because until
recently we only had a single snapshot ("global snapshot"). Now, since
editor snapshots are introduced, we need to make sure to update the
corresponding documents in these snapshots, too. To do this efficiently,
a revision is introduced for AbstractEditorSupport.

Task-number: QTCREATORBUG-10894

Change-Id: Ibad1dbbafb7c721d1328959c1e903345fe465326
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-11-25 17:40:30 +01:00
Eike Ziller
5e2e0e469b Merge remote-tracking branch 'origin/3.0'
Conflicts:
	qtcreator.pri
	qtcreator.qbs

Change-Id: I0485b1bf75cc02f9fbcb5c05e350da91f491abe3
2013-11-25 08:57:10 +01:00
Przemyslaw Gorszkowski
4836fa0106 C++: fix auto completion for member of classes accessed by using
Example:
namespace NS { struct S { int member; void fun(); }; }
using NS::S;
void S::fun()
{
mem// ctrl+space
}

Task-number: QTCREATORBUG-9037
Change-Id: I5a568be1b5c44deb02caa04996167a88a9c5d4d7
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
2013-11-22 16:12:53 +01:00
Eike Ziller
559e66cb35 Merge remote-tracking branch 'origin/3.0' 2013-11-22 09:11:51 +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
Eike Ziller
f61e643c95 Merge remote-tracking branch 'origin/3.0' 2013-11-20 11:25:36 +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
Eike Ziller
8fe04ce0ad Merge remote-tracking branch 'origin/3.0' 2013-11-19 07:41:47 +01:00
Nikolai Kosjar
c1225ea3f4 CppTools: Use editor manager's codec as fallback
...for reading not already opened files.

This partly reverts commit f7c68f6. In case TextFileFormat::detect()
fails, the user configurable editor manager's codec is used instead of
QTextCodec::codecForLocale().

Adds also a qWarning() to easier detect encoding errors.

Task-number: QTCREATORBUG-10378

Change-Id: I0fa4e6b898ed090d85414ce2a001f11b115a42d3
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
2013-11-18 13:03:08 +01:00
Eike Ziller
4538ccb46c Merge remote-tracking branch 'origin/3.0'
Conflicts:
	share/qtcreator/debugger/gdbbridge.py

Change-Id: I32d8158c475f927b50ef06fde9ab8189ebdbcbbc
2013-11-15 10:26:57 +01:00