'From Pharo6.0 of 13 May 2016 [Latest update: #60225] on 15 September 2016 at 10:27:15.932951 pm'! IconStyler subclass: #ExampleIconStyler instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Reflectivity-Tools-Breakpoints'! !AbstractFileReference methodsFor: 'accessing' stamp: 'NicolaiHess 9/15/2016 22:25'! basename "Returns the basename, i.e. /foo/gloops.taz basename is 'gloops.taz' ` '/foo/gloops.taz' asFileReference basename -> 'gloops.taz'.` <- suceeds, no output ` '/foo/gloops.taz' asFileReference basename -> 'gloops.ta'.` <- fails, shows asserter ` '/foo/gloops.taz' asFileReference basename` < opens inspector " ^ self fullPath basename! ! !ExampleIconStyler methodsFor: 'as yet unclassified' stamp: 'NicolaiHess 9/15/2016 14:37'! iconBlock: aNode ^ (self exampleIsFaulty: aNode) ifTrue: [ self notifySourceError: aNode ] ifFalse: [self runExampleBlock: aNode]! ! !ExampleIconStyler methodsFor: 'as yet unclassified' stamp: 'NicolaiHess 9/15/2016 14:38'! iconFor: aNode ^ (self exampleIsFaulty: aNode) ifTrue: [ self iconProvider iconNamed: #smallWarning ] ifFalse: [ self iconProvider iconNamed: #smallInfo ]! ! !ExampleIconStyler methodsFor: 'as yet unclassified' stamp: 'NicolaiHess 9/15/2016 14:35'! exampleIsFaulty: aNode ^ aNode comments anySatisfy: [ :commentNode | commentNode exampleNodes anySatisfy:[:node | node value isFaulty ]]! ! !ExampleIconStyler methodsFor: 'as yet unclassified' stamp: 'NicolaiHess 9/15/2016 14:39'! notifySourceError: aNode ^ [ | examples faultyExample | examples := aNode comments flatCollect: #exampleNodes. faultyExample := examples detect: [ :example | example value isFaulty ]. RBParser parseExpression: faultyExample value source ]! ! !ExampleIconStyler methodsFor: 'as yet unclassified' stamp: 'NicolaiHess 9/15/2016 12:53'! shouldStyleNode: aNode ^ (aNode isMethod and: [ aNode comments isEmpty not ]) and: [ aNode comments anySatisfy: [ :commentNode | commentNode exampleNodes isNotEmpty ] ]! ! !ExampleIconStyler methodsFor: 'as yet unclassified' stamp: 'NicolaiHess 9/15/2016 14:44'! iconLabel: aNode "3+4" ^ (self exampleIsFaulty: aNode) ifTrue: [ 'Faulty Example' ] ifFalse: [ 'Runnable Examle' ]! ! !ExampleIconStyler methodsFor: 'as yet unclassified' stamp: 'NicolaiHess 9/15/2016 14:37'! runExampleBlock: aNode ^ [ | examples | examples := aNode comments flatCollect: #exampleNodes. examples collect: [ :example | | result | result := Smalltalk compiler evaluate: example value formattedCode. (result isKindOf: Association) ifFalse: [ result inspect ] ifTrue: [ TestAsserter new assert: result key equals: result value ] ] ]! ! !RBComment methodsFor: 'accessing' stamp: 'NicolaiHess 9/15/2016 22:25'! exampleNodes | a | a := '`(([$#'']`)|[^`])+`' asRegex matchingRangesIn: self contents. ^ a collect: [ :text | | i node | i := text first + 1 to: text last - 1. node := RBParser parseFaultyExpression: (self contents copyFrom: i first to: i last ). node doSemanticAnalysis. i -> node ]! ! !RubSHTextStylerST80 methodsFor: 'visiting rb nodes' stamp: 'NicolaiHess 9/15/2016 12:50'! visitMethodNode: aMethodNode | link | aMethodNode comments do: [ :comment | self addStyle: #comment from: comment start to: comment stop ]. aMethodNode comments do:[:k | |enodes| enodes := k exampleNodes. enodes do:[:ar | |inode tt| inode := ar value. tt := inode source asText. self class new style: tt ast: inode. tt withIndexDo:[:char :ij ||index| index := ij -1 + k start. charAttr from: (ar key first + index) to: (ar key first + index) put: (tt attributesAt: ij)]]]. aMethodNode arguments do: [ :argument | self addStyle: #patternArg forNode: argument ]. link := TextMethodLink selector: aMethodNode selector. aMethodNode selectorParts with: aMethodNode keywordsPositions do: [ :keyword :position | self addStyle: #patternKeyword attribute: link from: position to: position + keyword size - 1 ]. aMethodNode pragmas do: [ :each | self visitNode: each ]. self visitNode: aMethodNode body! !