jv_smallsense.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 18 Sep 2013 01:29:45 +0100
changeset 91 920e30d788dc
parent 86 3b615594edf6
child 98 c21c3e61a377
permissions -rw-r--r--
Minor fixes in inferencer.

"{ Package: 'jv:smallsense' }"

LibraryDefinition subclass:#jv_smallsense
	instanceVariableNames:''
	classVariableNames:'Swizzled'
	poolDictionaries:''
	category:'* Projects & Packages *'
!


!jv_smallsense class methodsFor:'initialization'!

initialize

    "This should be logically done in postload, but postload
     is not called when classlibrary is built-in (i.e., not loaded
     by Smalltalk loadPackage: ...). This is indeed a bug. "

    Swizzled := false.
    self hasAllExtensionsLoaded ifTrue:[
        self swizzle
    ].

    "Created: / 19-08-2013 / 15:24:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-09-2013 / 12:29:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!jv_smallsense class methodsFor:'description'!

excludedFromPreRequisites
    "list all packages which should be ignored in the automatic
     preRequisites scan. See #preRequisites for more."

    ^ #(
    )
!

mandatoryPreRequisites
    "list all required mandatory packages.
     Packages are mandatory, if they contain superclasses of the package's classes
     or classes which are extended by this package.
     This list can be maintained manually or (better) generated and
     updated by scanning the superclass hierarchies
     (the browser has a menu function for that)"

    ^ #(
        #'stx:goodies/refactoryBrowser/helpers'    "BrowserEnvironment - superclass of SmallSense::SmalltalkUnacceptedMethodEnvironment "
        #'stx:goodies/refactoryBrowser/lint'    "RBLintRule - extended "
        #'stx:libbasic'    "Autoload - superclass of SmallSense::BaseTestClass "
        #'stx:libcomp'    "AbstractSyntaxHighlighter - superclass of SmallSense::SmalltalkParser "
        #'stx:libhtml'    "HTMLDocumentFrame - extended "
        #'stx:libtool'    "AbstractSettingsApplication - superclass of SmallSense::SettingsAppl "
        #'stx:libview'    "DeviceGraphicsContext - extended "
        #'stx:libview2'    "ApplicationModel - superclass of SmallSense::CompletionWindow "
        #'stx:libwidg2'    "DoWhatIMeanSupport - extended "
    )
!

preRequisites
    "list all required packages.
     This list can be maintained manually or (better) generated and
     updated by scanning the superclass hierarchies and looking for
     global variable accesses. (the browser has a menu function for that)
     Howevery, often too much is found, and you may want to explicitely
     exclude individual packages in the #excludedFromPrerequisites method."

    ^ #(
        #'stx:goodies/refactoryBrowser/helpers'    "BrowserEnvironment - superclass of SmallSenseUnacceptedMethodEnvironment "
        #'stx:goodies/refactoryBrowser/lint'    "RBLintRule - superclass of extended RBTransformationRule "
        #'stx:goodies/roeltyper'    "TypeCollector - superclass of SmallSenseTypeCollector "
        #'stx:goodies/sunit'
        #'stx:libbasic'    "Collection - superclass of SmallSenseTypeCollectorCache "
        #'stx:libbasic2'    "CacheDictionary - superclass of SmallSenseTypeCollectorCache "
        #'stx:libbasic3'    "ChangeSet - referenced by RBTransformationRule>>fixes: "
        #'stx:libcomp'    "Parser - superclass of SmallSenseAbstractInstvarInterfaceExtractor "
        #'stx:libhtml'    "HTMLDocumentFrame - superclass of extended HTMLDocumentView "
        #'stx:libtool'    "Tools::BackgroundSourceProcessingService - superclass of SmallSenseService "
        #'stx:libview'    "DeviceGraphicsContext - superclass of extended HTMLDocumentFrame "
        #'stx:libview2'    "SimpleDialog - superclass of SmallSenseCompletionWindow "
        #'stx:libwidg'
        #'stx:libwidg2'    "HierarchicalItem - superclass of SmallSenseParseNodeInspector::ParseNodeItem "
    )
!

referencedPreRequisites
    "list all packages containing classes referenced by the packages's members.
     This list can be maintained manually or (better) generated and
     updated by looking for global variable accesses
     (the browser has a menu function for that)
     However, often too much is found, and you may want to explicitely
     exclude individual packages in the #excludedFromPreRequisites method."

    ^ #(
        #'stx:goodies/refactoryBrowser/parser'    "RBFormatter - referenced by SmallSense::SmalltalkEditSupport>>keyPressReturn "
        #'stx:libbasic2'    "BackgroundQueueProcessingJob - referenced by SmallSense::Manager>>initialize "
        #'stx:libbasic3'    "ChangeSet - referenced by RBTransformationRule>>fixes: "
    )
!

subProjects
    "list packages which are known as subprojects.
     The generated makefile will enter those and make there as well.
     However: they are not forced to be loaded when a package is loaded;
     for those, redefine requiredPrerequisites"

    ^ #(
    )
! !

!jv_smallsense class methodsFor:'description - actions'!

postLoadAction
    "/ Swizzle methods. Note, that if they are already swizzled,
    "/ self swizzle is noop.

    self swizzle.

    "Created: / 02-09-2013 / 12:30:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!jv_smallsense class methodsFor:'description - compilation'!

additionalRules_bc_dot_mak
    "obsolete - kept for compatibility with old project files"

    ^ '
# HACK to make it compilable under CVS stx:libtool
$(INCLUDE_TOP)\stx\libtool\Tools__NavigationState.$(H): $(INCLUDE_TOP)\stx\libtool\Tools_NavigationState.$(H)
        copy $(INCLUDE_TOP)\stx\libtool\Tools_NavigationState.$(H) $(INCLUDE_TOP)\stx\libtool\Tools__NavigationState.$(H)
'

    "Created: / 04-09-2013 / 08:28:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

additionalRules_make_dot_proto
    "allows for additional rules to be added to the make.proto file."

    ^ '
# HACK to make it compilable under CVS stx:libtool
$(INCLUDE_TOP)/stx/libtool/Tools__NavigationState.$(H): $(INCLUDE_TOP)/stx/libtool/Tools_NavigationState.$(H)
        ln -s $(INCLUDE_TOP)/stx/libtool/Tools_NavigationState.$(H) $(INCLUDE_TOP)/stx/libtool/Tools__NavigationState.$(H)
'

    "Created: / 04-09-2013 / 08:02:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!jv_smallsense class methodsFor:'description - contents'!

classNamesAndAttributes
    "lists the classes which are to be included in the project.
     Each entry in the list may be: a single class-name (symbol),
     or an array-literal consisting of class name and attributes.
     Attributes are: #autoload or #<os> where os is one of win32, unix,..."

    ^ #(
        "<className> or (<className> attributes...) in load order"
        (#'SmallSense::BaseTestClass' autoload)
        #'SmallSense::CompletionWindow'
        #'SmallSense::CriticsWindow'
        #'SmallSense::EditService'
        #'SmallSense::EditSupport'
        (#'SmallSense::FinderTests' autoload)
        #'SmallSense::Info'
        #'SmallSense::Manager'
        #'SmallSense::PO'
        #'SmallSense::ParseNodeInspector'
        #'SmallSense::ParseNodeVisitor'
        #'SmallSense::ParseTreeIndex'
        #'SmallSense::ParseTreeIndexEntry'
        #'SmallSense::Position'
        #'SmallSense::Recognizer'
        (#'SmallSense::RecognizerTests' autoload)
        #'SmallSense::ResultSet'
        #'SmallSense::SelectorNode'
        #'SmallSense::SettingsAppl'
        #'SmallSense::SmalltalkChecker'
        #'SmallSense::SmalltalkLintAnnotation'
        #'SmallSense::SmalltalkLintHighlighter'
        #'SmallSense::SmalltalkLintService'
        #'SmallSense::SmalltalkParser'
        (#'SmallSense::SmalltalkParserTests' autoload)
        #'SmallSense::SmalltalkQuickFixer'
        #'SmallSense::SmalltalkSyntaxHighlighter'
        #'SmallSense::SmalltalkUnacceptedMethodEnvironment'
        #'SmallSense::SyntaxHighlightingService'
        (#'SmallSense::TestCase' autoload)
        #'SmallSense::Type'
        #'SmallSense::TypeHolder'
        #'jv_smallsense'
        #'SmallSense::ClassInfo'
        #'SmallSense::ClassPO'
        #'SmallSense::ClassType'
        #'SmallSense::ConstantPO'
        #'SmallSense::Finder'
        #'SmallSense::GenericEditSupport'
        #'SmallSense::JavaEditSupport'
        #'SmallSense::MethodInfo'
        #'SmallSense::MethodPO'
        #'SmallSense::SmalltalkEditSupport'
        #'SmallSense::SmalltalkInferencer'
        #'SmallSense::SnippetPO'
        #'SmallSense::UnionType'
        #'SmallSense::UnknownType'
        #'SmallSense::VariablePO'
    )
!

extensionMethodNames
    "lists the extension methods which are to be included in the project.
     Entries are 2-element array literals, consisting of class-name and selector."

    ^ #(
        ParseNode isSelector
        AssignmentNode childNamesAndValuesDo:
        AssignmentNode inferedType
        AssignmentNode inferedType:
        MessageNode childNamesAndValuesDo:
        ParseErrorNode childNamesAndValuesDo:
        ParseNode childNamesAndValuesDo:
        ParseNode inferedType
        ParseNode inferedType:
        PrimaryNode childNamesAndValuesDo:
        StatementNode childNamesAndValuesDo:
        StatementNode inferedType
        StatementNode inferedType:
        UserPreferences smallSenseEnabled
        UserPreferences smallSenseEnabled:
        VariableNode isGlobalOrPrivateClass
        'ConfigurableFeatures class' hasSmallSenseEnabled
        UserPreferences smallSenseBackgroundLintEnabled
        UserPreferences smallSenseBackgroundLintEnabled:
        RBLintRule fixes:
        RBTransformationRule fixes:
        UserPreferences smallSenseBackgroundTypingEnabled
        UserPreferences smallSenseBackgroundTypingEnabled:
        HTMLDocumentView doQuickFix:
        'Tools::CodeHighlightingService class' new
        DoWhatIMeanSupport smallSenseCodeCompletionForClass:context:codeView:
        #'Tools::NavigationState' smallSenseSelectedClasses
        'Tools::CodeCompletionService class' smallSenseIsUsefulFor:
    )
! !

!jv_smallsense class methodsFor:'description - project information'!

applicationIconFileName
    "Return the name (without suffix) of an icon-file (the app's icon); will be included in the rc-resource file"

    ^ nil
    "/ ^ self applicationName
!

companyName
    "Return a companyname which will appear in <lib>.rc"

    ^ 'eXept Software AG'
!

description
    "Return a description string which will appear in vc.def / bc.def"

    ^ 'Smalltalk/X Class library'
!

legalCopyright
    "Return a copyright string which will appear in <lib>.rc"

    ^ 'Copyright Claus Gittinger 1988-2011\nCopyright eXept Software AG 1998-2011'
!

productName
    "Return a product name which will appear in <lib>.rc"

    ^ 'Smalltalk/X'
! !

!jv_smallsense class methodsFor:'description - svn'!

svnRepositoryUrlString
    "Return a SVN repository URL of myself.
     (Generated since 2011-04-08)
    "        

    ^ '$URL: https://vranyj1@swing.fit.cvut.cz/svn/stx/libtool/branches/jv/smallsense/jv_smallsense.st $'
!

svnRevisionNr
    "Return a SVN revision number of myself.
     This number is updated after a commit"

    ^ "$SVN-Revision:"'7962            '"$"
! !

!jv_smallsense class methodsFor:'swizzling'!

swizzle
    "Swizzle all methods annotated as <swizzle:>"

    Swizzled ifTrue:[ ^ self ].
    self extensionMethods do:[:m|self swizzle: m].
    Swizzled := true.


    "
    jv_smallsense swizzle
    "

    "Created: / 19-08-2013 / 14:54:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 02-09-2013 / 12:30:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

swizzle: method
    "Swizzle the method if it is annotated by <swizzle:> annotation"

    | annotation |

    annotation := method annotationAt: #swizzle:.
    annotation notNil ifTrue:[
        self swizzle: method as: (annotation argumentAt: 1).
    ]

    "Created: / 19-08-2013 / 14:53:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

swizzle: originalMethod as: selector
    "Given an extension method, swizzle it into method's class
     under given selector."

    | cls overwrittenMethod swizzledMethod |

    cls := originalMethod mclass.
    overwrittenMethod := cls compiledMethodAt: selector.
    overwrittenMethod isNil ifTrue:[
        "/ Oops, method gone?
        self breakPoint: #jv.
        ^ self.
    ].

    self assert: originalMethod numArgs == overwrittenMethod numArgs.

    swizzledMethod := originalMethod copy.
    "/ Now, fake the package and source of swizzled method
    "/ so on fileout, original code gets filed out.
    swizzledMethod setPackage: overwrittenMethod package.
    swizzledMethod setCategory: overwrittenMethod category.
    swizzledMethod source: overwrittenMethod source.

    "/ Install the swizzled method
    cls methodDictionary at: selector put: swizzledMethod

    "Created: / 19-08-2013 / 14:01:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 19-08-2013 / 15:03:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!jv_smallsense class methodsFor:'documentation'!

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

version_SVN
    ^ '$Id: jv_smallsense.st 7967 2012-04-04 11:12:00Z vranyj1 $'
! !


jv_smallsense initialize!