3306 the directory info defaults to library name. |
3306 the directory info defaults to library name. |
3307 The library name may not be left blank. |
3307 The library name may not be left blank. |
3308 (this is done for backward compatibility,) |
3308 (this is done for backward compatibility,) |
3309 |
3309 |
3310 For example: |
3310 For example: |
3311 '....(libbasic)' -> module: stx directory: libbasic library: libbasic |
3311 '....(libbasic)' -> module: stx directory: libbasic library: libbasic |
3312 '....(stx:libbasic)' -> module: stx directory: libbasic library: libbasic |
3312 '....(stx:libbasic)' -> module: stx directory: libbasic library: libbasic |
3313 '....(aeg:libIECInterface)' -> module: aeg directory: libIECInterface library:libIECInterface |
3313 '....(stx:foo:libbfoo)' -> module: stx directory: foo library: libfoo |
3314 '....(stx:goodies/persistency:libdbase)' -> module: stx directory: goodies/persistency library:libdbase |
3314 '....(aeg:libIECInterface)' -> module: aeg directory: libIECInterface library:libIECInterface |
|
3315 '....(stx:goodies/persistency:libdbase)' -> module: stx directory: goodies/persistency library:libdbase |
3315 |
3316 |
3316 The way how the sourceCodeManager uses this to find the source location |
3317 The way how the sourceCodeManager uses this to find the source location |
3317 depends on the scheme used. For CVS, the module is taken as the -d arg, |
3318 depends on the scheme used. For CVS, the module is taken as the -d arg, |
3318 while the directory is prepended to the file name. |
3319 while the directory is prepended to the file name. |
3319 Other schemes may do things differently - these are not yet specified. |
3320 Other schemes may do things differently - these are not yet specified. |
3320 |
3321 |
3321 Caveat: |
3322 Caveat: |
3322 Encoding this info in the package string seems somewhat kludgy. |
3323 Encoding this info in the package string seems somewhat kludgy. |
3323 " |
3324 " |
3324 |
3325 |
3325 |owner sourceInfo packageString idx1 idx2 |
3326 |owner sourceInfo packageString idx1 idx2 |
3326 moduleString directoryString libraryString components dirComponents mgr| |
3327 moduleString directoryString libraryString components component1 component2 dirComponents mgr| |
3327 |
3328 |
3328 (owner := self owningClass) notNil ifTrue:[^ owner packageSourceCodeInfo]. |
3329 (owner := self owningClass) notNil ifTrue:[^ owner packageSourceCodeInfo]. |
3329 |
3330 |
3330 package isNil ifTrue:[^ nil]. |
3331 package isNil ifTrue:[^ nil]. |
3331 |
3332 |
3332 packageString := package asString. |
3333 packageString := package asString. |
3333 idx1 := packageString lastIndexOf:$(. |
3334 idx1 := packageString lastIndexOf:$(. |
3334 idx1 ~~ 0 ifTrue:[ |
3335 idx1 ~~ 0 ifTrue:[ |
3335 idx2 := packageString indexOf:$) startingAt:idx1+1. |
3336 idx2 := packageString indexOf:$) startingAt:idx1+1. |
3336 idx2 ~~ 0 ifTrue:[ |
3337 idx2 ~~ 0 ifTrue:[ |
3337 sourceInfo := packageString copyFrom:idx1 + 1 to:idx2 - 1 |
3338 sourceInfo := packageString copyFrom:idx1 + 1 to:idx2 - 1 |
3338 ] |
3339 ] |
3339 ] ifFalse:[ |
3340 ] ifFalse:[ |
3340 sourceInfo := packageString |
3341 sourceInfo := packageString |
3341 ]. |
3342 ]. |
3342 |
3343 |
3343 sourceInfo isNil ifTrue:[^ nil]. |
3344 sourceInfo isNil ifTrue:[^ nil]. |
3344 components := sourceInfo asCollectionOfSubstringsSeparatedBy:$:. |
3345 components := sourceInfo asCollectionOfSubstringsSeparatedBy:$:. |
3345 components size == 0 ifTrue:[ |
3346 components size == 0 ifTrue:[ |
3346 "/ moduleString := 'stx'. |
3347 "/ moduleString := 'stx'. |
3347 "/ directoryString := libraryString := ''. |
3348 "/ directoryString := libraryString := ''. |
3348 ^ nil |
3349 ^ nil |
3349 ]. |
3350 ]. |
|
3351 |
|
3352 component1 := components at:1. |
3350 components size == 1 ifTrue:[ |
3353 components size == 1 ifTrue:[ |
3351 "/ a single name given - the module becomes 'stx' or |
3354 "/ a single name given - the module becomes 'stx' or |
3352 "/ the very first directory component (if such a module exists). |
3355 "/ the very first directory component (if such a module exists). |
3353 "/ If the component includes slashes, its the directory |
3356 "/ If the component includes slashes, its the directory |
3354 "/ otherwise the library |
3357 "/ otherwise the library. |
3355 "/ |
3358 "/ |
3356 dirComponents := Filename concreteClass components:(components at:1). |
3359 dirComponents := Filename concreteClass components:component1. |
3357 |
3360 (dirComponents size > 1 |
3358 (dirComponents size > 1 |
3361 and:[(mgr := self sourceCodeManager) notNil |
3359 and:[(mgr := self sourceCodeManager) notNil |
3362 and:[mgr checkForExistingModule:dirComponents first]]) ifTrue:[ |
3360 and:[mgr checkForExistingModule:dirComponents first]]) ifTrue:[ |
3363 moduleString := dirComponents first. |
3361 moduleString := dirComponents first. |
3364 directoryString := libraryString := (Filename fromComponents:(dirComponents copyFrom:2)) asString. |
3362 directoryString := libraryString := (Filename fromComponents:(dirComponents copyFrom:2)) asString. |
3365 ] ifFalse:[ |
3363 ] ifFalse:[ |
3366 "/ non-existing; assume directory under the stx package. |
3364 moduleString := 'stx'. |
3367 moduleString := 'stx'. |
3365 directoryString := libraryString := components at:1. |
3368 (component1 startsWith:'stx/') ifTrue:[ |
3366 ]. |
3369 component1 := component1 copyFrom:5 |
3367 |
3370 ]. |
3368 (libraryString includes:$/) ifTrue:[ |
3371 directoryString := libraryString := component1. |
3369 libraryString := libraryString asFilename baseName |
3372 ]. |
3370 ] |
3373 |
|
3374 (libraryString includes:$/) ifTrue:[ |
|
3375 libraryString := libraryString asFilename baseName |
|
3376 ] |
3371 ] ifFalse:[ |
3377 ] ifFalse:[ |
3372 components size == 2 ifTrue:[ |
3378 component2 := components at:2. |
3373 "/ two components - assume its the module and the directory; |
3379 components size == 2 ifTrue:[ |
3374 "/ the library is assumed to be named after the directory |
3380 "/ two components - assume its the module and the directory; |
3375 "/ except, if slashes are in the name; then the libraryname |
3381 "/ the library is assumed to be named after the directory |
3376 "/ is the last component. |
3382 "/ except, if slashes are in the name; then the libraryname |
3377 "/ |
3383 "/ is the last component. |
3378 moduleString := components at:1. |
3384 "/ |
3379 directoryString := libraryString := components at:2. |
3385 moduleString := component1. |
3380 (libraryString includes:$/) ifTrue:[ |
3386 directoryString := libraryString := component2. |
3381 libraryString := libraryString asFilename baseName |
3387 (libraryString includes:$/) ifTrue:[ |
3382 ] |
3388 libraryString := libraryString asFilename baseName |
3383 ] ifFalse:[ |
3389 ] |
3384 "/ all components given |
3390 ] ifFalse:[ |
3385 moduleString := components at:1. |
3391 "/ all components given |
3386 directoryString := components at:2. |
3392 moduleString := component1. |
3387 libraryString := components at:3. |
3393 directoryString := component2. |
3388 ] |
3394 libraryString := components at:3. |
|
3395 ] |
3389 ]. |
3396 ]. |
3390 |
3397 |
3391 libraryString isEmpty ifTrue:[ |
3398 libraryString isEmpty ifTrue:[ |
3392 directoryString notEmpty ifTrue:[ |
3399 directoryString notEmpty ifTrue:[ |
3393 libraryString := directoryString asFilename baseName |
3400 libraryString := directoryString asFilename baseName |
3394 ]. |
3401 ]. |
3395 libraryString isEmpty ifTrue:[ |
3402 libraryString isEmpty ifTrue:[ |
3396 "/ lets extract the library from the liblist file ... |
3403 "/ lets extract the library from the liblist file ... |
3397 libraryString := Smalltalk libraryFileNameOfClass:self. |
3404 libraryString := Smalltalk libraryFileNameOfClass:self. |
3398 libraryString isNil ifTrue:[^ nil]. |
3405 libraryString isNil ifTrue:[^ nil]. |
3399 ] |
3406 ] |
3400 ]. |
3407 ]. |
3401 |
3408 |
3402 moduleString isEmpty ifTrue:[ |
3409 moduleString isEmpty ifTrue:[ |
3403 moduleString := 'stx'. |
3410 moduleString := 'stx'. |
3404 ]. |
3411 ]. |
3405 directoryString isEmpty ifTrue:[ |
3412 directoryString isEmpty ifTrue:[ |
3406 directoryString := libraryString. |
3413 directoryString := libraryString. |
3407 ]. |
3414 ]. |
3408 |
3415 |
3409 ^ IdentityDictionary |
3416 ^ IdentityDictionary |
3410 with:(#module->moduleString) |
3417 with:(#module->moduleString) |
3411 with:(#directory->directoryString) |
3418 with:(#directory->directoryString) |
3412 with:(#library->libraryString) |
3419 with:(#library->libraryString) |
3413 |
3420 |
3414 " |
3421 " |
3415 Object packageSourceCodeInfo |
3422 Object packageSourceCodeInfo |
3416 View packageSourceCodeInfo |
3423 View packageSourceCodeInfo |
3417 Model packageSourceCodeInfo |
3424 Model packageSourceCodeInfo |