reports/Builder__ReportClassSourceInfo.st
changeset 265 eb1cc3afb10c
parent 255 2eb81cedd55f
--- a/reports/Builder__ReportClassSourceInfo.st	Tue Dec 16 11:29:54 2014 +0100
+++ b/reports/Builder__ReportClassSourceInfo.st	Tue Dec 16 11:30:03 2014 +0100
@@ -10,6 +10,32 @@
 !
 
 
+!ReportClassSourceInfo methodsFor:'accessing'!
+
+pathNameAbsolute: aBoolean
+    "Return a path (as String) to file containing the source code. The file points to the
+     real source file. If `aBoolean` is true, then absolute path is returned, otherwise
+     realtive path to package root is returned."
+
+    | sourceFile packageDir |
+
+    sourceFile := klass classFilename notNil 
+                ifTrue:  [ klass classFilename ]
+                ifFalse: [ (Smalltalk fileNameForClass:klass) , '.st' ].
+    packageDir := aBoolean 
+                    ifTrue:[ (Smalltalk getPackageDirectoryForPackage: package) pathName ]
+                    ifFalse: [ package asString replaceAll: $: with: Filename separator; replaceAll: $/ with: Filename separator ].
+
+    ^ packageDir , Filename separator , sourceFile.
+
+    "
+    (Builder::ReportSourceInfo forClass: Object inPackage: 'stx:libbasic') pathNameAbsolute: true
+    (Builder::ReportSourceInfo forClass: Object inPackage: 'stx:libbasic') pathNameAbsolute: false
+    "
+
+    "Created: / 16-12-2014 / 10:25:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !ReportClassSourceInfo methodsFor:'initialization'!
 
 initializeWithPackage:aSymbolOrString class:aClass