Help Needed: Custom Formatting for <elseif> and <else> in SCXML Intellij Plugin

Answered

Hello Intellij Plugin Community,

I'm developing an Intellij plugin to improve the editing experience for SCXML files. SCXML is based on XML, and I've successfully defined a new language type SCXML derived from XML. However, I'm facing challenges when trying to customize the formatting, specifically to align <elseif> and <else> tags at the same indentation level as their parent <if> tag.

Desired Formatting

<if cond="">
   <log label="some test"/>
<elseif cond="true"/>
   <log label="some other test"/>
<else/>
</if>

I want <elseif> and <else> to be aligned with <if>, not indented as child elements.

What I’ve Tried:

  • Created custom block classes (ScxmlBlock and ScxmlTagBlock) extending IntelliJ’s XML formatting classes.
  • Overridden indentation methods to adjust the indentation based on tag names.
  • Registered a custom FormattingModelBuilder in plugin.xml.

While my custom block classes’ constructors are being called (verified via debug statements), the methods responsible for applying the custom indentation are not being executed. As a result, <elseif> and <else> tags are still indented incorrectly.

What I’m Unsure About:

  • Am I missing a crucial step in the formatting model setup?
  • Is there a better approach to achieve the desired indentation for specific SCXML tags?
  • Are there specific Intellij APIs or best practices I should follow for customizing XML-based language formatting?

 

Any guidance, resources, or examples of similar implementations would be greatly appreciated!

Thank you in advance for your help!

0
1 comment

Hi,

Could you please share your blocks' code?

0

Please sign in to leave a comment.