Improved Code Style
This commit is contained in:
@@ -41,36 +41,23 @@
|
||||
@implementation MPExpressionLayout
|
||||
|
||||
# pragma mark Creation Methods
|
||||
- (instancetype)initRootLayoutWithExpression:(MPExpression *)expression
|
||||
- (instancetype)initWithExpression:(MPExpression *)expression
|
||||
parent:(MPFunctionLayout *)parent
|
||||
{
|
||||
self = [super init];
|
||||
self = [super initWithParent:parent];
|
||||
if (self) {
|
||||
_expression = expression;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithElementAtPath:(NSIndexPath *)path
|
||||
inRootExpression:(MPExpression *)rootExpression
|
||||
parent:(MPLayout *)parent
|
||||
{
|
||||
self = [super initWithElementAtPath:path
|
||||
inRootExpression:rootExpression
|
||||
parent:parent];
|
||||
if (self) {
|
||||
_expression = [rootExpression elementAtIndexPath:path];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark Cache Methods
|
||||
- (MPLayout *)childLayoutAtIndex:(NSUInteger)index
|
||||
{
|
||||
id cachedObject = [self cachableObjectForIndex:index generator:^id{
|
||||
NSIndexPath *indexPath = [self.expression.indexPath indexPathByAddingIndex:index];
|
||||
MPFunctionLayout *layout = [MPFunctionLayout functionLayoutForFunctionAtIndexPath:indexPath
|
||||
inRootExpression:self.expression.rootExpression
|
||||
parent:self];
|
||||
MPFunction *function = (MPFunction *)[self.expression elementAtIndex:index];
|
||||
MPFunctionLayout *layout = [MPFunctionLayout functionLayoutForFunction:function
|
||||
parent:self];
|
||||
layout.flipped = self.flipped;
|
||||
layout.usesSmallSize = self.usesSmallSize;
|
||||
return layout;
|
||||
@@ -114,7 +101,7 @@
|
||||
- (NSRect)boundingRectForRange:(NSRange)range
|
||||
{
|
||||
NSUInteger startOffset;
|
||||
NSUInteger startElementIndex = [self.expression indexOfElementAtSymbolLocation:range.location
|
||||
NSUInteger startElementIndex = [self.expression indexOfElementAtLocation:range.location
|
||||
offset:&startOffset];
|
||||
// Calculate x position
|
||||
CGFloat x = 0, width = 0;
|
||||
@@ -139,7 +126,7 @@
|
||||
}
|
||||
|
||||
NSUInteger endOffset;
|
||||
NSUInteger endElementIndex = [self.expression indexOfElementAtSymbolLocation:NSMaxRange(range)
|
||||
NSUInteger endElementIndex = [self.expression indexOfElementAtLocation:NSMaxRange(range)
|
||||
offset:&endOffset];
|
||||
|
||||
// Selection is inside of one string element
|
||||
|
||||
Reference in New Issue
Block a user