-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Revamp MGLStyleLayer, MGLSource inheritance #6588
Conversation
@1ec5, thanks for your PR! By analyzing the history of the files in this pull request, we identified @frederoni, @boundsj and @incanus to be potential reviewers. |
ea86b9f
to
0e80f50
Compare
@implementation MGLForegroundStyleLayer | ||
|
||
- (instancetype)initWithIdentifier:(NSString *)identifier source:(MGLSource *)source { | ||
if (self = [super initWithIdentifier:identifier]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this initializer raise an exception?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is the designated initializer called by the concrete classes’ designated initializers. If the developer erroneously creates an MGLForegroundStyleLayer directly using this initializer, they’ll run into an exception as soon as they try to add the style layer to the style because the layer
property will be undefined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. That makes perfect sense for the abstract classes.
@class MGLSource; | ||
|
||
/** | ||
`MGLSourcedStyleLayer` is an abstract superclass for style layers whose content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MGLForegroundStyleLayer
is ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
`MGLSourcedStyleLayer` is an abstract superclass for style layers whose content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MGLVectorStyleLayer
is ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
0e80f50
to
390c2e4
Compare
Would it make sense to override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since Unfortunately, we can’t do anything about the developer calling
The comments for all the abstract superclasses already say that the developer must initialize a concrete subclass, not the abstract superclass. I reiterate the point in the exception messages. |
Removed the MGLStyleLayer protocol, because almost none of its members was actually implemented in every class that adopted the protocol. Removed the unused mapView backpointer property with no replacement. Renamed MGLBaseStyleLayer to MGLStyleLayer. Created the intermediate abstract classes MGLForegroundStyleLayer and MGLVectorStyleLayer to cover subsets of style layer classes with like functionality. Moved each MGLBaseStyleLayer initializer and the corresponding properties down to an abstract subclass such that the initializer makes sense for all concrete subclasses. Moved more initializers and the predicate property up to MGLVectorStyleLayer to eliminate duplication among the concrete subclasses. Marked these initializers as designated initializers. Removed “source” or “layer” before identifier wherever the type of identifier is apparent. Removed extra MGLGeoJSONSource initializer variants in favor of nullable parameters. Added copious documentation comments for source and style layer classes, including several previously undocumented methods and properties. In particular, some preconditions and postconditions have been documented. Added pragma marks to break up the jazzy documentation pages into sections. Reformatted exceptions for consistency.
390c2e4
to
43658db
Compare
I was mistaken: |
This PR cleans up the runtime styling API’s class hierarchy and completes the documentation thereof.
The MGLStyleLayer protocol has been removed, because almost none of its members was actually implemented in every class that adopted the protocol, and because all the concrete classes ultimately derived from the same base class. The unused
mapView
backpointer property has been removed with no replacement, although we’ll eventually have to bring it back – privately – for #6254. MGLBaseStyleLayer has been renamed to MGLStyleLayer. New intermediate abstract classes, MGLForegroundStyleLayer and MGLVectorStyleLayer, cover subsets of style layer classes with like functionality. To summarize, the style layer class hierarchy looks like this now (classes in italics are abstract):Private
category)Each MGLBaseStyleLayer initializer and the corresponding properties have been pushed down to an abstract subclass such that the initializer makes sense for all concrete subclasses. Additional initializers and the predicate property have been pushed up to MGLVectorStyleLayer to eliminate duplication among the concrete subclasses. These initializers are all marked as designated initializers, and exceptions prevent developers from misusing them.
The word “source” or “layer” before “identifier” has been removed wherever the type of identifier is apparent. Extra MGLGeoJSONSource initializer variants have been removed in favor of nullable parameters (overlapping a little with #6524 for #6302).
Copious documentation comments have been added for source and style layer classes, including several previously undocumented methods and properties. In particular, the documentation now includes important preconditions and postconditions, as well as details about the subset of the predicate API that we support. Pragma marks break up the jazzy documentation pages into sections. Unfortunately, the fancy, marked-up documentation comments show up as plain text in Xcode 8: rdar://problem/28628571. At least they look good in jazzy:
Fixes #6406, fixes #6407, fixes #6582. Working towards #5970.
/cc @frederoni @incanus @boundsj