Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync should take into account Class prefix #896

Open
Ducasse opened this issue Oct 17, 2024 · 0 comments
Open

Sync should take into account Class prefix #896

Ducasse opened this issue Oct 17, 2024 · 0 comments

Comments

@Ducasse
Copy link
Contributor

Ducasse commented Oct 17, 2024

In latest version of microdown we have support to know if a method is in sync with its counter part in a pharo system.

For example

degrees
	"Answer the angle the receiver makes with origin in degrees. right is 0; down is 90."
	| tan theta |
	^ x = 0
		ifTrue:
			[ y >= 0
				ifTrue: [ 90.0 ]
				ifFalse: [ 270.0 ] ]
		ifFalse:
			[ tan := y asFloat / x asFloat.
			theta := tan arcTan.
			x >= 0
				ifTrue:
					[ y >= 0
						ifTrue: [ theta radiansToDegrees ]
						ifFalse: [ 360.0 + theta radiansToDegrees ] ]
				ifFalse: [ 180.0 + theta radiansToDegrees ] ]

will tell the author if the method Point>>#degrees is changed.

Now it is based on string equality so this is not really good.

First because we can format it a bit differently on the book second because in books we often prefix with the class name e.g.

Point >> #degrees
	"Answer the angle the receiver makes with origin in degrees. right is 0; down is 90."
	| tan theta |
	^ x = 0
		ifTrue:
			[ y >= 0
				ifTrue: [ 90.0 ]
				ifFalse: [ 270.0 ] ]
		ifFalse:
			[ tan := y asFloat / x asFloat.
			theta := tan arcTan.
			x >= 0
				ifTrue:
					[ y >= 0
						ifTrue: [ theta radiansToDegrees ]
						ifFalse: [ 360.0 + theta radiansToDegrees ] ]
				ifFalse: [ 180.0 + theta radiansToDegrees ] ]

And Point >> is not part of the definition of the method.

A solution is

  • to check and identify the method starts by ignoring the Point >> or Point class >>. Note that this part is also optional since the author may just put the method body.
  • to use ast comparison instead of string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant