Skip to content

Setting names in the Symbols Builder can lead to inconsistencies #97

@schmalzing

Description

@schmalzing

Are you able replicate the bug in the latest version of MontiCore.

Describe the bug

Names in the context of symbol builders are weird.

First, full names: Why is there even an option to set the full name of a symbol in the builder? Isn't a full name a lazy loaded derived property? If there is a use case to be able to set the full name via the builder, then I would at least expect some checks:

  1. The last part of the full name is the name (if present)
  2. The qualifier of the full name is the package name (if present)
  3. If the package name is not present, the qualifier of the full name is the qualifier derived from the scope structure

And if neither name nor package name is not present, I expect these to be derived from the full name. Being able to set all and inconsistently is prone to errors.

Furthermore, the package name has similar problems to the full name. Usually, the package name is derived from the scope structure. The package that can be set via the builder is more or less useless but prone to inconsistencies. If you set the name and package for the OOSymbol builder but not the enclosing scope package, the symbol's package is ignored; the full name is just the simple name.

For the package name, I expect similar checks to those defined above for the full name.

Steps to reproduce

How to reproduce inconsistent fullname and package name

OOSymbolsMill.oOTypeSymbolBuilder()
        .setPackageName("java.lang")
        .setName("Boolean")
        .setSpannedScope(MontiArcMill.scope())
        .setEnclosingScope(scope)
        .build()

How to reproduce inconsistent fullname, name, and package name

OOSymbolsMill.oOTypeSymbolBuilder()
        .setPackageName("java.lang")
        .setName("Boolean")
        .setFullName("non.java.lang.Character")
        .setSpannedScope(MontiArcMill.scope())
        .setEnclosingScope(scope)
        .build()

Expected behaviour

I would expect there to be no option to set the full name. I also would expect there to be at least consistency checks between as defined above.

Minimal reproducible example

No response

Relevant CI workflow/pipeline

No response

Gradle Log

No response

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions