Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

feat(codeintel): Add scip-ctags support for Magik#63504

Merged
mmanela merged 15 commits intomainfrom
mmanela/graph-623-magik-symbol-side-bar-scip-ctags-or-universal-ctags
Jul 8, 2024
Merged

feat(codeintel): Add scip-ctags support for Magik#63504
mmanela merged 15 commits intomainfrom
mmanela/graph-623-magik-symbol-side-bar-scip-ctags-or-universal-ctags

Conversation

@mmanela
Copy link
Contributor

@mmanela mmanela commented Jun 27, 2024

Adds scip-ctags support for Magik. Some of the interesting pieces are that Magik uses a more prototype style of classes (called examplars) and tried to map those properly as classes. In addition, it has Mixins defined in a similar way and I also mapped those are classes as well

image

Test plan

  • Add test cases
  • Validate symbol browser in product

Changelog

  • Add symbol browsing support for the Magik language

@kritzcreek
Copy link
Contributor

  1. When / why would I use @enclosing versus @scope

From what I can tell at a glance @enclosing is trying to match this SCIP concept: https://github.com/sourcegraph/scip/blob/e7242d57e6ac8e9461378822fb3b5fd8a7a0acb8/scip.proto#L669-L721

Marking a global definition as @enclosing means, that the closest surrounding scope will be added to its occurrence. So the global is the enclosed thing here. A @scope is used to mark a node in the tree that encloses other things.

  1. For a magik exemplar, should I call it a object or a struct or a class? (I went with struct)

From a quick read I'd say it's closest to a class.

  1. You can also define a mixin in Magik. I labeled mixin as a class but I am not sure that is correct.

Mixins are meta-classes. The closest mainstream analogy might be a "decorator"... Looking at the list of capture kinds I don't see anything that matches better than class.

Comment on lines +17 to +19
_method line_parser.new()
_return _clone.init()
_endmethod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastiaanspeck is it common/possible to have non-trivial tree structures of declarations in Magik? I.e.

  1. A def_slotted_exemplar or def_mixin inside a method body (if this is possible, is it accessible outside the method)
  2. Another method definition inside a method body.
  3. Method bodies inside a slotted exemplar or mixin definition (similar to other languages like Java or Ruby)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastiaanspeck Ping on this if you can help us.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry, missed this comment completely.

  1. def_slotted_exemplar and def_mixin are invokable proc's. You could definitely call those inside a method body. The class (or in Magik exemplar) will be available to the package it is declared in.

Question 2:

_method example.method_a
    _method example.method_b
        >> "Hello World"
    _endmethod
_endmethod
$

This will not work.

Question 3:

def_slotted_examplar(:example, {}, 
    _method example.method_a
        >> "Hello World"
    _endmethod)
$
def_slotted_examplar(:example, {})
$

_method example.method_a
    >> "Hello World"
_endmethod
$

If you are talking about the second snippet, that is absolutely possible:

@mmanela mmanela marked this pull request as ready for review July 4, 2024 00:05
_block
_local some_local << 1
_constant some_local_constant << 1
_global some_global1, some_global2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebastiaanspeck Does defining a global inside of a block or a method create a new top-level global, or does it only let you refer to an existing top-level global?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the referring global variable already exists, it will access that one.

If the name does not include a package qualifier (@sw: or sw:) and there is no matching top level global, then the value of !global_auto_declare?! determines the subsequent behaviour:

  • if true, the Magik compiler creates a global variable with value unset
  • if maybe, the Magik compiler interactively queries the user if you want to declare a global variable.
  • if false, the Magik compiler raises an error

@mmanela mmanela merged commit d839e44 into main Jul 8, 2024
@mmanela mmanela deleted the mmanela/graph-623-magik-symbol-side-bar-scip-ctags-or-universal-ctags branch July 8, 2024 13:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants