[FIX] Warning about corrupted sources

Henrik Gedenryd Henrik.Gedenryd at lucs.lu.se
Mon Mar 13 19:16:22 UTC 2000

Disables the new sources warning when the class uses a custom parser, like
Prolog (or Squeak will warn you on every method you click on even if they
are ok).

Also adds Mac-specific info on the probable cause--if Bruce's recent tweak
makes this never pop up, then so much for the better, but it should be
there, still. 

Note that this problem may concern both .sources and .changes files.


< = > .

-------------- next part --------------
'From Squeak2.8alpha of 7 February 2000 [latest update: #1919] on 13 March 2000 at 12:10:40 pm'!

!Browser methodsFor: 'message list' stamp: 'hg 3/13/2000 11:49'!
	"Answer a copy of the source code for the selected message selector."
	| class selector method tempNames |
	contents == nil ifFalse: [^ contents copy].
	class _ self selectedClassOrMetaClass.
	selector _ self selectedMessageName.
	method _ class compiledMethodAt: selector ifAbsent: [
		^ ''].	"method deleted while in another project"
	currentCompiledMethod _ method.

	(Sensor controlKeyPressed
		or: [method fileIndex > 0 and: [(SourceFiles at: method fileIndex) == nil]])
		["Emergency or no source file -- decompile without temp names"
		contents _ (class decompilerClass new decompile: selector in: class method: method)
		contents _ contents asText makeSelectorBoldIn: class.
		^ contents copy].

	Sensor leftShiftDown ifTrue:
		["Special request to decompile -- get temps from source file"
		tempNames _ (class compilerClass new
						parse: method getSourceFromFile asString in: class notifying: nil)
		contents _ ((class decompilerClass new withTempNames: tempNames)
				decompile: selector in: class method: method) decompileString.
		contents _ contents asText makeSelectorBoldIn: class.
		^ contents copy].

	contents _ class sourceCodeAt: selector.
	self validateMessageSource: selector.

	Preferences browseWithPrettyPrint ifTrue:
		[contents _ class compilerClass new
			format: contents in: class notifying: nil decorated: Preferences colorWhenPrettyPrinting].
	self showDiffs ifTrue:
		[contents _ self diffFromPriorSourceFor: contents].

	contents _ contents asText makeSelectorBoldIn: class.
	^ contents copy! !

!Browser methodsFor: 'message list' stamp: 'hg 3/13/2000 12:07'!
validateMessageSource: selector
	(self selectedClass compilerClass == Object compilerClass 
			and: [(contents asString findString: selector keywords first ) ~= 1])
		ifTrue: [
			PopUpMenu notify: 'Possible problem with source file!!

The method source should start with the method selector 
but this is not the case!! You may proceed with caution 
but it is recommended that you get a new source file.

This can happen if you download the "SqueakV2.sources" file, 
or the ".changes" file you use, as Text. It must be transfered 
in Binary mode, even if it looks like a text file, 
to preserve the CR line ends.

Mac users: This may have been caused by Stuffit Expander. 
To prevent the files above to be converted to Mac line ends 
when they are expanded, do this: Start the program, then 
from Preferences... in the File menu, choose the Cross 
Platform panel, then select "Never" and press OK. 
Then expand the compressed archive again.'].! !

More information about the Squeak-dev mailing list