ProjectChecker.st
author vrany
Wed, 31 Oct 2012 18:31:02 +0100
changeset 2966 bf5ea36104cd
parent 2965 bd6117e07789
child 2967 c5f1d6853ad1
permissions -rw-r--r--
Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     1
"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     3
              All Rights Reserved
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     4
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     5
 This software is furnished under a license and may be used
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     6
 only in accordance with the terms of that license and with the
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     8
 be provided or otherwise made available to, or used by, any
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
     9
 other person.  No title to or ownership of the software is
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    10
 hereby transferred.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    11
"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    12
"{ Package: 'stx:libbasic3' }"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    13
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    14
Object subclass:#ProjectChecker
2966
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
    15
        instanceVariableNames:'package packageDef classes methods problems phase'
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
    16
        classVariableNames:''
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
    17
        poolDictionaries:''
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
    18
        category:'System-Support-Projects'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    19
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    20
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    21
!ProjectChecker class methodsFor:'documentation'!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    22
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    23
copyright
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    24
"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    25
 COPYRIGHT (c) 2006 by eXept Software AG
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    26
              All Rights Reserved
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    27
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    28
 This software is furnished under a license and may be used
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    29
 only in accordance with the terms of that license and with the
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    31
 be provided or otherwise made available to, or used by, any
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    32
 other person.  No title to or ownership of the software is
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    33
 hereby transferred.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    34
"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    35
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    36
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    37
documentation
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    38
"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    39
    A simple project checker that can search whole projects or individual
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    40
    classes or methods for various problems that may cause build problems such
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    41
    as:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    42
        - inconsistent/messed up project definition class
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    43
        - method code problems
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    44
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    45
    NOTE: Not yet finished. This code is meant as a single central entry for all the
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    46
    source code management tools like SCM Utilities, NewSystemBrowser ets. That code
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    47
    will be refactored later once this tool prooves itself useful and mature enough.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    48
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    49
    [author:]
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    50
        Jan Vrany <jan.vrany@fit.cvut.cz>
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    51
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    52
    [instance variables:]
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    53
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    54
    [class variables:]
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    55
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    56
    [see also:]
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    57
        Tools::ProjectCheckerBrowser
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    58
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    59
"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    60
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    61
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    62
examples
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    63
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    64
    "
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    65
        ProjectChecker check: 'stx:libbasic'
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    66
        ProjectChecker check: 'stx:libtool'
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
    67
        ProjectChecker check: 'stx:libbasic3'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    68
    "
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    69
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    70
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    71
!ProjectChecker class methodsFor:'instance creation'!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    72
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    73
forPackage: packageId
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    74
    ^self new
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    75
        package: packageId;
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    76
        yourself.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    77
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    78
    "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
    79
!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    80
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    81
new
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    82
    "return an initialized instance"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    83
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    84
    ^ self basicNew initialize.
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    85
! !
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
    86
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    87
!ProjectChecker class methodsFor:'checking'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    88
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    89
check: package
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    90
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    91
    ^self new check: package
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    92
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    93
    "Created: / 11-01-2012 / 16:46:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    94
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
    95
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    96
!ProjectChecker class methodsFor:'others'!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    97
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
    98
version_CVS
2966
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
    99
    ^ '$Header: /cvs/stx/stx/libbasic3/ProjectChecker.st,v 1.10 2012-10-31 17:31:02 vrany Exp $'
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   100
! !
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   101
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   102
!ProjectChecker methodsFor:'accessing'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   103
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   104
classes: aCollection
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   105
    classes := aCollection.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   106
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   107
    "Created: / 13-02-2012 / 17:06:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   108
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   109
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   110
methods
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   111
    ^ methods
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   112
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   113
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   114
methods:something
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   115
    methods := something.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   116
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   117
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   118
package
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   119
    ^ package
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   120
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   121
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   122
package:packageId
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   123
    package := packageId asSymbol.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   124
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   125
    "Modified: / 11-04-2012 / 16:00:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   126
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   127
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   128
problems
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   129
    ^ problems
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   130
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   131
    "Modified: / 23-02-2012 / 15:14:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   132
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   133
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   134
!ProjectChecker methodsFor:'checking'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   135
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   136
check
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   137
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   138
    problems removeAll.
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   139
    packageDef := ProjectDefinition definitionClassForPackage: package.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   140
    packageDef isNil ifTrue:[
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   141
        self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   142
            (ProjectProblem newProjectDefinitionDoesNotExist package: package).
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   143
        ^self    
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   144
    ].
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   145
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   146
    self
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   147
        checkPackage;
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   148
        checkClasses;
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   149
        checkMethods
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   150
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   151
    "Created: / 11-01-2012 / 16:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   152
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   153
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   154
check: package
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   155
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   156
    self package: package.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   157
    self check.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   158
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   159
    "Created: / 11-01-2012 / 16:47:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   160
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   161
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   162
!ProjectChecker methodsFor:'checks-individual'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   163
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   164
checkClassListConsistency
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   165
    "Checks whether all classes listed in #classNamesAndAttributes are present
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   166
    and if all present classes are listed"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   167
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   168
    |classesInImage classesInDescription classesInDescriptionChecked onlyInDescription|
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   169
    "WARNING: Copy/paste of ProjectDefinition>>validateDescription"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   170
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   171
    classesInImage := Smalltalk allClasses select:[:cls | (cls package = self package) and:[cls isPrivate not]].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   172
    "/ classesInDescription := self classes asIdentitySet.
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   173
    classesInDescription := OrderedCollection new.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   174
    ((packageDef compiled_classNamesForPlatform:(OperatingSystem platformName))
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   175
    , (packageDef compiled_classNames_common)
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   176
    , (packageDef autoloaded_classNames)) do:[:nm |
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   177
        |cls|
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   178
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   179
        cls := Smalltalk at:nm asSymbol.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   180
        cls isNil ifTrue:[
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   181
            self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   182
                (ProjectProblem newClassListedButDoesNotExist className: nm)
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   183
        ] ifFalse:[
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   184
            classesInDescription add:cls.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   185
        ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   186
    ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   187
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   188
    classesInDescriptionChecked := OrderedCollection new.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   189
    classesInDescription do:[:eachClass |
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   190
        (classesInDescriptionChecked includes: eachClass) ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   191
                    self addProblem: 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   192
                        (ProjectProblem newClassListedMultipleTimes
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   193
                            className: eachClass name)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   194
        ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   195
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   196
        eachClass sharedPoolNames do:[:eachPoolName |
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   197
            |pool|
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   198
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   199
            pool := eachClass nameSpace classNamed:eachPoolName.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   200
            pool isNil ifTrue:[
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   201
                eachClass nameSpace ~~ Smalltalk ifTrue:[
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   202
                    pool := Smalltalk classNamed:eachPoolName.
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   203
                ]
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   204
            ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   205
            pool isNil ifTrue:[
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   206
                self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   207
                    (ProjectProblem newClassUsesPoolButItDoesNotExist
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   208
                        className: eachClass name;
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   209
                        poolName: eachPoolName).
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   210
            ] ifFalse:[
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   211
                pool isSharedPool ifFalse:[
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   212
                    self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   213
                        (ProjectProblem newClassUsesPoolButItIsNotASharedPool
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   214
                            className: eachClass name;
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   215
                            poolName: eachPoolName).                
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   216
                ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   217
            ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   218
        ].
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   219
2966
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
   220
        (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
   221
            and:[eachClass superclass package == eachClass package]) ifTrue:[
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   222
            (classesInDescriptionChecked includes: eachClass superclass) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   223
                self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   224
                    (ProjectProblem newClassListedBeforeItsSuperclass
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   225
                        className: eachClass name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   226
                        superClassName: eachClass superclass name)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   227
            ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   228
        ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   229
        eachClass sharedPools do:[:eachPool|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   230
            eachPool package == eachClass package ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   231
                (classesInDescriptionChecked includes: eachPool) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   232
                    self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   233
                        (ProjectProblem newClassListedBeforeItsPool
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   234
                            className: eachClass name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   235
                            poolName: eachPool name)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   236
                ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   237
            ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   238
        ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   239
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   240
        classesInDescriptionChecked add: eachClass.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   241
    ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   242
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   243
    classesInImage ~= classesInDescription ifTrue:[
2856
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   244
        "This is done later in checkClassesListedInProjectDefinition:"
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   245
"/        onlyInImage := (classesInImage reject:[:cls | classesInDescription includes:cls]).
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   246
"/        onlyInImage do:[:cls|
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   247
"/            self addProblem: 
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   248
"/                (ProjectProblem newClassNotListed className: cls name).
a1cee28488c0 changed: #checkClassListConsistency - do not warn about not-listed classes twice
vrany
parents: 2853
diff changeset
   249
"/        ].
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   250
        onlyInDescription := (classesInDescription reject:[:cls | classesInImage includes:cls]).
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   251
        onlyInDescription do:[:cls|
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   252
            self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   253
                (ProjectProblem newClassListedButDoesNotExist className: cls name)
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   254
        ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   255
    ].
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   256
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   257
    "Created: / 11-01-2012 / 17:14:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2966
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
   258
    "Modified: / 26-10-2012 / 12:59:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2718
vrany
parents: 2716
diff changeset
   259
!
vrany
parents: 2716
diff changeset
   260
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   261
checkClassesForMethodsInNoProject:classesToCheck 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   262
    | checker |
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   263
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   264
    checker := [:cls | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   265
        cls 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   266
            selectorsAndMethodsDo:[:sel :mth | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   267
                (mth package isNil or:[ mth package == PackageId noProjectID ]) ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   268
                    "Sigh, special hack for Expecco"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   269
                    ((cls name = 'Expecco::AbstractApplication class' and:[ sel = 'flags' ]) or:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   270
                     (cls name = 'Expecco::Browser class' and:[ sel = 'flags' ])]) ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   271
                        self addProblem:(ProjectProblem newMethodInNoPackage className:cls name
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   272
                                    selector:sel).
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   273
                    ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   274
                ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   275
            ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   276
    ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   277
    classesToCheck do:[:class | 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   278
        checker value:class theMetaclass.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   279
        checker value:class theNonMetaclass.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   280
    ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   281
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   282
    "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
   283
!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   284
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   285
checkClassesForNonQualifiedSharedPools: classesToCheck 
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   286
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   287
    classesToCheck do:[:cls|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   288
        cls sharedPoolNames do:[:poolName|
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   289
            (Smalltalk at: poolName asSymbol) isNil ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   290
                | ns |
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   291
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   292
                ns := cls nameSpace.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   293
                (ns ~~ Smalltalk and:[(ns at: poolName asSymbol) notNil]) ifTrue:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   294
                    self addProblem:
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   295
                        (ProjectProblem newClassUsesPoolButItIsNotASharedPool
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   296
                                className: cls name;
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   297
                                poolName: poolName)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   298
                ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   299
            ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   300
        ]
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   301
    ].
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   302
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   303
    "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
   304
!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   305
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   306
checkClassesListedInProjectDefinition: classesToCheck
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   307
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   308
    | classNamesListed |
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   309
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   310
    classNamesListed := packageDef classNames.
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   311
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   312
    classesToCheck do:[:class|
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   313
        (class isPrivate not and:[(classNamesListed includes: class name) not]) ifTrue:[
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   314
            self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   315
                (ProjectProblem newClassNotListed className: class name).
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   316
        ]
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   317
    ].
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   318
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   319
    "Created: / 13-02-2012 / 18:18:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   320
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   321
2718
vrany
parents: 2716
diff changeset
   322
checkExtensionsListConsistency
vrany
parents: 2716
diff changeset
   323
    "Checks whether all extensions listed in #extensionMethodNames are present
vrany
parents: 2716
diff changeset
   324
    and if all extension methods are listed"
vrany
parents: 2716
diff changeset
   325
vrany
parents: 2716
diff changeset
   326
    | extensionsListed extensionsPresent |
vrany
parents: 2716
diff changeset
   327
vrany
parents: 2716
diff changeset
   328
    extensionsListed := OrderedCollection new.
vrany
parents: 2716
diff changeset
   329
    packageDef extensionMethodNames pairWiseDo:[:cls :sel|
vrany
parents: 2716
diff changeset
   330
        extensionsListed add: (Array with: cls with: sel)
vrany
parents: 2716
diff changeset
   331
    ].
vrany
parents: 2716
diff changeset
   332
    extensionsPresent := OrderedCollection new.
vrany
parents: 2716
diff changeset
   333
    packageDef searchForExtensions do:[:each|
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   334
        "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
   335
         should not be listed in extensionMethodNames.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   336
         They are loaded lazily by JavaClassReader and if listed here,
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   337
         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
   338
         Sort of a HACK, indeed"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   339
        each mclass isJavaClass ifFalse:[
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   340
            extensionsPresent add: (Array with: each mclass name with: each selector)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   341
        ].
2718
vrany
parents: 2716
diff changeset
   342
    ].
vrany
parents: 2716
diff changeset
   343
vrany
parents: 2716
diff changeset
   344
    (extensionsListed \ extensionsPresent) do:[:clsAndSel|
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   345
         self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   346
            (ProjectProblem newExtensionMethodListedButDoesNotExist
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   347
                className: clsAndSel first selector: clsAndSel second).                            
2718
vrany
parents: 2716
diff changeset
   348
    ].
vrany
parents: 2716
diff changeset
   349
vrany
parents: 2716
diff changeset
   350
    (extensionsPresent \ extensionsListed) do:[:clsAndSel|
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   351
         self addProblem: 
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   352
            (ProjectProblem newExtensionMethodNotListed
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   353
                className: clsAndSel first selector: clsAndSel second).                            
2718
vrany
parents: 2716
diff changeset
   354
    ].
vrany
parents: 2716
diff changeset
   355
vrany
parents: 2716
diff changeset
   356
    "Created: / 12-01-2012 / 12:31:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
vrany
parents: 2716
diff changeset
   357
!
vrany
parents: 2716
diff changeset
   358
vrany
parents: 2716
diff changeset
   359
checkExtensionsPrerequisites
vrany
parents: 2716
diff changeset
   360
    "Checks whether packages of all extensions method classes are listed
vrany
parents: 2716
diff changeset
   361
     in package prerequisites"
vrany
parents: 2716
diff changeset
   362
vrany
parents: 2716
diff changeset
   363
    packageDef searchForExtensions do:[:mthd|
vrany
parents: 2716
diff changeset
   364
        (packageDef preRequisites includes: mthd mclass package) ifFalse:[
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   365
"/            self problem: ('%3 required by extension method but not in prerequisites' bindWith: mthd mclass package)
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   366
"/                 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
   367
"/                 severity: #error data: mthd
2718
vrany
parents: 2716
diff changeset
   368
         ].
vrany
parents: 2716
diff changeset
   369
    ]
vrany
parents: 2716
diff changeset
   370
vrany
parents: 2716
diff changeset
   371
    "Created: / 12-01-2012 / 12:41:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   372
!
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   373
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   374
checkMethodCodingStyle: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   375
    "Checks for various coding style violations such as 'self halt' or
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   376
     improper indentation :-)"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   377
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   378
    "To be implemented"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   379
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   380
    "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
   381
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   382
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   383
checkMethodSTCCompilability1: method into: problem
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   384
    "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
   385
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   386
    | lang |
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   387
    lang := method programmingLanguage.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   388
    lang isSmalltalk ifFalse:[ ^ self ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   389
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   390
    lang compilerClass new
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   391
        compile:method source
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   392
        forClass:method mclass
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   393
        inCategory:'others'
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   394
        notifying:problem
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   395
        install:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   396
        skipIfSame:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   397
        silent:false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   398
        foldConstants:true
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   399
        ifFail:[ ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   400
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   401
    "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
   402
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   403
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   404
checkMethodSTCCompilability2: method into: problem
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   405
    "Checks is the method can be compiled by STC based on selected lint rules"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   406
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   407
    "Not yet implemented"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   408
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   409
    "Created: / 11-04-2012 / 15:54:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   410
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   411
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   412
checkMethodSTCCompilability: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   413
    "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
   414
     everything bytecode compiler/jit compiler does, sigh"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   415
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   416
    | issue |
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   417
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   418
    "No need to check the method if the class is autoloaded"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   419
    (packageDef autoloaded_classNames includes: method mclass theNonMetaclass name) ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   420
        ^ self
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   421
    ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   422
    
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   423
    issue := ProjectProblem newMethodCompilabilityIssue.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   424
    issue method: method.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   425
    self checkMethodSTCCompilability1: method into: issue.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   426
    self checkMethodSTCCompilability2: method into: issue.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   427
    issue hasIssue ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   428
        self addProblem: issue
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   429
    ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   430
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   431
    "Created: / 11-04-2012 / 12:37:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   432
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   433
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   434
checkMethodSourceCode: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   435
    "Checks, whether method's source code is both
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   436
     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
   437
     is syntactically correct, false otherwise"
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   438
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   439
    | source |
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   440
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   441
    [    
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   442
        source := method source.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   443
    ] on: Error do:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   444
        self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   445
            (ProjectProblem newMethodSourceNotAvailable method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   446
        ^false
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   447
    ].
2913
041df7e717bc changed: #checkMethodSourceCode:
vrany
parents: 2910
diff changeset
   448
    method programmingLanguage isSmalltalk ifFalse:[ ^ false ].
041df7e717bc changed: #checkMethodSourceCode:
vrany
parents: 2910
diff changeset
   449
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   450
    [
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   451
        (Parser parseMethod: method source) == #Error ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   452
            self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   453
                (ProjectProblem newMethodSourceCorrupted method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   454
            ^false.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   455
        ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   456
    ] on: Error do:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   457
        self addProblem:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   458
            (ProjectProblem newMethodSourceCorrupted method: method).
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   459
        ^false.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   460
    ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   461
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   462
    ^true
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   463
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   464
    "Created: / 11-04-2012 / 12:29:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   465
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   466
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   467
!ProjectChecker methodsFor:'checks-private'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   468
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   469
checkClasses
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   470
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   471
    classes notNil ifTrue:[
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   472
        self checkClasses: classes
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   473
    ] ifFalse:[
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   474
        self checkClasses: (Smalltalk allClasses select:[:cls | (cls package = self package)]).
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   475
    ].
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   476
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   477
    "Created: / 11-01-2012 / 16:55:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   478
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   479
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   480
checkClasses: classesToCheck
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   481
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   482
    self checkClassesListedInProjectDefinition: classesToCheck.
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   483
    self checkClassesForMethodsInNoProject:classesToCheck.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   484
    self checkClassesForNonQualifiedSharedPools:classesToCheck.
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   485
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   486
    "Created: / 13-02-2012 / 18:18:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
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
checkMethod: method
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   490
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   491
    (self checkMethodSourceCode: method) ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   492
        "/OK, method's source is OK, perform further checks
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   493
        self checkMethodSTCCompilability: method.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   494
        self checkMethodCodingStyle: method.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   495
    ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   496
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   497
    "Created: / 11-04-2012 / 12:27:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   498
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   499
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   500
checkMethods
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   501
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   502
    methods notEmptyOrNil ifTrue:[
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   503
        self checkMethods: methods.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   504
        ^self.
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   505
    ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   506
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   507
    self checkMethods:
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   508
        (Iterator on:[:whatToDo|
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   509
            (classes notNil ifTrue:[classes] ifFalse:[Smalltalk allClasses]) do:[:cls|
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   510
                cls theNonMetaclass withAllPrivateClassesDo:[:each |
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   511
                    each instAndClassSelectorsAndMethodsDo:[:s :m | m package = package ifTrue:[whatToDo value:m]]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   512
                ].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   513
            ]
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   514
        ])
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   515
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   516
    "Created: / 11-01-2012 / 16:55:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   517
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   518
2853
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   519
checkMethods: methodsToCheck
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   520
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   521
    methodsToCheck do:[:m|self checkMethod: m].
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   522
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   523
    "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
   524
!
b28d27ac2c67 Initial version of project checker
vrany
parents: 2797
diff changeset
   525
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   526
checkPackage
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   527
2716
9a74597bcd4b Do not use annotations as stc crashes when compiling them
vrany
parents: 2707
diff changeset
   528
    self checkClassListConsistency.
2718
vrany
parents: 2716
diff changeset
   529
    self checkExtensionsListConsistency.
vrany
parents: 2716
diff changeset
   530
    self checkExtensionsPrerequisites.
vrany
parents: 2716
diff changeset
   531
2716
9a74597bcd4b Do not use annotations as stc crashes when compiling them
vrany
parents: 2707
diff changeset
   532
    "add more here..."
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   533
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   534
    "Created: / 11-01-2012 / 16:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   535
! !
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   536
2910
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   537
!ProjectChecker methodsFor:'initialization'!
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   538
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   539
initialize
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   540
    "Invoked when a new instance is created."
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   541
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   542
    "/ please change as required (and remove this comment)
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   543
    "/ package := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   544
    "/ packageDef := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   545
    "/ classes := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   546
    "/ methods := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   547
    problems := List new.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   548
    "/ phase := nil.
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   549
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   550
    "/ super initialize.   -- commented since inherited method does nothing
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   551
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   552
    "Modified: / 13-09-2012 / 17:24:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   553
! !
b603824e85d5 - new checks to ensure class list consistency
vrany
parents: 2856
diff changeset
   554
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   555
!ProjectChecker methodsFor:'reporting'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   556
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   557
addProblem: aProjectProblem
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   558
    aProjectProblem package: self package.
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   559
    problems isNil ifTrue:[problems := OrderedCollection new].
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   560
    problems add: aProjectProblem
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   561
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   562
    "Created: / 23-02-2012 / 13:10:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2718
vrany
parents: 2716
diff changeset
   563
! !
vrany
parents: 2716
diff changeset
   564
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   565
!ProjectChecker class methodsFor:'documentation'!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   566
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   567
version
2966
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
   568
    ^ '$Header: /cvs/stx/stx/libbasic3/ProjectChecker.st,v 1.10 2012-10-31 17:31:02 vrany Exp $'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   569
!
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   570
2797
ab7cc3e21a2b Updated from SVN
vrany
parents: 2718
diff changeset
   571
version_SVN
2966
bf5ea36104cd Fix in #checkClassListConsistency - care about classes with nil superclass (Autoload/Object)
vrany
parents: 2965
diff changeset
   572
    ^ '§Id: ProjectChecker.st 1971 2012-09-27 19:37:25Z vranyj1 §'
2707
68860a7700c2 initial checkin
vrany
parents:
diff changeset
   573
! !