Class.st
changeset 11429 b863adcf4b12
parent 11413 6ec31156cc0d
child 11484 e4e902c40ac6
equal deleted inserted replaced
11428:e002708d8caf 11429:b863adcf4b12
  4443 !
  4443 !
  4444 
  4444 
  4445 sourceStream
  4445 sourceStream
  4446     "return an open stream on my sourcefile, nil if that is not available"
  4446     "return an open stream on my sourcefile, nil if that is not available"
  4447 
  4447 
  4448     |owner source stream encoding|
  4448     |owner source stream|
  4449 
  4449 
  4450     (owner := self owningClass) notNil ifTrue:[^ owner sourceStream].
  4450     (owner := self owningClass) notNil ifTrue:[^ owner sourceStream].
  4451 
  4451 
  4452     classFilename notNil ifTrue:[
  4452     classFilename notNil ifTrue:[
  4453         source := classFilename
  4453         source := classFilename
  4455         source := (Smalltalk fileNameForClass:self) , '.st'
  4455         source := (Smalltalk fileNameForClass:self) , '.st'
  4456     ].
  4456     ].
  4457     stream := self sourceStreamFor:source.
  4457     stream := self sourceStreamFor:source.
  4458     stream notNil ifTrue:[
  4458     stream notNil ifTrue:[
  4459         "/ see if its utf8 encoded...
  4459         "/ see if its utf8 encoded...
  4460         encoding := CharacterEncoder guessEncodingOfStream:stream.
  4460         stream := ChangeSet decodedStreamFor:stream.
  4461         (encoding notNil and:[encoding ~~ #'iso8859-1' and:[encoding ~~ #'ascii']]) ifTrue:[
       
  4462             stream := EncodedStream stream:stream encoder:(CharacterEncoder encoderFor:encoding).
       
  4463         ].
       
  4464     ].
  4461     ].
  4465     ^ stream.
  4462     ^ stream.
  4466 !
  4463 !
  4467 
  4464 
  4468 sourceStreamFor:source
  4465 sourceStreamFor:source
  4897 ! !
  4894 ! !
  4898 
  4895 
  4899 !Class class methodsFor:'documentation'!
  4896 !Class class methodsFor:'documentation'!
  4900 
  4897 
  4901 version
  4898 version
  4902     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.536 2008-12-16 11:27:11 cg Exp $'
  4899     ^ '$Header: /cvs/stx/stx/libbasic/Class.st,v 1.537 2009-01-12 08:54:42 cg Exp $'
  4903 ! !
  4900 ! !