Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[ios, macos] Rename featureProperties to featureAttributes. #11748

Merged
merged 4 commits into from
Apr 23, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[ios, macos] Rename featureProperties to featureAttributes.
fabian-guerra committed Apr 20, 2018
commit 21aa5aadc81c058cd6b770b82f34d8c753c9003c
4 changes: 3 additions & 1 deletion platform/darwin/src/NSExpression+MGLAdditions.h
Original file line number Diff line number Diff line change
@@ -80,7 +80,9 @@ extern MGL_EXPORT const MGLExpressionInterpolationMode MGLExpressionInterpolatio
<a href="https://www.mapbox.com/mapbox-gl-js/style-spec/#expressions-properties"><code>properties</code></a>
expression operator in the Mapbox Style Specification.
*/
@property (class, nonatomic, readonly) NSExpression *featurePropertiesVariableExpression;
@property (class, nonatomic, readonly) NSExpression *featureAttributesVariableExpression;

@property (class, nonatomic, readonly) NSExpression *featurePropertiesVariableExpression __attribute__((deprecated("Use -featureAttributesVariableExpression.")));

#pragma mark Creating Conditional Expressions

9 changes: 7 additions & 2 deletions platform/darwin/src/NSExpression+MGLAdditions.mm
Original file line number Diff line number Diff line change
@@ -656,6 +656,10 @@ + (NSExpression *)featureIdentifierVariableExpression {
return [NSExpression expressionForVariable:@"featureIdentifier"];
}

+ (NSExpression *)featureAttributesVariableExpression {
return [NSExpression expressionForVariable:@"featureAttributes"];
}

+ (NSExpression *)featurePropertiesVariableExpression {
return [NSExpression expressionForVariable:@"featureProperties"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: return self.featureAttributesVariableExpression so there are fewer code paths.

}
@@ -901,7 +905,7 @@ + (instancetype)expressionWithMGLJSONObject:(id)object {
} else if ([op isEqualToString:@"id"]) {
return NSExpression.featureIdentifierVariableExpression;
} else if ([op isEqualToString:@"properties"]) {
return NSExpression.featurePropertiesVariableExpression;
return NSExpression.featureAttributesVariableExpression;
} else if ([op isEqualToString:@"var"]) {
return [NSExpression expressionForVariable:argumentObjects.firstObject];
} else if ([op isEqualToString:@"case"]) {
@@ -1000,7 +1004,8 @@ - (id)mgl_jsonExpressionObject {
if ([self.variable isEqualToString:@"featureIdentifier"]) {
return @[@"id"];
}
if ([self.variable isEqualToString:@"featureProperties"]) {
if ([self.variable isEqualToString:@"featureProperties"] ||
[self.variable isEqualToString:@"featureAttributes"]) {
return @[@"properties"];
}
return @[@"var", self.variable];
10 changes: 7 additions & 3 deletions platform/darwin/test/MGLExpressionTests.mm
Original file line number Diff line number Diff line change
@@ -183,11 +183,15 @@ - (void)testVariableExpressionObject {
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"id"]], expression);
}
{
NSExpression *expression = [NSExpression expressionForVariable:@"featureProperties"];
NSExpression *expression = [NSExpression expressionForVariable:@"featureAttributes"];
XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"properties"]);
XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$featureProperties"].mgl_jsonExpressionObject, @[@"properties"]);
XCTAssertEqualObjects([NSExpression expressionWithFormat:@"$featureAttributes"].mgl_jsonExpressionObject, @[@"properties"]);
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:@[@"properties"]], expression);
}
{
NSExpression *expression = [NSExpression expressionForVariable:@"featureProperties"];
XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, @[@"properties"]);
}
{
NSExpression *expression = [NSExpression expressionForVariable:@"loremIpsum"];
NSArray *jsonExpression = @[@"var", @"loremIpsum"];
@@ -867,7 +871,7 @@ - (void)testLookupExpressionObject {
}
{
NSExpression *expression = [NSExpression expressionForFunction:@"mgl_does:have:"
arguments:@[[NSExpression expressionForVariable:@"featureProperties"],
arguments:@[[NSExpression expressionForVariable:@"featureAttributes"],
[NSExpression expressionForConstantValue:@"x"]]];
NSArray *jsonExpression = @[@"has", @"x", @[@"properties"]];
XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);