tools/extensions.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Tue, 21 May 2013 00:17:00 +0100
branchperformance-optimizations
changeset 2603 000dff7f0e7b
parent 2482 109ed9ecf4f7
child 2731 13f5be2bf83b
permissions -rw-r--r--
Optimization of JavaClass>>includesBehavior: Do not build a list of all interfaces. Instead. enaumerate them and return true onf first match.

"{ Package: 'stx:libjava/tools' }"!

!ConfigurableFeatures class methodsFor:'queries-features'!

hasGroovySupport
    "Actually, same as hasJavaToolingSupport, byt maybe
     we'll separate later"

    ^self hasJavaToolingSupport


    "
     ConfigurableFeatures hasGroovySupport
     ConfigurableFeatures includesFeature:#GroovySupport
    "

    "Created: / 18-02-2012 / 16:57:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!ConfigurableFeatures class methodsFor:'queries-features'!

hasJavaToolingSupport
    "/ use Smalltalk-at to trick the dependency/prerequisite generator

    ^self hasJavaSupport
	and:[(Smalltalk at:#'stx_libjava_tools') notNil]


    "
     ConfigurableFeatures hasJavaToolingSupport
     ConfigurableFeatures includesFeature:#JavaToolingSupport
    "

    "Created: / 18-02-2012 / 16:44:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaObject methodsFor:'inspecting'!

inspectorClass

    "Return an inspector class for the receiver.
     Bit ugly, but reasonably fast :-)"

    | cls nm ifaces |
    nm := (cls := self class) name.

    (nm == #'java/util/ArrayList') ifTrue:[
	^JavaListInspectorView
    ].
    (nm == #'java/util/LinkedList') ifTrue:[
	^JavaListInspectorView
    ].
    (nm == #'java/util/HashMap') ifTrue:[
	^JavaMapInspectorView
    ].
    (nm == #'java/util/TreeMap') ifTrue:[
	^JavaMapInspectorView
    ].
    (nm == #'java/util/HashSet') ifTrue:[
	^JavaSetInspectorView
    ].
    ifaces := self class allInterfaces.
    ifaces do:[:i|
	i name == #'java/util/List' ifTrue:[
	    ^JavaListInspectorView
	].
	i name == #'java/util/Map' ifTrue:[
	    ^JavaMapInspectorView
	].
	i name == #'java/util/Set' ifTrue:[
	    ^JavaSetInspectorView
	].
    ].
    ^super inspectorClass

    "Created: / 04-12-2011 / 16:50:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!Tools::NewSystemBrowser methodsFor:'menu actions-class'!

classMenuNewGroovyClass

    | currentClass superClass code category |
    currentClass := self theSingleSelectedClass.
    currentClass notNil ifTrue:[
	superClass := currentClass theNonMetaclass superclass.
	superClass notNil ifTrue:[
	    superClass isJavaClass ifFalse:[
		superClass := Java classForName:'java.lang.Object'.
	    ]
	]
    ] ifFalse:[
	superClass := Java classForName:'java.lang.Object'.
    ].

    category := self hasCategorySelected
		    ifTrue:[self selectedCategoriesValue first]
		    ifFalse:[Compiler defaultMethodCategory]. "/ '* As yet uncategorized *'


    code := GroovyLanguage instance
		    classTemplateFor: superClass
		    in: category
		    asNamespace: false
		    private: false.

    self showCode: code.
    self setAcceptAction: [:theCode | self doAcceptGroovyClassDefinition: theCode asString ].
    self codeAspect:#newClassDefinition.

    "Created: / 18-02-2012 / 17:16:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!stx_libjava_tools class methodsFor:'documentation'!

extensionsVersion_HG

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