ProjectChecker.st
author Merge Script
Tue, 16 Aug 2016 06:52:00 +0200
branchjv
changeset 4081 5a9726876c20
parent 4041 71b5dc4ee4c0
parent 4078 49d23af00621
child 4199 89ebbba27db6
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
     1
"{ Encoding: utf8 }"
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
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
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
   236
            and:[eachClass superclass package == eachClass package]) ifTrue:[
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   237
            (classesInDescriptionChecked includes: eachClass superclass) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   238
                self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   239
                    (ProjectProblem newClassListedBeforeItsSuperclass
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   240
                        className: eachClass name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   241
                        superClassName: eachClass superclass name)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   242
            ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   243
        ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   244
        eachClass sharedPools do:[:eachPool|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   245
            eachPool package == eachClass package ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   246
                (classesInDescriptionChecked includes: eachPool) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   247
                    self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   248
                        (ProjectProblem newClassListedBeforeItsPool
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   249
                            className: eachClass name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   250
                            poolName: eachPool name)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   251
                ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   252
            ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   253
        ].
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
        classesInDescriptionChecked add: eachClass.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   256
    ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   257
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   258
    classesInImage ~= classesInDescription ifTrue:[
2856
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   259
        "This is done later in checkClassesListedInProjectDefinition:"
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   260
"/        onlyInImage := (classesInImage reject:[:cls | classesInDescription includes:cls]).
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   261
"/        onlyInImage do:[:cls|
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   262
"/            self addProblem: 
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   263
"/                (ProjectProblem newClassListedButInOtherPackage className: cls name).
2856
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   264
"/        ].
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   265
        onlyInDescription := (classesInDescription reject:[:cls | classesInImage includes:cls]).
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   266
        onlyInDescription do:[:cls|
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   267
            self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   268
                (ProjectProblem newClassListedButDoesNotExist className: cls name)
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   269
        ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   270
    ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   271
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   272
    "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
   273
    "Modified: / 22-02-2014 / 21:46:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2718
vrany
parents: 2716
diff changeset
   274
!
vrany
parents: 2716
diff changeset
   275
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   276
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
   277
    currentPackageDef classNamesAndAttributesDo:[:clsnm :attributes|
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   278
        | cls superclass |
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   279
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   280
        cls := Smalltalk at: clsnm.
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   281
        (aCollection includes: cls) ifTrue:[
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   282
            (attributes includes: #autoload) ifFalse:[
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   283
                "/ Care for Object!!
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   284
                superclass := cls superclass.
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   285
                superclass notNil ifTrue:[
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   286
                    | superDef |
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   287
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   288
                    superDef := ProjectDefinition definitionClassForPackage: superclass package.
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   289
                    superDef isNil ifTrue:[
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   290
                        problems add:
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   291
                            (ProjectProblem newClassIsCompiledButSuperclassProjectDefinitionIsMissing
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   292
                                            package: currentPackage;
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   293
                                            className: clsnm;
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   294
                                            yourself)   
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   295
                    ] ifFalse:[
3780
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   296
                        (superDef isAutoloaded:superclass) ifTrue:[
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   297
                            problems add:
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   298
                                (ProjectProblem newClassIsCompiledButSuperclassIsAutoloaded
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   299
                                    package: currentPackage;
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   300
                                    className: clsnm;
d9c489fb2a98 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3686
diff changeset
   301
                                    yourself)
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   302
                        ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   303
                    ]
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   304
                ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   305
            ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   306
        ].
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   307
    ].
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
    "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
   310
    "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
   311
!
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   312
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   313
checkClassesForMethodsInNoProject:classesToCheck 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   314
    | checker |
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   315
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   316
    checker := [:cls | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   317
        cls 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   318
            selectorsAndMethodsDo:[:sel :mth | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   319
                (mth package isNil or:[ mth package == PackageId noProjectID ]) ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   320
                    "Sigh, special hack for Expecco"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   321
                    ((cls name = 'Expecco::AbstractApplication class' and:[ sel = 'flags' ]) or:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   322
                     (cls name = 'Expecco::Browser class' and:[ sel = 'flags' ])]) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   323
                        self addProblem:(ProjectProblem newMethodInNoPackage className:cls name
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   324
                                    selector:sel).
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   325
                    ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   326
                ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   327
            ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   328
    ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   329
    classesToCheck do:[:class | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   330
        checker value:class theMetaclass.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   331
        checker value:class theNonMetaclass.
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
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   334
    "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
   335
!
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
checkClassesForNonQualifiedSharedPools: classesToCheck 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   338
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   339
    classesToCheck do:[:cls|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   340
        cls sharedPoolNames do:[:poolName|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   341
            (Smalltalk at: poolName asSymbol) isNil ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   342
                | ns |
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   343
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   344
                ns := cls nameSpace.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   345
                (ns ~~ Smalltalk and:[(ns at: poolName asSymbol) notNil]) ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   346
                    self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   347
                        (ProjectProblem newClassUsesPoolButItIsNotASharedPool
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   348
                                className: cls name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   349
                                poolName: poolName)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   350
                ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   351
            ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   352
        ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   353
    ].
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
    "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
   356
!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   357
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   358
checkClassesListedInProjectDefinition: classesToCheck
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   359
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   360
    | classNamesListed |
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   361
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   362
    classNamesListed := currentPackageDef classNames.
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   363
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   364
    classesToCheck do:[:class|
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   365
        (class isPrivate not and:[(classNamesListed includes: class name) not]) ifTrue:[
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   366
            self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   367
                (ProjectProblem newClassNotListed className: class name).
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   368
        ]
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   369
    ].
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   370
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   371
    "Created: / 13-02-2012 / 18:18:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   372
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   373
2718
vrany
parents: 2716
diff changeset
   374
checkExtensionsListConsistency
vrany
parents: 2716
diff changeset
   375
    "Checks whether all extensions listed in #extensionMethodNames are present
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   376
     and if all extension methods are listed.
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   377
     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
   378
     (which may happen after a move, if the original package was not updated)"
2718
vrany
parents: 2716
diff changeset
   379
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   380
    | extensionsListed extensionsPresent allOtherExtensions checkMethod|
2718
vrany
parents: 2716
diff changeset
   381
vrany
parents: 2716
diff changeset
   382
    extensionsListed := OrderedCollection new.
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   383
    currentPackageDef extensionMethodNames pairWiseDo:[:cls :sel|
2718
vrany
parents: 2716
diff changeset
   384
        extensionsListed add: (Array with: cls with: sel)
vrany
parents: 2716
diff changeset
   385
    ].
vrany
parents: 2716
diff changeset
   386
    extensionsPresent := OrderedCollection new.
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   387
    currentPackageDef searchForExtensions do:[:each|
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   388
        "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
   389
         should not be listed in extensionMethodNames.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   390
         They are loaded lazily by JavaClassReader and if listed here,
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   391
         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
   392
         Sort of a HACK, indeed"
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   393
        each mclass theNonMetaclass isJavaClass ifFalse:[
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   394
            extensionsPresent add: (Array with: each mclass name with: each selector)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   395
        ].
2718
vrany
parents: 2716
diff changeset
   396
    ].
vrany
parents: 2716
diff changeset
   397
vrany
parents: 2716
diff changeset
   398
    (extensionsListed \ extensionsPresent) do:[:clsAndSel|
3167
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   399
        |cls clsName selector|
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   400
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   401
        clsName := clsAndSel first.
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   402
        selector := clsAndSel second.
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   403
        (cls := Smalltalk classNamed: clsName) isNil ifTrue:[
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   404
            self addProblem: 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   405
                (ProjectProblem newExtensionMethodsClassDoesNotExist
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   406
                    className: clsName selector: selector).                            
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   407
        ] ifFalse:[
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   408
            (cls compiledMethodAt:selector) isNil ifTrue:[
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   409
                self addProblem: 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   410
                    (ProjectProblem newExtensionMethodListedButDoesNotExist
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   411
                        className: clsName selector: selector). 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   412
            ] ifFalse:[
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   413
                self addProblem: 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   414
                    (ProjectProblem newExtensionMethodListedButInDifferentPackage
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   415
                        className: clsName selector: selector). 
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   416
            ]
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   417
        ]
2718
vrany
parents: 2716
diff changeset
   418
    ].
vrany
parents: 2716
diff changeset
   419
vrany
parents: 2716
diff changeset
   420
    (extensionsPresent \ extensionsListed) do:[:clsAndSel|
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   421
         self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   422
            (ProjectProblem newExtensionMethodNotListed
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   423
                className: clsAndSel first selector: clsAndSel second).                            
2718
vrany
parents: 2716
diff changeset
   424
    ].
vrany
parents: 2716
diff changeset
   425
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   426
    allOtherExtensions := Set new.
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   427
    ProjectDefinition allSubclassesDo:[:eachOther |
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   428
        eachOther ~~ currentPackageDef ifTrue:[
3805
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   429
            Error handle:[:ex |
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   430
                Transcript showCR:('ProjetChecker [warning]: ignored error while asking ',eachOther name,' for extensionMethods').
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   431
                ex return
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   432
            ] do:[
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   433
                allOtherExtensions addAll:(eachOther extensionMethods).
f279311c75a6 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3804
diff changeset
   434
            ].
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   435
        ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   436
    ].
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
    checkMethod :=
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   439
        [:eachMethodHere |
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   440
            (allOtherExtensions includes:eachMethodHere) ifTrue:[
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   441
                |otherProjectDefinitions|
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   442
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   443
                otherProjectDefinitions := OrderedCollection new.
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   444
                "/ where is it?
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   445
                ProjectDefinition allSubclassesDo:[:someOtherPackage |
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   446
                    someOtherPackage ~~ currentPackageDef ifTrue:[
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   447
                        (someOtherPackage extensionMethods includes:eachMethodHere) ifTrue:[
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   448
                            otherProjectDefinitions add:someOtherPackage
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   449
                        ]
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   450
                    ]
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
                otherProjectDefinitions notEmptyOrNil ifTrue:[
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   453
                    otherProjectDefinitions sortBySelector:#package.
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   454
                    self addProblem: 
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   455
                       (ProjectProblem newMethodListedInOtherPackage
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   456
                           className: (eachMethodHere mclass name) selector: (eachMethodHere selector);
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   457
                           otherProjectDefinitionClasses:otherProjectDefinitions;
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   458
                           yourself).                            
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   459
                ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   460
            ].
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
3795
fb9b9489df78 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3791
diff changeset
   463
    currentPackageDef compiled_classesForPlatform do:[:eachClass |
3791
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   464
        eachClass instAndClassMethodsDo:[:m |
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   465
            (m package = currentPackage) ifTrue:[ checkMethod value:m].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   466
        ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   467
    ].
edc9f920cfb1 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3780
diff changeset
   468
    currentPackageDef extensions do:checkMethod.
2718
vrany
parents: 2716
diff changeset
   469
!
vrany
parents: 2716
diff changeset
   470
vrany
parents: 2716
diff changeset
   471
checkExtensionsPrerequisites
vrany
parents: 2716
diff changeset
   472
    "Checks whether packages of all extensions method classes are listed
vrany
parents: 2716
diff changeset
   473
     in package prerequisites"
vrany
parents: 2716
diff changeset
   474
3116
9ddba2316fec class: ProjectChecker
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   475
    |preRequisites|
9ddba2316fec class: ProjectChecker
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   476
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   477
    preRequisites := currentPackageDef effectivePreRequisites.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   478
    currentPackageDef searchForExtensions do:[:mthd|
3116
9ddba2316fec class: ProjectChecker
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   479
        (preRequisites includes: mthd mclass package) ifFalse:[
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   480
"/            self problem: ('%3 required by extension method but not in prerequisites' bindWith: mthd mclass package)
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   481
"/                 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
   482
"/                 severity: #error data: mthd
2718
vrany
parents: 2716
diff changeset
   483
         ].
vrany
parents: 2716
diff changeset
   484
    ]
vrany
parents: 2716
diff changeset
   485
vrany
parents: 2716
diff changeset
   486
    "Created: / 12-01-2012 / 12:41:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   487
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   488
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   489
checkMethodCodingStyle: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   490
    "Checks for various coding style violations such as 'self halt' or
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   491
     improper indentation :-)"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   492
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   493
    "To be implemented"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   494
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   495
    "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
   496
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   497
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   498
checkMethodSTCCompilability1: method into: problemIssue
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   499
    "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
   500
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   501
    | lang compiler |
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   502
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   503
    lang := method programmingLanguage.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   504
    lang isSmalltalk ifFalse:[ ^ self ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   505
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   506
    compiler := lang compilerClass new.
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   507
    compiler
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   508
        compile:method source
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   509
        forClass:method mclass
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   510
        inCategory:'others'
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   511
        notifying:problemIssue
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   512
        install:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   513
        skipIfSame:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   514
        silent:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   515
        foldConstants:true
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   516
        ifFail:[ ].
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   517
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   518
    compiler usedGlobals do:[:nm | 
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   519
        (nm startsWith:Smalltalk undeclaredPrefix) ifTrue:[
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   520
            problemIssue 
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   521
                addWarning:'Contains unresolved reference to: ',(nm copyFrom:(Smalltalk undeclaredPrefix size + 1))
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   522
                from:0 to:0
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   523
        ]
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   524
    ].
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   525
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   526
    "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
   527
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   528
3161
3f9f36f40778 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3148
diff changeset
   529
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
   530
    | 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
   531
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   532
    "/ 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
   533
    (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
   534
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   535
    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
   536
    env addClass: method mclass selector: method selector.
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   537
3686
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   538
    rulesApplied isNil ifTrue:[
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   539
        rulesApplied := RBCompositeLintRule allRules 
3804
7accb0e1e60e class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
   540
                    selectRules:[:rule | (rule isTaggedAs: #stc) and:[ rule severity == #error ]].
3686
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   541
    ].
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   542
    rules := rulesApplied.
544231883156 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   543
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   544
    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
   545
3804
7accb0e1e60e class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3795
diff changeset
   546
    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
   547
    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
   548
        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
   549
    ].
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   550
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   551
    "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
   552
    "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
   553
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   554
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   555
checkMethodSTCCompilability: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   556
    "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
   557
     everything bytecode compiler/jit compiler does, sigh"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   558
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   559
    | cls issue1 issue2 |
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   560
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   561
    "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
   562
    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
   563
    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
   564
        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
   565
    ].
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   566
    (currentPackageDef autoloaded_classNames includes: cls name) ifTrue:[
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   567
        ^ self
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   568
    ].
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   569
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
   570
    "/ 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
   571
    "/ 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
   572
    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
   573
3563
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   574
    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
   575
    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
   576
    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
   577
    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
   578
        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
   579
    ].
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   580
1590b29dbdef Added lint-based check for stc bugs to ProjectChecker (#checkMethodSTCCompilability2:)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3548
diff changeset
   581
    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
   582
    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
   583
    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
   584
    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
   585
        self addProblem: issue2
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   586
    ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   587
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   588
    "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
   589
    "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
   590
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   591
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   592
checkMethodSourceCode: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   593
    "Checks, whether method's source code is both
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   594
     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
   595
     is syntactically correct, false otherwise"
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   596
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   597
    | source |
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   598
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   599
    [    
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   600
        source := method source.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   601
    ] on: Error do:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   602
        self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   603
            (ProjectProblem newMethodSourceNotAvailable method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   604
        ^false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   605
    ].
2913
041df7e717bc changed: #checkMethodSourceCode:
vrany
parents: 2910
diff changeset
   606
    method programmingLanguage isSmalltalk ifFalse:[ ^ false ].
041df7e717bc changed: #checkMethodSourceCode:
vrany
parents: 2910
diff changeset
   607
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   608
    [
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   609
        (Parser parseMethod: method source) == #Error ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   610
            self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   611
                (ProjectProblem newMethodSourceCorrupted method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   612
            ^false.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   613
        ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   614
    ] on: Error do:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   615
        self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   616
            (ProjectProblem newMethodSourceCorrupted method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   617
        ^false.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   618
    ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   619
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   620
    ^true
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   621
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   622
    "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
   623
!
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   624
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   625
checkSubProjects
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   626
    "Checks whether all subprojects listed in #subprojects are present."
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   627
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   628
    |isValidName subProjectsListed invalidNames validNames subProjectsNotPresent|
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 := 
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   631
        [:prj |
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   632
            (prj first isLetter
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   633
            and:[ ((prj occurrencesOf:$:) <= 1)
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   634
            and:[ ((prj copyReplaceAll:$: with:$/) 
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   635
                        conform:[:ch | ch isLetterOrDigit or:['/-_.' includes:ch]]) ]])
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   636
        ].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   637
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   638
    subProjectsListed := currentPackageDef subProjects.
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   639
    invalidNames := subProjectsListed select:[:prj | (isValidName value:prj) not].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   640
    validNames := subProjectsListed select:isValidName.
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   641
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   642
    subProjectsNotPresent := validNames select:[:prj | prj asPackageId projectDefinitionClass isNil].
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
    invalidNames do:[:eachBadName |                                
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   645
        self addProblem: (ProjectProblem newInvalidPackageName badName:eachBadName).
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   646
    ].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   647
    subProjectsNotPresent do:[:eachMissing |                                
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   648
        self addProblem: (ProjectProblem newProjectDefinitionDoesNotExist missing: eachMissing).
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   649
    ].
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   650
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   651
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   652
!ProjectChecker methodsFor:'checks-private'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   653
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   654
checkClasses
3535
f02b2535dd15 Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   655
    | classesToCheck |
f02b2535dd15 Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   656
f02b2535dd15 Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   657
    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
   658
    classesToCheck := classesToCheck select:[:each | each programmingLanguage isSmalltalk and:[ each package = currentPackage ] ].
3589
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   659
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   660
    (currentPackageDef notNil and:[currentPackageDef isFolderForProjectsDefinition]) ifTrue:[
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   661
        classesToCheck remove:currentPackageDef ifAbsent:[]
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   662
    ].
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   663
3535
f02b2535dd15 Fix for multi-package check.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3508
diff changeset
   664
    self checkClasses: classesToCheck.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   665
3589
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   666
    (currentPackageDef notNil and:[currentPackageDef isFolderForProjectsDefinition]) ifTrue:[
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   667
        classesToCheck do:[:eachClass |
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   668
            self addProblem: 
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   669
                (ProjectProblem newClassShouldNotBeInPackage className: eachClass name).
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   670
        ].
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   671
    ].
ec7033799261 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3570
diff changeset
   672
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   673
    "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
   674
    "Modified: / 31-07-2014 / 09:47:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   675
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   676
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   677
checkClasses: classesToCheck
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   678
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   679
    self checkClassesListedInProjectDefinition: classesToCheck.
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   680
    self checkClassesForMethodsInNoProject:classesToCheck.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   681
    self checkClassesForNonQualifiedSharedPools:classesToCheck.
3467
253e31a8aabd merged in jv's changes
Claus Gittinger <cg@exept.de>
parents: 3233
diff changeset
   682
    self checkClassesAutoloadedSuperclasse:classesToCheck.
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   683
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   684
    "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
   685
    "Modified: / 20-09-2013 / 11:08:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   686
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   687
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   688
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
   689
    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
   690
        (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
   691
            "/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
   692
            "/ 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
   693
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
   694
            "/ 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
   695
            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
   696
            "/ 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
   697
            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
   698
        ]
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
    ].
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   700
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   701
    "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
   702
    "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
   703
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   704
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   705
checkMethods
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   706
    methods notEmptyOrNil ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   707
        self checkMethods: methods.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   708
        ^self.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   709
    ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   710
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   711
    self checkMethods:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   712
        (Iterator on:[:whatToDo|
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   713
            | classesToCheck |
3233
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   714
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   715
            classes notNil ifTrue:[
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   716
                classesToCheck := classes
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   717
            ] ifFalse:[
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   718
                classesToCheck := (Smalltalk allClasses select:[:cls | (cls package = currentPackage)]).
3233
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   719
            ].
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   720
            classesToCheck do:[:cls|
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   721
                cls theNonMetaclass withAllPrivateClassesDo:[:eachClass |
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   722
                    ActivityNotification raiseRequestWith:self errorString:('Checking %1...' bindWith:eachClass name).
b80cfaa73cb4 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3167
diff changeset
   723
                    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
   724
                        m package = currentPackage ifTrue:[
3148
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   725
                            ((checkExtensionsOnly ? false) not
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   726
                            or:[ m package ~~ cls package "isExtension" ]) ifTrue:[
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   727
                                whatToDo value:m
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   728
                            ]
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   729
                        ]
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   730
                    ]
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   731
                ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   732
            ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   733
        ])
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   734
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   735
    "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
   736
    "Modified: / 22-02-2014 / 21:48:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   737
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   738
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   739
checkMethods: methodsToCheck
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   740
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   741
    methodsToCheck do:[:m|self checkMethod: m].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   742
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   743
    "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
   744
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   745
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   746
checkPackage
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   747
    currentPackageDef isNil ifTrue:[^ self].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   748
    currentPackageDef isFolderForProjectsDefinition ifFalse:[
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   749
        (checkExtensionsOnly ? false) ifFalse:[
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   750
            self checkClassListConsistency.
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   751
        ].
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   752
        self checkExtensionsListConsistency.
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   753
        self checkExtensionsPrerequisites.
3148
2a6c8e1b5f69 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3116
diff changeset
   754
    ].
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   755
    self checkSubProjects.
2718
vrany
parents: 2716
diff changeset
   756
2716
9a74597bcd4b Do not use annotations as stc crashes when compiling them
vrany
parents: 2707
diff changeset
   757
    "add more here..."
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   758
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   759
    "Created: / 11-01-2012 / 16:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   760
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   761
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   762
!ProjectChecker methodsFor:'initialization'!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   763
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   764
initialize
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   765
    "Invoked when a new instance is created."
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   766
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   767
    "/ 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
   768
    packages := OrderedCollection new.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   769
    "/ currentPackage := nil.
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   770
    "/ currentPackageDef := nil.
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   771
    "/ classes := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   772
    "/ methods := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   773
    problems := List new.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   774
    "/ phase := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   775
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   776
    "/ super initialize.   -- commented since inherited method does nothing
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   777
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   778
    "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
   779
! !
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   780
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   781
!ProjectChecker methodsFor:'reporting'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   782
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   783
addProblem: aProjectProblem
3807
9746e6873402 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3805
diff changeset
   784
Transcript showCR:aProjectProblem.
3508
dd0e9fe9c7e2 Added support for checking multiple packages at once.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3467
diff changeset
   785
    aProjectProblem package: currentPackage.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   786
    problems isNil ifTrue:[problems := OrderedCollection new].
3548
265e326c3bd0 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
   787
    problems add: aProjectProblem.
265e326c3bd0 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3535
diff changeset
   788
    aProjectProblem allProblems:problems.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   789
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   790
    "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
   791
    "Modified: / 22-02-2014 / 21:45:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2718
vrany
parents: 2716
diff changeset
   792
! !
vrany
parents: 2716
diff changeset
   793
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   794
!ProjectChecker class methodsFor:'documentation'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   795
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   796
version
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   797
    ^ '$Header$'
3167
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   798
!
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   799
56a8d17b6987 class: ProjectChecker
Claus Gittinger <cg@exept.de>
parents: 3161
diff changeset
   800
version_CVS
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   801
    ^ '$Header$'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   802
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   803
4041
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   804
version_HG
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   805
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   806
    ^ '$Changeset: <not expanded> $'
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   807
!
71b5dc4ee4c0 Added `SystemProfiler` from (now obsolete) package stx:libprofiler.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3838
diff changeset
   808
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   809
version_SVN
4078
49d23af00621 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3807
diff changeset
   810
    ^ '$Id$'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   811
! !
3116
9ddba2316fec class: ProjectChecker
Stefan Vogel <sv@exept.de>
parents: 2976
diff changeset
   812