How to debug issues related to the code index

The class GtPharoIndex GtIndex subclass: #GtPharoIndex instanceVariableNames: 'globalCache selectorCache shouldRecomputeSubclasses selectorWordCache classWordCache' classVariableNames: '' package: 'GToolkit-Pharo-Index' indexes all the code in the image and provides fast operations for browsing code, like looking for senders and implementors of methods.

Lifecycle scripts

To inspect the current index:

GtPharoIndex current
  

To rebuild the index:

GtPharoIndex initializeCache
  

To disable the index (should be rebuilt afterwards to be up to date)

GtPharoIndex current unsubscribeFromSystem
  

Subscribing back to the system announcer

GtPharoIndex current subscribeToSystem
  

Checking for corruptions

Inspecting the cache objects should show advices in case there are corruptions.

Alternatively, the script below looks for methods that are in the cache but are not in any class from the image.

GtPharoIndex current selectorCache notInstalledMethods
  

It can be useful to check for corruptions in implementors or senders separately.

(GtPharoIndex current selectorCache  
	gtImplementersAreInstalled: GtNoAdvice new) result toArray wait
  
(GtPharoIndex current selectorCache  
	gtReferencesAreInstalled: GtNoAdvice new) result toArray wait
  

Ouerying the cache

The main way to query the cache is to look for senders and implementors.

One way to do the query is using synchronized methods that work with full selector names.

GtPharoIndex current implementersOf:  #drawOnSpartaCanvas:
  

There are several ways to query implementers:

GtPharoIndex current allImplementersOf:  #drawOnSpartaCanvas:
  
GtPharoIndex current installedImplementersOf:  #drawOnSpartaCanvas:
  
GtPharoIndex current sendersOf:  #drawOnSpartaCanvas:
  

There are several ways to query senders:

GtPharoIndex current allSendersOf:  #drawOnSpartaCanvas:
  
GtPharoIndex current installedSendersOf:  #drawOnSpartaCanvas:
  

Another way to query is using async methods that work with partial selector names.

GtPharoIndex current asyncImplementersForWord: 'drawOnSparta'
  
GtPharoIndex current asyncSendersForWord: 'drawOnSparta'
  

Update parts of the cache

We can update parts of the cache manually.

GtPharoIndex current 
	recompileMethodsIn: BlElement.
  
GtPharoIndex current 
	recompiledMethod: BlElement>>#addChild:at:as:
  

Other scripts

Finding subscriptions of GtPharoIndex GtIndex subclass: #GtPharoIndex instanceVariableNames: 'globalCache selectorCache shouldRecomputeSubclasses selectorWordCache classWordCache' classVariableNames: '' package: 'GToolkit-Pharo-Index' to the current SystemAnnouncer Announcer subclass: #SystemAnnouncer instanceVariableNames: 'suspended private storedAnnouncements' classVariableNames: '' package: 'System-Announcements-Core'

subscriptions := OrderedCollection new.
SystemAnnouncer uniqueInstance  subscriptions 
	subscriptionsOf: GtPharoIndex current  
	do: [ :each | subscriptions add: each ].
subscriptions 
  

Enabling/disabling the debug mode

GtPharoIndex enableDebugMode
  
GtPharoIndex disableDebugMode