Commit Graph

363 Commits

Author SHA1 Message Date
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
Eike Ziller
78c4cf9884 Fix wrong color of line/column label
Fix up of a8aa4bbb31. That introduced a
non-QToolBar widget that should be styled like a tool bar, so use a
StyledBar instead of plain widget.

Task-number: QTCREATORBUG-20916
Change-Id: Ifd899fac136ef4e3310cd5d2b9cd9f0cd2de1376
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2018-08-09 15:04:29 +00:00
Orgad Shaneh
5b95d91294 TextEditor: Fix crash
Happens when closing an editor while tooltip processing is in progress.

Change-Id: I023f62ab6ba1e8b1bbe207da08c1e526fb99430a
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-26 08:05:26 +00:00
David Schulz
cdcac66c78 TextEditor: Do not paint invisible search results
Painting search results outside of the visible area of
the text editor widget can become costly, so avoid it.

Task-number: QTCREATORBUG-20599
Change-Id: I3e65e40c4bb40c3e7b1ccd1337dee1208bd22d28
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-06-20 04:50:29 +00:00
Eike Ziller
8623a93998 Fix that bookmarks couldn't be added to .pro files with mouse
The area with the marks was not showing up.
This patch reverses the logic for showing the marks area to opt-out.
Almost all editors were opting in for it already. The AndroidManifest
editor, VCS base editor, and widget designer text editor opt out now.

Task-number: QTCREATORBUG-20339
Change-Id: Iccb6d0256618f7ef70e8921847ce2fd46fd660c0
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-06-19 07:59:17 +00:00
David Schulz
3e618cbf76 Editor: fix continuosly repainting partially visible annotations
Task-number: QTCREATORBUG-20422
Change-Id: Id171d8cb3022dd6e345e55fdf029c445bc42c382
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-05-29 04:50:12 +00:00
Jarek Kobus
df50dd7353 HighlightScrollBar: Always show the current line
Also when the scrollbar handle occupies the whole scrollbar area.

Change-Id: I124950e3f0898f853a187ea393731ddb0800aa99
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-05-17 05:57:50 +00:00
Jarek Kobus
80beedfa49 Refactor the highlight scrollbar painting
Scale the highlight on the handle according to the number of lines
visible on screen. In case when document has huge amount of lines
and only couple of lines are visible on screen, this
generates a nice magnification effect.

Change-Id: I43d7cce859cbc14da77272685a6f8d2350b41bb7
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-05-04 11:49:55 +00:00
Eike Ziller
a8aa4bbb31 More improvements of text editor tool bar
Make line/column label always visible, and move context drop down to the
right, so it vanishes first. Reduce the minimum size and stretch of the
outline drop down, so the context drop down doesn't vanish too early
either.

Task-number: QTCREATORBUG-15218
Task-number: QTCREATORBUG-19386
Change-Id: Ie2ced1cb62a27a0129438f5605d5711bfac50cd0
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-04-25 07:10:52 +00:00
Eike Ziller
ce84f64d1b TextEditor: Fix some static analyzer warnings
Use nullptr, do explicit double/float/int conversions, use constFirst.

Change-Id: I269718ade5c54ac613357f59c774e2f47e18a9df
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-04-24 07:46:49 +00:00
Orgad Shaneh
7d3a79c696 Utils: Purge asConst
Replace by qAsConst.

Change-Id: I3301366f73c066c86f08df7188d70dc3b613c55c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-04-09 09:04:00 +00:00
Eike Ziller
454e9ee5ca Add Context Help to text editor context menu
For this make the default context menu for the text editor extensible
and add the context help item from the help plugin, which now has an
optional dependency on the text editor to ensure correct loading order
if both are present.

Task-number: QTCREATORBUG-55
Change-Id: I378a491ba3700e65fc262bdb10c8ead5ad62cb33
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-03-29 08:26:24 +00:00
Eike Ziller
5e6305f346 TextEditor: Fix default context menu
Text editor implementations that did not do anything special with
invoking their context menu, including our plain text editor, only had
Qt's default context menu, without Qt Creator's clipboard history and
BOM actions.

Make the default actions in our custom context menu more similar to Qt's
default actions by adding Undo, Redo and Select All, and not hiding
disabled actions, and use that by default in all text editor
implementations.

Change-Id: Idd5fb276dcd652223d96536dacde8110f9eb576f
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-03-22 07:57:34 +00:00
Ivan Donchevskii
08d1274ccc CppTools: Remove processEvents call from follow symbol
processEvents is a bad way of dealing with asynchronous
requests. Use QFutureWatcher for that purpose.

Change-Id: I3839cb9db80a6d391f6af1178e96986a325b7b99
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-03-19 13:37:46 +00:00
Eike Ziller
0b10ecc718 Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/plugins/cmakeprojectmanager/cmakeproject.h
	src/plugins/debugger/debuggerplugin.cpp
	src/plugins/ios/iosrunfactories.cpp
	src/plugins/nim/project/nimproject.h
	src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp
	src/plugins/qmakeandroidsupport/qmakeandroidrunfactories.cpp
	src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp
	src/plugins/qmlprojectmanager/qmlproject.h
	src/plugins/qnx/qnxrunconfigurationfactory.cpp
	src/plugins/qtsupport/exampleslistmodel.cpp
	src/plugins/winrt/winrtrunfactories.cpp

Change-Id: Ib029fdbaa65270426332f5edd6e90264be5fb539
2018-03-13 11:25:38 +01:00
Eike Ziller
e693c9a02e Fix issue with snippet variables not behaving correctly on Gnome
Directly after triggering the snippet completion, a funny input method
event is sent that doesn't contain any data. This still results in a
even more funny contentsChanged signal from QPlainTextEdit which made
our text editor think that the document has changed somewhere else. In
which case we close the snippet variable input.
So ignore funny input method events.

Task-number: QTCREATORBUG-19571
Change-Id: I3958e8736b1b3e3dea5225356ee4cd173d6beaa0
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-03-05 09:49:20 +00:00
Eike Ziller
7c3cfa166d Merge remote-tracking branch 'origin/4.6'
Conflicts:
	src/plugins/coreplugin/helpmanager.cpp

Change-Id: I2feb60ec0afb2f22f75dc137a01c3fa217b299d8
2018-02-23 10:56:52 +01:00
David Schulz
dc358dc841 TextEditor: update scrollbar after adding annotation between lines
Emit documentSizeChanged after resizing the block boundaries because of
an annotation between lines.

Task-number: QTCREATORBUG-19790
Change-Id: If468ec003a43f37fdcb182344992e4094b269c92
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-02-22 13:40:04 +00:00
David Schulz
464a9ad9ab Editor: Fix block for offset calculation
Take block bounding rects into account, when calculating the row count
or the center visible line.

Change-Id: If933828867df25920eeb56359e9a42a8b95d9c6d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-02-15 09:51:46 +00:00
David Schulz
b4a1798618 TextEditor: add document content completer
Add completion based on words of the document. This provides basic
assistance for programming languages without a code model.

Task-number: QTCREATORBUG-13869
Change-Id: I3a9c59c741dfd6895442fc0524cfd1bd3b2b0111
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-02-14 13:38:22 +00:00
Eike Ziller
c7bb8305d7 Add overlooked Goto Document Start/End shortcut settings
Change-Id: I2f60e2607660cea98aebb1057226010ea4837156
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2018-02-13 13:29:27 +00:00
Nikolai Kosjar
f75983b0aa TextEditor: Modernize texteditor.{cpp,h}
Apply some clazy and modernize fixes from clang tidy: mostly use of
nullptr and removal of type duplication.

Change-Id: Ibd9ee8f9b8a836a40d6f9be0b95acc91513a1a01
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-02-07 11:36:53 +00:00
Eike Ziller
049b761242 Fix inconsistency between tool tip and context help
For the tool tip it moves the position to the start of the word before
passing it to the hoverhandler. That wasn't the case if the user
requests context help, which lead to the strange situation that the tool
tip showed help, but context help at the same position did not (e.g. on
QApplication::topLevelWidgets() with the cursor between the
parentheses).

Related to QTCREATORBUG-15959

Change-Id: I2b9918ea235869c2ddeeba6e749958c10a47d259
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2018-01-29 09:51:23 +00:00
Nikolai Kosjar
4db7fd064f TextEditor: Avoid running hover handlers for same request
...in case the current run is not yet finished.

Change-Id: Id78db576ad8fad10af6b21c73e5b47b49d58d26b
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-01-22 12:33:12 +00:00
Nikolai Kosjar
9fd9bd25ab TextEditor: Let BaseHoverHandler handle help id callbacks
...to support asynchronous hover handlers like ClangHoverHandler.

Change-Id: I8dc7189db37ec3a923cf493b8957c59ec9be447c
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-01-19 13:58:07 +00:00
Nikolai Kosjar
0a4073ef90 TextEditor: Return hover handler priority by callback
...to get rid of the asynchronous code path.

Change-Id: I56377510440631b0be712333b2a4018717c86389
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-01-19 13:57:57 +00:00
Nikolai Kosjar
dd06a4188d Core: Return context help id by callback
...to support asynchronous providers.

Change-Id: I483489c74e7886d5bc2bf00b65540c3d2c7afee0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-01-18 13:54:02 +00:00
David Schulz
8cecd73d2b Editor: show text mark icon while dragging
Change-Id: Ib8c3cbb6e298c3af5e159b18cb474f9b2baa1a83
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-01-12 09:20:06 +00:00
David Schulz
30d733a2e1 Editor: initialize block count after duplicate
Task-number: QTCREATORBUG-19550
Change-Id: I0f93823ca919a269b07412103715a0fe0a8adeb8
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-01-08 13:57:43 +00:00
Jarek Kobus
990da15c1e Refactor HighlightScrollBar
Rename it into HighlightScrollBarController.
Don't derive it anymore from QScrollBar.
Make it based on QObject and decorate
the existing instance of QAbstractScrollArea as needed.

Fix the highlight of the shared scrollbar of the SideBySideDiffEditor.
Both left and right diff editors have their own
HighlightScrollBarController and their own separate overlays, but both
overlays are created as children of the same right editor instance.

Synchronize also the cursor between left and right editors.
Make highlight current line working.

Make the overlay transparent for mouse events - this fixes
issues on macOS when scolling over invisible scrollbar.

Change-Id: Iab05c360173e09d8748658c59785da86438a7189
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-12 08:17:58 +00:00
Eike Ziller
508a9bdb24 Move line/column label functionality into single place
Create a LineColumnLabel class that aggregates the functionality that
was before spread through the editor widget and factory classes.

Change-Id: I6ba316174b2f690a0b146bdd606c6f8ed985ec20
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-07 12:49:26 +00:00
Eike Ziller
9687593bce Rename LineColumnLabel
It is not only used for line and column.

Change-Id: I544244dbca0b9f084e45ff2d7e4f28f79d2cae09
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-12-07 12:49:15 +00:00
Eike Ziller
a2739f55ed Merge remote-tracking branch 'origin/4.5'
Change-Id: Ic7c16091268083c0426cf29f0691a7ee458f2bd9
2017-12-07 09:16:01 +01:00
David Schulz
d0bf2a4528 TextEditor: fix animate navigation within file
The calculation based on visible lines is not working as
expected when we have collapsed blocks. Using QPlainTextEdit
functions to get the correct target scroll bar value.

Task-number: QTCREATORBUG-19327
Change-Id: I0393fc94ba2a11caeaa77d6d87bc69c6c7de1bb7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-12-01 07:58:43 +00:00
Ivan Donchevskii
8efb598e60 TextEditor: move Link class to separate header in Utils
Link is a common class and is used across the plugins.

Change-Id: Id92e47e1b8604316ca8b970804e57abaf404ec28
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-11-27 13:57:02 +00:00
David Schulz
c815d456ed TextEditor: Add option to display annotation between lines
Task-number: QTCREATORBUG-19181
Change-Id: I9b3957c678c08ca2f3ddf9cfa5ff272241547471
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-11-22 10:08:01 +00:00
David Schulz
2d437325b8 TextEditor: Restructure TextEditorWidget::extraAreaPaintEvent
Change-Id: I832168226bfe254f0540ca1a947bf16170494549
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-10-26 08:32:55 +00:00
Eike Ziller
7f626b1182 Merge remote-tracking branch 'origin/4.5'
Change-Id: Iceaa4ca40b5318744bde8a76c6d3ccca08df71bb
2017-10-25 16:07:21 +02:00
Eike Ziller
1a1681bbcc TextEditor: Work around linguist issues
lupdate has issues with resolving non-trivial uses of "using namespace"
(QTBUG-64007)
Move "using namespace" directive to a place where it is better handled
by lupdate.
Also use TextEditorWidget instead of *Private as the context.

Change-Id: I7d3bb8e1bc493196e47085827be31f97e0dce7b8
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-10-25 07:13:45 +00:00
Robert Loehning
289dbab200 TextEditor: Initialize PaintEventData::rightMargin
Change-Id: I64690e594cf20f073ba348f5896a8cf9da5260b8
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-10-23 13:35:40 +00:00
David Schulz
0c0c10b167 TextEditor: Fix block for visible row calculation
Take into account that a block can contain multiple visible rows.

Change-Id: Ifedeb113b3c1a6a374fa9418106e612c56559cba
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-10-23 10:58:18 +00:00