ProjectChecker.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Fri, 01 Feb 2019 23:46:31 +0000
branchjv
changeset 4396 5333bef41730
parent 4199 89ebbba27db6
child 4576 ba355d431e55
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     1
"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     3
              All Rights Reserved
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     4
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     5
 This software is furnished under a license and may be used
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     6
 only in accordance with the terms of that license and with the
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     9
 other person.  No title to or ownership of the software is
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    10
 hereby transferred.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    11
"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    12
"{ Package: 'stx:libbasic3' }"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    13
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
    14
"{ NameSpace: Smalltalk }"
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
    15
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    16
Object subclass:#ProjectChecker
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
    17
	instanceVariableNames:'packages currentPackage currentPackageDef classes methods
3686
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
    18
		problems phase checkExtensionsOnly rulesApplied'
2967
c5f1d6853ad1 changed: #checkClassListConsistency (class order)
vrany
parents: 2966
diff changeset
    19
	classVariableNames:''
c5f1d6853ad1 changed: #checkClassListConsistency (class order)
vrany
parents: 2966
diff changeset
    20
	poolDictionaries:''
c5f1d6853ad1 changed: #checkClassListConsistency (class order)
vrany
parents: 2966
diff changeset
    21
	category:'System-Support-Projects'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    22
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    23
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    24
!ProjectChecker class methodsFor:'documentation'!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    25
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    26
copyright
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    27
"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    28
 COPYRIGHT (c) 2006 by eXept Software AG
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    29
              All Rights Reserved
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    30
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    31
 This software is furnished under a license and may be used
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    32
 only in accordance with the terms of that license and with the
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    33
 inclusion of the above copyright notice.   This software may not
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    34
 be provided or otherwise made available to, or used by, any
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    35
 other person.  No title to or ownership of the software is
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    36
 hereby transferred.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    37
"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    38
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    39
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    40
documentation
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    41
"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    42
    A simple project checker that can search whole projects or individual
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
    43
    classes or methods for various problems that may cause build problems,
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
    44
    such as:
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    45
        - inconsistent/messed up project definition class
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    46
        - method code problems
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    47
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
    48
    NOTE: this is not a lint. It only checks for inconsitent configuration
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
    49
    (projectDefinition class data vs. real data) and compilability (stc limitations).
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
    50
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    51
    NOTE: Not yet finished. This code is meant as a single central entry for all the
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    52
    source code management tools like SCM Utilities, NewSystemBrowser ets. That code
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    53
    will be refactored later once this tool prooves itself useful and mature enough.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    54
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    55
    [author:]
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    56
        Jan Vrany <jan.vrany@fit.cvut.cz>
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    57
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    58
    [instance variables:]
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    59
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    60
    [class variables:]
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    61
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    62
    [see also:]
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    63
        Tools::ProjectCheckerBrowser
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    64
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    65
"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    66
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    67
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    68
examples
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    69
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    70
    "
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    71
        ProjectChecker check: 'stx:libbasic'
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    72
        ProjectChecker check: 'stx:libtool'
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    73
        ProjectChecker check: 'stx:libbasic3'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    74
    "
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    75
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    76
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    77
!ProjectChecker class methodsFor:'instance creation'!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    78
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    79
forPackage: packageId
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    80
    ^self new
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    81
        package: packageId;
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    82
        yourself.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    83
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    84
    "Created: / 25-07-2012 / 18:00:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    85
!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    86
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    87
new
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    88
    "return an initialized instance"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    89
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    90
    ^ self basicNew initialize.
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    91
! !
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    92
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    93
!ProjectChecker class methodsFor:'checking'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    94
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    95
check: package
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    96
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    97
    ^self new check: package
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    98
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    99
    "Created: / 11-01-2012 / 16:46:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   100
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   101
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   102
!ProjectChecker methodsFor:'accessing'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   103
3148
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   104
checkExtensionsOnly:aBoolean
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   105
    checkExtensionsOnly := aBoolean.
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   106
!
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   107
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   108
classes: aCollection
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   109
    classes := aCollection.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   110
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   111
    "Created: / 13-02-2012 / 17:06:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   112
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   113
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   114
methods
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   115
    ^ methods
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   116
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   117
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   118
methods:something
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   119
    methods := something.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   120
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   121
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   122
package:packageId
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   123
    "Adds `packageId` to set of checked packages"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   124
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   125
    (packages includes: packageId) ifFalse:[ 
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   126
        packages add: packageId 
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   127
    ].
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   128
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   129
    "Modified (comment): / 22-02-2014 / 22:03:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   130
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   131
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   132
problems
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   133
    ^ problems
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   134
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   135
    "Modified: / 23-02-2012 / 15:14:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   136
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   137
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   138
!ProjectChecker methodsFor:'checking'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   139
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   140
check
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   141
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   142
    problems removeAll.
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   143
    packages do:[:each |
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   144
        currentPackage := each.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   145
        currentPackageDef := ProjectDefinition definitionClassForPackage: currentPackage.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   146
        currentPackageDef isNil ifTrue:[
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   147
            self addProblem: (ProjectProblem newProjectDefinitionDoesNotExist package: currentPackage).
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   148
            ^self    
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   149
        ].
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   150
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   151
        ActivityNotification raiseRequestWith:self errorString:'Checking package...'.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   152
        self checkPackage.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   153
        (checkExtensionsOnly ? false) ifFalse:[
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   154
            ActivityNotification raiseRequestWith:self errorString:'Checking classes...'.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   155
            self checkClasses.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   156
        ].
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   157
        ActivityNotification raiseRequestWith:self errorString:'Checking methods...'.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   158
        self checkMethods.
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   159
    ].
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   160
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   161
    "Created: / 11-01-2012 / 16:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   162
    "Modified: / 22-02-2014 / 21:59:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   163
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   164
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   165
check: package
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   166
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   167
    self package: package.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   168
    self check.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   169
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   170
    "Created: / 11-01-2012 / 16:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   171
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   172
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   173
!ProjectChecker methodsFor:'checks-individual'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   174
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   175
checkClassListConsistency
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   176
    "Checks whether all classes listed in #classNamesAndAttributes are present
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   177
    and if all present classes are listed"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   178
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   179
    |classesInImage classesInDescription classesInDescriptionChecked onlyInDescription onlyInImage|
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   180
    "WARNING: Copy/paste of ProjectDefinition>>validateDescription"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   181
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   182
    classesInImage := Smalltalk allClasses select:[:cls | (cls package = currentPackage) and:[cls isPrivate not]].
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   183
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   184
    "/ classesInDescription := self classes asIdentitySet.
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   185
    classesInDescription := OrderedCollection new.
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   186
    ( (currentPackageDef compiled_classNames_common)
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   187
    , (currentPackageDef compiled_classNamesForPlatform:(OperatingSystem platformName))
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   188
    , (currentPackageDef autoloaded_classNames)) do:[:nm |
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   189
        |cls|
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   190
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   191
        cls := Smalltalk at:nm asSymbol.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   192
        cls isNil ifTrue:[
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   193
            self addProblem: (ProjectProblem newClassListedButDoesNotExist className: nm)
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   194
        ] ifFalse:[
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   195
            cls package ~= currentPackage ifTrue:[
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   196
                self addProblem: (ProjectProblem newClassListedButInOtherPackage className: nm)
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   197
            ] ifFalse:[
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   198
                classesInDescription add:cls.
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   199
            ]
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   200
        ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   201
    ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   202
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   203
    classesInDescriptionChecked := Set new.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   204
    classesInDescription do:[:eachClass |
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   205
        (classesInDescriptionChecked includes: eachClass) ifTrue:[
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   206
            self addProblem: (ProjectProblem newClassListedMultipleTimes className: eachClass name)
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   207
        ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   208
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   209
        eachClass sharedPoolNames do:[:eachPoolName |
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   210
            |pool|
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   211
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   212
            pool := eachClass nameSpace classNamed:eachPoolName.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   213
            pool isNil ifTrue:[
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   214
                eachClass nameSpace ~~ Smalltalk ifTrue:[
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   215
                    pool := Smalltalk classNamed:eachPoolName.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   216
                ]
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   217
            ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   218
            pool isNil ifTrue:[
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   219
                self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   220
                    (ProjectProblem newClassUsesPoolButItDoesNotExist
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   221
                        className: eachClass name;
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   222
                        poolName: eachPoolName).
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   223
            ] ifFalse:[
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   224
                pool isSharedPool ifFalse:[
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   225
                    self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   226
                        (ProjectProblem newClassUsesPoolButItIsNotASharedPool
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   227
                            className: eachClass name;
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   228
                            poolName: eachPoolName).                
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   229
                ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   230
            ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   231
        ].
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   232
2966
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
   233
        (eachClass superclass notNil "/Care about classes with nil superclass - Object & Autoload
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
   234
            and:[eachClass superclass package == eachClass package]) ifTrue:[
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   235
            (classesInDescriptionChecked includes: eachClass superclass) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   236
                self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   237
                    (ProjectProblem newClassListedBeforeItsSuperclass
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   238
                        className: eachClass name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   239
                        superClassName: eachClass superclass name)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   240
            ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   241
        ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   242
        eachClass sharedPools do:[:eachPool|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   243
            eachPool package == eachClass package ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   244
                (classesInDescriptionChecked includes: eachPool) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   245
                    self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   246
                        (ProjectProblem newClassListedBeforeItsPool
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   247
                            className: eachClass name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   248
                            poolName: eachPool name)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   249
                ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   250
            ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   251
        ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   252
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   253
        classesInDescriptionChecked add: eachClass.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   254
    ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   255
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   256
    classesInImage ~= classesInDescription ifTrue:[
2856
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   257
        "This is done later in checkClassesListedInProjectDefinition:"
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   258
"/        onlyInImage := (classesInImage reject:[:cls | classesInDescription includes:cls]).
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   259
"/        onlyInImage do:[:cls|
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   260
"/            self addProblem: 
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   261
"/                (ProjectProblem newClassListedButInOtherPackage className: cls name).
2856
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   262
"/        ].
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   263
        onlyInDescription := (classesInDescription reject:[:cls | classesInImage includes:cls]).
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   264
        onlyInDescription do:[:cls|
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   265
            self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   266
                (ProjectProblem newClassListedButDoesNotExist className: cls name)
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   267
        ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   268
    ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   269
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   270
    "Created: / 11-01-2012 / 17:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   271
    "Modified: / 22-02-2014 / 21:46:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2718
vrany
parents: 2716
diff changeset
   272
!
vrany
parents: 2716
diff changeset
   273
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   274
checkClassesAutoloadedSuperclasse: aCollection"of Class"
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   275
    currentPackageDef classNamesAndAttributesDo:[:clsnm :attributes|
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   276
        | cls superclass |
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   277
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   278
        cls := Smalltalk at: clsnm.
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   279
        (aCollection includes: cls) ifTrue:[
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   280
            (attributes includes: #autoload) ifFalse:[
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   281
                "/ Care for Object!!
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   282
                superclass := cls superclass.
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   283
                superclass notNil ifTrue:[
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   284
                    | superDef |
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   285
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   286
                    superDef := ProjectDefinition definitionClassForPackage: superclass package.
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   287
                    superDef isNil ifTrue:[
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   288
                        problems add:
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   289
                            (ProjectProblem newClassIsCompiledButSuperclassProjectDefinitionIsMissing
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   290
                                            package: currentPackage;
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   291
                                            className: clsnm;
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   292
                                            yourself)   
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   293
                    ] ifFalse:[
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   294
                        (superDef isAutoloaded:superclass) ifTrue:[
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   295
                            problems add:
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   296
                                (ProjectProblem newClassIsCompiledButSuperclassIsAutoloaded
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   297
                                    package: currentPackage;
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   298
                                    className: clsnm;
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   299
                                    yourself)
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   300
                        ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   301
                    ]
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   302
                ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   303
            ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   304
        ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   305
    ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   306
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   307
    "Created: / 20-09-2013 / 11:08:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   308
    "Modified: / 05-10-2013 / 12:45:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   309
!
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   310
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   311
checkClassesForMethodsInNoProject:classesToCheck 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   312
    | checker |
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   313
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   314
    checker := [:cls | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   315
        cls 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   316
            selectorsAndMethodsDo:[:sel :mth | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   317
                (mth package isNil or:[ mth package == PackageId noProjectID ]) ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   318
                    "Sigh, special hack for Expecco"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   319
                    ((cls name = 'Expecco::AbstractApplication class' and:[ sel = 'flags' ]) or:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   320
                     (cls name = 'Expecco::Browser class' and:[ sel = 'flags' ])]) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   321
                        self addProblem:(ProjectProblem newMethodInNoPackage className:cls name
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   322
                                    selector:sel).
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   323
                    ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   324
                ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   325
            ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   326
    ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   327
    classesToCheck do:[:class | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   328
        checker value:class theMetaclass.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   329
        checker value:class theNonMetaclass.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   330
    ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   331
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   332
    "Created: / 13-02-2012 / 18:18:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   333
!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   334
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   335
checkClassesForNonQualifiedSharedPools: classesToCheck 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   336
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   337
    classesToCheck do:[:cls|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   338
        cls sharedPoolNames do:[:poolName|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   339
            (Smalltalk at: poolName asSymbol) isNil ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   340
                | ns |
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   341
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   342
                ns := cls nameSpace.
4189
51a4e49728af #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 4078
diff changeset
   343
                (ns == Smalltalk or:[(ns at: poolName asSymbol) isNil]) ifTrue:[
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   344
                    self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   345
                        (ProjectProblem newClassUsesPoolButItIsNotASharedPool
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   346
                                className: cls name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   347
                                poolName: poolName)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   348
                ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   349
            ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   350
        ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   351
    ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   352
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   353
    "Created: / 13-09-2012 / 16:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   354
!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   355
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   356
checkClassesListedInProjectDefinition: classesToCheck
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   357
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   358
    | classNamesListed |
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   359
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   360
    classNamesListed := currentPackageDef classNames.
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   361
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   362
    classesToCheck do:[:class|
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   363
        (class isPrivate not and:[(classNamesListed includes: class name) not]) ifTrue:[
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   364
            self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   365
                (ProjectProblem newClassNotListed className: class name).
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   366
        ]
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   367
    ].
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   368
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   369
    "Created: / 13-02-2012 / 18:18:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   370
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   371
2718
vrany
parents: 2716
diff changeset
   372
checkExtensionsListConsistency
vrany
parents: 2716
diff changeset
   373
    "Checks whether all extensions listed in #extensionMethodNames are present
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   374
     and if all extension methods are listed.
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   375
     Also check if any regular or extension method is also listed in some other package
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   376
     (which may happen after a move, if the original package was not updated)"
2718
vrany
parents: 2716
diff changeset
   377
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   378
    | extensionsListed extensionsPresent allOtherExtensions checkMethod|
2718
vrany
parents: 2716
diff changeset
   379
vrany
parents: 2716
diff changeset
   380
    extensionsListed := OrderedCollection new.
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   381
    currentPackageDef extensionMethodNames pairWiseDo:[:cls :sel|
2718
vrany
parents: 2716
diff changeset
   382
        extensionsListed add: (Array with: cls with: sel)
vrany
parents: 2716
diff changeset
   383
    ].
vrany
parents: 2716
diff changeset
   384
    extensionsPresent := OrderedCollection new.
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   385
    currentPackageDef searchForExtensions do:[:each|
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   386
        "JV@2012-09-07: Do not take Java methods into an account, they
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   387
         should not be listed in extensionMethodNames.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   388
         They are loaded lazily by JavaClassReader and if listed here,
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   389
         they would cause an error if the package is loaded from source.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   390
         Sort of a HACK, indeed"
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   391
        each mclass theNonMetaclass isJavaClass ifFalse:[
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   392
            extensionsPresent add: (Array with: each mclass name with: each selector)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   393
        ].
2718
vrany
parents: 2716
diff changeset
   394
    ].
vrany
parents: 2716
diff changeset
   395
vrany
parents: 2716
diff changeset
   396
    (extensionsListed \ extensionsPresent) do:[:clsAndSel|
3167
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   397
        |cls clsName selector|
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   398
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   399
        clsName := clsAndSel first.
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   400
        selector := clsAndSel second.
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   401
        (cls := Smalltalk classNamed: clsName) isNil ifTrue:[
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   402
            self addProblem: 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   403
                (ProjectProblem newExtensionMethodsClassDoesNotExist
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   404
                    className: clsName selector: selector).                            
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   405
        ] ifFalse:[
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   406
            (cls compiledMethodAt:selector) isNil ifTrue:[
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   407
                self addProblem: 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   408
                    (ProjectProblem newExtensionMethodListedButDoesNotExist
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   409
                        className: clsName selector: selector). 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   410
            ] ifFalse:[
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   411
                self addProblem: 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   412
                    (ProjectProblem newExtensionMethodListedButInDifferentPackage
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   413
                        className: clsName selector: selector). 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   414
            ]
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   415
        ]
2718
vrany
parents: 2716
diff changeset
   416
    ].
vrany
parents: 2716
diff changeset
   417
vrany
parents: 2716
diff changeset
   418
    (extensionsPresent \ extensionsListed) do:[:clsAndSel|
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   419
         self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   420
            (ProjectProblem newExtensionMethodNotListed
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   421
                className: clsAndSel first selector: clsAndSel second).                            
2718
vrany
parents: 2716
diff changeset
   422
    ].
vrany
parents: 2716
diff changeset
   423
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   424
    allOtherExtensions := Set new.
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   425
    ProjectDefinition allSubclassesDo:[:eachOther |
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   426
        eachOther ~~ currentPackageDef ifTrue:[
3805
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   427
            Error handle:[:ex |
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   428
                Transcript showCR:('ProjetChecker [warning]: ignored error while asking ',eachOther name,' for extensionMethods').
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   429
                ex return
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   430
            ] do:[
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   431
                allOtherExtensions addAll:(eachOther extensionMethods).
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   432
            ].
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   433
        ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   434
    ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   435
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   436
    checkMethod :=
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   437
        [:eachMethodHere |
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   438
            (allOtherExtensions includes:eachMethodHere) ifTrue:[
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   439
                |otherProjectDefinitions|
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   440
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   441
                otherProjectDefinitions := OrderedCollection new.
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   442
                "/ where is it?
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   443
                ProjectDefinition allSubclassesDo:[:someOtherPackage |
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   444
                    someOtherPackage ~~ currentPackageDef ifTrue:[
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   445
                        (someOtherPackage extensionMethods includes:eachMethodHere) ifTrue:[
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   446
                            otherProjectDefinitions add:someOtherPackage
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   447
                        ]
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   448
                    ]
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   449
                ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   450
                otherProjectDefinitions notEmptyOrNil ifTrue:[
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   451
                    otherProjectDefinitions sortBySelector:#package.
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   452
                    self addProblem: 
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   453
                       (ProjectProblem newMethodListedInOtherPackage
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   454
                           className: (eachMethodHere mclass name) selector: (eachMethodHere selector);
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   455
                           otherProjectDefinitionClasses:otherProjectDefinitions;
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   456
                           yourself).                            
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   457
                ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   458
            ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   459
        ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   460
3795
fb9b9489df78 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3791
diff changeset
   461
    currentPackageDef compiled_classesForPlatform do:[:eachClass |
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   462
        eachClass instAndClassMethodsDo:[:m |
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   463
            (m package = currentPackage) ifTrue:[ checkMethod value:m].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   464
        ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   465
    ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   466
    currentPackageDef extensions do:checkMethod.
2718
vrany
parents: 2716
diff changeset
   467
!
vrany
parents: 2716
diff changeset
   468
vrany
parents: 2716
diff changeset
   469
checkExtensionsPrerequisites
vrany
parents: 2716
diff changeset
   470
    "Checks whether packages of all extensions method classes are listed
vrany
parents: 2716
diff changeset
   471
     in package prerequisites"
vrany
parents: 2716
diff changeset
   472
3116
9ddba2316fec class: ProjectChecker
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   473
    |preRequisites|
9ddba2316fec class: ProjectChecker
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   474
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   475
    preRequisites := currentPackageDef effectivePreRequisites.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   476
    currentPackageDef searchForExtensions do:[:mthd|
3116
9ddba2316fec class: ProjectChecker
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   477
        (preRequisites includes: mthd mclass package) ifFalse:[
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   478
"/            self problem: ('%3 required by extension method but not in prerequisites' bindWith: mthd mclass package)
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   479
"/                 description: ('An extension method %1>>%2 extends class in package %3 but the package is not listed in package''s prerequisited. This leads into missing methods and strange bugs when application is compiled and run!!' bindWith: mthd class with: mthd selector with: mthd class package)
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   480
"/                 severity: #error data: mthd
2718
vrany
parents: 2716
diff changeset
   481
         ].
vrany
parents: 2716
diff changeset
   482
    ]
vrany
parents: 2716
diff changeset
   483
vrany
parents: 2716
diff changeset
   484
    "Created: / 12-01-2012 / 12:41:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   485
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   486
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   487
checkMethodCodingStyle: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   488
    "Checks for various coding style violations such as 'self halt' or
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   489
     improper indentation :-)"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   490
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   491
    "To be implemented"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   492
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   493
    "Created: / 11-04-2012 / 12:38:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   494
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   495
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   496
checkMethodSTCCompilability1: method into: problemIssue
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   497
    "Checks is the method can be compiled by STC based on Parser error/warnings"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   498
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   499
    | lang compiler |
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   500
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   501
    lang := method programmingLanguage.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   502
    lang isSmalltalk ifFalse:[ ^ self ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   503
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   504
    compiler := lang compilerClass new.
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   505
    compiler
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   506
        compile:method source
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   507
        forClass:method mclass
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   508
        inCategory:'others'
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   509
        notifying:problemIssue
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   510
        install:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   511
        skipIfSame:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   512
        silent:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   513
        foldConstants:true
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   514
        ifFail:[ ].
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   515
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   516
    compiler usedGlobals do:[:nm | 
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   517
        (nm startsWith:Smalltalk undeclaredPrefix) ifTrue:[
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   518
            problemIssue 
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   519
                addWarning:'Contains unresolved reference to: ',(nm copyFrom:(Smalltalk undeclaredPrefix size + 1))
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   520
                from:0 to:0
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   521
        ]
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   522
    ].
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   523
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   524
    "Created: / 11-04-2012 / 15:31:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   525
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   526
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   527
checkMethodSTCCompilability2: method into: problemIssue
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   528
    | env rules violations |
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   529
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   530
    "/ Check if SmallLint is available...
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   531
    (Smalltalk at:#RBCompositeLintRule) isNil ifTrue:[ ^ self ].
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   532
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   533
    env := SelectorEnvironment new.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   534
    env addClass: method mclass selector: method selector.
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   535
3686
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   536
    rulesApplied isNil ifTrue:[
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   537
        rulesApplied := RBCompositeLintRule allRules 
3804
7accb0e1e60e class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
   538
                    selectRules:[:rule | (rule isTaggedAs: #stc) and:[ rule severity == #error ]].
3686
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   539
    ].
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   540
    rules := rulesApplied.
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   541
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   542
    rules runOnEnvironment: env.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   543
3804
7accb0e1e60e class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
   544
    violations := rules selectRules:[:each | each result includesSelector: method selector in: method mclass ]. 
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   545
    violations flatten do:[:each | 
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   546
        problemIssue addViolation: each
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   547
    ].
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   548
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   549
    "Created: / 11-04-2012 / 15:54:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   550
    "Modified: / 29-05-2014 / 16:59:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   551
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   552
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   553
checkMethodSTCCompilability: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   554
    "Checks is the method can be compiled by STC (since STC won't compile
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   555
     everything bytecode compiler/jit compiler does, sigh"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   556
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   557
    | cls issue1 issue2 |
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   558
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   559
    "No need to check the method if the class is autoloaded"
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   560
    cls := method mclass theNonMetaclass.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   561
    cls isPrivate ifTrue:[ 
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   562
        cls := cls topOwningClass.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   563
    ].
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   564
    (currentPackageDef autoloaded_classNames includes: cls name) ifTrue:[
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   565
        ^ self
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   566
    ].
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   567
3570
52c403d0b881 Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3563
diff changeset
   568
    "/ Speed optimization: do not check method if it was compiled by 
52c403d0b881 Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3563
diff changeset
   569
    "/ stc and hasn't been changed since then.
52c403d0b881 Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3563
diff changeset
   570
    method byteCode isNil ifTrue:[ ^ self ].
52c403d0b881 Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3563
diff changeset
   571
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   572
    issue1 := ProjectProblem newMethodCompilabilityIssue1.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   573
    issue1 method: method.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   574
    self checkMethodSTCCompilability1: method into: issue1.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   575
    issue1 hasIssue ifTrue:[
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   576
        self addProblem: issue1
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   577
    ].
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   578
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   579
    issue2 := ProjectProblem newMethodCompilabilityIssue2.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   580
    issue2 method: method.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   581
    self checkMethodSTCCompilability2: method into: issue2.
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   582
    issue2 hasIssue ifTrue:[
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   583
        self addProblem: issue2
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   584
    ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   585
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   586
    "Created: / 11-04-2012 / 12:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3570
52c403d0b881 Speed optimization: do not check method for STC compilabiliry if it was compiled by stc and hasn't been changed since then.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3563
diff changeset
   587
    "Modified (format): / 29-05-2014 / 16:54:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   588
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   589
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   590
checkMethodSourceCode: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   591
    "Checks, whether method's source code is both
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   592
     available and parseable. Return true if the code
2966
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
   593
     is syntactically correct, false otherwise"
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   594
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   595
    | source |
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   596
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   597
    [    
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   598
        source := method source.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   599
    ] on: Error do:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   600
        self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   601
            (ProjectProblem newMethodSourceNotAvailable method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   602
        ^false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   603
    ].
2913
041df7e717bc changed: #checkMethodSourceCode:
vrany
parents: 2910
diff changeset
   604
    method programmingLanguage isSmalltalk ifFalse:[ ^ false ].
041df7e717bc changed: #checkMethodSourceCode:
vrany
parents: 2910
diff changeset
   605
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   606
    [
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   607
        (Parser parseMethod: method source) == #Error ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   608
            self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   609
                (ProjectProblem newMethodSourceCorrupted method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   610
            ^false.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   611
        ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   612
    ] on: Error do:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   613
        self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   614
            (ProjectProblem newMethodSourceCorrupted method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   615
        ^false.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   616
    ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   617
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   618
    ^true
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   619
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   620
    "Created: / 11-04-2012 / 12:29:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   621
!
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   622
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   623
checkSubProjects
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   624
    "Checks whether all subprojects listed in #subprojects are present."
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   625
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   626
    |isValidName subProjectsListed invalidNames validNames subProjectsNotPresent|
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   627
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   628
    isValidName := 
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   629
        [:prj |
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   630
            (prj first isLetter
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   631
            and:[ ((prj occurrencesOf:$:) <= 1)
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   632
            and:[ ((prj copyReplaceAll:$: with:$/) 
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   633
                        conform:[:ch | ch isLetterOrDigit or:['/-_.' includes:ch]]) ]])
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   634
        ].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   635
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   636
    subProjectsListed := currentPackageDef subProjects.
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   637
    invalidNames := subProjectsListed select:[:prj | (isValidName value:prj) not].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   638
    validNames := subProjectsListed select:isValidName.
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   639
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   640
    subProjectsNotPresent := validNames select:[:prj | prj asPackageId projectDefinitionClass isNil].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   641
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   642
    invalidNames do:[:eachBadName |                                
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   643
        self addProblem: (ProjectProblem newInvalidPackageName badName:eachBadName).
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   644
    ].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   645
    subProjectsNotPresent do:[:eachMissing |                                
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   646
        self addProblem: (ProjectProblem newProjectDefinitionDoesNotExist missing: eachMissing).
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   647
    ].
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   648
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   649
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   650
!ProjectChecker methodsFor:'checks-private'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   651
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   652
checkClasses
3535
f02b2535dd15 Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   653
    | classesToCheck |
f02b2535dd15 Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   654
f02b2535dd15 Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   655
    classesToCheck := classes notNil ifTrue:[ classes ] ifFalse:[ Smalltalk allClasses ].
3618
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   656
    classesToCheck := classesToCheck select:[:each | each programmingLanguage isSmalltalk and:[ each package = currentPackage ] ].
3589
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   657
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   658
    (currentPackageDef notNil and:[currentPackageDef isFolderForProjectsDefinition]) ifTrue:[
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   659
        classesToCheck remove:currentPackageDef ifAbsent:[]
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   660
    ].
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   661
3535
f02b2535dd15 Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   662
    self checkClasses: classesToCheck.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   663
3589
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   664
    (currentPackageDef notNil and:[currentPackageDef isFolderForProjectsDefinition]) ifTrue:[
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   665
        classesToCheck do:[:eachClass |
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   666
            self addProblem: 
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   667
                (ProjectProblem newClassShouldNotBeInPackage className: eachClass name).
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   668
        ].
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   669
    ].
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   670
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   671
    "Created: / 11-01-2012 / 16:55:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3618
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   672
    "Modified: / 31-07-2014 / 09:47:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   673
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   674
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   675
checkClasses: classesToCheck
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   676
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   677
    self checkClassesListedInProjectDefinition: classesToCheck.
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   678
    self checkClassesForMethodsInNoProject:classesToCheck.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   679
    self checkClassesForNonQualifiedSharedPools:classesToCheck.
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   680
    self checkClassesAutoloadedSuperclasse:classesToCheck.
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   681
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   682
    "Created: / 13-02-2012 / 18:18:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   683
    "Modified: / 20-09-2013 / 11:08:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   684
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   685
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   686
checkMethod: method
3618
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   687
    method programmingLanguage isSmalltalk ifTrue:[
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   688
        (self checkMethodSourceCode: method) ifTrue:[
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   689
            "/OK, method's source code is fine, perform more checks on
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   690
            "/ it's source code.
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   691
3618
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   692
            "/ ActivityNotification raiseRequestWith:self errorString:'Checking stc compilability...'.
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   693
            self checkMethodSTCCompilability: method.
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   694
            "/ ActivityNotification raiseRequestWith:self errorString:'Checking coding style...'.
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   695
            self checkMethodCodingStyle: method.
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   696
        ]
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   697
    ].
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   698
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   699
    "Created: / 11-04-2012 / 12:27:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3618
851e57ea8ad1 Fix for non-Smalltalk classes: do not check classes nor methods which are not Smalltalk ones.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3607
diff changeset
   700
    "Modified: / 31-07-2014 / 09:48:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   701
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   702
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   703
checkMethods
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   704
    methods notEmptyOrNil ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   705
        self checkMethods: methods.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   706
        ^self.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   707
    ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   708
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   709
    self checkMethods:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   710
        (Iterator on:[:whatToDo|
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   711
            | classesToCheck |
3233
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   712
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   713
            classes notNil ifTrue:[
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   714
                classesToCheck := classes
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   715
            ] ifFalse:[
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   716
                classesToCheck := (Smalltalk allClasses select:[:cls | (cls package = currentPackage)]).
3233
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   717
            ].
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   718
            classesToCheck do:[:cls|
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   719
                cls theNonMetaclass withAllPrivateClassesDo:[:eachClass |
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   720
                    ActivityNotification raiseRequestWith:self errorString:('Checking %1...' bindWith:eachClass name).
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   721
                    eachClass instAndClassSelectorsAndMethodsDo:[:s :m | 
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   722
                        m package = currentPackage ifTrue:[
3148
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   723
                            ((checkExtensionsOnly ? false) not
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   724
                            or:[ m package ~~ cls package "isExtension" ]) ifTrue:[
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   725
                                whatToDo value:m
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   726
                            ]
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   727
                        ]
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   728
                    ]
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   729
                ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   730
            ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   731
        ])
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   732
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   733
    "Created: / 11-01-2012 / 16:55:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   734
    "Modified: / 22-02-2014 / 21:48:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   735
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   736
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   737
checkMethods: methodsToCheck
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   738
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   739
    methodsToCheck do:[:m|self checkMethod: m].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   740
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   741
    "Created: / 11-04-2012 / 12:16:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   742
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   743
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   744
checkPackage
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   745
    currentPackageDef isNil ifTrue:[^ self].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   746
    currentPackageDef isFolderForProjectsDefinition ifFalse:[
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   747
        (checkExtensionsOnly ? false) ifFalse:[
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   748
            self checkClassListConsistency.
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   749
        ].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   750
        self checkExtensionsListConsistency.
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   751
        self checkExtensionsPrerequisites.
3148
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   752
    ].
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   753
    self checkSubProjects.
2718
vrany
parents: 2716
diff changeset
   754
2716
9a74597bcd4b Do not use annotations as stc crashes when compiling them
vrany
parents: 2707
diff changeset
   755
    "add more here..."
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   756
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   757
    "Created: / 11-01-2012 / 16:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   758
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   759
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   760
!ProjectChecker methodsFor:'initialization'!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   761
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   762
initialize
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   763
    "Invoked when a new instance is created."
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   764
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   765
    "/ please change as required (and remove this comment)
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   766
    packages := OrderedCollection new.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   767
    "/ currentPackage := nil.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   768
    "/ currentPackageDef := nil.
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   769
    "/ classes := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   770
    "/ methods := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   771
    problems := List new.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   772
    "/ phase := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   773
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   774
    "/ super initialize.   -- commented since inherited method does nothing
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   775
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   776
    "Modified: / 22-02-2014 / 21:41:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   777
! !
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   778
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   779
!ProjectChecker methodsFor:'reporting'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   780
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   781
addProblem: aProjectProblem
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   782
Transcript showCR:aProjectProblem.
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   783
    aProjectProblem package: currentPackage.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   784
    problems isNil ifTrue:[problems := OrderedCollection new].
3548
265e326c3bd0 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
   785
    problems add: aProjectProblem.
265e326c3bd0 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
   786
    aProjectProblem allProblems:problems.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   787
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   788
    "Created: / 23-02-2012 / 13:10:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   789
    "Modified: / 22-02-2014 / 21:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2718
vrany
parents: 2716
diff changeset
   790
! !
vrany
parents: 2716
diff changeset
   791
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   792
!ProjectChecker class methodsFor:'documentation'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   793
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   794
version
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   795
    ^ '$Header$'
3167
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   796
!
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   797
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   798
version_CVS
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   799
    ^ '$Header$'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   800
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   801
4041
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   802
version_HG
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   803
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   804
    ^ '$Changeset: <not expanded> $'
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   805
!
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   806
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   807
version_SVN
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   808
    ^ '$Id$'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   809
! !
3116
9ddba2316fec class: ProjectChecker
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   810