Skip to content

Conversation

@alexanderpann
Copy link
Collaborator

@alexanderpann alexanderpann commented Dec 2, 2025

The extension point is called AliasCustomization and can be used like this:

extension ExpressionWithInSpectorNewAlias of AliasCustomization { 
   
  activate 
  deactivate 
   
  IAliasCustomization get() { 
    new IAliasCustomization() { 
      @Override 
      public int getPriority()  { 
        0; 
      } 
       
      /** 
        Returns the map the contains mappings from the concept of the old aliases to the new aliases. The parameters to the 
        closure are the concept descriptor builder that could be used further customize the structure aspect of a concept 
        and the old alias. It must return a new alias for the concept. 
       */ 
      @Override 
      public map<concept<>, {SRepository, ConceptDescriptorBuilder2, string => string}> getAliasMapping()  { 
        map<concept<>, {SRepository, ConceptDescriptorBuilder2, string => string}> mapping = new hashmap<> ; 
        mapping[concept/ExpressionWithInspector/] = {SRepository repository, ConceptDescriptorBuilder2 builder, string oldAlias => 
			return oldAlias + " (" + concept/ExpressionWithInspector/.getShortDescription() + ")"; }; 
        mapping; 
      } 
    }; 
  } 
}

Through the ConceptDescriptorBuilder2 instance, the full concept structure aspect could be customized as well.

@alexanderpann alexanderpann changed the title feat(conditionalEditor): make it possible to customize the alias of any concept Conditional editor: Make it possible to customize the alias of any concept Dec 2, 2025
@alexanderpann alexanderpann force-pushed the feature/concept_alias_customization branch 2 times, most recently from b545afa to 512fc20 Compare December 2, 2025 14:27
@AtanasM98 AtanasM98 self-requested a review December 2, 2025 14:53
@alexanderpann alexanderpann force-pushed the feature/concept_alias_customization branch from 512fc20 to 552add5 Compare December 3, 2025 06:37
@alexanderpann alexanderpann merged commit 4b3f67f into maintenance/mps20251 Dec 3, 2025
2 checks passed
@alexanderpann alexanderpann deleted the feature/concept_alias_customization branch December 3, 2025 06:56
@sergej-koscejev
Copy link
Collaborator

This should somehow indicate that this is a big hack (the part about rebuilding the entire concept descriptor to change an alias) and can break in later MPS versions. What if some code somewhere decides to cache the old descriptor? And we should also link this to an issue on the JetBrains side where we request a proper implementation.

I don't quite understand the extension point API. A concept builder is provided to customize the concept but also you can return an alias? What happens if I use the builder to set alias A but return alias B?

@sergej-koscejev
Copy link
Collaborator

Overall, I'm unhappy that this got merged without a proper review from codeowners.

@alexanderpann
Copy link
Collaborator Author

This should somehow indicate that this is a big hack (the part about rebuilding the entire concept descriptor to change an alias) and can break in later MPS versions.

Yes, it is a hack, the alternative was to change a private final field, which is even worse and won't work in newer MPS versions. The last time a change was made to the descriptors, was probably for the transient fields, but other than that, they seem quite stable. They are recreated in the PR based on http://127.0.0.1:63320/node?ref=r%3A00000000-0000-4000-0000-011c89590293%28jetbrains.mps.lang.structure.generator_new.baseLanguage%40generator%29%2F540685334803387390.

What if some code somewhere decides to cache the old descriptor?

I never saw this before. Why would anyone cache a compiled descriptor? This has no performance advantages. You get the descriptor, for example, like this: ConceptRegistry.getInstance().getConceptDescriptor(MetaIdHelper.getConcept(concept/ClassConcept/))

I don't quite understand the extension point API.

We could remove the ConceptDescriptorBuilder2 parameter. It is not necessary, and I just added it in case someone wants to modify other parts of the descriptor. When you set the alias through the builder, it would immediately be overwritten by the returned string in the function.

And we should also link this to an issue on the JetBrains side where we request a proper implementation.

I created https://youtrack.jetbrains.com/issue/MPS-39355/Alias-Customization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants