Skip to content

Commit

Permalink
Merge pull request #137 from dalehenrich/issue_136
Browse files Browse the repository at this point in the history
fix for Issue #136
Conflicts:

	repository/MonticelloFileTree-Core.package/MCFileTreeStCypressReader.class/instance/addClassDefinitionFrom.comment..st
	repository/MonticelloFileTree-Core.package/MCFileTreeStCypressReader.class/instance/addExtensionClassAndMethodDefinitionsFromEntry..st
	repository/MonticelloFileTree-Core.package/MCFileTreeStCypressReader.class/instance/addMethodDefinitionsForClass.methodProperties.in..st
  • Loading branch information
dalehenrich committed Jan 31, 2015
1 parent 5990191 commit 5b7f4eb
Show file tree
Hide file tree
Showing 31 changed files with 391 additions and 72 deletions.
@@ -1,17 +1,31 @@
utilities
addClassDefinitionFrom: classPropertiesDict comment: classComment
definitions
add:
(MCClassDefinition
name: (classPropertiesDict at: 'name')
superclassName: (classPropertiesDict at: 'super')
traitComposition: (classPropertiesDict at: 'traitcomposition' ifAbsent: [ '{}' ])
classTraitComposition: (classPropertiesDict at: 'classtraitcomposition' ifAbsent: [ '{}' ])
category: (classPropertiesDict at: 'category' ifAbsent: [ self packageNameFromPackageDirectory ])
instVarNames: (classPropertiesDict at: 'instvars' ifAbsent: [ #() ])
classVarNames: (classPropertiesDict at: 'classvars' ifAbsent: [ #() ])
poolDictionaryNames: (classPropertiesDict at: 'pools' ifAbsent: [ #() ])
classInstVarNames: (classPropertiesDict at: 'classinstvars' ifAbsent: [ #() ])
type: (classPropertiesDict at: 'type' ifAbsent: [ 'normal' ]) asSymbol
comment: classComment
commentStamp: (classPropertiesDict at: 'commentStamp' ifAbsent: [ '' ]))
| typeSymbolOrArray categoryName className |
typeSymbolOrArray := classPropertiesDict at: 'type' ifAbsent: [ 'normal' ].
typeSymbolOrArray isArray
ifTrue: [
typeSymbolOrArray := typeSymbolOrArray
collect: [ :each |
each isArray
ifTrue: [ each collect: [ :ea | ea asSymbol ] ]
ifFalse: [ each asSymbol ] ] ]
ifFalse: [ typeSymbolOrArray := typeSymbolOrArray asSymbol ].
className := classPropertiesDict at: 'name'.
categoryName := classPropertiesDict
at: 'category'
ifAbsent: [ self packageNameFromPackageDirectory ].
self validateClassCategory: categoryName for: className.
definitions
add:
(MCClassDefinition
name: className
superclassName: (classPropertiesDict at: 'super')
category: categoryName
instVarNames: (classPropertiesDict at: 'instvars' ifAbsent: [ #() ])
classVarNames: (classPropertiesDict at: 'classvars' ifAbsent: [ #() ])
poolDictionaryNames: (classPropertiesDict at: 'pools' ifAbsent: [ #() ])
classInstVarNames:
(classPropertiesDict at: 'classinstvars' ifAbsent: [ #() ])
type: typeSymbolOrArray
comment: classComment
commentStamp: (classPropertiesDict at: 'commentStamp' ifAbsent: [ '' ]))
@@ -1,17 +1,24 @@
utilities
addExtensionClassAndMethodDefinitionsFromEntry: classEntry
| classDirectory classPropertiesDict methodPropertiesDict entries |
classDirectory := self fileUtils directoryFromEntry: classEntry.
((entries := classDirectory entries) detect: [ :entry | self isPropertyFile: entry] ifNone: [ ])
ifNotNil: [ :propertyEntry | propertyEntry readStreamDo: [ :fileStream | classPropertiesDict := MCFileTreeJsonParser parseStream: fileStream ] ].
methodPropertiesDict := Dictionary new.
(entries detect: [ :entry | self isMethodPropertyFile: entry] ifNone: [ ])
ifNotNil: [ :propertyEntry |
propertyEntry
readStreamDo: [ :fileStream |
"Issue 33: https://github.com/dalehenrich/filetree/issues/33"
methodPropertiesDict := MCFileTreeJsonParser parseStream: fileStream ] ].
self
addMethodDefinitionsForClass: (classPropertiesDict at: 'name')
methodProperties: methodPropertiesDict
in: entries
| classDirectory classPropertiesDict methodPropertiesDict entries |
classDirectory := self fileUtils directoryFromEntry: classEntry.
((entries := classDirectory entries)
detect: [ :entry | self isPropertyFile: entry ]
ifNone: [ ])
ifNotNil: [ :propertyEntry |
propertyEntry
readStreamDo: [ :fileStream |
classPropertiesDict := MCFileTreeJsonParser
parse: fileStream contents decodeFromUTF8 ] ].
methodPropertiesDict := Dictionary new.
(entries detect: [ :entry | self isMethodPropertyFile: entry ] ifNone: [ ])
ifNotNil: [ :propertyEntry |
propertyEntry
readStreamDo: [ :fileStream |
"Issue 33: https://github.com/dalehenrich/filetree/issues/33"
methodPropertiesDict := MCFileTreeJsonParser parseStream: fileStream ] ].
self
addMethodDefinitionsForClass: (classPropertiesDict at: 'name')
methodProperties: methodPropertiesDict
in: entries
extensionMethod: true
@@ -1,35 +1,7 @@
utilities
addMethodDefinitionsForClass: className methodProperties: methodProperties in: entries
entries
do: [ :entry |
| classIsMeta |
classIsMeta := false.
entry name = 'class'
ifTrue: [ classIsMeta := true ].
(entry name = 'instance' or: [ entry name = 'class' ])
ifTrue: [
((self fileUtils directoryFromEntry: entry) entries select: [ :each | each name endsWith: '.st' ])
do: [ :methodEntry |
methodEntry
readStreamDo: [ :fileStream |
| category source timestamp selector |
category := fileStream nextLine.
source := fileStream upToEnd.
selector := self methodSelectorFor: source.
timestamp := methodProperties
at:
(classIsMeta
ifTrue: [ 'class' ]
ifFalse: [ 'instance' ])
ifPresent: [ :map | map at: selector asString ifAbsent: [ ] ]. "Issue 33: https://github.com/dalehenrich/filetree/issues/33"
timestamp
ifNil: [ timestamp := self info author , ' ' , self info date mmddyyyy , ' ' , self info time print24 ].
definitions
add:
(MCMethodDefinition
className: className
classIsMeta: classIsMeta
selector: selector
category: category
timeStamp: timestamp
source: source) ] ] ] ]
^ self
addMethodDefinitionsForClass: className
methodProperties: methodProperties
in: entries
extensionMethod: false
@@ -0,0 +1,41 @@
utilities
addMethodDefinitionsForClass: className methodProperties: methodProperties in: entries extensionMethod: extensionMethod
entries
do: [ :entry |
| classIsMeta |
classIsMeta := false.
entry name = 'class'
ifTrue: [ classIsMeta := true ].
(entry name = 'instance' or: [ entry name = 'class' ])
ifTrue: [
((self fileUtils directoryFromEntry: entry) entries
select: [ :each | each name endsWith: '.st' ])
do: [ :methodEntry |
methodEntry
readStreamDo: [ :fileStream |
| category source timestamp selector |
category := fileStream nextLine decodeFromUTF8.
category := category copyFrom: 1 to: category size - 1. "remove newline"
source := fileStream upToEnd decodeFromUTF8.
selector := self methodSelectorFor: source.
timestamp := methodProperties
at:
(classIsMeta
ifTrue: [ 'class' ]
ifFalse: [ 'instance' ])
ifPresent: [ :map | map at: selector asString ifAbsent: [ ] ]. "Issue 33: https://github.com/dalehenrich/filetree/issues/33"
timestamp
ifNil: [
timestamp := self info author , ' ' , self info date mmddyyyy , ' '
, self info time print24 ].
extensionMethod
ifTrue: [ self validateExtensionMethodCategory: category for: className selector: selector ].
definitions
add:
(MCMethodDefinition
className: className
classIsMeta: classIsMeta
selector: selector
category: category
timeStamp: timestamp
source: source) ] ] ] ]
@@ -0,0 +1,15 @@
validation
validateClassCategory: categoryName for: className
"https://github.com/dalehenrich/filetree/issues/136"

"class category must match the package name ... guard against manual editing mistakes"

| prefix |
prefix := self packageNameFromPackageDirectory.
(self verifyCategory: categoryName matches: prefix)
ifTrue: [ ^ self ].
self
error:
'Class category name ' , categoryName printString , ' for the class '
, className printString , ' is inconsistent with the package name '
, prefix printString
@@ -0,0 +1,24 @@
validation
validateExtensionMethodCategory: categoryName for: className selector: selector
"https://github.com/dalehenrich/filetree/issues/136"

"method category must match the package name for extension methods... guard against manual editing mistakes"

"extracted from PackageInfo>>isForeignClassExtension:"

| prefix prefixSize catSize |
prefix := '*' , self packageNameFromPackageDirectory asLowercase.
categoryName
ifNotNil: [
(categoryName isEmpty not
and: [
categoryName first = $*
and: [
"asLowercase needed in GemStone 3.1.0.6?"
self verifyCategory: categoryName asLowercase matches: prefix ] ])
ifTrue: [ ^ self ] ].
self
error:
'Method protocol ' , categoryName printString , ' for the method '
, selector printString , ' in class ' , className printString
, ' is inconsistent with the package name ' , prefix printString
@@ -0,0 +1,15 @@
validation
verifyCategory: categoryName matches: prefix
"https://github.com/dalehenrich/filetree/issues/136"

"copied from PackageInfo>>category:matches:"

| prefixSize catSize |
categoryName ifNil: [ ^ false ].
catSize := categoryName size.
prefixSize := prefix size.
catSize < prefixSize
ifTrue: [ ^ false ].
(categoryName findString: prefix startingAt: 1 caseSensitive: false) = 1
ifFalse: [ ^ false ].
^ (categoryName at: prefix size + 1 ifAbsent: [ ^ true ]) = $-
Expand Up @@ -5,14 +5,18 @@
"instance" : {
"addClassAndMethodDefinitionsFromDirectory:" : "dkh 4/4/2012 10:27",
"addClassAndMethodDefinitionsFromEntry:" : "dkh 8/10/2012 13:48",
"addClassDefinitionFrom:comment:" : "dkh 6/27/2012 14:18",
"addExtensionClassAndMethodDefinitionsFromEntry:" : "dkh 8/10/2012 14:00",
"addMethodDefinitionsForClass:methodProperties:in:" : "dkh 8/10/2012 14:01",
"addClassDefinitionFrom:comment:" : "dkh 01/31/2015 06:51",
"addExtensionClassAndMethodDefinitionsFromEntry:" : "dkh 01/31/2015 06:56",
"addMethodDefinitionsForClass:methodProperties:in:" : "dkh 01/31/2015 06:55",
"addMethodDefinitionsForClass:methodProperties:in:extensionMethod:" : "dkh 01/31/2015 06:56",
"basicVersion" : "dkh 6/27/2012 20:19",
"isMethodPropertyFile:" : "dkh 6/16/2013 12:47:20",
"isPropertyFile:" : "dkh 6/16/2013 12:47:20",
"loadDefinitions" : "dkh 5/23/2013 21:05",
"loadPackage" : "dkh 6/27/2012 20:21",
"loadVersionInfo" : " 08/08/2013 15:01",
"loadVersionInfo" : "08/08/2013 15:01",
"methodSelectorFor:" : "ChristopheDemarey 5/31/2013 23:28",
"packageNameFromPackageDirectory" : "dkh 6/27/2012 13:49" } }
"packageNameFromPackageDirectory" : "dkh 8/10/2012 14:55",
"validateClassCategory:for:" : "dkh 01/31/2015 07:06",
"validateExtensionMethodCategory:for:selector:" : "dkh 01/31/2015 08:24",
"verifyCategory:matches:" : "dkh 01/31/2015 07:05" } }
107 changes: 106 additions & 1 deletion repository/MonticelloFileTree-Core.package/monticello.meta/version

Large diffs are not rendered by default.

Empty file.
@@ -0,0 +1,3 @@
running
tearDownPackagesList
^ #('Issue136-1' 'Issue136-2')
@@ -0,0 +1,18 @@
tests
testClassError
| packageName gofer hitError description |
packageName := 'Issue136-1'.
{packageName} do: [ :pn | self deny: (self hasPackage: pn) ].
gofer := Gofer new
disablePackageCache;
repository: (self getTestRepository: 'issue136');
package: packageName;
yourself.
hitError := false.
[ gofer load ]
on: Error
do: [ :ex |
hitError := (description := ex description)
endsWith:
'Class category name ''Issue97'' for the class ''CypressMockIssue97'' is inconsistent with the package name ''Issue136-1''' ].
self assert: hitError description: description
@@ -0,0 +1,18 @@
tests
testExtensionMethodError
| packageName gofer hitError description |
packageName := 'Issue136-2'.
{packageName} do: [ :pn | self deny: (self hasPackage: pn) ].
gofer := Gofer new
disablePackageCache;
repository: (self getTestRepository: 'issue136');
package: packageName;
yourself.
hitError := false.
[ gofer load ]
on: Error
do: [ :ex |
hitError := (description := ex description)
endsWith:
'Method protocol ''*Issue97'' for the method ''isCypressMockIssue97'' in class ''Object'' is inconsistent with the package name ''*issue136-2''' ].
self assert: hitError description: description
@@ -0,0 +1,7 @@
{
"class" : {
},
"instance" : {
"tearDownPackagesList" : "dkh 01/31/2015 07:31",
"testClassError" : "dkh 01/31/2015 07:46",
"testExtensionMethodError" : "dkh 01/31/2015 10:22" } }
@@ -0,0 +1,14 @@
{
"category" : "MonticelloFileTree-Tests",
"classinstvars" : [
],
"classvars" : [
],
"commentStamp" : "",
"instvars" : [
],
"name" : "MCFileTreeIssue136Test",
"pools" : [
],
"super" : "MCFileTreeGenericLoaderTest",
"type" : "normal" }
Expand Up @@ -2,5 +2,5 @@
"class" : {
},
"instance" : {
"tearDownPackagesList" : " 08/01/2013 18:35",
"testLoad" : " 08/01/2013 18:46" } }
"tearDownPackagesList" : "08/01/2013 18:35",
"testLoad" : "08/01/2013 18:46" } }

0 comments on commit 5b7f4eb

Please sign in to comment.