SmallSenseTypeCollectorCache.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 05 Aug 2013 10:27:05 +0100
changeset 52 3ca8f7181ed5
parent 32 658f47bc231e
permissions -rw-r--r--
Factored out common support for code completion.

"{ Package: 'jv:smallsense' }"

CacheDictionary subclass:#SmallSenseTypeCollectorCache
	instanceVariableNames:'typingJob'
	classVariableNames:'SharedCache'
	poolDictionaries:''
	category:'SmallSense-Roel Typer'
!


!SmallSenseTypeCollectorCache class methodsFor:'initialization'!

initialize
    "Invoked at system start or when the class is dynamically loaded."

    "/ please change as required (and remove this comment)

    SharedCache := self new: 1024.
    SharedCache startBackgroundTypingJob.

    "Modified: / 28-04-2011 / 22:00:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmallSenseTypeCollectorCache class methodsFor:'accessing'!

shared

    ^SharedCache

    "Created: / 28-04-2011 / 19:48:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmallSenseTypeCollectorCache methodsFor:'accessing'!

at: class

    self assert: class isBehavior.
    ^self 
        at: class 
        ifAbsentPut:
        [self newCollectorFor: class].
    "
        SmallSenseTypeCollectorCache shared removeAll. 
        SmallSenseTypeCollectorCache shared at: SmallSenseTypeCollector
    "

    "Created: / 28-04-2011 / 19:49:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 29-04-2011 / 08:06:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmallSenseTypeCollectorCache methodsFor:'private'!

newCollectorFor: class

    | c sc  |
    c := SmallSenseTypeCollector onClass: class.
    sc := class superclass 
            ifNil:[nil]
            ifNotNil:[self at: class superclass].
    sc ifNotNil:[c master: sc].            
    typingJob notNil ifTrue:[typingJob add: c].
    ^c

    "Created: / 28-04-2011 / 20:42:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 28-04-2011 / 23:03:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

startBackgroundTypingJob

    typingJob := BackgroundQueueProcessingJob
        named: 'Typing job'
        on: [:collector|collector type].
    "typingJob start"

    "Created: / 28-04-2011 / 21:59:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 18-05-2011 / 23:31:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!SmallSenseTypeCollectorCache class methodsFor:'documentation'!

version_HG

    ^ '$Changeset: <not expanded> $'
!

version_SVN
    ^ '$Id: SmallSenseTypeCollectorCache.st 7823 2011-11-26 16:55:59Z vranyj1 $'
! !


SmallSenseTypeCollectorCache initialize!