Hello,

Suppose that you want to show the diff between the source code of two
methods. In the case that both methods are in the same class, and that such
class is present in the system, then no problem: In a DiffModel, one can
set a context to the smalltalk syntax styler and get a nice output.

DiffModel new
leftText: (Point >> #x) sourceCode;
rightText: (Point >> #y) sourceCode;
contextClass: Point;
openWithSpec.
[image: Inline image 1]

But what happens in the case that the class does not exist in the system?

If one doesn't set any context to the styler, then the string will be shown
all in black, which is not nice. A partial solution could be to set Object
as a context, then the styler will color the code, but instance variables
are in red:

DiffModel new
leftText: (Point >> #x) sourceCode;
rightText: (Point >> #y) sourceCode;
contextClass: Object;
openWithSpec.

[image: Inline image 2]

Which is also not nice. In my opinion, there should be a styler that just
colors the code following the syntax, without checking if the variables or
classes are present in the system. It would be an environment-independent
styler.

What do you recommend to implement this? I guess it should be easy to
subclass SHTextStylerST80 and override some methods to do not check
anything in the environment.

What's your opinion?

Thanks,
Martin

Reply via email to