--- a/ProjectProblem.st Tue Feb 24 18:53:06 2015 +0100
+++ b/ProjectProblem.st Wed Feb 25 00:48:50 2015 +0100
@@ -55,6 +55,13 @@
privateIn:ProjectProblem
!
+ProjectProblem::InconsistentProjectDefinition subclass:#ClassListedButInOtherPackage
+ instanceVariableNames:''
+ classVariableNames:''
+ poolDictionaries:''
+ privateIn:ProjectProblem
+!
+
ProjectProblem::InconsistentProjectDefinition subclass:#ClassListedMultipleTimes
instanceVariableNames:''
classVariableNames:''
@@ -292,6 +299,11 @@
"Created: / 23-02-2012 / 13:18:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
+newClassListedButInOtherPackage
+
+ ^ClassListedButInOtherPackage new
+!
+
newClassListedMultipleTimes
^ClassListedMultipleTimes new
@@ -830,11 +842,108 @@
!
doMoveClassToPackage
- | cls |
+ | cls def |
+
+ def := self packageDefinitionClass.
+ def isNil ifTrue:[ ^ false ].
+ cls := self klass.
+ cls isNil ifTrue:[ ^ false ].
+ cls package:def package.
+ UserNotification notify: ('Do not forget to check in the class into the appropriate repository!!').
+ ^true
+!
+
+doRemoveClassFromProjectDefinition
+ | def cls |
+
+ def := self packageDefinitionClass.
+ def isNil ifTrue:[ ^ false ].
+ cls := self klass.
+ cls isNil ifTrue:[ ^ false ].
+ def excludeClasses:{ cls } usingCompiler:nil.
+ UserNotification notify: ('Class removed from project. Do not forget to check in build support files!!' bindWith: className).
+ ^true
+!
+
+fixes
+ "return a list of description-actionBlock pairs for possible fixes"
+
+ |allFixes|
+
+ allFixes := OrderedCollection new.
+ allFixes add:{
+ 'Remove from project definition' .
+ [ self doRemoveClassFromProjectDefinition ]
+ }.
+ self klass notNil ifTrue:[
+ allFixes add:{
+ 'Move class to package' .
+ [ self doMoveClassToPackage ]
+ }.
+ ].
+ allFixes addAll:super fixes.
+ ^ allFixes
+! !
+
+!ProjectProblem::ClassListedButInOtherPackage methodsFor:'accessing'!
+
+severity
+ "Return a severity - one of #error, #warning, #info"
+
+ ^#error
+
+ "Created: / 11-04-2012 / 12:48:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!ProjectProblem::ClassListedButInOtherPackage methodsFor:'accessing-description'!
+
+description
+ "Return a (HTML) describing the problem."
+
+ |msg|
+
+ msg :=
+'Class "<code>%1</code>" is listed in the project definition but is assigned to another package (%2).
+<br>
+You should either remove it from the classList %3 or completely assign it to %4.'.
+
+ ^ msg
+ bindWith: className
+ with:(self klass package)
+ with: (self linkToClass: self packageDefinitionClass class selector: #classNamesAndAttributes omitClassName: true)
+ with: package
+!
+
+label
+ ^'Class %1 is assigned to another package (%2)'
+ bindWith:className allBold
+ with: self klass package
+! !
+
+!ProjectProblem::ClassListedButInOtherPackage methodsFor:'fixing'!
+
+alreadyFixed
+ | cls def |
+
+ def := self packageDefinitionClass.
+ def isNil ifTrue:[ ^ false ]. "/ ouch - can this happen?
+
+ (def allClassNames includes:className) ifFalse:[^ true].
cls := self klass.
+ cls isNil ifTrue:[^ false].
+
+ ^ cls package = package
+!
+
+doMoveClassToPackage
+ | cls def |
+
+ def := self packageDefinitionClass.
+ def isNil ifTrue:[ ^ false ].
+ cls := self klass.
cls isNil ifTrue:[ ^ false ].
- cls package:(cls package).
+ cls package:def package.
UserNotification notify: ('Do not forget to check in the class into the appropriate repository!!').
^true
!
@@ -2323,14 +2432,14 @@
!ProjectProblem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic3/ProjectProblem.st,v 1.43 2015-02-15 18:10:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic3/ProjectProblem.st,v 1.44 2015-02-24 23:48:50 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic3/ProjectProblem.st,v 1.43 2015-02-15 18:10:09 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic3/ProjectProblem.st,v 1.44 2015-02-24 23:48:50 cg Exp $'
!
version_SVN
- ^ '$Id: ProjectProblem.st,v 1.43 2015-02-15 18:10:09 cg Exp $'
+ ^ '$Id: ProjectProblem.st,v 1.44 2015-02-24 23:48:50 cg Exp $'
! !