Skip to content

Commit 0218da9

Browse files
committed
Use MatcherType instead of Type to remove shadowing from C# Type
1 parent 95b0329 commit 0218da9

File tree

3 files changed

+26
-33
lines changed

3 files changed

+26
-33
lines changed

Assets/Editor/FilterStyleEditor.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class FilterStyleEditor : EditorBase
3030
private int selectedLayer;
3131

3232
[SerializeField]
33-
private FeatureStyle.Matcher.Type selectedMatcherType;
33+
private FeatureStyle.Matcher.MatcherType selectedMatcherType;
3434

3535
[SerializeField]
3636
private List<LayerStyleEditor> layerStyleEditors;
@@ -59,7 +59,7 @@ public FilterStyleEditor(FeatureStyle.FilterStyle filterStyle)
5959

6060
if (filterStyle.Matcher != null)
6161
{
62-
selectedMatcherType = filterStyle.Matcher.MatcherType;
62+
selectedMatcherType = filterStyle.Matcher.Type;
6363
this.matcherEditor = new MatcherEditor(filterStyle.Matcher);
6464
}
6565
}
@@ -142,20 +142,17 @@ public void OnInspectorGUI()
142142

143143
EditorGUI.indentLevel--;
144144

145-
var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast<FeatureStyle.Matcher.Type>();
146-
var matcherTypeStringList = matcherTypeList.Select(type => type.ToString());
147145
var oldType = selectedMatcherType;
148146

149-
selectedMatcherType = (FeatureStyle.Matcher.Type)EditorGUILayout.Popup("Matcher:",
150-
(int)selectedMatcherType, matcherTypeStringList.ToArray());
147+
selectedMatcherType = (FeatureStyle.Matcher.MatcherType)EditorGUILayout.EnumPopup("Matcher:", selectedMatcherType);
151148

152149
if (selectedMatcherType != oldType)
153150
{
154151
matcherEditor = new MatcherEditor(new FeatureStyle.Matcher(selectedMatcherType));
155152
}
156153
else
157154
{
158-
if (selectedMatcherType == FeatureStyle.Matcher.Type.None)
155+
if (selectedMatcherType == FeatureStyle.Matcher.MatcherType.None)
159156
{
160157
matcherEditor = null;
161158
}

Assets/Editor/MatcherEditor.cs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class MatcherEditor : EditorBase
1212
{
1313
[SerializeField]
14-
private FeatureStyle.Matcher.Type selectedMatcherType;
14+
private FeatureStyle.Matcher.MatcherType selectedMatcherType;
1515

1616
[SerializeField]
1717
private FeatureStyle.Matcher matcher;
@@ -42,17 +42,13 @@ private MatcherEditor AddMatcherLayout()
4242

4343
EditorGUILayout.BeginHorizontal();
4444
{
45-
var matcherTypeList = Enum.GetValues(typeof(FeatureStyle.Matcher.Type)).Cast<FeatureStyle.Matcher.Type>();
46-
var matcherTypeStringList = matcherTypeList.Select(type => type.ToString());
47-
48-
selectedMatcherType = (FeatureStyle.Matcher.Type)EditorGUILayout.Popup("Matcher:",
49-
(int)selectedMatcherType, matcherTypeStringList.ToArray());
45+
selectedMatcherType = (FeatureStyle.Matcher.MatcherType)EditorGUILayout.EnumPopup("Matcher:", selectedMatcherType);
5046

5147
EditorConfig.SetColor(EditorConfig.AddButtonColor);
5248
if (GUILayout.Button(EditorConfig.AddButtonContent, EditorConfig.SmallButtonWidth)
53-
&& selectedMatcherType != FeatureStyle.Matcher.Type.None)
49+
&& selectedMatcherType != FeatureStyle.Matcher.MatcherType.None)
5450
{
55-
var matcherType = (FeatureStyle.Matcher.Type)selectedMatcherType;
51+
var matcherType = (FeatureStyle.Matcher.MatcherType)selectedMatcherType;
5652
var newMatcher = new FeatureStyle.Matcher(matcherType);
5753

5854
editor = new MatcherEditor(newMatcher);
@@ -79,13 +75,13 @@ public void OnInspectorGUI()
7975
}
8076
else
8177
{
82-
switch (matcher.MatcherType)
78+
switch (matcher.Type)
8379
{
84-
case FeatureStyle.Matcher.Type.Property:
80+
case FeatureStyle.Matcher.MatcherType.Property:
8581
matcher.HasProperty = EditorGUILayout.TextField("Has property:", matcher.HasProperty);
8682
break;
8783

88-
case FeatureStyle.Matcher.Type.PropertyRange:
84+
case FeatureStyle.Matcher.MatcherType.PropertyRange:
8985
matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
9086
EditorGUILayout.BeginHorizontal();
9187
matcher.MinRange = EditorGUILayout.FloatField("min:", matcher.MinRange);
@@ -97,12 +93,12 @@ public void OnInspectorGUI()
9793
EditorGUILayout.EndHorizontal();
9894
break;
9995

100-
case FeatureStyle.Matcher.Type.PropertyValue:
96+
case FeatureStyle.Matcher.MatcherType.PropertyValue:
10197
matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
10298
matcher.PropertyValue = EditorGUILayout.TextField("Property value:", matcher.PropertyValue);
10399
break;
104100

105-
case FeatureStyle.Matcher.Type.PropertyRegex:
101+
case FeatureStyle.Matcher.MatcherType.PropertyRegex:
106102
matcher.HasProperty = EditorGUILayout.TextField("Property:", matcher.HasProperty);
107103
matcher.RegexPattern = EditorGUILayout.TextField("Regex:", matcher.RegexPattern);
108104
break;
@@ -113,7 +109,7 @@ public void OnInspectorGUI()
113109
{
114110
var editor = matcherEditors[i];
115111

116-
var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), editor.Matcher.MatcherType.ToString());
112+
var state = FoldoutEditor.OnInspectorGUI(editor.GUID.ToString(), editor.Matcher.Type.ToString());
117113

118114
if (state.show)
119115
{

Assets/Mapzen/Unity/FeatureStyle.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public PolylineBuilder.Options GetPolylineOptions(Feature feature, float inverse
6868
[Serializable]
6969
public class Matcher
7070
{
71-
public enum Type
71+
public enum MatcherType
7272
{
7373
None,
7474
AllOf,
@@ -81,7 +81,7 @@ public enum Type
8181
}
8282

8383
[SerializeField]
84-
private Type type;
84+
private MatcherType type;
8585

8686
[SerializeField]
8787
private List<Matcher> matchers;
@@ -96,7 +96,7 @@ public enum Type
9696

9797
public bool IsCompound()
9898
{
99-
return type == Type.AllOf || type == Type.NoneOf || type == Type.AnyOf;
99+
return type == MatcherType.AllOf || type == MatcherType.NoneOf || type == MatcherType.AnyOf;
100100
}
101101

102102
public List<Matcher> Matchers
@@ -123,13 +123,13 @@ public IFeatureMatcher GetFeatureMatcher()
123123

124124
switch (type)
125125
{
126-
case FeatureStyle.Matcher.Type.AllOf:
126+
case MatcherType.AllOf:
127127
matcher = FeatureMatcher.AllOf(predicates.ToArray());
128128
break;
129-
case FeatureStyle.Matcher.Type.NoneOf:
129+
case FeatureStyle.Matcher.MatcherType.NoneOf:
130130
matcher = FeatureMatcher.NoneOf(predicates.ToArray());
131131
break;
132-
case FeatureStyle.Matcher.Type.AnyOf:
132+
case FeatureStyle.Matcher.MatcherType.AnyOf:
133133
matcher = FeatureMatcher.AnyOf(predicates.ToArray());
134134
break;
135135
}
@@ -138,19 +138,19 @@ public IFeatureMatcher GetFeatureMatcher()
138138
{
139139
switch (type)
140140
{
141-
case FeatureStyle.Matcher.Type.PropertyRange:
141+
case MatcherType.PropertyRange:
142142
double? min = MinRangeEnabled ? (double)MinRange : (double?)null;
143143
double? max = MaxRangeEnabled ? (double)MaxRange : (double?)null;
144144

145145
matcher = FeatureMatcher.HasPropertyInRange(HasProperty, min, max);
146146
break;
147-
case FeatureStyle.Matcher.Type.Property:
147+
case MatcherType.Property:
148148
matcher = FeatureMatcher.HasProperty(HasProperty);
149149
break;
150-
case FeatureStyle.Matcher.Type.PropertyValue:
150+
case MatcherType.PropertyValue:
151151
matcher = FeatureMatcher.HasPropertyWithValue(HasProperty, PropertyValue);
152152
break;
153-
case FeatureStyle.Matcher.Type.PropertyRegex:
153+
case MatcherType.PropertyRegex:
154154
try
155155
{
156156
matcher = FeatureMatcher.HasPropertyWithRegex(HasProperty, RegexPattern);
@@ -166,12 +166,12 @@ public IFeatureMatcher GetFeatureMatcher()
166166
return matcher;
167167
}
168168

169-
public Type MatcherType
169+
public MatcherType Type
170170
{
171171
get { return type; }
172172
}
173173

174-
public Matcher(Type type)
174+
public Matcher(MatcherType type)
175175
{
176176
this.matchers = new List<Matcher>();
177177
this.type = type;

0 commit comments

Comments
 (0)