Commit Graph

353 Commits

Author SHA1 Message Date
David Schulz
6b59d711a8 TextEditor: return all BaseTextEditor for a document
Change-Id: Iab483528357fdba1b7107130c19370974c03979c
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-03-13 05:38:00 +00:00
Orgad Shaneh
cbfc6e522d Merge remote-tracking branch 'origin/4.9'
Change-Id: I801042a53ae4d02d1891ea582ca9ea89b00d3181
2019-03-01 13:06:57 +02:00
David Schulz
8a0f7bcfd5 TextEditor: add option to remember highlighter definition
Add a button to the multiple definition found info that saves the
definition of the current highlighter for the open document.

Change-Id: I04b1b7571a864d781747547a1d315ec25bb6b5a1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2019-02-28 07:14:43 +00:00
hjk
6f37348b4c Replace static_casts by QOverload where possible
Mainly to get rid of the QProcess::finished deprecation warning.

Also adjust coding style in the surrounding connects when needed.

Change-Id: I12f9b248c7974b892c4a069356e578e80f8c59e9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-26 15:18:14 +00:00
Eike Ziller
6d43aaf134 Merge remote-tracking branch 'origin/4.9'
Change-Id: I7bdb6a4658c5fca1a7e1dda5adbb5613dabc6d18
2019-02-19 09:08:53 +01:00
Friedemann Kleint
ec6b38dea0 Fix Qt 5.13 deprecation warning about QFontMetrics::width()
Replace by QFontMetrics::horizontalAdvance(), fixing:
warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated:
 Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]

Change-Id: I9991ffefe6e87e872dc35ba291d562e06b28ca64
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2019-02-15 15:12:02 +00:00
Alessandro Portale
88d1d92728 Bump minimum Qt version (to build Qt Creator) to 5.11
Recent adaptations to Qt 5.13's API deprecations require using APIs
which were introduces in Qt 5.11.

Change-Id: I6c077d824c9ce716e019543b290c355a5d512fad
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-15 14:39:12 +00:00
Eike Ziller
2bebfe9985 Help: Add fallback word lookup for context help to base text editor
If we do not have a hover handler, or that did not produce any result,
use the word under cursor and try with that.
This adds at least some help fallback mechanism to all text editors,
e.g. we get some context help (though a bit crude) for Pyside
"for free".

Change-Id: I1b6d91ad6f46bfd12e242b1aec9f4fcadae23403
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-15 14:06:50 +00:00
Christian Stenger
6ae786bcc8 TextEditor: Fix build for Qt5.9
Do not use functions that are not supported with
the minimum supported Qt for building QC.
Partially reverts 963dc84cc5.

Change-Id: Ife03143a7cf5a8f428754040e7004efe42d70a8a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 13:39:21 +00:00
David Schulz
82466375b9 TextEditor: Show info when multiple highlight definitions are available
Show an editor info bar when multiple highlight definitions can be found
for a single file or mime type. Add a combo box to the info that allows
the user to choose between them.

Change-Id: I07278d065e19d4e04fba24a6d789c8b6c9f55d60
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 12:45:04 +00:00
Friedemann Kleint
963dc84cc5 Fix some deprecation warnings in basic plugins
Fix warnings apppearing in 5.13, for example:
warning: ‘QDir& QDir::operator=(const QString&)’ is deprecated: Use QDir::setPath() instead [-Wdeprecated-declarations]
...
warning: ‘static QRgb QColorDialog::getRgba(QRgb, bool*, QWidget*)’ is deprecated: Use getColor() [-Wdeprecated-declarations]
warning: ‘Qt::DropAction QDrag::start(Qt::DropActions)’ is deprecated: Use QDrag::exec() instead [-Wdeprecated-declarations]
warning: ‘void QProcess::finished(int)’ is deprecated: Use QProcess::finished(int, QProcess::ExitStatus) instead [-Wdeprecated-declarations]
...
warning: ‘const QRect QDesktopWidget::availableGeometry(int) const’ is deprecated: Use QGuiApplication::screens() [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::background() const’ is deprecated: Use QPalette::window() instead [-Wdeprecated-declarations]
...
warning: ‘const QBrush& QPalette::foreground() const’ is deprecated: Use QPalette::windowText() instead [-Wdeprecated-declarations]
...
warning: ‘void QTextOption::setTabStop(qreal)’ is deprecated [-Wdeprecated-declarations]
warning: ‘void QList<T>::swap(int, int) [with T = ProjectExplorer::BuildStep*]’ is deprecated: Use QList<T>::swapItemsAt() [-Wdeprecated-declarations]
warning: ‘void QProcess::setReadChannelMode(QProcess::ProcessChannelMode)’ is deprecated: Use QProcess::setProcessChannelMode() instead [-Wdeprecated-declarations]
...
warning: ‘QString QFileInfo::readLink() const’ is deprecated: Use QFileInfo::symLinkTarget() instead [-Wdeprecated-declarations]

Change-Id: I1d893d42d372245892f2de8406f52dbe7bbd552a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-02-11 09:32:06 +00:00
David Schulz
874dde6863 TextEditor: extract initilizing the generic highlighter
Change-Id: Ibdd37aeb761087118dd4974a06d82c0dbe1f1731
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 13:49:00 +00:00
David Schulz
f75934f297 TextEditor: shorten namespace noise
Change-Id: I16bc218ccefb7234cb9c1299ee3022549b178600
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 12:51:27 +00:00
David Schulz
f4a45884ca TextEditor: add convenient definition for document function
Change-Id: I8bbaec71a4682e36d3919924932b410e2e9d74a9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 12:51:19 +00:00
David Schulz
1dd462ac4d TextEditor: update the infobar after setting up the highlighter
removes the need of public function and member carrying the
information whether a highlight definition was found.

Change-Id: I8a0f24c9b376c01246116b502f5bbc06b3c65d21
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 12:51:12 +00:00
David Schulz
bf6dfa0db9 TextEditor: remove senseless function call
updating the info bar only makes sense after trying to set
a generic highlighter, otherwise the member capturing the
information whether a highlight definition for the current
file is available might be uninitialized.

Change-Id: I5cce70ecf1df0ba34f43eeb01743c1fae729cc6b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-02-07 12:51:05 +00:00
Eike Ziller
a0969a3c09 Merge remote-tracking branch 'origin/4.8' into 4.9
Change-Id: I216c7dcbef1e840751332e7a6558c9d633444af3
2019-02-07 10:03:28 +01:00
Eike Ziller
f369556dca Merge remote-tracking branch 'origin/master' into 4.9
Change-Id: I0768e59f13f2fae0bdf13047431de9fac870bf74
2019-02-07 07:43:26 +01:00
Eike Ziller
14f66e0eb5 Fix highlighting of regexp search results in editor
The highlighting in the editor was still done with QRegExp,
so if you used Perl regular expression features, highlighting in
the editor was incorrect.

Fixes: QTCREATORBUG-21940
Change-Id: I785f0b2413a291d9f06de5877b18067a30d58588
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-02-07 06:19:10 +00:00
Christian Kandeler
6ab9078e87 Project tree: Do not pretend to support moving files via Drag & Drop
We claimed to support the move action, so on Windows the user could drag
files away to e.g. the Desktop or the Explorer. This resulted in
inconsistent state, because we do not (cannot?) handle an "external
drop" in any of our build system managers.
Instead, we now support only the copy action, which leaves our project
sources untouched. This is also more likely to be what the user wants.

Fixes: QTCREATORBUG-14494
Change-Id: Ie327780768f1ac68d6dbe95c3daa4aa4dc3f0f41
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2019-02-05 11:30:12 +00:00
Nikolai Kosjar
c5e43d86d1 Clang: Make diagnostic tooltips consistent
Fix that triggering a diagnostic tooltip from the diagnostic
location/range itself (underlined text) did not show the icon on the
left and the actions/toolbuttons on the right in the tooltip.

Instead of showing the tooltip content itself, request the tooltip for
the corresponding text mark to get the extra decoration and actions.

Change-Id: I5e94aca117a761f7a798d4f4b33db6e386e54d84
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2019-02-05 11:22:27 +00:00
Nikolai Kosjar
a5317cdaa5 TextEditor: Polish separator in text mark tooltip
Use one row instead of two for showing "Other annotations" and the
separator line.

Change-Id: I25234fc2fb49ccb71125a1cf762c89b668032b77
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-05 08:44:01 +00:00
Eike Ziller
66226453a1 Merge remote-tracking branch 'origin/4.9'
Change-Id: I873266bc23680ea02aaff6387790f2a834335113
2019-02-05 09:02:01 +01:00
Nikolai Kosjar
107028dd19 TextEditor: Remove duplication when handling textmark tooltips
Change-Id: I1df48c91a6248f3e8a5feb62bbcd7644d765eeab
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-05 07:40:11 +00:00
Eike Ziller
92ddaea43e Help: Make a difference between "empty" and "valid"
Context help should take the HelpItem from the tool tip if it was set,
even if it isn't valid.
Similarly, if the help item was set on the text editor, it should not
ask the hover handlers (again), even if that is invalid

Change-Id: I481f8ad73c3cf8fdbb90f737ab36b4e380467026
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-04 09:20:55 +00:00
Eike Ziller
32429e11c9 Help: Avoid double lookup for help tooltips
Save the HelpItem directly in the tooltip instead of the help ID which
would need to be looked up again.

Change-Id: I107e82e89d9ea26cad9d6532ad4c687d1ac8f1ec
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-01 11:00:55 +00:00
Ivan Donchevskii
1dee275f58 ClangFormat: Add cursor position to the indenter interface
Sometimes it's imnportant where the cursor currently is
to properly format the code without affecting the current line.

Change-Id: I8b1fb11d2303adb5f960c7cb80a0ed2e6e45010f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-01-31 10:25:18 +00:00
Ivan Donchevskii
80fb0178fd ClangFormat: Introduce check to format code instead of indenting
Ctrl+I with the new check will reformat the selected code or
the current line instead.

Change-Id: Ia5a72c4a09621034d0dfe463f669fe1ca36b0b5f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2019-01-31 10:25:05 +00:00
Eike Ziller
282805b66d Rename IContext::HelpIdCallback -> IContext::HelpCallback
It no longer takes an ID but a HelpItem.

Change-Id: I0aa738549fea4fcfd0151adc2dfd642c63f0f60d
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-01-29 07:58:19 +00:00
Eike Ziller
418dcfbcbb Help: Avoid multiple lookups of help id for context help
Context help would first query the database with potential IDs, and
afterwards the help plugin would look up the links for the resulting ID
again.
Pass the HelpItem (which potentially contains the cached links) directly
to context help.

Change-Id: I73bddcd3cd4eacaea412b98d53c5e5354a31f3d5
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-01-29 07:57:19 +00:00
David Schulz
14834e6b0a TextEditor: replace generic highlighter with ksyntaxhighlighting
Fixes: QTCREATORBUG-21029
Change-Id: I9894c4384e0e47da6bf030b7b8e07c3ad4737ff3
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-01-28 11:37:08 +00:00
David Schulz
7b7a2ad630 TextEditor: Use callback in refactoring markers
Allows to trigger actions without adding specific handling into the
editor.

Change-Id: Ia63d65d3feca37bcefca1b6322ade039027a92d8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-01-25 06:13:11 +00:00
Ivan Donchevskii
d7058e1afe ClangFormat: Refactor indenter to allow ClangFormat unit-tests
We do not build texteditor files in unit-tests so some tricks
were required to make ClangFormatIndenter available.

First simple unit-test proofs it builds and runs.

Change-Id: I81d5ea099bd27fd1c1ed8b5b7877299dcc62a67f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-01-22 09:52:15 +00:00
Alessandro Portale
616e19ff9e Fix warning: "Missing emit keyword on signal call"
[-Wclazy-incorrect-emit]

Change-Id: I93bdc6e23cdaccf35c9899ae16870ccc65a54f80
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-01-17 15:54:56 +00:00
Eike Ziller
9084ca73df Merge remote-tracking branch 'origin/4.8'
Conflicts:
	qbs/modules/qtc/qtc.qbs
	qtcreator.pri
	src/plugins/cpptools/compileroptionsbuilder.cpp

Change-Id: I87f47cecbb924064296a002fd9446a0627acad8e
2018-12-12 09:44:13 +01:00
David Schulz
318b83587f TextEditor: fix painting annotations
The painting of annotations for one line will be aborted as soon as we
hit the first text mark that returns an empty bounding rect for the
annotation. This results in no painting at all when having a line with
multiple text marks with and without annotation. Prefilter the text
marks to make sure we only try to paint text marks with an annotation.

Change-Id: I4f07127fafe935b2ad4ed418b326b6f2ab5b1c50
Fixes: QTCREATORBUG-21628
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-12-10 11:19:33 +00:00
Alessandro Portale
2e2059e8b5 TextEditor: Modernize
modernize-*

Change-Id: Ic497fea1942a77cf017be3b0033f92e3807066f1
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
2018-11-30 17:35:18 +00:00
Eike Ziller
29c9f8080d Merge remote-tracking branch 'origin/4.8'
Conflicts:
	src/plugins/android/androidrunnerworker.cpp

Change-Id: Ibd8b99435365fb7e7d488313fd1d2b3a75adad1b
2018-11-29 13:36:14 +01:00
David Schulz
95cba448a1 move find usages to TextEditor
In preperation for supporting find usages by the language client plugin

Task-number: QTCREATORBUG-21577
Change-Id: I7a6da3a9d53478c1d486e0ddc5829c9ea09a2a20
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-28 12:29:44 +00:00
Nikolai Kosjar
03ee0e6acc Clang: Abort hover handlers on ~TextEditorWidget
We have a QPointer<QTextEditorWidget> in HoverHandlerRunner and a check
in onHandlerFinished() to handle the editor-closed-case. However, the
HoverHandlerRunner and thus the QPointer<> do not outlive the
TextEditorWidget.

Abort the handlers in ~HoverHandlerRunner instead.

Task-number: QTCREATORBUG-21582
Change-Id: I03b78802ca75ddd4be9fea994e3dd9b152060e72
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-11-28 09:22:30 +00:00
David Schulz
25a135ef95 Revert "Fix issue with snippet variables not behaving correctly on Gnome"
This reverts commit e693c9a02e.

The workaround filters out the last input mehtod event when deleting
characters with backspace leading to unwanted side effects. Also we
were not able to reproduce the original issue with the latest Qt neither
on Debian nor Ubuntu with GNOME.

Fixes: QTCREATORBUG-21483
Change-Id: I986d48216b5f62b0f67fc62f94f8e876bbea23d2
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-11-22 14:09:52 +00:00
David Schulz
bd9c2f04c0 TextEditor: fix crash on setting text cursor
Setting a text cursor with a currently open edit block results in
crashes.

Fixes: QTCREATORBUG-21471
Change-Id: I267cdaf10b20959654c2923e5dcc0a07793f3094
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-11-16 08:30:34 +00:00
Ivan Donchevskii
e9d0083ccd ClangFormat: Do not format text but indent only
Provide the separate infrastructure for the formatting
but use it only when QTC_FORMAT_INSTEAD_OF_INDENT is
provided in run environment.

Fixes: QTCREATORBUG-21447
Fixes: QTCREATORBUG-21459
Change-Id: I1ad6fe23f5de17016c0c7b18749c6977fc03a22b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-14 09:29:41 +00:00
Ivan Donchevskii
8469e317c9 Utils: Adjust column numbers affected by convertPosition change
convertPosition change was introduced in 931ec39f64.
It changed 0-based column to 1-based which is how it
naturally is in Qt Creator.

This fixed some usages but broke many more. This is an
attempt to fix the remaining use cases.

Fixes CppEditor auto-tests.

Change-Id: Ia8d14da0ebb035cd2fdd6da4ff6ec89c1c5121a8
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-11-09 08:51:21 +00:00
Ivan Donchevskii
cafd5ced1a Clang: Significantly improve ClangFormat plugin usability
What's new:
1. New LibFormat option is used to prevent lines shrink,
   which allows to drop most of tricks used before for that purpose.
2. Cached UTF-8 source code is used to improve performance
3. Improved error handling.
4. Slightly improved UI.

Change-Id: I4605200fa103167369a40650b2e1ad2c61e8133b
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-10-17 07:16:04 +00:00
Eike Ziller
20d7305318 Merge remote-tracking branch 'origin/4.7' into 4.8
Change-Id: I9d988b8b708d7908c6d1eab7d95d8bb1e68beeb8
2018-09-28 11:03:39 +02:00
David Schulz
b6b756e737 Editor: Do not jump over invisible blocks in paintEvent sub routine
The paintEvent relies on invisible blocks to find
collapsed blocks and paint the collapsed block popup.

Task-number: QTCREATORBUG-21040
Change-Id: Id50e8602722fd807e57fa008cf9fd8106ffdafe1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-09-28 08:55:03 +00:00
Orgad Shaneh
1486359251 Core: Change IEditor::document() to const
All the implementations are const.

Change-Id: Ib9753fe764dd482d4f4392eec70878d42edc737a
Reviewed-by: hjk <hjk@qt.io>
2018-09-26 06:20:51 +00:00
Ivan Donchevskii
ca84a51f86 Clang: Use clang-format for indentation
This is the new experimental plugin based on LibFormat.

It replaces the default indenter for CppEditorDocument
and applies clang-format after the CR or the set of 'electric'
characters.

Uses the global .clang-format kept in QtC settings or
the one for current project. Both can be configured.

For indentation some style modifications and code manipulations
are done to prevent line shrinking when it's not expected.

Manual indentation uses unmodified style from .clang-format file.

Change-Id: I6279b805e418e1804b553efa615f5c843f395a58
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-12 07:59:30 +00:00
David Schulz
d61d29cf16 Introduce a basic client for the language server protocol
The language server protocol is used to transport language specific
information needed to efficiently edit source files. For example
completion, go to operations and symbol information. These information
are transferred via JSON-RPC. The complete definition can be found under
https://microsoft.github.io/language-server-protocol/specification.

This language server protocol support consists of two major parts, the
C++ representation of the language server protocol, and the client part
for the communication with an external language server.

The TypeScript definitions of the protocol interfaces are transferred to
C++ classes. Those classes have getter and setter for every interface
value. Optional values from the protocol are represented by
Utils::optional<ValueType>. The JSON objects that are used to transfer
the data between client and server are hidden by a specialized
JsonObject class derived from QJsonObject. Additionally this JsonObject
provides a validity check that is capable of creating a detailed error
message for malformed, or at least unexpected JSON representation of the
protocol.

The client is the interface between Qt Creator and language server
functionality, like completion, diagnostics, document and workspace
synchronization. The base client converts the data that is sent from/to
the server between the raw byte array and the corresponding C++ objects.
The transportat layer is defined in a specialized base client (this
initial change will only support stdio language server). The running
clients are handled inside the language client manager, which is also
used to connect global and exclusive Qt Creator functionality to the
clients.

Task-number: QTCREATORBUG-20284
Change-Id: I8e123e20c3f14ff7055c505319696d5096fe1704
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-09-03 08:00:46 +00:00