reports/Builder__ReportClassSourceInfo.st
author Claus Gittinger <cg@exept.de>
Thu, 28 Mar 2019 13:54:38 +0100
changeset 542 aa25a71be62a
parent 265 eb1cc3afb10c
permissions -rw-r--r--
#DOCUMENTATION by cg class: stx_goodies_builder_quickSelfTest class definition class: stx_goodies_builder_quickSelfTest class added:18 methods
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
201
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/builder/reports' }"
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Builder }"
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     5
ReportSourceInfo subclass:#ReportClassSourceInfo
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     6
	instanceVariableNames:'klass'
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     7
	classVariableNames:''
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     8
	poolDictionaries:''
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     9
	category:'Builder-Reports-Utils'
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
265
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    13
!ReportClassSourceInfo methodsFor:'accessing'!
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    14
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    15
pathNameAbsolute: aBoolean
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    16
    "Return a path (as String) to file containing the source code. The file points to the
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    17
     real source file. If `aBoolean` is true, then absolute path is returned, otherwise
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    18
     realtive path to package root is returned."
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    19
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    20
    | sourceFile packageDir |
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    21
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    22
    sourceFile := klass classFilename notNil 
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    23
                ifTrue:  [ klass classFilename ]
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    24
                ifFalse: [ (Smalltalk fileNameForClass:klass) , '.st' ].
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    25
    packageDir := aBoolean 
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    26
                    ifTrue:[ (Smalltalk getPackageDirectoryForPackage: package) pathName ]
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    27
                    ifFalse: [ package asString replaceAll: $: with: Filename separator; replaceAll: $/ with: Filename separator ].
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    28
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    29
    ^ packageDir , Filename separator , sourceFile.
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    30
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    31
    "
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    32
    (Builder::ReportSourceInfo forClass: Object inPackage: 'stx:libbasic') pathNameAbsolute: true
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    33
    (Builder::ReportSourceInfo forClass: Object inPackage: 'stx:libbasic') pathNameAbsolute: false
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    34
    "
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    35
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    36
    "Created: / 16-12-2014 / 10:25:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    37
! !
eb1cc3afb10c Added ReportSourceInfo>>pathNameAbsolute: aBoolean
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 255
diff changeset
    38
201
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
!ReportClassSourceInfo methodsFor:'initialization'!
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    40
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    41
initializeWithPackage:aSymbolOrString class:aClass 
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    42
    package := aSymbolOrString asSymbol.
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    43
    klass := aClass theNonMetaclass.
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
    self setup.
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    45
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    46
    "Created: / 29-07-2013 / 18:37:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    47
! !
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    48
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    49
!ReportClassSourceInfo methodsFor:'utilities'!
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    50
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    51
fileOutOn:aStream
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    52
    | filter |
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    53
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    54
    "JV@2012-02-02: Do not fileout extensionVersion methods, that one is filed out
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    55
     when extensions are filed out."
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    56
    (klass inheritsFrom: ProjectDefinition) ifTrue:[
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    57
        filter := [:m| m package = package 
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    58
                        and:[ (AbstractSourceCodeManager isExtensionsVersionMethodSelector:m selector) not 
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    59
                         "m selector ~~ self nameOfVersionMethodForExtensions"] 
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    60
                  ]
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    61
    ] ifFalse:[
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    62
        filter := [:mth | mth package = package ].
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    63
    ].
255
2eb81cedd55f Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 201
diff changeset
    64
    klass isLoaded ifFalse:[ klass autoload ].
2eb81cedd55f Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 201
diff changeset
    65
    klass fileOutOn:aStream 
2eb81cedd55f Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 201
diff changeset
    66
           withTimeStamp:false 
2eb81cedd55f Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 201
diff changeset
    67
           withInitialize:true 
2eb81cedd55f Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 201
diff changeset
    68
           withDefinition:true
2eb81cedd55f Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 201
diff changeset
    69
           methodFilter:filter.
201
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    70
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    71
    "Created: / 01-03-2013 / 17:51:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
255
2eb81cedd55f Fixes for Lint report.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 201
diff changeset
    72
    "Modified: / 15-12-2014 / 11:27:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
201
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    73
!
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    74
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    75
validate
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    76
    | file |
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    77
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    78
    file := (Smalltalk getPackageDirectoryForPackage: klass package) / ((Smalltalk fileNameForClass: klass) , '.st').
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    79
    ^ self validateAgainstReference: file
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    80
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    81
    "Modified: / 29-07-2013 / 14:54:35 / Jan Vrany <jan.vrany@fit.cvut.cz>"
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    82
! !
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    83
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    84
!ReportClassSourceInfo class methodsFor:'documentation'!
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    85
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
version
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
    ^ '$Header$'
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
!
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
version_CVS
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
    ^ '$Header$'
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
! !
cc1dd618738d initial checkin
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93