ProjectDefinition.st
changeset 12371 9c1aeddd92b2
parent 12370 98519f85d7f4
child 12372 f2e1ae83b5a4
--- a/ProjectDefinition.st	Mon Oct 26 20:39:21 2009 +0100
+++ b/ProjectDefinition.st	Mon Oct 26 22:53:18 2009 +0100
@@ -84,6 +84,103 @@
 
 !ProjectDefinition class methodsFor:'instance creation'!
 
+definitionClassForMonticelloPackage:aMonicelloPackagename
+    ^ self definitionClassForMonticelloPackage:aMonicelloPackagename createIfAbsent:false
+
+    "
+     self definitionClassForMonticelloPackage:'foobar'
+    "
+!
+
+definitionClassForMonticelloPackage:aMonicelloPackagename createIfAbsent:createIfAbsent
+    ^ self allSubclasses 
+        detect:[:eachProjectDefinition |
+            eachProjectDefinition monticelloPackageName = aMonicelloPackagename ]
+        ifNone:[
+            |dfn squeakPackageInfo|
+
+            createIfAbsent ifTrue:[
+                dfn := ApplicationDefinition 
+                    definitionClassForPackage:'mc:',aMonicelloPackagename createIfAbsent:true projectType:GUIApplicationType.
+
+                "/ if the squeak-stuff is loaded, use it.
+                squeakPackageInfo := PackageInfo allSubclasses 
+                                            detect:[:pi | pi new packageName = aMonicelloPackagename] ifNone:nil.
+
+                squeakPackageInfo notNil ifTrue:[
+                    dfn classNames:(squeakPackageInfo new classes collect:[:each | each name]).
+                ].
+            ] ifFalse:[
+                nil
+            ]
+        ]
+
+    "
+     self definitionClassForMonticelloPackage:'foobar'
+     self definitionClassForMonticelloPackage:'foobar' createIfAbsent:true
+    "
+!
+
+definitionClassForPackage:aPackageID
+    ^ self definitionClassForPackage:aPackageID createIfAbsent:false
+
+    "Modified: / 17-08-2006 / 14:33:35 / cg"
+!
+
+definitionClassForPackage:aPackageID createIfAbsent:doCreateIfAbsent
+    ^ self definitionClassForPackage:aPackageID createIfAbsent:doCreateIfAbsent projectType:nil
+
+    "Modified: / 23-08-2006 / 14:29:15 / cg"
+!
+
+definitionClassForPackage: aPackageID createIfAbsent: doCreateIfAbsent projectType:typeOrNil
+    |packageDefinitionClassName class|
+
+    packageDefinitionClassName := ProjectDefinition initialClassNameForDefinitionOf:aPackageID.
+    class := Smalltalk classNamed:packageDefinitionClassName.
+    class isNil ifTrue:[
+        doCreateIfAbsent ifTrue:[
+            class := self newForPackage:aPackageID.
+            "setup before prerequisites are defined"
+            class setupForType:typeOrNil.
+            "/ look what is there and include it; is this ok ?
+            class compileDescriptionMethods 
+        ].
+    ] ifFalse:[
+        typeOrNil notNil ifTrue:[
+            class projectType == typeOrNil ifFalse: [
+                class setupForType:typeOrNil.
+            ].
+        ].
+    ].
+    ^ class
+
+    "Created: / 23-08-2006 / 14:29:21 / cg"
+    "Modified: / 23-08-2006 / 15:35:26 / cg"
+!
+
+definitionClassForPackage:newProjectID projectType:typeOrNil createIfAbsent:createIfAbsent
+    ^ (self definitionClassForType:typeOrNil)
+            definitionClassForPackage:newProjectID 
+            createIfAbsent:createIfAbsent
+            projectType:typeOrNil
+
+    "Created: / 23-08-2006 / 14:28:53 / cg"
+!
+
+definitionClassForType: type
+    "answer the class that describes a give project type"
+
+    (type = LibraryType) ifTrue:[ ^ LibraryDefinition ].
+    (type = GUIApplicationType) ifTrue:[ ^ ApplicationDefinition ].
+    (type = NonGUIApplicationType) ifTrue:[ ^ ApplicationDefinition ].
+    (type = 'Application') ifTrue:[ ^ ApplicationDefinition ].     "/ temporary - for backward compat.
+    self error:'unknown project type'.
+
+    "Created: / 17-08-2006 / 14:46:28 / cg"
+    "Modified: / 23-08-2006 / 13:49:27 / cg"
+!
+
 newForPackage:packageID
     ^ self 
         newNamed:(self initialClassNameForDefinitionOf:packageID) 
@@ -739,16 +836,40 @@
 
 !ProjectDefinition class methodsFor:'accessing - packaging'!
 
+classNames:aCollectionOfClassNames
+    "set the set of classes"
+
+    self classNamesAndAttributes:aCollectionOfClassNames usingCompiler:nil
+!
+
+classNamesAndAttributes:newSpec usingCompiler:compilerOrNil
+    "set the set of classes. and attributes 
+     Because this requires compilation of my classList-method, a compiler can be passed in, 
+     which has to do the job.
+     (this is used by the systembrowser to pass in a CodeGeneratorTool with undo support)"
+
+    |oldSpec newCode|
+
+    oldSpec := self classNamesAndAttributes.
+    newSpec = oldSpec ifTrue: [^ self].
+
+    newCode := self classNamesAndAttributes_codeFor:newSpec.
+
+    (compilerOrNil ? self compilerClass)
+        compile:newCode
+        forClass:self theMetaclass
+        inCategory:'description - contents'.
+!
+
 excludeClasses:toExclude usingCompiler:compilerOrNil
     "exclude (remove from classList) a number of classes. 
      Because this requires compilation of my classList-method, a compiler can be passed in, 
      which has to do the job.
      (this is used by the systembrowser to pass in a CodeGeneratorTool with undo support)"
 
-    |oldSpec newSpec newCode|
-
-    oldSpec := self classNamesAndAttributes.
-    newSpec := oldSpec copy.
+    |newSpec|
+
+    newSpec := self classNamesAndAttributes copy.
 
     toExclude do:[:eachClassToExclude |
         |className|
@@ -762,15 +883,7 @@
             ].
         ].
     ].
-
-    newSpec = oldSpec ifTrue: [^ self].
-
-    newCode := self classNamesAndAttributes_codeFor:newSpec.
-
-    (compilerOrNil ? self compilerClass)
-        compile:newCode
-        forClass:self theMetaclass
-        inCategory:'description - contents'.
+    self classNamesAndAttributes:newSpec usingCompiler:compilerOrNil
 
     "Created: / 30-08-2007 / 18:28:28 / cg"
 !
@@ -781,7 +894,7 @@
      which has to do the job.
      (this is used by the systembrowser to pass in a CodeGeneratorTool with undo support)"
 
-    |oldSpec newSpec newCode|
+    |oldSpec newSpec|
 
     oldSpec := self classNamesAndAttributes.
     newSpec := oldSpec copy.
@@ -806,14 +919,7 @@
         ].
     ].
 
-    newSpec = oldSpec ifTrue: [^ self].
-
-    newCode := self classNamesAndAttributes_codeFor:newSpec.
-
-    (compilerOrNil ? self compilerClass)
-        compile:newCode
-        forClass:self theMetaclass
-        inCategory:'description - contents'.
+    self classNamesAndAttributes:newSpec usingCompiler:compilerOrNil
 !
 
 makeClassesAutoloaded:toMakeAutoloaded usingCompiler:compilerOrNil
@@ -822,10 +928,9 @@
      which has to do the job.
      (this is used by the systembrowser to pass in a CodeGeneratorTool with undo support)"
 
-    |oldSpec newCode newSpec|
-
-    oldSpec := self classNamesAndAttributes.
-    newSpec := oldSpec copy.
+    |newSpec|
+
+    newSpec := self classNamesAndAttributes copy.
 
     toMakeAutoloaded do:[:eachClassToMakeAutoloaded |
         |className|
@@ -849,14 +954,7 @@
         ].
     ].
 
-    newSpec = oldSpec ifTrue: [^ self].
-
-    newCode := self classNamesAndAttributes_codeFor:newSpec.
-
-    (compilerOrNil ? self compilerClass)
-        compile:newCode
-        forClass:self theMetaclass
-        inCategory:'description - contents'.
+    self classNamesAndAttributes:newSpec usingCompiler:compilerOrNil
 ! !
 
 !ProjectDefinition class methodsFor:'accessing - svn'!
@@ -4445,6 +4543,8 @@
 !ProjectDefinition class methodsFor:'private-prerequisites'!
 
 addReferencesToClassesFromGlobalsIn:aSetOfClasses to:usedClassReasons
+    "helper for searchForPreRequisites"
+
     aSetOfClasses
         do:[:aClass |
             self
@@ -4464,6 +4564,8 @@
 !
 
 addReferencesToClassesFromGlobalsInMethods:someMethods to:usedClassReasons
+    "helper for searchForPreRequisites"
+
     someMethods do:[:method |
         |resources|
 
@@ -4666,93 +4768,6 @@
     "Created: / 18-08-2006 / 13:37:56 / cg"
 !
 
-definitionClassForMonticelloPackage:aMonicelloPackagename
-    ^ self definitionClassForMonticelloPackage:aMonicelloPackagename createIfAbsent:false
-
-    "
-     self definitionClassForMonticelloPackage:'foobar'
-    "
-!
-
-definitionClassForMonticelloPackage:aMonicelloPackagename createIfAbsent:createIfAbsent
-    ^ self allSubclasses 
-        detect:[:eachProjectDefinition |
-            eachProjectDefinition monticelloPackageName = aMonicelloPackagename ]
-        ifNone:[
-            createIfAbsent ifTrue:[
-                ApplicationDefinition 
-                    definitionClassForPackage:'mc:',aMonicelloPackagename createIfAbsent:true projectType:GUIApplicationType.                
-            ] ifFalse:[
-                nil
-            ]
-        ]
-
-    "
-     self definitionClassForMonticelloPackage:'foobar'
-     self definitionClassForMonticelloPackage:'foobar' createIfAbsent:true
-    "
-!
-
-definitionClassForPackage:aPackageID
-    ^ self definitionClassForPackage:aPackageID createIfAbsent:false
-
-    "Modified: / 17-08-2006 / 14:33:35 / cg"
-!
-
-definitionClassForPackage:aPackageID createIfAbsent:doCreateIfAbsent
-    ^ self definitionClassForPackage:aPackageID createIfAbsent:doCreateIfAbsent projectType:nil
-
-    "Modified: / 23-08-2006 / 14:29:15 / cg"
-!
-
-definitionClassForPackage: aPackageID createIfAbsent: doCreateIfAbsent projectType:typeOrNil
-    |packageDefinitionClassName class|
-
-    packageDefinitionClassName := ProjectDefinition initialClassNameForDefinitionOf:aPackageID.
-    class := Smalltalk classNamed:packageDefinitionClassName.
-    class isNil ifTrue:[
-        doCreateIfAbsent ifTrue:[
-            class := self newForPackage:aPackageID.
-            "setup before prerequisites are defined"
-            class setupForType:typeOrNil.
-            "/ is this ok ?
-            class compileDescriptionMethods 
-        ].
-    ] ifFalse:[
-        typeOrNil notNil ifTrue:[
-            class projectType == typeOrNil ifFalse: [
-                class setupForType:typeOrNil.
-            ].
-        ].
-    ].
-    ^ class
-
-    "Created: / 23-08-2006 / 14:29:21 / cg"
-    "Modified: / 23-08-2006 / 15:35:26 / cg"
-!
-
-definitionClassForPackage:newProjectID projectType:typeOrNil createIfAbsent:createIfAbsent
-    ^ (self definitionClassForType:typeOrNil)
-            definitionClassForPackage:newProjectID 
-            createIfAbsent:createIfAbsent
-            projectType:typeOrNil
-
-    "Created: / 23-08-2006 / 14:28:53 / cg"
-!
-
-definitionClassForType: type
-    "answer the class that describes a give project type"
-
-    (type = LibraryType) ifTrue:[ ^ LibraryDefinition ].
-    (type = GUIApplicationType) ifTrue:[ ^ ApplicationDefinition ].
-    (type = NonGUIApplicationType) ifTrue:[ ^ ApplicationDefinition ].
-    (type = 'Application') ifTrue:[ ^ ApplicationDefinition ].
-    self error:'unknown project type'.
-
-    "Created: / 17-08-2006 / 14:46:28 / cg"
-    "Modified: / 23-08-2006 / 13:49:27 / cg"
-!
-
 extensionMethods
     "list my extension methods.
      Project must be loaded - otherwise an error is reported here.
@@ -4994,11 +5009,11 @@
 !ProjectDefinition class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.275 2009-10-26 19:39:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.276 2009-10-26 21:53:18 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.275 2009-10-26 19:39:21 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.276 2009-10-26 21:53:18 cg Exp $'
 ! !
 
 ProjectDefinition initialize!