#REFACTORING by cg
class: Smalltalk
added: #addIdeTopDirectoryToPackagePath
changed:
#addIDETopDirectoryToPackagePath
#addWorkspaceDirectoryToPackagePath
#initSystemPath
path fixes
--- a/Smalltalk.st Fri Oct 14 17:54:48 2016 +0200
+++ b/Smalltalk.st Fri Oct 14 17:58:55 2016 +0200
@@ -523,6 +523,7 @@
PackagePath := OperatingSystem defaultPackagePath.
].
self addWorkspaceDirectoryToPackagePath.
+ self addIdeTopDirectoryToPackagePath.
"
Smalltalk initSystemPath
@@ -6764,6 +6765,36 @@
!Smalltalk class methodsFor:'system management-files'!
+addIdeTopDirectoryToPackagePath
+ "{ Pragma: +optSpace }"
+
+ |topDirectory|
+
+ (topDirectory := OperatingSystem pathOfSTXExecutable) notNil ifTrue:[
+ topDirectory := topDirectory asFilename.
+ (topDirectory directory / 'stc') exists ifTrue:[
+ topDirectory := topDirectory directory.
+ ] ifFalse:[
+ (topDirectory directory directory / 'stc') exists ifTrue:[
+ topDirectory := topDirectory directory directory.
+ ] ifFalse:[
+ (topDirectory directory directory directory / 'stc') exists ifTrue:[
+ topDirectory := topDirectory directory directory directory.
+ ] ifFalse:[
+ topDirectory := nil
+ ].
+ ].
+ ].
+ topDirectory notNil ifTrue:[
+ "/ one above "stx"
+ topDirectory := topDirectory directory pathName.
+ (PackagePath includes:topDirectory) ifFalse:[
+ PackagePath add:topDirectory
+ ]
+ ]
+ ].
+!
+
addWorkspaceDirectoryToPackagePath
"{ Pragma: +optSpace }"
@@ -6771,7 +6802,10 @@
(workspaceDirectory := UserPreferences current workspaceDirectory) notNil ifTrue:[
(workspaceDirectory := workspaceDirectory asFilename) exists ifTrue:[
- PackagePath addFirst:workspaceDirectory pathName
+ workspaceDirectory := workspaceDirectory pathName.
+ (PackagePath includes:workspaceDirectory) ifFalse:[
+ PackagePath addFirst:workspaceDirectory
+ ]
]
].
!