Skip to content

Add an Interface SpaceKind #809

@dburriss

Description

@dburriss

I am opening this issue to have a discussion and record my findings. This may be something we don't want to do.

The idea is to add SpaceKind::Interface enum value so that interfaces show like classes (see image below).

This was kicked off from the conversation here with @calixteman .

Scope and motivation
This would be used in supported languages that make use interfaces ie. Java, TypeScript (future C# and Go?). This makes more sense recently since, for good or ill, many languages support default implementations on interfaces. This would give other languages a little more parity with the Rust implementation which distinguishes trait and impl already.

Effort and impact
This appears to be a fairly trivial feature to add:

  • Add SpaceKind::Interface enum
  • Add SpaceKind::Interface => "interface", to the match in the SpaceKind Display trait's fmt implementation

The following tasks are needed per language

  • For language's Getter.get_space_kind return SpaceKind::Interface for correct grammar elements ie. InterfaceDeclaration in Java ie. InterfaceDeclaration => SpaceKind::Interface
  • For the language's Checker implementation, add the grammar elements in the previous task to the is_func_space mk_checker macro arguments so the interface is included as a space for functions and metrics

I am not sure if this has much of a performance impact? I imagine not because of the type of change but I would need input or time to run tests.

Result
I implemented this for the Java lang and this is what it looks like.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions