Add an Interface SpaceKind
dburriss opened this issue · 2 comments
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 interface
s 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 theSpaceKind
Display
trait'sfmt
implementation
The following tasks are needed per language
- For language's
Getter
.get_space_kind
returnSpaceKind::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 theis_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.
Some open questions for me on this:
- Do we even want to do this? Support this?
- Perf impact?
- Is this a breaking change? It does change the structure of output so are people depending on metrics being in only
Unit
,Class
, orFunction
? - How can this be tested?