Skip to content

Commit

Permalink
More work on indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
atg committed Mar 5, 2010
1 parent e8d1175 commit a1d9659
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 28 deletions.
16 changes: 8 additions & 8 deletions CHDocumentationBrowser.xib
Expand Up @@ -23,13 +23,13 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="79"/>
<integer value="191"/>
<integer value="114"/>
<integer value="19"/>
<integer value="392"/>
<integer value="1"/>
<integer value="79"/>
<integer value="370"/>
<integer value="392"/>
<integer value="19"/>
<integer value="114"/>
<integer value="191"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -66,15 +66,15 @@
<string key="NSWindowClass">IGKWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<string key="NSWindowContentMinSize">{700, 500}</string>
<string key="NSWindowContentMinSize">{500, 300}</string>
<object class="NSView" key="NSWindowView" id="1006">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{756, 602}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
<string key="NSMinSize">{700, 522}</string>
<string key="NSMinSize">{500, 322}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
</object>
<object class="NSView" id="4605457">
Expand Down Expand Up @@ -3872,7 +3872,7 @@ ZQCUhAEqhIQLe0NHU2l6ZT1kZH2aAIOQAAAAAAAAAIaGA</bytes>
<string>{196, 240}</string>
<string>{{202, 428}, {480, 270}}</string>
<boolean value="YES"/>
<string>{700, 500}</string>
<string>{500, 300}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
Expand Down
4 changes: 2 additions & 2 deletions IGKArrayController.m
Expand Up @@ -87,7 +87,7 @@ - (void)fetch:(void (^)(NSArray *managedObjectIDs, BOOL fetchContainsVip))comple
}
- (void)refresh
{
[self refreshAndSelectFirst:YES renderSelection:NO];
[self refreshAndSelectFirst:YES renderSelection:YES];
}
- (void)refreshAndSelectFirst:(BOOL)selectFirst renderSelection:(BOOL)renderSelection
{
Expand All @@ -112,7 +112,7 @@ - (void)refreshAndSelectFirst:(BOOL)selectFirst renderSelection:(BOOL)renderSele
[tableView scrollRowToVisible:0];

if (renderSelection)
[[tableView delegate] tableViewSelectionDidChange:nil];
[[tableView delegate] tableViewSelectionDidChange:[NSNotification notificationWithName:NSTableViewSelectionDidChangeNotification object:tableView]];
}
}];
}
Expand Down
61 changes: 45 additions & 16 deletions IGKScraper.m
Expand Up @@ -581,34 +581,58 @@ - (void)scrape

//Depending on the type of obj, we will need to parse it differently
NSEntityDescription *entity = [transientObject entity];
if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"ObjCAbstractMethodContainer" inManagedObjectContext:transientContext]])
if ([transientObject isKindOfEntityNamed:@"ObjCAbstractMethodContainer"])
{
[self scrapeAbstractMethodContainer];
}
else if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"ObjCMethod" inManagedObjectContext:transientContext]])
else if ([transientObject isKindOfEntityNamed:@"ObjCMethod"])
{
[self scrapeMethod];
}
else if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"CFunction" inManagedObjectContext:transientContext]])
else if ([transientObject isKindOfEntityNamed:@"CFunction"])
{
[self scrapeApplecode:@"c/func"];
}
else if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"CTypedef" inManagedObjectContext:transientContext]])
else if ([transientObject isKindOfEntityNamed:@"CTypedef"])
{
[self scrapeApplecode:@"c/tdef"];
}
else if ([entity isKindOfEntity:[NSEntityDescription entityForName:@"CStruct" inManagedObjectContext:transientContext]])
else if ([transientObject isKindOfEntityNamed:@"CStruct"])
{
[self scrapeApplecode:@"c/tdef"];
}
else if ([transientObject isKindOfEntityNamed:@"CEnum"])
{
[self scrapeApplecode:@"c/tdef"];
}
else if ([transientObject isKindOfEntityNamed:@"CMacro"])
{
[self scrapeApplecode:@"c/macro"];
}
else if ([transientObject isKindOfEntityNamed:@"CConstant"])
{
[self scrapeApplecodes:[NSArray arrayWithObjects:@"c/econst", @"c/data", @"c/tag", nil]];
}
else if ([transientObject isKindOfEntityNamed:@"CGlobal"])
{
[self scrapeApplecode:@"c/constant_group"];
}
}

- (void)scrapeApplecode:(NSString *)applecode
{
[self scrapeApplecodes:[NSArray arrayWithObject:applecode]];
}
- (void)scrapeApplecodes:(NSArray *)applecodes
{
NSError *err = nil;
NSArray *methodNodes = [[doc rootElement] nodesForXPath:@"//a" error:&err];

NSString *fullApplecodePattern = [NSString stringWithFormat:@"//apple_ref/%@*", applecode];
NSMutableArray *fullApplecodePatterns = [[NSMutableArray alloc] init];
for (NSString *applecode in applecodes)
{
[fullApplecodePatterns addObject:[NSString stringWithFormat:@"//apple_ref/%@*", applecode]];
}

//Search through all anchors in the document, and record their parent elements
NSMutableSet *containersSet = [[NSMutableSet alloc] init];
Expand All @@ -624,19 +648,24 @@ - (void)scrapeApplecode:(NSString *)applecode
NSString *strval = [el commentlessStringValue];

//(instm|clm|intfm|intfcm|intfp|instp)
if ([strval isLike:fullApplecodePattern])
for (NSString *fullApplecodePattern in fullApplecodePatterns)
{
NSString *methodName = [transientObject valueForKey:@"name"];

//This is a bit ropey
if ([strval isLike:[@"*" stringByAppendingString:methodName]])
if ([strval isLike:fullApplecodePattern])
{
[containersSet addObject:[a parent]];
NSString *methodName = [transientObject valueForKey:@"name"];

NSArray *children = [[a parent] children];
NSInteger index = [children indexOfObject:a];
if (index != -1)
[self scrapeMethodChildren:children index:index managedObject:transientObject];
//This is a bit ropey
if ([strval isLike:[@"*" stringByAppendingString:methodName]])
{
[containersSet addObject:[a parent]];

NSArray *children = [[a parent] children];
NSInteger index = [children indexOfObject:a];
if (index != -1)
[self scrapeMethodChildren:children index:index managedObject:transientObject];

break;
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion IGKWindowController.h
Expand Up @@ -98,7 +98,9 @@ typedef enum {
BOOL awaken;
BOOL shouldIndex;
BOOL isIndexing;


NSManagedObjectID *currentObjectIDInBrowser;

NSArray *selectedFilterDocset;
}

Expand Down
11 changes: 10 additions & 1 deletion IGKWindowController.m
Expand Up @@ -506,6 +506,8 @@ - (IBAction)changeSelectedFilterDocset:(id)sender

- (void)setBrowserActive:(BOOL)active
{
currentObjectIDInBrowser = nil;

if (active)
{
id superview = [noselectionView superview];
Expand Down Expand Up @@ -634,6 +636,7 @@ - (void)sideSearchTableChangedSelection
//If there's no selection, switch to the no selection search page
else if ([sideSearchController selection] == nil)
{
currentObjectIDInBrowser = nil;
acceptableDisplayTypes = 0;

[self setBrowserActive:NO];
Expand Down Expand Up @@ -683,9 +686,15 @@ - (void)loadDocIntoBrowser
if (![[self currentArrayController] selection])
return;

NSManagedObject *currentSelectionObject = [[self currentArrayController] selection];
if (currentObjectIDInBrowser && [[currentSelectionObject objectID] isEqual:currentObjectIDInBrowser])
return;

currentObjectIDInBrowser = [currentSelectionObject objectID];

IGKHTMLGenerator *generator = [[IGKHTMLGenerator alloc] init];
[generator setContext:[[[NSApp delegate] valueForKey:@"kitController"] managedObjectContext]];
[generator setManagedObject:[[self currentArrayController] selection]];
[generator setManagedObject:currentSelectionObject];
[generator setDisplayTypeMask:[self tableOfContentsSelectedDisplayTypeMask]];

acceptableDisplayTypes = [generator acceptableDisplayTypes];
Expand Down

0 comments on commit a1d9659

Please sign in to comment.