summaryrefslogtreecommitdiff
path: root/src/libs/utils/textutils.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Utils: add Position::fromCursor with testsDavid Schulz2023-05-171-0/+5
| | | | | | Change-Id: I1cd989eaf7e75bc04f171989f9f9fe932402abef Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: add tests for Position::fromPositionInDocumentDavid Schulz2023-05-161-0/+2
| | | | | | | Change-Id: I2b530cf62a4defe0292c51834b1e5093a7d5e55f Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Utils: add tests for Position::fromFileNameDavid Schulz2023-05-161-1/+8
| | | | | Change-Id: I321b91567e47e08883c7b991cd24d02bb8a9b9c6 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: fix Text::Range length and remove midDavid Schulz2023-05-121-8/+16
| | | | | | | | | | | | | | | | Those functions are based on the assumption that the passed text starts at the begin position, which was good enough for search results, but if used in other parts of the codebase it might give unwanted results. Calculate the length of the range now as expected and subtract the beginning lines. In order to still got the correct results for the text result texts modify the result range to always start at the first line before calculating the length of the range. Also add tests for the modified functionality Change-Id: I7ccd75b642dda6dd4f738877cbe3543d46c03652 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: use Text::Position instead of LineColumn in textutilsDavid Schulz2023-05-111-23/+9
| | | | | Change-Id: I606b0b4f8106bdb2f97383d6c81ac065e7e61858 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: move extractFromFileName from LineColumn to Text::PositionDavid Schulz2023-05-111-1/+35
| | | | | | Change-Id: Ibb2465e66c280d4201377921f69741a050d94bc1 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Utils: remove OptionalLineColumnDavid Schulz2023-05-111-7/+4
| | | | | | | LineColumn already has a isValid() that is sufficient for the use case. Change-Id: I7f6e1d64b66a9af05d74ce0ef45717265dc28ed3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: Make column of LineColumn consistently 0-basedDavid Schulz2023-05-111-3/+2
| | | | | | Change-Id: I4ab153d1c55653936efbcdc13ac04463185930e0 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Utils: move TextPosition/Range to textutilsDavid Schulz2023-05-101-4/+32
| | | | | Change-Id: Id94a7a96f3b0f978e94850d67eb4b8fba6c18fe2 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Remove GPL-3.0+ from license identifiersKai Köhne2023-01-061-1/+1
| | | | | | | | | | | | | | | 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>
* Use SPDX license identifiersLucie Gérard2022-08-261-24/+2
| | | | | | | | | 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>
* Utils: More forward declarations / drop unused headers [T-Z]Jarek Kobus2022-05-251-2/+2
| | | | | | | | | | | Round 1 - focus on headers. For classes with initial in range [T-Z]. Replace QT_FORWARD_DECLARE_CLASS with QT_BEGIN_NAMESPACE and QT_END_NAMESPACE and forward declare inside. Change-Id: I4ac3a8391e6167aa2db3973a9f94a45ac3c8ebd1 Reviewed-by: hjk <hjk@qt.io>
* Utils: swap anchor and position of Utils::Text::selectAtDavid Schulz2021-09-301-2/+2
| | | | | | | selecting now from column to column+length Change-Id: I34fdf2d3db7fb15687b973094b2ca063b5c6587c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: fix selectAt used with invisible blocksDavid Schulz2020-06-111-5/+3
| | | | | | | | | | Using QTextCursor::movePosition with QTextCursor::NextBlock seems to jump over invisible blocks. Use setPosition instead. Change-Id: I3271fb8570678ef6f09141032948dedee308e20c Fixes: QTCREATORBUG-24019 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Editor: add formatter supportDavid Schulz2020-01-221-0/+20
| | | | | Change-Id: I65590273b2541e08a39970cd9bb4739a5634b2f7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Clang: Extract Utils::utf8AdvanceCodePointNikolai Kosjar2019-08-271-0/+25
| | | | | Change-Id: I922c7b0f2f0e0d50f34035e9affef4504df59892 Reviewed-by: David Schulz <david.schulz@qt.io>
* Standardize on int for line and column valueshjk2019-07-261-1/+1
| | | | | | | | | | | | | | | Recently tons of warnings show up for presumably "problematic" singned <-> unsigned and size conversions. The Qt side uses 'int', and that's the biggest 'integration surface' for us, so instead of establishing some internal boundary between signed and unsigned areas, push that boundary out of creator core code, and use 'int' everywhere. Because it reduces friction further, also do it in libcplusplus. Change-Id: I84f3b79852c8029713e7ea6f133ffb9ef7030a70 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* ClangFormat: Fix UTF-16 line and column for 0 offsetIvan Donchevskii2019-03-061-2/+5
| | | | | Change-Id: I348a32d623da1c2da7f3e7f18cad8c9c06dc7b06 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* ClangFormat: Refactor codeIvan Donchevskii2019-02-201-0/+22
| | | | | | | Reorder some functions, remove code duplication. Change-Id: I33e118e567dee7db622bbc99e6a7c500db54e5c5 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Help: Add fallback word lookup for context help to base text editorEike Ziller2019-02-151-0/+7
| | | | | | | | | | | | 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>
* ClangFormat: Fix the return value for the line offsetIvan Donchevskii2018-12-121-0/+3
| | | | | | | Return -1 for the lines which do not exist in the document. Change-Id: Ieccb2121f7db260bf72b36886d1f820af01cca0d Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* ClangFormat: Make more readable helper functionsIvan Donchevskii2018-10-241-6/+6
| | | | | Change-Id: I25828a17104a778d4be156bf2a2879cefbd08691 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Clang: Significantly improve ClangFormat plugin usabilityIvan Donchevskii2018-10-171-0/+15
| | | | | | | | | | | | 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>
* Utils: Fix column returned from helper functionIvan Donchevskii2018-10-111-1/+1
| | | | | | | The second function overload must also return 1-based column. Change-Id: I1d3a58c9267e4a8c8a031c72230f963596a7bb2b Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Clang: Change the way completion fix-its are shownIvan Donchevskii2018-10-021-1/+2
| | | | | | | | Move the completion information to the tooltip and show fix-it icon on the right of such item. Change-Id: I7eff410384104387e547695171e4864760c07fb9 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
* Introduce a basic client for the language server protocolDavid Schulz2018-09-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Clang: Provide all overloads for function definition completionIvan Donchevskii2018-08-021-1/+0
| | | | | | | | When we complete a function definition with the parameter list it is important to have multiple entries to select. Change-Id: I25e94b58cfe4831387d66eecdec74712addb7ec5 Reviewed-by: Marco Bubke <marco.bubke@qt.io>
* Utils: Remove superfluous qualificationsOrgad Shaneh2018-07-191-2/+2
| | | | | Change-Id: I36e17dac0cff87f82f0ddaf97bc613389110f218 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Move common positionInText function to Utils::TextIvan Donchevskii2018-06-191-0/+7
| | | | | Change-Id: I5d74a73058ca457b0fb3f13eaf945f224d5699fb Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Clang: Use LineColumn instead of explicit integers for line and columnMarco Bubke2018-01-171-0/+12
| | | | | | | | With OptionalLineColumn we don't need any bool return parameter any more. Change-Id: I6f57f221c1bfdf08a92a87a7d71ea0eecf83dbcf Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* TextEditor: move convenience from texteditor to utilsIvan Donchevskii2017-09-221-0/+125
Allows to use this header without texteditor dependency. Change-Id: I706f42799c3ea42473a716fa9ef9f3cfbef6fdd4 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>