Skip to content

Cypress topaz format has trouble when classes in system have empty method category names (I think) #16

@dalehenrich

Description

@dalehenrich

Error running Cypress package boilerplate for topaz:

topaz 1> doit
| packageName |
packageName := 'Cypress-GemStoneCompatibilityLayer'.
System myUserProfile symbolList do: [:symDict |
	symDict do: [:possibleClass |
			| toRemove |
		possibleClass isBehavior ifTrue: [
			{possibleClass. possibleClass class} do: [:aClass |
				aClass category = packageName
					ifTrue: [
							"*anythingbutpackagename[-anything]"
						toRemove := aClass categoryNames select: 
										[:each |
										(each first = $* and: [(each size = (packageName size + 1) and: [(each findStringNoCase: packageName startingAt: 2) = 2])
														or: [each size > (packageName size + 1) and: [(each findStringNoCase: packageName startingAt: 2) = 2 and: [(each at: packageName size + 2) = $-]]]])
										or: [each first ~= $*]]
					]
					ifFalse: [
							"*packagename[-anything]"
						toRemove := aClass categoryNames select: 
										[:each |
										each first = $* and: [(each size = (packageName size + 1) and: [(each findStringNoCase: packageName startingAt: 2) = 2])
														or: [each size > (packageName size + 1) and: [(each findStringNoCase: packageName startingAt: 2) = 2 and: [(each at: packageName size + 2) = $-]]]]]
					].
				toRemove do: [:each | aClass removeCategory: each].
			]
		]
	]
].
true.
%
ERROR 2019 , a ImproperOperation occurred (error 2019), reason:objErrCollectionEmpty, An attempt was made to access elements of the empty collection #''. (ImproperOperation)

From code inspection it looks like we need to protect the senders of `#first':

    aClass categoryNames select:
                                        [:each |
                                        each first = $* ...
to something like this:

    aClass categoryNames select:
                                        [:each |
                                        each isEmpty not and: [each first = $* ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions