Skip to content

Commit

Permalink
added static analyzer message highlight support
Browse files Browse the repository at this point in the history
  • Loading branch information
armadillu committed May 6, 2012
1 parent c10a191 commit cc15d9c
Showing 1 changed file with 28 additions and 3 deletions.
Expand Up @@ -2,6 +2,7 @@
#import <objc/runtime.h>
#import "XCFixin.h"


static IMP gOriginalnewMessageAttributesForFont = nil;


Expand All @@ -10,22 +11,27 @@ - (id)initWithHighlightColor:(id)arg1 borderTopColor:(id)arg2 borderBottomColor:
@end


@interface XCFixin_DisableAnimations2 : NSObject{
@interface XCFixin_CustomizeWarningErrorHighlights : NSObject{
}

@end

static DVTTextAnnotationTheme * warningTheme;
static DVTTextAnnotationTheme * errorTheme;
static DVTTextAnnotationTheme * analyzerTheme;


@implementation XCFixin_DisableAnimations2
@implementation XCFixin_CustomizeWarningErrorHighlights

static void overridenewMessageAttributesForFont(id self, SEL _cmd, DVTTextAnnotationTheme* arg1, id arg2){

const char* className = class_getName([self class]);
DVTTextAnnotationTheme * newTheme = arg1;

if ( strcmp(className, "IDEBuildIssueStaticAnalyzerResultAnnotation") == 0 ){ // apply our own theme for Warning Messages
newTheme = analyzerTheme;
}

if ( strcmp(className, "IDEDiagnosticWarningAnnotation") == 0 ){ // apply our own theme for Warning Messages
newTheme = warningTheme;
}
Expand Down Expand Up @@ -58,6 +64,7 @@ + (void)pluginDidLoad: (NSBundle *)plugin{
caretColor: [NSColor yellowColor]
highlightedRangeBorderColor: [NSColor clearColor]
];
[gWarning release];

//define gradient for error text highlight
NSGradient * gError = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:1 green:0 blue:0 alpha:0.5]
Expand All @@ -74,7 +81,25 @@ + (void)pluginDidLoad: (NSBundle *)plugin{
caretColor: [NSColor redColor]
highlightedRangeBorderColor: [NSColor clearColor]
];
[gError release];

//define gradient for static Analyzer text highlight
NSGradient * gAnalyzer = [[NSGradient alloc] initWithStartingColor:[NSColor colorWithDeviceRed:0.8 green:0.8 blue:1 alpha:0.5]
endingColor: [NSColor colorWithDeviceRed:0.8 green:0.8 blue:1 alpha:0.5]];

//define static Analyzer text highlight theme
analyzerTheme =
[[DVTTextAnnotationTheme alloc] initWithHighlightColor: [NSColor colorWithDeviceRed:0.8 green:0.8 blue:1 alpha:0.2]
borderTopColor: [NSColor clearColor]
borderBottomColor: [NSColor clearColor]
overlayGradient: nil
messageBubbleBorderColor: [NSColor colorWithDeviceRed:0.8 green:0.8 blue:1 alpha:0.3]
messageBubbleGradient: gAnalyzer
caretColor: [NSColor blueColor]
highlightedRangeBorderColor: [NSColor clearColor]
];
[gAnalyzer release];

gOriginalnewMessageAttributesForFont = XCFixinOverrideMethodString(@"DVTTextAnnotation", @selector(setTheme:forState:), (IMP)&overridenewMessageAttributesForFont);
XCFixinAssertOrPerform(gOriginalnewMessageAttributesForFont, goto failed);
XCFixinPostflight();
Expand Down

0 comments on commit cc15d9c

Please sign in to comment.