From e9544d2f83d6f757632b2639c2a891c8d3edcda8 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Fri, 27 Feb 2015 12:19:20 +0300 Subject: [PATCH] refactor project configurations reading code --- src/dlangide/workspace/project.d | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/dlangide/workspace/project.d b/src/dlangide/workspace/project.d index af283af..5728c43 100644 --- a/src/dlangide/workspace/project.d +++ b/src/dlangide/workspace/project.d @@ -259,20 +259,18 @@ struct ProjectConfiguration { static ProjectConfiguration[string] load(Setting s) { ProjectConfiguration[string] res = [DEFAULT_NAME: DEFAULT]; - if(s.map is null || "configurations" !in s.map || s.map["configurations"].array is null) + Setting configs = s.objectByPath("configurations"); + if(configs is null || configs.type != SettingType.ARRAY) return res; - foreach(conf; s.map["configurations"].array) - { - if(conf.map is null || "name" !in conf.map) continue; + foreach(conf; configs) { + if(!conf.isObject) continue; Type t = Type.Default; - if("targetType" in conf.map) { - t = parseType(conf.map["targetType"].str); - } - string confName = conf.map["name"].str; - res[confName] = ProjectConfiguration(confName, t); + if(auto typeName = conf.getString("targetType")) + t = parseType(typeName); + if (string confName = conf.getString("name")) + res[confName] = ProjectConfiguration(confName, t); } - return res; } }