Project.st
changeset 4685 d145298696b7
parent 4670 21eec331e1e9
child 4688 1b27165b9f97
--- a/Project.st	Mon Sep 06 14:58:14 1999 +0200
+++ b/Project.st	Mon Sep 06 16:58:20 1999 +0200
@@ -14,8 +14,9 @@
 	instanceVariableNames:'name changeSet views directoryName properties packageName
 		repositoryDirectory repositoryModule defaultNameSpace
 		overwrittenMethods subProjects prerequisites bitmapFiles
-		documentFiles otherFiles'
-	classVariableNames:'CurrentProject SystemProject NextSequential AllProjects'
+		documentFiles otherFiles isLoaded'
+	classVariableNames:'CurrentProject SystemProject NextSequential AllProjects
+		LoadedProjects'
 	poolDictionaries:''
 	category:'System-Support'
 !
@@ -100,7 +101,7 @@
     "/ collect project info while scanning all classes
     "/ and methods ...
 
-    |packages|
+    |packages anyUnloaded|
 
     packages := IdentitySet new.
 
@@ -111,7 +112,7 @@
     ].
     Smalltalk allClassesDo:[:aClass |
         |packageID prj classFilename pkgInfo revInfo 
-         repositoryPath dir module lib|
+         repositoryPath dir module lib nm|
 
         aClass isMeta ifFalse:[
             (aClass isNamespace not or:[aClass == Smalltalk]) ifTrue:[
@@ -127,22 +128,30 @@
                     prj repositoryModule:'unknown'.
                     prj repositoryDirectory:'unknown'.
 
+                    nm := 'unknown'.
+
                     pkgInfo := aClass packageSourceCodeInfo.
                     pkgInfo notNil ifTrue:[
+                        module := pkgInfo at:#module ifAbsent:nil.
+                        module notNil ifTrue:[
+                            prj repositoryModule:module    
+                        ].
                         dir := pkgInfo at:#directory ifAbsent:nil.
                         dir notNil ifTrue:[
                             prj directory:dir    
                         ].
-                        module := pkgInfo at:#directory ifAbsent:nil.
-                        module notNil ifTrue:[
-                            prj repositoryModule:module    
-                        ].
                         lib := pkgInfo at:#library ifAbsent:nil.
                         lib notNil ifTrue:[
                             prj type:#library.
                         ].
-                        prj name:module.    
+                        prj isLoaded:true.
                     ].
+
+                    nm := (module ? 'unknown')
+                          , ':'
+                          , (dir ? (lib ? 'unknown')).
+                        
+                    prj name:nm.
                     AllProjects add:prj.
                 ].
             ].
@@ -167,6 +176,7 @@
                     prj directory:'???'.
                     prj repositoryModule:'stx'.
                     prj repositoryDirectory:'???'.
+                    prj isLoaded:true.
                     AllProjects add:prj.
                 ].
             ]
@@ -241,9 +251,9 @@
     ].
 
     CurrentProject := SystemProject.
-    AllProjects := OrderedCollection new.
-"/    AllProjects := OrderedCollection with:SystemProject.
-    self initKnownProjects.
+    AllProjects := nil.
+"/ now done lazy ...
+"/    self initKnownProjects.
 
     "
      SystemProject := nil.
@@ -260,13 +270,23 @@
 !Project class methodsFor:'accessing'!
 
 addKnownProject:aProject
-    AllProjects size == 0 ifTrue:[
-        AllProjects := OrderedCollection new.
+    |allProjects|
+
+    allProjects := self knownProjects.
+    (allProjects detect:[:p | p package = aProject package] ifNone:nil) notNil ifTrue:[
+        self warn:'Project for ' , aProject package , ' is already present.'.
+        ^ self.
     ].
+
     AllProjects add:aProject.
     self changed:#allProjects
 !
 
+addLoadedProject:aProject
+    aProject isLoaded:true.
+    self addKnownProject:aProject.
+!
+
 current
     "return the currently active project"
 
@@ -302,9 +322,36 @@
 !
 
 knownProjects
+    AllProjects isNil ifTrue:[
+        self initKnownProjects
+    ].
     ^ AllProjects ? #()
 !
 
+loadedProjects
+    ^ self knownProjects select:[:p | p isLoaded]
+!
+
+projectNamed:aProjectName
+    "retrieve the named project; return nil if not known"
+
+    ^ self knownProjects detect:[:p | p name = aProjectName] ifNone:nil.
+
+    "
+     Project projectNamed:'libbasic'
+    "
+!
+
+projectWithId:aPackageId
+    "retrieve the project with a particular id; return nil if not known"
+
+    ^ self knownProjects detect:[:p | p package = aPackageId] ifNone:nil.
+
+    "
+     Project projectWithId:#'stx:libbasic'
+    "
+!
+
 setDefaultProject
     "set the currently active project to be the SystemDEfault project"
 
@@ -542,6 +589,10 @@
     "Modified: 27.1.1997 / 12:00:47 / cg"
 !
 
+isLoaded:aBoolean
+    isLoaded := aBoolean
+!
+
 name
     "return the projects name.
      This is for the user only - shown in the projectViews label"
@@ -585,6 +636,16 @@
     "Modified: 27.1.1997 / 12:10:00 / cg"
 !
 
+package:aPackageId
+    "set the projects package identifier.
+     This identifier marks all methods and new classes which were created
+     in this project."
+
+    packageName := aPackageId
+
+    "Modified: 27.1.1997 / 12:10:00 / cg"
+!
+
 packageName
     "return the projects package identifier.
      This identifier marks all methods and new classes which were created
@@ -1851,6 +1912,29 @@
     "
 
     "Modified: 7.6.1996 / 09:16:25 / stefan"
+!
+
+isLoaded
+    "return true, if all of this project-package has been loaded
+     into the system"
+
+    |binaryModule|
+
+    isLoaded notNil ifTrue:[^ isLoaded].
+
+    "/ check for loaded class-libraries.
+    binaryModule := ObjectMemory binaryModuleInfo detect:[:i | i package = self package] ifNone:nil.
+    binaryModule notNil ifTrue:[
+        ^ true
+    ].
+
+    self halt.
+
+    "
+     (Project projectWithId:#'stx:libbasic') isLoaded
+     (Project projectWithId:#'stx:goodies/persistency') isLoaded 
+    "
+
 ! !
 
 !Project methodsFor:'specifications'!
@@ -2016,6 +2100,6 @@
 !Project class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.86 1999-09-02 21:44:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Project.st,v 1.87 1999-09-06 14:58:20 cg Exp $'
 ! !
 Project initialize!