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