Skip to content

Commit 23f280a

Browse files
committed
Minor changes.
1 parent 7e8a058 commit 23f280a

File tree

3 files changed

+9
-39
lines changed

3 files changed

+9
-39
lines changed

src/UnityUxmlGenerator/Extensions/TypeSyntaxExtensions.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,16 @@ namespace UnityUxmlGenerator.Extensions;
55

66
internal static class TypeSyntaxExtensions
77
{
8-
public static bool IsBoolType(this TypeSyntax typeSyntax)
9-
{
10-
if (typeSyntax is PredefinedTypeSyntax predefinedTypeSyntax)
11-
{
12-
return IsBoolType(predefinedTypeSyntax);
13-
}
14-
15-
return IsBoolKind(typeSyntax.RawKind);
16-
}
17-
188
public static bool IsBoolType(this PredefinedTypeSyntax typeSyntax)
199
{
2010
return IsBoolKind(typeSyntax.Keyword.RawKind);
2111
}
2212

23-
public static bool IsStringType(this TypeSyntax typeSyntax)
24-
{
25-
if (typeSyntax is PredefinedTypeSyntax predefinedTypeSyntax)
26-
{
27-
return IsStringType(predefinedTypeSyntax);
28-
}
29-
30-
return IsStringKind(typeSyntax.RawKind);
31-
}
32-
3313
public static bool IsStringType(this PredefinedTypeSyntax typeSyntax)
3414
{
3515
return IsStringKind(typeSyntax.Keyword.RawKind);
3616
}
3717

38-
public static bool IsNumericType(this TypeSyntax typeSyntax)
39-
{
40-
if (typeSyntax is PredefinedTypeSyntax predefinedTypeSyntax)
41-
{
42-
return IsNumericType(predefinedTypeSyntax);
43-
}
44-
45-
return IsNumericKind(typeSyntax.RawKind);
46-
}
47-
4818
public static bool IsNumericType(this PredefinedTypeSyntax typeSyntax)
4919
{
5020
return IsNumericKind(typeSyntax.Keyword.RawKind);

src/UnityUxmlGenerator/UxmlGenerator.Traits.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,32 +129,32 @@ private static UxmlAttributeInfo GetAttributeInfo(GeneratorExecutionContext cont
129129

130130
var info = new UxmlAttributeInfo
131131
{
132-
TypeIdentifier = GetPropertyTypeIdentifier(context, property, out var typeSyntax),
132+
TypeIdentifier = GetPropertyTypeIdentifier(context, property, out var predefinedTypeSyntax),
133133
PrivateFieldName = propertyName.ToPrivateFieldName(),
134134
AttributeUxmlName = propertyName.ToDashCase()
135135
};
136136

137-
if (uxmlAttributeDefaultValue is null || typeSyntax is null)
137+
if (uxmlAttributeDefaultValue is null || predefinedTypeSyntax is null)
138138
{
139139
info.DefaultValueAssignmentExpression =
140140
LiteralExpression(SyntaxKind.DefaultLiteralExpression, Token(SyntaxKind.DefaultKeyword));
141141
return info;
142142
}
143143

144-
if (typeSyntax.IsBoolType())
144+
if (predefinedTypeSyntax.IsBoolType())
145145
{
146146
info.DefaultValueAssignmentExpression = IdentifierName(uxmlAttributeDefaultValue);
147147
return info;
148148
}
149149

150-
if (typeSyntax.IsStringType())
150+
if (predefinedTypeSyntax.IsStringType())
151151
{
152152
info.DefaultValueAssignmentExpression = LiteralExpression(SyntaxKind.StringLiteralExpression,
153153
Literal(uxmlAttributeDefaultValue));
154154
return info;
155155
}
156156

157-
if (typeSyntax.IsNumericType())
157+
if (predefinedTypeSyntax.IsNumericType())
158158
{
159159
info.DefaultValueAssignmentExpression = LiteralExpression(SyntaxKind.NumericLiteralExpression,
160160
Literal(uxmlAttributeDefaultValue, uxmlAttributeDefaultValue));
@@ -172,15 +172,15 @@ private static UxmlAttributeInfo GetAttributeInfo(GeneratorExecutionContext cont
172172
}
173173

174174
private static string GetPropertyTypeIdentifier(GeneratorExecutionContext context,
175-
BasePropertyDeclarationSyntax property, out TypeSyntax? typeSyntax)
175+
BasePropertyDeclarationSyntax property, out PredefinedTypeSyntax? predefinedTypeSyntax)
176176
{
177177
switch (property.Type)
178178
{
179179
case PredefinedTypeSyntax predefinedType:
180180
{
181181
var propertyTypeIdentifier = predefinedType.Keyword.Text.FirstCharToUpper();
182182

183-
typeSyntax = predefinedType;
183+
predefinedTypeSyntax = predefinedType;
184184

185185
return $"Uxml{propertyTypeIdentifier}AttributeDescription";
186186
}
@@ -191,15 +191,15 @@ private static string GetPropertyTypeIdentifier(GeneratorExecutionContext contex
191191
var typeNamespace = customTypeSyntax.GetTypeNamespace(context);
192192
var propertyTypeText = $"global::{typeNamespace}.{type}";
193193

194-
typeSyntax = customTypeSyntax;
194+
predefinedTypeSyntax = default;
195195

196196
return propertyTypeText == UnityColorTypeFullName
197197
? UxmlColorAttributeDescription
198198
: $"UxmlEnumAttributeDescription<{propertyTypeText}>";
199199
}
200200

201201
default:
202-
typeSyntax = default;
202+
predefinedTypeSyntax = default;
203203
return property.Type.GetText().ToString().Trim();
204204
}
205205
}

0 commit comments

Comments
 (0)