aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/refactoringchanges.cpp
Commit message (Collapse)AuthorAgeFilesLines
* TextEditor: Make RefactoringFile::apply() a no-op for empty change setsChristian Kandeler45 hours1-0/+3
| | | | | | | To simplify some calling sites. Change-Id: I9736e88053659e5e90bca7b70e6d7e84b0d4fb4e Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Add a convenience overload for RefactoringFile::apply()Christian Kandeler4 days1-1/+7
| | | | | | | | | ... and make use of it. In most contexts, apply() immediately follows setChangeSet(), so combining the two can save a lot of code on the call site. Change-Id: I421001bd47000cb64678a57b19760becf59a4863 Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Insert clang-format removal blocker at the endChristian Kandeler2024-01-301-2/+6
| | | | | | | | | | ... of an "empty" line. Otherwise previous leading whitespace will survive re-formatting. Also reset the formatting cursors when setting a new change set. Fixes: QTCREATORBUG-30244 Change-Id: I3fb8668b56c3823972d4acda8da9657fb0bbfe41 Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Fix quickfix formattingChristian Kandeler2024-01-241-12/+19
| | | | | | | | | | | | | ... for e.g. function insertion. In some contexts, the insertion position is on the last line of some unrelated code (e.g. a preceding function implementation) and the inserted code starts with a newline. In that case, advance the position of the formatting cursor, so that we do not accidentally format the existing code. Fixes: QTCREATORBUG-30229 Change-Id: Id0be7f22e1797affa0602bb1d392a5e0802cbdcd Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: fix autoIndentDavid Schulz2024-01-181-1/+1
| | | | | | | | | | | | | e70b99c7da49c27b519f2fcacb4e06974ef1f6ad broke the auto indent for all indenters because those indenters are all based on the text indenter. Add a fallback indenter that is used if no other indenter is configured for a document, and avoid the auto indentation only if that fallback indenter is used. Change-Id: I00e04a07ab14c5fc433a71d1b9826f8e4cc5c0a0 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* TextEditor: Use FilePath::isWritableFileMarcus Tillmanns2024-01-121-1/+1
| | | | | Change-Id: I67850a4cb5f692765b0692a86252025e2fe64829 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Add formatting information to ChangeSet::EditOpChristian Kandeler2023-12-131-6/+3
| | | | | | | | | | | ... and make use of that in TextEditor::RefactoringFile. This allows calling code to have fine-grained control over which parts of a refactoring should get re-formatted, while also providing sensible default values that are "almost always" right, so things typically work as expected out of the box. Change-Id: I9200c2135b7477c33bc5a61c5d410b34853e4b61 Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Get rid of extra indent ranges in RefactoringFileChristian Kandeler2023-11-221-113/+48
| | | | | | | | | | Having extra indent regions complicates the interface, the implementation and the calling code. Instead, derive the indent regions from the change set and let callers opt out for the relatively few cases where indentation is not desired. Change-Id: I49d2854830a51778534ef260fb5c9f2c7685554a Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Introduce PlainRefactoringFileFactoryChristian Kandeler2023-11-201-7/+7
| | | | | | | | This makes it immediately clear that there are more specialized variants available, which helps users make a conscious decision. Change-Id: I35feb4bed2d91fb4f83ede6e731d9ce89fd4af3f Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Rename class RefactoringChangesChristian Kandeler2023-11-201-2/+2
| | | | | | | ... and remove outdated comment. Change-Id: I6dcd0a38608192ccdd6734affd33e170d39e8299 Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Remove RefactoringChanges::createFile()Christian Kandeler2023-11-201-8/+0
| | | | | | | Dissolve into only caller. Change-Id: I2eaac8bf31c0ecd2dfb863b7fae79af557ccad95 Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Move more code out of RefactoringChangesChristian Kandeler2023-11-201-44/+40
| | | | | | | | The only callers are in RefactoringFile, so put the functions there. Change-Id: I94141d759d32c20a334804e98dfeb262e10c5e11 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Remove now-unused RefactoringChangesDataChristian Kandeler2023-11-171-2/+0
| | | | | | | Change-Id: Idf82ce013f19422d2b5931669e1aaa4a3aa64b16 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Remove RefactoringChanges::m_dataChristian Kandeler2023-11-171-4/+0
| | | | | | | | | There is no use for a data member in the base class. Change-Id: I126d8713d2a7bf4061ecbd60b4c144d39c08d550 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Remove RefactoringFile::m_dataChristian Kandeler2023-11-171-6/+3
| | | | | | | | | There is no use for a generic data member. Change-Id: Iabfbc0587db2cffcc1c19baed832aa866f696ffe Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Move more code into RefactoringFileChristian Kandeler2023-11-171-22/+12
| | | | | | | We want to get rid of RefactoringChangesData. Change-Id: Ia428563a0ff70ec9660761beac3eb7168b8e9eca Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Move code from RefactoringChanges to RefactoringFileChristian Kandeler2023-11-171-32/+37
| | | | | | | | | Preparation for de-polymorphisation of RefactoringChangesData. Change-Id: Ia2a8f8e2a3a403f809e67c907d3474e7c1a52417 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>
* Merge remote-tracking branch 'origin/qds/dev'Tim Jenssen2023-11-161-3/+3
|\ | | | | | | Change-Id: Ic852bc9977d0292fb6cd93a319f4bfdebb22a1b0
| * Editor: centrally emit filesChangedInternally after refactoringsDavid Schulz2023-11-161-3/+3
| | | | | | | | | | | | | | | | | | ...instead of relying on the surrounding code of the refactoring to emit the signal. This also ensures that the signal is only emitted for files that are not opened inside a TextEditor. Change-Id: I6223362864014c691962d895b864f9f44c36e035 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* | TextEditor: Remove unused member functions from RefactoringChangesChristian Kandeler2023-11-161-15/+0
|/ | | | | Change-Id: I7e301fcf7be7690e88d9b31e60cf900660336a07 Reviewed-by: David Schulz <david.schulz@qt.io>
* Editor: simplify RefactoringChanges::openEditorDavid Schulz2023-07-071-4/+1
| | | | | Change-Id: Ia095ab3d24f8f5822954976db5353c925f0b4256 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* CppEditor: Format quickfix code only if formatting is enabledChristian Kandeler2023-07-031-1/+7
| | | | | | | | | | | | | | | ... in the ClangFormat settings (rather than the default of just indenting). As opposed to files generated by the wizard, quickfixes are often touching existing code, and since ClangFormat works on line granularity, users will experience unexpected re-formattings when ClangFormat is in indent- only mode. Therefore, do the formatting only if the user has enabled it in the ClangFormat settings. Change-Id: Icb30f166f2b6fb94113a8f25c4a5f92ff8bca9b0 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CppEditor: Add test case for quickfix formattingChristian Kandeler2023-06-291-1/+1
| | | | | | | | | | Also fixes an off-by-one error in the formatting code that was uncovered by the test. Change-Id: I013194e21cf37f318bb806bb60ea659b91b99fbf Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* CppEditor: Format code inserted by quickfixesChristian Kandeler2023-06-281-1/+96
| | | | | | | | Task-number: QTCREATORBUG-10807 Task-number: QTCREATORBUG-19158 Change-Id: Ieac52e1a1a10afad91fea56290e7dcfd1d302e7f Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Tr::trhjk2023-01-181-8/+6
| | | | | | Change-Id: I28aa68e25c53c3a4d1c370074d7b3318944dc45a Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* 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>
* TextEditorPlugin: Limit the usage of std::make_pairJarek Kobus2022-09-301-2/+1
| | | | | | | | And qMakePair. Change-Id: Id92a662fa0674b9e9f835280bb9378c8d00549e8 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@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>
* TextEditor: Remove foreach / Q_FOREACH usageArtem Sokolovskii2022-05-191-1/+1
| | | | | | | | Task-number: QTCREATORBUG-27464 Change-Id: Ie9594bf661dbeecf22589c1580648252f0bfb7fb Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io>
* Merge remote-tracking branch 'origin/7.0'Eike Ziller2022-03-281-1/+7
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: cmake/QtCreatorIDEBranding.cmake qbs/modules/qtc/qtc.qbs qtcreator_ide_branding.pri src/plugins/studiowelcome/recentpresets.h src/plugins/studiowelcome/userpresets.h Change-Id: Ie573b945eb28347a36ee1b3582fbd6ab0c0f866c
| * TextEditor: Make sure cursor is visible after refactoringChristian Kandeler2022-03-251-1/+7
| | | | | | | | | | | | | | Fixes: QTCREATORBUG-27210 Change-Id: I612f6e91188730d6abdfef3f2fe8a286fcec4831 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* | LanguageClient: Indent code coming from the serverChristian Kandeler2022-02-031-5/+1
|/ | | | | | | | | | | ... if the client implementation requests it. The server is not necessarily aware of our indentation style, so we might have to apply it to the newly inserted code. Change-Id: I43518575c7124568da42be3b04a28d7f352f6dc2 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Optionally auto-save refactored filesChristian Kandeler2021-08-191-0/+3
| | | | | | | | | This is particularly helpful with clangd, which considers only the on- disk state of header files when parsing dependent sources. Fixes: QTCREATORBUG-25924 Change-Id: I41d313f8a203a576d3ed5fbe75bbe918334486d4 Reviewed-by: David Schulz <david.schulz@qt.io>
* Core: filepathify expected document changesDavid Schulz2021-06-171-1/+1
| | | | | Change-Id: Ifa9341e55c79459db9ecef3c441da9b2816695bf Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* TextEditor: filepathify RefactoringChangesDavid Schulz2021-06-081-44/+55
| | | | | Change-Id: Ie97e484bcdeaa0cb2f5d04b3c79ace55ff2e426c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: filepathify TextFileFormatDavid Schulz2021-05-181-6/+10
| | | | | | Change-Id: I6a4e2d38b0bbdec661a4a492901d9182a9f2e502 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* TextEditor: RefactoringChanges improve readabilityDavid Schulz2021-02-101-13/+12
| | | | | Change-Id: I0626f3e97eda6228130fe094c596ccbb3901b079 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Don't access static functions/fields via instanceAlessandro Portale2020-11-191-1/+1
| | | | | | | Courtesy of readability-static-accessed-through-instance Change-Id: I71f54244f1e091315dac2943d9e1bfad6efa56a9 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Core: replace QString with Utils::FilePath to get documentsDavid Schulz2020-09-041-1/+1
| | | | | Change-Id: I01777c227398be8bd3bf877c5429b84a75aa361b Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* TextEditor: After refactoring, do not open the same document againChristian Kandeler2020-08-121-1/+3
| | | | | | | | | ... if it is already visible in a different split view. Activate that one instead. Fixes: QTCREATORBUG-13145 Change-Id: I5facfb23e8e8163d8653c7926d5bf6848f42bd9a Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: Sort indent ranges before applyingChristian Kandeler2020-06-151-1/+5
| | | | | | | | | | It can easily happen that callers insert indent ranges out of order, and without sorting the indentation done earlier in the file is not considered for the later parts, leading to inconsistent results. Fixes: QTCREATORBUG-18929 Change-Id: Ice2abe92d54446bcdd102c6a1f822262a8533543 Reviewed-by: David Schulz <david.schulz@qt.io>
* Use dialogParent() instead of mainWindow()Eike Ziller2020-06-021-1/+1
| | | | | | | | | | There are very few reasons to use mainWindow() directly. Especially for modal dialogs, using dialogParent() is important, since that guarantees the stacking order in case of other dialogs currently being open. Change-Id: I7ad2c23c5034b43195eb35cfe405932a7ea003e6 Reviewed-by: hjk <hjk@qt.io>
* Make TextEditor setup more flexibleEike Ziller2020-02-121-2/+2
| | | | | | | | | | | | | | | | | | | | So far it was only possible to combine TextEditorFactory, BaseTextEditor and TextEditorWidget directly. That TextEditorWidget is also directly a QPlainTextEdit made it impossible to "decorate" the text editor widget with something else without a lot of effort. Make it possible to create a text editor factory that returns an arbitrary widget, as long as it can be "cast" to a TextEditorWidget with either qobject_cast or Aggregation::query. That way the TextEditorWidget instance can be attached to the editor widget via Aggregation. Adapt other code that accesses TextEditorWidget from editors accordingly. Introduce a common method how to do that. Change-Id: I72b8721f3a8a8d8281c39af75253e9c80cbe1250 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: David Schulz <david.schulz@qt.io>
* Standardize on int for line and column valueshjk2019-07-261-3/+3
| | | | | | | | | | | | | | | 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>
* Core: FilePath-ify ReadOnlyFilesDialoghjk2019-05-291-2/+1
| | | | | Change-Id: Iccde7e5cfcee0bdb02720279e8a310857c0a7a67 Reviewed-by: David Schulz <david.schulz@qt.io>
* TextEditor: ModernizeAlessandro Portale2018-11-301-5/+3
| | | | | | | | modernize-* Change-Id: Ic497fea1942a77cf017be3b0033f92e3807066f1 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: hjk <hjk@qt.io>
* TextEditor: ModernizeOrgad Shaneh2018-09-201-22/+6
| | | | | | | override, auto, nullptr, member initializers. Change-Id: I04c6ebb683849568973bd7782fb5a3279267141e Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Fix handling of read-only editors when applying refactoringsEike Ziller2018-08-221-2/+8
| | | | | | | | | | | | | If e.g. a ".ui" file is open, there is a read-only text editor widget for the file, even though the file itself is writable. The application of refactorings or global text-based replace should not change the content of this read-only editor widget, but instead operate directly on the file as if it wasn't open in Qt Creator at all. It should also silently reload these files after modification on disk. Task-number: QTCREATORBUG-19958 Change-Id: I409d5d03059be4c3520a1031ff0fbfa9feb675bb Reviewed-by: David Schulz <david.schulz@qt.io>
* ClangTools: Reflect state of fixitsNikolai Kosjar2018-05-231-4/+9
| | | | | | | | | ...in the fixit column to avoid confusion. As a side effect, add some error handling. Change-Id: Ia30e9c9782f3c8021aedd2be7c682853a26d3f39 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
* ClangTools: Allow applying fixitsNikolai Kosjar2018-05-161-0/+5
| | | | | | | | | | | | | Add a new column to the view that allows to check diagnostics with fixits. The checked fixits can then be applied with the also new "Apply Fixits" button in the toolbar. Some corner cases are not yet handled: * File is open in editor * File changed in the mean time Change-Id: I3d3f353a4150699a0d082f2a4348e331a4213bcf Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>