Commit Graph

180 Commits

Author SHA1 Message Date
hjk
a5d165aa82 TextEditor: Setup TextMarkFactory more canonically
Change-Id: Iaa360615c47ed7c4c3e2ace95ad53006e99aa2d0
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-17 11:59:46 +00:00
hjk
a9621ef1fd TextEditor: Hide plugin class definition in .cpp
Change-Id: Ib796333a0c46311fbead63de0e4562918d14a59f
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2024-01-17 11:59:38 +00:00
hjk
f662009bca TextEditor: Move test setup closer to tested code
Change-Id: Ib6edee42b20830a322d47fc1ba071d3cdf2d7538
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-17 11:59:26 +00:00
hjk
cac955f2d7 TextEditor: Move OutlineFactory setup closer to new pattern
This is quite special due to the extra signal, but at least that's
hidden in the implementation now.

Change-Id: Id1130669fd1fdfb631d89460cfb884fb53858eec
Reviewed-by: David Schulz <david.schulz@qt.io>
2024-01-10 09:41:32 +00:00
hjk
b442ca3873 Core: Rename ActionBuilder::setOn* to addOn*
There could be multiple connections.

Change-Id: I7dbca9d24599f776b7d1f1bfa11826e3eeb5640a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-12-13 13:00:00 +00:00
hjk
e17f0b6164 Core: Rename ActionBuilder::setContainer to addToContainer
An action/command can be used in several places.

Change-Id: Ifa26f64f7d200d93ada13f272de0fa833f886997
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-12-13 08:37:10 +00:00
Artem Sokolovskii
b26c43f133 SyntaxHighlighter: Move static functions to other namespace
- Created HighlighterHelper namespace and static functions
were moved there from the highlighter class

Change-Id: Ib93785a3819317d7c1d5cc480652d4635cb9339b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-11-20 16:04:59 +00:00
hjk
ab8ba7f264 Core: Replace new "Action" by an "ActionBuilder"
This needs not be stored somewhere but does its work latest
at destruction automatically.

Change-Id: If929f5a5ccc15b085f110d8d9db8f72ff2a5fac5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2023-11-10 14:33:15 +00:00
hjk
792d88aa05 Core: Introduce Menu and Action classes
Idea is to have a bit more "object { propertySetter }" kind of pattern
for common cases and to couple actions and menus only via Ids, not
real objects.

In a LayoutBuilder context this might later look like

    Menu {
        id(BOOKMARKS_MENU),
        title(Tr::tr("&Bookmarks")),
        container(Core::Constants::M_TOOLS)
    }

in the end.

Overall line count increases but I claim it reduces complexity on the
user code side.

Change-Id: I166e0c8c6b3036430dc464fd652fb37ded21c09a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-11-09 08:00:37 +00:00
Eike Ziller
c2a470e853 Revert "TextEditor: Hide LineNumberFilter implementation"
Fixes missing "Line in Current Document" locator filter.
Locator filters need to be created during startup.

This reverts commit 8af6d16b6c.

Change-Id: I53ec1c1079b4a719169e8db95b6d77f703264b65
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-10-17 07:46:02 +00:00
hjk
8af6d16b6c TextEditor: Hide LineNumberFilter implementation
One of the two non-standard items exposed in the TextEditorPlugin class
interface.

Change-Id: I89755c6a2b168f31b69d3904d6d043273b462ea6
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-10-09 12:23:25 +00:00
hjk
963ff4381d Bookmarks: Merge plugin into TextEditor
Change-Id: I4c9438f3596daff2c18680a731764bf5010e1e25
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-28 11:03:02 +00:00
hjk
2e5805d4b0 TextEditor: Hide part of OutlineFactory implementation
Change-Id: Ifb1c743ba53e2e55605b78336b57c993c12ead3e
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-09-04 12:13:05 +00:00
David Schulz
ddb4aa0151 TextEditor: add json indenter
Use an EditorFactory that sets up a custom indenter for json files.

Change-Id: Id5ade9f9f551835131a62e381a972f0b6032e7c0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-08-28 08:18:59 +00:00
Christian Kandeler
b92ac9a941 TextEditor: Introduce a per-project variant of the comments settings
These settings can clearly differ per project.
Note that the classes have to live in the ProjectExplorer plugin, which
has a (questionable) dependency on TextEditor.

Change-Id: I7e3816da30cecd1ccb66549a2226b44dc0a26cb4
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-08-08 12:50:58 +00:00
David Schulz
bae8e28fee TextEditor: Add tests for the generic highlighter
Change-Id: I5a5092ed0a997800bf6653ab25d69f08f4aa0c37
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-06-07 06:20:42 +00:00
David Schulz
95b4da9ba9 TextEditor: add tests for the code assistant
Task-number: QTCREATORBUG-28989
Change-Id: Id76d5df589ab50c7deb96b8ad29d1f29bc368e59
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2023-05-31 13:38:13 +00:00
hjk
dce7025969 MarkdownView: Merge into TextEditor
Make it a bit more compact, too.

Change-Id: I448164371c5a1d6969a292feba17caa2826f58c3
Reviewed-by: Tasuku Suzuki <tasuku.suzuki@signal-slot.co.jp>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2023-02-21 07:17:29 +00:00
hjk
118b84ffd6 Use simpler Plugin::initialize() when feasible
Change-Id: I567965d266f20526bda9f823e31a04b354d53fb1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-20 12:13:10 +00:00
hjk
17b20e0622 TextEditor: Tr::tr
Change-Id: I28aa68e25c53c3a4d1c370074d7b3318944dc45a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-01-18 07:02:12 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Jarek Kobus
131ecdd3ec TextEditor: Pass context object to lambda connections
Remove some unneeded lambda () brackets.
Glue lambda brackets with parameters brackets.

Change-Id: I66da839573a1633104f689834740bc2953f5868f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-12 06:54:59 +00:00
Jarek Kobus
4c1f410881 TextEditorPlugin: Limit the usage of std::make_pair
And qMakePair.

Change-Id: Id92a662fa0674b9e9f835280bb9378c8d00549e8
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
2022-09-30 11:25:19 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Ihor Ivlev
6f7e7980d2 Display parent functions in the Find Usages menu
To display the parent function, first we find it in displayResults and
store the information to SearchResultItem, then
SearchResultTreeItemDelegate gets the information and renders it.

Similar approach is applied to ClangdClient, in addSearchResultsForFile.

This change also adds default style for containing function highlight in
the search.
Default foreground and background colors are same as usual text colors.

Task-number: QTCREATORBUG-27550
Change-Id: Id1251afa192f8d1232524742b7c211770bcb83fb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-05-25 15:05:25 +00:00
Eike Ziller
dc5717bd06 Move File System view to Core plugin
So it can be accessed from a wider range of places.

Change-Id: I282883addecf7bb070a65d9f4f7b8e6e2e4b5e47
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-10-27 09:02:23 +00:00
David Schulz
d03f723060 TextEditor: add macro variable containing the word under cursor
Fixes: QTCREATORBUG-24836
Change-Id: Ib872fd12e5842bdb752dd3969ef9c5eb9dd2f650
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-11 12:44:40 +00:00
Alessandro Portale
b2a766a79a Don't access static functions/fields via instance
Courtesy of readability-static-accessed-through-instance

Change-Id: I71f54244f1e091315dac2943d9e1bfad6efa56a9
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2020-11-19 08:42:14 +00:00
Christian Kandeler
4376bc1e39 Core: Allow different highlight colors in search result window
... and make use of that in CppTool's "Find Usages" by assigning
different colors to read and write accesses.

Fixes: QTCREATORBUG-12734
Change-Id: I067db2c8d693bb2c5be44249931ee4f0269f7e52
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-09-18 09:33:07 +00:00
Christian Kandeler
7938320291 TextEditor: Introduce shortcut for forcing a function hint proposal
... and support it in the ClangCodeModel.
This allows users to get function signature(s) displayed regardless of
where exactly the cursor is on the function call.

Fixes: QTCREATORBUG-19394
Change-Id: I033e8774db93680bfc3ee52610b817e0ef8ccc76
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-08-11 10:10:08 +00:00
hjk
430a33dcd9 Core/Utils: Migrate further to Utils::Id
The coreplugin/id.h header is kept for downstream for now.

Change-Id: I8c44590f7b988b3770ecdc177c40783e12353e66
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-07-06 06:07:13 +00:00
hjk
299d34d547 Remove apparently unneeded QtPlugin includes
Change-Id: I511c0318a72dbf2a92e4749dee02eabfc9826139
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-02-12 16:03:37 +00:00
Christian Kandeler
5f845a02cd FancyLineEdit: Make completers triggerable via Ctrl+Space
In particular, this allows to trigger the completer without providing a
leading character, thus showing all history entries.

Task-number: QTCREATORBUG-17891
Change-Id: I8ae900d196de2e5083a626faa757648637b325ae
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-30 08:53:20 +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
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
hjk
d3bb3c0953 TextEditor: Use a non-static d-ptr
Change-Id: I21ae4599f152964166c65095996e3fc4ac417ba5
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-02-07 09:46:10 +00:00
hjk
58a168db82 TextEditorPlugin: Pimpl and remove uses of global object pool
Change-Id: I17eb0e928788f02f6089fd2a2ed2393d7f577d11
Reviewed-by: David Schulz <david.schulz@qt.io>
2018-02-07 07:49:06 +00:00
David Schulz
0eb7bab20c Core: make useMacShortcut constexpr
Change-Id: I293b96428784b6efecac6dae4f2f9690af0027da
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-02-02 13:15:55 +00:00
hjk
cc88302309 De-emphasize PluginManager::getObjects<Type>()
... by additionally keeping local (currently non-owning) pools per
"interesting" type.

Current situation:
  - The global object pool does not scale well for looking up
    objects, as iteration plus qobject_cast typically iterates
    over all pooled objects.
  - User code that can use typed results from the object
    pool need to have access to the full type definition anyway,
    i.e.  depend on the plugin of the target class anyway.

The patch here solves the scaling problem is to have local
type-specific pools to which objects register in their
constructors and deregister in their destructors.

This patch here does *not* change the ownership model of the
pooled objects, however, it opens the possibility to change
the ownership model per type (e.g. by not putting things into
the global pool at all anymore and make the local pool 'owning')
and the intent is to handle that in later patchs.

Even without the follow-up patches this here is a performance
improvement for the cases that access the local pools instead
the global one, i.e. "practically all".

Change-Id: Ib11a42df2c4ecf5e1155534730083a520dd1995b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2017-12-15 07:08:05 +00:00
Jesus Fernandez
f3cd5cdb7e Add a ShowContextMenu action
Allow users without physical MenuKey to open the context menu

Change-Id: Id886a5614e26d614cba6ceb3b08a9df6148e9655
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-06-09 10:30:35 +00:00
David Schulz
daac41338e TextEditor: Simplify TextMarkRegistry
The registry is an implementation detail and doesn't need to be exported
so move it to the textmark.cpp file.

Change-Id: Ic103b122cb20063fa4bc220bdc90cecff27054aa
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-05-30 05:01:16 +00:00
Eike Ziller
9443f7104b Remove the need to create ISnippetProvider subclasses
Change-Id: I1810aaa945136d9726a66dad41377429a6adc8e1
Reviewed-by: David Schulz <david.schulz@qt.io>
2017-04-25 12:03:08 +00:00
Tobias Hunger
c6f90e575e Utils: Introduce a TemporaryDirectory and TemporaryFile class
Both wrap the corresponding Qt class, but make sure all temporary files
or directories are created inside a "master temporary directory".

Change-Id: I55461be507c828c965224c02863ea5ed9bbf9498
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-20 12:17:10 +00:00
Tobias Hunger
9dab028fa8 TextEditor: Initialize all members
Creator can start to shutdown before initialize is called. This should
be safe here right now, but let's not take chances in case somebody
refactors this later.

Change-Id: I961c215b8dffc92cf90d9f83e91b0b3034772077
Reviewed-by: David Schulz <david.schulz@qt.io>
2016-12-05 13:46:10 +00:00
Orgad Shaneh
558c08e2c5 Git: Hook grep into Find In File System dialog
Change-Id: I0fc77ad61c8874a21afd5b5135df4d30fa795a8e
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2016-02-04 11:58:29 +00:00
Tobias Hunger
397e7f4843 Update License according to agreement with Free Qt Foundation
* Update files in src/plugins

Change-Id: Ia5d77fad7d19d4bb3498e78661982f68729adb22
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2016-01-19 15:57:01 +00:00
Orgad Shaneh
9d3b2f0998 TextEditor: Use Qt5-style connects
The heavy lifting was done by clazy.

Change-Id: I380120e3419d2a3c0e272f51cc3e0d5f6aaa5e9b
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
2015-12-18 11:54:12 +00:00
Friedemann Kleint
54da18eaaa Clean exported headers of the Core plugin.
Change-Id: I26472d568844d5fee62323e01f5c5c12082d5450
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2015-03-05 07:18:14 +00:00
Eike Ziller
5a3a940ad3 Use new mime database
Change-Id: I4305872b6b11ef3e8a364280ffa5209a5a793600
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-02-17 13:00:07 +00:00
Eike Ziller
a22dc36aaf Generic highlighter: Fix matching the right definition
No longer uses artificial mime types for highlighting files that do not
specify a mime type. No longer registers mime types that are specified
but that Qt Creator does not know about.

Instead, try to match the mime type, and if that fails, or if the result
does not match the file name pattern, try to match file name patterns
instead.

This also fixes the potential problem that mime types were always only
added, never removed, even if the user removed definitions and triggered
a reparse.

Also fixes that a highlight definition in the fallback location could
overwrite a highlight definition in the preferred location, if it has a
higher priority setting.

Task-number: QTCREATORBUG-13912
Change-Id: I86ce10f4f4341f6add0d2b58a04f080501d0cbf4
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
2015-02-17 09:55:30 +00:00