From e8d02209e8cc2d18ed2ca09cf5e1990f97ac3ff5 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@theqtcompany.com>
Date: Fri, 24 Oct 2014 17:27:24 +0200
Subject: [PATCH] JsonWizard: Add a way to check for existence of a variable

Change-Id: Ia1368334156c33ca270b5cc7d946efcdb7b635a8
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
---
 src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
index 9970140545c..57bf6a6df0c 100644
--- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
+++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp
@@ -54,6 +54,13 @@ JsonWizard::JsonWizard(QWidget *parent) :
         }
         return v.isValid();
     });
+    m_expander.registerPrefix("Exists", tr("Check whether a variable exists. Returns \"true\" if it does and an empty string if not."),
+                   [this](const QString &value) -> QString
+    {
+        const QString key = QString::fromLatin1("%{") + value + QLatin1Char('}');
+        return m_expander.expand(key) == key ? QString() : QLatin1String("true");
+    });
+
 }
 
 JsonWizard::~JsonWizard()
-- 
GitLab