From f25a6016d3f0a775b673557b9f6bc24dc69adf01 Mon Sep 17 00:00:00 2001 From: rolandleth Date: Thu, 30 Apr 2015 16:02:31 +0300 Subject: [PATCH 1/2] Variable coloring for Swift. Added `nodeType == 16` check --- Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m b/Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m index 27b1e98..b2d3a49 100644 --- a/Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m +++ b/Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m @@ -53,7 +53,8 @@ - (NSColor *)ply_colorAtCharacterIndex:(unsigned long long)index effectiveRange: { long long nodeType = [self nodeTypeAtCharacterIndex:newRange.location effectiveRange:effectiveRange context:context]; - if (nodeType == 9) + if (nodeType == 9 || + nodeType == 16) { PLYMockSwift *fauxSwiftService = (PLYMockSwift *)self.languageService; NSRange funcDefinitionRange = [fauxSwiftService methodDefinitionRangeAtIndex:newRange.location]; From 570b20b62127f0772af013eb1e027e53c997d8e4 Mon Sep 17 00:00:00 2001 From: rolandleth Date: Thu, 30 Apr 2015 18:04:51 +0300 Subject: [PATCH 2/2] A more verbose approach. --- .../Categories/DVTTextStorage+PLYHighlightingHook.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m b/Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m index b2d3a49..bfa0f1f 100644 --- a/Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m +++ b/Polychromatic/Categories/DVTTextStorage+PLYHighlightingHook.m @@ -53,8 +53,9 @@ - (NSColor *)ply_colorAtCharacterIndex:(unsigned long long)index effectiveRange: { long long nodeType = [self nodeTypeAtCharacterIndex:newRange.location effectiveRange:effectiveRange context:context]; - if (nodeType == 9 || - nodeType == 16) + if (nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:@"xcode.syntax.identifier.variable"] || + nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:@"xcode.syntax.identifier.constant"] || + nodeType == [DVTSourceNodeTypes registerNodeTypeNamed:@"xcode.syntax.identifier"]) { PLYMockSwift *fauxSwiftService = (PLYMockSwift *)self.languageService; NSRange funcDefinitionRange = [fauxSwiftService methodDefinitionRangeAtIndex:newRange.location];