Archived
1

Invalid Numbers Are Now a Syntax Error

Syntax Errors Now Include a Range
Syntax Errors Are Now Displayed in a Selectable List
This commit is contained in:
Kim Wittenburg
2014-11-29 00:19:52 +01:00
parent 4bc2fdead1
commit b6973dc24a
6 changed files with 62 additions and 43 deletions

View File

@@ -430,23 +430,25 @@
return;
}
self.syntaxErrorsPopUpButton.hidden = NO;
[self.syntaxErrorsPopUpButton addItemWithTitle:@""];
NSString *title;
if (syntaxErrors.count == 1) {
NSString *title = NSLocalizedString(@"1 Syntax Error", nil);
NSDictionary *attributes = @{NSForegroundColorAttributeName: [NSColor redColor],
NSFontAttributeName: [NSFont boldSystemFontOfSize:12.0]};
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attributes];
[self.syntaxErrorsPopUpButton itemAtIndex:0].attributedTitle = attributedTitle;
title = NSLocalizedString(@"1 Syntax Error", nil);
} else {
NSString *title = [NSString stringWithFormat:NSLocalizedString(@"%ld Syntax Errors", nil), syntaxErrors.count];
NSDictionary *attributes = @{NSForegroundColorAttributeName: [NSColor redColor],
NSFontAttributeName: [NSFont boldSystemFontOfSize:12.0]};
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attributes];
[self.syntaxErrorsPopUpButton itemAtIndex:0].attributedTitle = attributedTitle;
title = [NSString stringWithFormat:NSLocalizedString(@"%ld Syntax Errors", nil), syntaxErrors.count];
}
NSDictionary *attributes = @{NSForegroundColorAttributeName: [NSColor redColor],
NSFontAttributeName: [NSFont boldSystemFontOfSize:12.0]};
NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attributes];
NSMenuItem *titleItem = [[NSMenuItem alloc] init];
titleItem.attributedTitle = attributedTitle;
[self.syntaxErrorsPopUpButton.menu addItem:titleItem];
NSUInteger index = 0;
for (NSError *error in syntaxErrors) {
[self.syntaxErrorsPopUpButton addItemWithTitle:error.localizedDescription];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:error.localizedDescription
action:NULL
keyEquivalent:@""];
[self.syntaxErrorsPopUpButton.menu addItem:item];
index++;
}
}
@@ -538,8 +540,9 @@
{
NSError *error = self.syntaxErrors[sender.indexOfSelectedItem-1];
NSIndexPath *pathToExpression = error.userInfo[MPPathToExpressionKey];
pathToExpression = [pathToExpression indexPathByAddingIndex:[error.userInfo[MPErrorIndexKey] integerValue]];
self.selection = MPMakeRangePath(pathToExpression, 0);
NSRange errorRange = [error.userInfo[MPErrorRangeKey] rangeValue];
pathToExpression = [pathToExpression indexPathByAddingIndex:errorRange.location];
self.selection = MPMakeRangePath(pathToExpression, errorRange.length);
}
#pragma mark Actions
@@ -721,7 +724,7 @@
fromReferenceFrame:MPSymbolReferenceFrame
toReferenceFrame:MPElementReferenceFrame];
NSIndexPath *functionPath = [self.selection.location indexPathByReplacingLastIndexWithIndex:functionElementIndex];
self.selection = MPMakeRangePath([[functionPath indexPathByAddingIndex:1] indexPathByAddingIndex:0], 0);
self.selection = MPMakeRangePath([[functionPath indexPathByAddingIndex:0] indexPathByAddingIndex:0], 0);
}
- (void)insertNewline:(id)sender