Skip to content

Commit

Permalink
Now colors property names in @properties and prevents setter/getter a…
Browse files Browse the repository at this point in the history
…ttributes from receiving coloring. Fixes #17.
  • Loading branch information
kolinkrewinkel committed Mar 23, 2015
1 parent 525f761 commit 3fe4589
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,23 @@ - (NSColor *)ply_colorAtCharacterIndex:(unsigned long long)index effectiveRange:

/* It's possible for us to simply use the source model, but we may want to express fine-grain control based on the node. Plus, we already have the item onhand. */

if ([item ply_isIdentifier] && ![item.parent ply_isMethod])
BOOL isIdentifier = [item ply_isIdentifier];
BOOL parentIsMethod = [item.parent ply_isMethod];
BOOL inheritsFromPropertyDeclaration = [item ply_inheritsFromNodeOfType:32];

/*
This is relatively backwards: for some reason, explicitly defined setters and getters in @property are *not* considered methods/children of methods, whereas the property names themselves are. To combat this, the following two obscure BOOLs are used to disable the getters/setters and enable the coloring of the property var names.
*/

/* Disallows getter/setter-attributes from being colored, as their parents are not methods but they inherit from property declarations. */
BOOL parentIsNotMethodAndDoesNotInheritFromPropertyDeclaration = (!parentIsMethod && !inheritsFromPropertyDeclaration);

/* Ensures property var names are colored as they are considered methods and are within property declarations. */
BOOL parentIsMethodAndInheritsFromPropertyDeclaration = (parentIsMethod && inheritsFromPropertyDeclaration);

if (isIdentifier &&
(parentIsNotMethodAndDoesNotInheritFromPropertyDeclaration ||
parentIsMethodAndInheritsFromPropertyDeclaration))
{
NSString *string = [self.sourceModelService stringForItem:item];
return [[PLYVariableManager sharedManager] colorForVariable:string inWorkspace:workspace];;
Expand Down

0 comments on commit 3fe4589

Please sign in to comment.