Skip to content

Commit

Permalink
Merge pull request #43 from JanBliznicenko/master
Browse files Browse the repository at this point in the history
File parsing error fix, tree inspection fixes and cleanup
  • Loading branch information
astares authored Feb 3, 2025
2 parents f8619c6 + 1809008 commit 26a8883
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
50 changes: 21 additions & 29 deletions src/XML-Parser-Tools/XMLNode.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,16 @@ XMLNode >> inspectSourceIn: specBuilder [

{ #category : '*XML-Parser-Tools' }
XMLNode >> inspectTreeIn: specBuilder [

<inspectorPresentationOrder: 28 title: 'Tree'>

| roots |

roots := self inspectorRoots.
^ specBuilder newTree
roots: roots;
display: [ :aNode |
self inspectorTreeStringFor: aNode
];
" displayIcon: [ :aNode | aNode iconName ifNotNil: [ :aName | self iconNamed: aName ] ];"
children: [ :aNode |

aNode hasChildren ifTrue: [ aNode descendantElements ] ifFalse: [ #() ]]


roots: roots;
display: [ :aNode | self inspectorTreeStringFor: aNode ];
" displayIcon: [ :aNode | aNode iconName ifNotNil: [ :aName | self iconNamed: aName ] ];"
children: [ :aNode | aNode elements ];
expandRoots
]

{ #category : '*XML-Parser-Tools' }
Expand All @@ -37,21 +31,19 @@ XMLNode >> inspectorRoots [

{ #category : '*XML-Parser-Tools' }
XMLNode >> inspectorTreeStringFor: anXMLElement [
| display |
anXMLElement isStringNode ifTrue: [ ^ anXMLElement string ].
display := String streamContents: [:s|
s nextPutAll: anXMLElement name.
anXMLElement hasAttributes ifTrue: [
s space.
anXMLElement attributes associations do: [:association |
s
nextPutAll: association key;
nextPutAll: '="';
nextPutAll: association value;
nextPutAll: '"'.
] separatedBy: [ s space ]
]
].
anXMLElement descendantElements isEmpty ifFalse: [ ^ '<',display, '>' ].
^ anXMLElement asString

anXMLElement hasElements ifFalse: [ ^ anXMLElement asString ].
^ String streamContents: [ :s |
s
nextPut: $<;
nextPutAll: anXMLElement name.
anXMLElement hasAttributes ifTrue: [
anXMLElement attributes associations do: [ :association |
s
space;
nextPutAll: association key;
nextPutAll: '="';
nextPutAll: association value;
nextPutAll: '"' ] ].
s nextPut: $> ]
]
2 changes: 1 addition & 1 deletion src/XML-Parser/XMLDecodingReadStreamAdapter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ XMLDecodingReadStreamAdapter >> atEnd [
XMLDecodingReadStreamAdapter >> detectEncoding [
prePeekStreamPosition := nil.
peekChar := nil.
stream reset.
stream position: 0.

(((self hasNullStreamConverter
or: [self hasImplicitStreamConverter])
Expand Down
14 changes: 14 additions & 0 deletions src/XML-Parser/XMLNode.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ XMLNode >> documentRoot [
^ documentRoot.
]

{ #category : 'accessing' }
XMLNode >> elements [
"returns a new node list of all of the receiver's elements"

^ XMLNodeList empty
]

{ #category : 'private' }
XMLNode >> errorXMLWritingUnsupported [
XMLDOMException signal: 'The XMLWriter package is required for writng DOM objects'
Expand All @@ -202,6 +209,13 @@ XMLNode >> hasChildren [
^ false
]

{ #category : 'testing' }
XMLNode >> hasElements [
"returns true if the receiver has element children"

^ false
]

{ #category : 'private' }
XMLNode >> hasNodeList: aNodeList [
^ false
Expand Down

0 comments on commit 26a8883

Please sign in to comment.