aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/macroexpander.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use QString::size() instead QString::length()hjk2025-11-131-2/+2
| | | | | | | Minor gain in debug builds and when stepping. Change-Id: I2540d309661e4babfd7331b068c17657ded2a098 Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Guard most MacroExpanderProvidershjk2025-09-191-1/+26
| | | | | | | Amends 303c1934241b3. Closer to a proper solution. Change-Id: I661b5d2046b5facb6217e731c8a15b352fe7c9fe Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Utils: Add variable for a file path's parent directory nameChristian Kandeler2025-07-141-0/+6
| | | | | | Fixes: QTCREATORBUG-33205 Change-Id: I294761b46e4b03e19964d7f0990f8024a6b912d5 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Macros: Add better examples for "prefix" variablesEike Ziller2025-06-301-10/+30
| | | | | | | | | | | | | Variables registered with `registerPrefix` are shown in the variable chooser as `Prefix:<value>`, and that was used to show the "current value" as the example in the variable chooser. Add an explicit "example value" to the registerPrefix calls that is used instead of "<value>" for the expanded example in the variable chooser. Fixes: QTCREATORBUG-33120 Change-Id: I4cc522856bf9a7fefeea2ea498de5f67d503b86a Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* ProjectExplorer: Add setting for a default working directoryChristian Kandeler2025-05-071-2/+6
| | | | | | | | Analogous to the default build directory. Fixes: QTCREATORBUG-29798 Change-Id: I74d7e2e080f8213880ce72677543089df0182a3b Reviewed-by: hjk <hjk@qt.io>
* Utils: Fix an occurrence of the old IPlugin::initialize() signaturehjk2025-04-171-1/+1
| | | | | | | ... in a comment. Change-Id: I9d3e3ce03bccd96b52c6276be83c202b069e71e1 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Replace a few make_unexpected with ResultErrorhjk2025-04-151-3/+2
| | | | | Change-Id: I64637b8b43c1932dee59e37b8922c18d27c2deb9 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Replace most expected_str by Utils::Resulthjk2025-04-111-1/+1
| | | | | | | | Keep it in Axivion dto, which is generated. Change-Id: I83a12de6234ac7b0218b369875bdc72d25dbadfb Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* ProjectExplorer: Provide project-specific vars in build dir templateChristian Kandeler2025-04-111-11/+24
| | | | | | | | | While they cannot get expanded in the settings dialog, it helps the user to know that they exist. Task-number: QTCREATORBUG-31135 Change-Id: Icc7325665038c549879059cc600a23c71c9ae0c5 Reviewed-by: hjk <hjk@qt.io>
* Drop a few unneeded #includeshjk2025-03-041-2/+0
| | | | | Change-Id: Ifb4cddb9da4eeebdbce809e2565f91e5e2d34f10 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: Rename FilePath::toString() into toUrlishString()hjk2025-01-101-1/+1
| | | | | | | | | | | | | | | | toString() is almost always the wrong conversion, but unfortunately too easy to find and often even working at least for local setup. This here raises the bar as the non-availability of the "obvious" toString() hopefully helps people to think about the semantics of the needed conversion and choose the right toXXX() function. The chosen new name is intentional ugly to reduce the likelihood that this (still almost always wrong) function is used out of convenience. Change-Id: I57f1618dd95ef2629d7d978688d130275e096c0f Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Allow remote paths in MacroExpander::registerFileVariablehjk2024-12-191-2/+2
| | | | | Change-Id: I5156366b3009f119ab4524b7078fa72f23b2b251 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Utils: Add reason why MacroExpander::expand(FilePath) does what it doeshjk2024-11-071-1/+7
| | | | | Change-Id: I7f3f7081fc9e5246267168ca1a220d0dc8c6908d Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
* MacroExpander: Return error from expandArgs and handle themMarcus Tillmanns2024-10-221-4/+6
| | | | | Change-Id: Ie4eea11d6e85ab45bc6abf7d255aa204b9c73c92 Reviewed-by: hjk <hjk@qt.io>
* Utils: Remove AbstractMacroExpanderMarcus Tillmanns2024-10-211-6/+121
| | | | | | | | | | It was only used by its own tests. Instead move the functionality into MacroExpander(Private). The existing unittests are moved into tst_expander. Change-Id: Ia54f659efa7976b17f47a0084900f98acc834939 Reviewed-by: hjk <hjk@qt.io>
* Revert "Utils: Expand FilePaths per part, not as a full string"Marcus Tillmanns2024-10-181-4/+1
| | | | | | | | | | | | | | | | | | This reverts commit e8855f97d59670f8be8103bbe662de761a225f39. Reason for revert: Since no one remembers what potential side effects there may have been, and the commit in general makes "expand" worse. The problem with e8855f97d59670f8be8103bbe662de761a225f39 is when "fileNameWithVariables" contains something like "%{ProjectDirectory}", which expands to e.g. `docker://image/some/path`, we cannot rely on "fromParts" to do the right thing. It will write everything into the corresponding slot of a FilePath no matter what the content is, so the "docker://" wil become part of the path, and not be recognized as the scheme. Change-Id: I72aeba0ed6c4a6c9a9e5ecb52b3e8e4043ae5669 Reviewed-by: hjk <hjk@qt.io>
* ProjectExplorer: Display build configuration specific variables againhjk2024-10-181-0/+5
| | | | | | | | Continues d308b86847abad8. Task-number: QTCREATORBUG-31614 Change-Id: I408d96ccd6854b7bb62e13252c00ed3a29788b4c Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Utils: Expand FilePaths per part, not as a full stringhjk2024-07-191-1/+4
| | | | | | | | | | Avoid the potential side effects from the toString/fromUserInput round trip. Fixes: QTCREATORBUG-31259 Change-Id: Id004d71079b4ef8ac26b927921c5cd7a23531110 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
* Fix QMetaType::type() related deprecation warningshjk2024-05-231-1/+1
| | | | | | | Not in sdktool, which still builds with Qt 5.15 Change-Id: I6e6f4331127b821e471e2840e7959cd65e6419e9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Fix i18n issuesEike Ziller2024-02-211-1/+1
| | | | | | | | Fix some missing Tr::, and some namespace usages that confused lupdate. Change-Id: Ib5a411fc53a28a6b807600db50aacc68955ca5dc Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Utils: Replace QVector with QListJarek Kobus2023-07-201-2/+2
| | | | | | | | | | | Make usages of QList consistent. In some cases the declaration contained QVector arg, while the definition had QList arg. Remove some unneeded includes of QList. Change-Id: I7c15b39f261cefdeec6aaaf506ff4cc981432855 Reviewed-by: hjk <hjk@qt.io>
* Fix some more *::count() deprecation warningshjk2023-06-071-1/+1
| | | | | Change-Id: Ib7d1552a6f7b167e15beb7ca1ef26c7d57e090e9 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Doc: Add missing \a commands to MacroExpander docsLeena Miettinen2023-05-301-4/+14
| | | | | | Change-Id: I153e4a4e7c687d6f524bbbff42c758282bb5deaf Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* Utils: Treat FilePath with variables as user input when expandingAlessandro Portale2023-05-241-1/+1
| | | | | | | | | | | | | When macro-expanding FilePaths with environment variables, it can happen that non-conformant path separators end up in the intermediate expanded string. For example with "%{Env:PROGRAMFILES}" on Windows. Since we generally treat paths from environment variables as user input, it makes sense to treat macros as user input as-well in this case. Change-Id: I0daa57b7dbf3d8fd25c98fb82b2beb1bc6ded825 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
* Doc: Add "\inmodule QtCreator" to \class and \namespace docsLeena Miettinen2023-05-221-0/+1
| | | | | | | To get rid of QDoc warnings. Change-Id: Idd39b7ae4327798c376f424c94d6617bcaee2258 Reviewed-by: hjk <hjk@qt.io>
* Process: Rename QtcProcessPrivate -> ProcessPrivateJarek Kobus2023-05-101-1/+1
| | | | | | | | | | Rename the logging category for Process. Fix inline comments accordingly. Adapt warning/debug messages accordingly. Change-Id: I2b1f0f558701def3afa3c1b04adf629833dba9e7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@qt.io>
* MacroExpander: Fix Path and FilePath on WindowsOrgad Shaneh2023-04-201-2/+2
| | | | | | | | | They should have / separator. Amends commit 4fbc56d453ef2fa73e494f371bd44285e3ac0d50. Change-Id: I7218c345b271360f24c03aea5ee62be05342afe0 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Remove unnecessary codeMarcus Tillmanns2023-04-041-7/+7
| | | | | Change-Id: I3844d71d3f77d49f7e84c4feae910679391fa91a Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Utils: Change macro expander to use FilePathMarcus Tillmanns2023-04-041-35/+39
| | | | | Change-Id: Ib7787d1b7f72f6b4728893636f6844e4297fcecd Reviewed-by: hjk <hjk@qt.io>
* Utils: Tr::trAlessandro Portale2023-02-011-11/+11
| | | | | | Change-Id: Ic03e20993f05fb5b49a12c891d86afb2c8e18e08 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: hjk <hjk@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>
* Utils: Pass context object to lambda connectionsJarek Kobus2022-12-071-1/+1
| | | | | | | | Remove some unneeded lambda () brackets. Change-Id: I6b7e07cad8a240a7021c6ddacc84a971809ee717 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Fix expansion of macros in FilePathhjk2022-11-291-4/+2
| | | | | | | | | | | In the New Project wizards, we do have e.g. %{ProFile} that should expand to {scheme}://{device}//{path-to-pro}, not to {}://{}//{schemedevicepath-to-pro} or similar. Task-number: QTCREATORBUG-28355 Change-Id: Idbad709f3fce583f21186a1d43f27ecac15be2ea Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Read env variable using qtc function in MacroExpanderPiotr Mućko2022-09-011-2/+4
| | | | | Change-Id: I2570a526d8b0b8a115b3e06a2d672f7b70d2d970 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Utils: Replace FilePath part settershjk2022-09-011-5/+4
| | | | | | | | | | ... by a combined version. This will make it easier to store the parts in one QString object. Change-Id: Ie85a77e3957c78a30e49998fe2e617af35a8ad17 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
* 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: Port some FilePath part accessors to QStringViewhjk2022-08-221-2/+2
| | | | | | Change-Id: Ib5cc262e44c73880b6538eed714365e3d685870a Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Utils lib: Remove unneeded includes from cpp filesJarek Kobus2022-05-191-3/+0
| | | | | | | | It's a result of a team work consisting of yellow triangle and me. Change-Id: I8b4812766da70e0785ae71bf0cb71357379e2514 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Utils: Remove one ProcessArgs::expandMacros overloadhjk2021-07-061-1/+7
| | | | | | | | | Only used once. Also allow logging of expansion failures. Change-Id: I357ed6ed28fe379d482358c46b495bc727f86902 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Change signature of MacroExpander::registerFileVariableshjk2021-06-031-7/+7
| | | | | | | | | ... to take a function returning a FilePath as base. Implementation is (not) yet changed. Change-Id: I624efab35cf38631c816b630be5296bdf696899e Reviewed-by: David Schulz <david.schulz@qt.io>
* Utils: Simplify and extend MacroExpander::expand(FilePath)hjk2021-06-011-6/+5
| | | | | | | At least for the host it is imaginable that variables might be useful. Change-Id: Ia8aeeef49c195db3877256c6726a832ec966c420 Reviewed-by: David Schulz <david.schulz@qt.io>
* Move CommandLine out of fileutils.hEike Ziller2021-05-111-1/+1
| | | | | | | | | to ProcessArgs and rename the files to commandline.*. fileutils was a strange place for CommandLine, and this reduces the dependencies needed for sdktool. Change-Id: I9d7e8ffe8a3560f5d12934457b086f9446976883 Reviewed-by: hjk <hjk@qt.io>
* Utils: Move ProcessArgs class into filepair of its ownhjk2021-05-111-1/+2
| | | | | | | | There's not much interaction between ProcessArgs and QtcProcess and both .cpp are still quite big, with non-trivial bits. Change-Id: Id84202f6c34057bf87cc8f27fbb45f78f105e9a5 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Move process arguments class out of QtcProcesshjk2021-05-111-1/+1
| | | | | | | | | | | | The main QtcProcess interface is nowadays a CommandLine, with no explicit references left to QtcProcess::Arguments and related static helper functions, so it only clutters the QtcProcess class interface So move these items out of QtcProcess, later potentially to a separate file pair. Change-Id: I45c300b656f5b30e2e2717232c855fdd97c2d1d7 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Utils: Make MacroExpander work with remote file nameshjk2021-04-281-0/+5
| | | | | Change-Id: I2c71c9f7c6ac3523f640e3c57267090444032973 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
* Aggregation/Utils/ExtensionSystem: Make member functions const/staticAlessandro Portale2020-11-271-1/+1
| | | | | | | | | | | | | | | | | | readability-make-member-function-const finds lots of member functions that could be made const. This change just picks getter functions that really should be const. readability-convert-member-functions-to-static finds non-static member functions which do not access this. This change turns most of them into static ones, but leaves some non static to keep the class API consistent. readability-static-accessed-through-instance fixes the places where the originally non-static, now static functions were called through instance. Change-Id: I8cf16c01f7988a7c9d073b5f8ede6a9706b94fb0 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* ProjectExplorer: Clean up variablesChristian Kandeler2020-10-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Global variables with names such as "CurrentProject*", "CurrentKit*" etc are harmful, because the term "current project" as used in Qt Creator does not refer to the "active project", but simply stands for the project that contains the node that is currently selected in the project tree, which in turn may or may not correspond to the current editor document, depending on the "sync with editor" setting. In other words, the "current project" is almost a random value with little meaning outside the project tree itself. Therefore, we remove "CurrentProject*" and friends, except the ones that are currently intentionally in use. The latter get renamed to "CurrentDocument:Project*", so their purpose becomes clear. Their old names are kept around for backward compatibility, but are not suggested by the variable chooser anymore, so new usages are unlikely and we can remove them at some point. We also add some ActiveProject* variants that have been requested in the past. Also remove the "CurrentSession" prefix that was deprecated six years ago. Fixes: QTCREATORBUG-12724 Fixes: QTCREATORBUG-24606 Change-Id: Ibba5d0e0ce3d2beb444a5eec01fbb9b745d90a1d Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils/ProjectExplorer: Move re-usabled bits of aspects to Utilshjk2020-09-231-1/+1
| | | | | | | | | | | Classes involved are BaseAspect and some derived classes, LayoutBuilder and VariableChooser. This is mostly mechanical, with various include/using changes to make it compile. Change-Id: I624a457f3555f102e541c4c71e33a9423af32250 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Compile fix with recent Qt devhjk2019-07-291-4/+1
| | | | | | | | | The reasoning in 1b4766e26c6b did not take into account that the scope of QT_NO_JAVA_STYLE_ITERATORS may change over time, as done with f70905448f6 in Qt base. Change-Id: Ib1966ff26c4d36d5f62e149d6b45baa4aecf825d Reviewed-by: Eike Ziller <eike.ziller@qt.io>
* Utils: Rename FileName to FilePathhjk2019-05-281-3/+3
| | | | | | | | More in line with QFileInfo terminonlogy which appears to be best-of-breed within Qt. Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>