Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from dalehenrich/issue_136
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
1 parent
5990191
commit 5b7f4eb
Showing
31 changed files
with
391 additions
and
72 deletions.
There are no files selected for viewing
44 changes: 29 additions & 15 deletions
44
...-Core.package/MCFileTreeStCypressReader.class/instance/addClassDefinitionFrom.comment..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: [ '' ])) |
37 changes: 22 additions & 15 deletions
37
...FileTreeStCypressReader.class/instance/addExtensionClassAndMethodDefinitionsFromEntry..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
38 changes: 5 additions & 33 deletions
38
...leTreeStCypressReader.class/instance/addMethodDefinitionsForClass.methodProperties.in..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
41 changes: 41 additions & 0 deletions
41
...eader.class/instance/addMethodDefinitionsForClass.methodProperties.in.extensionMethod..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) ] ] ] ] |
15 changes: 15 additions & 0 deletions
15
...eTree-Core.package/MCFileTreeStCypressReader.class/instance/validateClassCategory.for..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
24 changes: 24 additions & 0 deletions
24
...MCFileTreeStCypressReader.class/instance/validateExtensionMethodCategory.for.selector..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
15 changes: 15 additions & 0 deletions
15
...FileTree-Core.package/MCFileTreeStCypressReader.class/instance/verifyCategory.matches..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ]) = $- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 106 additions & 1 deletion
107
repository/MonticelloFileTree-Core.package/monticello.meta/version
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
3 changes: 3 additions & 0 deletions
3
...celloFileTree-Tests.package/MCFileTreeIssue136Test.class/instance/tearDownPackagesList.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
running | ||
tearDownPackagesList | ||
^ #('Issue136-1' 'Issue136-2') |
18 changes: 18 additions & 0 deletions
18
.../MonticelloFileTree-Tests.package/MCFileTreeIssue136Test.class/instance/testClassError.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
18 changes: 18 additions & 0 deletions
18
...oFileTree-Tests.package/MCFileTreeIssue136Test.class/instance/testExtensionMethodError.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
7 changes: 7 additions & 0 deletions
7
...itory/MonticelloFileTree-Tests.package/MCFileTreeIssue136Test.class/methodProperties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" } } |
14 changes: 14 additions & 0 deletions
14
repository/MonticelloFileTree-Tests.package/MCFileTreeIssue136Test.class/properties.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"category" : "MonticelloFileTree-Tests", | ||
"classinstvars" : [ | ||
], | ||
"classvars" : [ | ||
], | ||
"commentStamp" : "", | ||
"instvars" : [ | ||
], | ||
"name" : "MCFileTreeIssue136Test", | ||
"pools" : [ | ||
], | ||
"super" : "MCFileTreeGenericLoaderTest", | ||
"type" : "normal" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.