[FIX] TimeProfileBrowser fixes

Doug Way dway at mat.net
Sat Mar 4 08:31:37 UTC 2000


This changeset fixes a couple of bugs in the way the TimeProfileBrowser
parsed the output from MessageTally.

1. The first character of each line is no longer truncated.
2. Non-super class-side methods can now be browsed without generating an
error.

(For an example of #2, try "TimeProfileBrowser onBlock: [Morph
repairMorphsUnknownToTheirOwners]".

- Doug Way
  EAI/Transom Technologies, Ann Arbor, MI
  http://www.transom.com
  dway at mat.net, @eai.com
-------------- next part --------------
'From Squeak2.8alpha of 14 February 2000 [latest update: #1852] on 4 March 2000 at 1:53:39 am'!
"Change Set:		TimeProfileFixes-dew
Date:			4 March 2000
Author:			Doug Way

Fixes a couple of parsing bugs with the TimeProfileBrowser.  It no longer truncates the first character of each line, and class-side non-super methods now show up properly."!


!TimeProfileBrowser methodsFor: 'private' stamp: 'dew 3/2/2000 19:59'!
runBlock

	| stream list |
	tally := MessageTally new.
	tally spyEvery: 16 on: block.
	stream := ReadWriteStream with: (String streamContents: [:s | tally report: s; close]).
	stream reset.
	list := OrderedCollection new.
	[stream atEnd]
		whileFalse:
		[list add: (stream upTo: Character cr)].
	self initializeMessageList: list.
	self changed: #messageList.
	self changed: #messageListIndex.
! !

!TimeProfileBrowser methodsFor: 'private' stamp: 'dew 3/2/2000 20:04'!
setClassAndSelectorIn: csBlock
	"Decode strings of the form    <selectorName> (<className> [class])  "

	| string strm class sel parens |
	messageListIndex < 3 ifTrue: [^contents := nil].		"Ignore first 2 lines"
	string _ self selection asString.
	string isEmpty ifTrue: [^contents := nil].
	string first == $* ifTrue: [^contents := nil].		"Ignore lines starting with *"
	parens := string includes: $(.					"Does it have open-paren?"
	strm := ReadStream on: string.
	parens
		ifTrue: [strm skipTo: $(.		"easy case"
			class := strm upTo: $).
			strm next: 2.
			sel := strm upToEnd]
		ifFalse: [strm position: (string findString: ' class>>').
			strm position > 0
				ifFalse: [strm position: (string findLast: [ :ch | ch == $ ])]
				ifTrue:
					[ | subString |  "find the next to last space character"
					subString := strm contents copyFrom: 1 to: (string findLast: [ :ch | ch == $ ]) - 1.
					strm position: (subString findLast: [ :ch | ch == $ ])].
		"ifFalse: [strm position: (string findLast: [ :ch | ch == $ ])."
			class := strm upTo: $>.
			strm next.
			sel := strm upToEnd].
	class isEmpty ifTrue: [^contents := nil].
	sel isEmpty ifTrue: [^contents := nil].
	^MessageSet parse: (class, ' ', sel) toClassAndSelector: csBlock! !




More information about the Squeak-dev mailing list