Part I. SAP Commerce Developers Toolset (v.2022.3.1 IntelliJ IDEA plugin)


This article is brought by
Mykhailo Lytvyn
Software Engineering Team Leader, Solution Architect, Development/Performance/Open-Source Lead

Contributors & Editors:
Myles Bunbury, P.Eng, Senior Director, Technology Solutions, Global SAP Customer Experience Lead
Rauf Aliev, Chief Software Engineer, Solution Architect

 

A brief history of the topic

It has been over three years since Mykyta Kostiuk published his origin article that launched the SAP Commerce Developers Toolset IDEA Plugin (“Plugin”) as EPAM’s “give back” to the Hybris community.

For many years, EPAM has supported the Plugin, focusing on its ongoing compatibility with each IDEA release to keep developers free to work on SAP Commerce (Hybris) & SAP Commerce Cloud.


Questions you may ask are:

  1. What’s next, and…
  2. Will you be able to continue using this free version of the Plugin?

YES! Today I’ll share with you the results of active development started one late night in October 2022.

This article covers all changes made to the Plugin v2022.2 – v2022.3.1, along with some TODO’s and ideas for the future.

If you would like to contribute or share any ideas, the Plugin‘s GitHub repository is open, so feel free to contribute. As a starting point, check out the official Intellij Platform Plugin SDK documentation.


Just Open It

In the early days of the Plugin, there was only one way to create a new SAP Commerce IDEA project, via the “New Project” wizard.

Jetbrains is continuously working on new capabilities for Intellij IDEA and have introduced a new simplified process of project creation by just opening the folder.

From now on, if you have the Plugin installed and are trying to open a folder which is a potential SAP Commerce project, it will be imported with default settings and, once imported, you will be only asked to select the correct JDK.

Note: Due to the simplified import process, it is not possible to specify additional external modules such as Eclipse, Gradle or Maven projects. On other hand it is possible in latest version of the Plugin.


Plugin Settings Regrouped

Initially, some of the Plugin settings were placed under the Tool Window.

From now on, both Application & Project Plugin settings will be available under the common IDEA Settings page.

The remote instances configuration has been moved from the Tool Window to the new Plugin Settings page.

It is now possible to change settings used during Project Refresh after initial import.


Enabled Plugin Settings Synchronization

Switch your laptop, switch from one IDE to another, or even start from the scratch – settings of the Plugin will not be lost and can be restored/synced thanks to introduced support for the official Intellij IDEA Sync capabilities.

Login with your account and enable “Settings Sync” for the Plugin to ensure graceful switch from IDE to IDE.


Under the Plugin‘s Hood – Global Meta Model Concept

The original type system implementation which was used in code inspections for items.xml had one crucial issue – it was looking at the current file content and not at the “final” type system. This led to incorrectly reported violations of the validation rules.

To ensure that the logic will respect the so-called “final” state of the type system, one which will be actually available and created by SAP Commerce itself, a new, merged, global representation of the type system was required. It had to be used everywhere, in code inspections, code completions and navigation. Nevertheless, it had to follow a simple concept which could be applied for multiple SAP Commerce contexts.

As a result of refactoring, the new concept of the Global Meta Model was introduced. Instead of working on a single items.xml, beans.xml or *-cockpitng.xml file, a complete Global Meta Model will be built from all suitable sources. This uncovers new capabilities for code inspection, validation, and meta information retrieval from any place and also improves performance a lot.

The same concept was applied for multiple SAP Commerce configurations, including:

  • Type System
  • Bean System
  • Cockpit NG System
  • Business Processes
  • Extension Info files
  • Local Extension files

Type System

Type System – Preview

If you were ever wondering how to find out how a declared item would look like after all merges and manipulations without deploying or running SAP Commerce, it is now possible with Preview of the Type System.

Due to the fact that this preview relies on the global meta model of the type system, it will be refreshed on every modification and represent the latest version.

It can be found under [y] Tool Window > Type System and provides read-only access to the details of each declared item.

To ensure that this preview will show valuable data, the following content and actions are available in read-only mode (for now):

  • Atomics, Collections, Enums, Items, Maps & Relations
  • List all details, such as attributes, properties, indexes, types & declarations
  • Filtering out non-custom definitions
  • Other different grouping and filter options


Type System – items.xml

items.xml… Some may like, some may not. It may not be big, it may not be small. Less discussions, no more concussions, with new capabilities you just need to rock.

  • Added navigation to Enum’s alternative definitions
  • Added navigation to Map definition
  • Added support of the Map and Atomic types
  • Added navigation to Spring Bean definition of the attribute handler (Ultimate only)
  • Added navigation to Interceptor declaration(s) (Ultimate only)

Type System – In Code

SAP Commerce capabilities are hard to count. One of those is dynamic attributes. If you’re using them with caution, then there will be no issues, but in some cases they can be used in unsuitable places.

An excellent example of such usage is user.getAllGroups(). Inaccurate usage of dynamic attributes may lead to serious performance issues.

The situation is usually complicated due to the fact that it is not easy to distinguish “common” attributes from “dynamic” ones.

To support developers in such cases, new inlay hints will be added for each getter/setter in the Java code for dynamic attributes.


Type System – Inspections

Why? Why? Oh why does code inspection for items.xml with ~15k lines take soooooo much time!! I can’t image how many times I have asked myself this question.

In some cases, complete inspection of items.xml can take up to 10 minutes. And re-inspection is triggered on every modification, even on adding a space.

Luckily, it didn’t take much time to identify the root cause of the performance issue and strange grouping of the results, eg. only one single [y] inspection group.

The root cause of this behavior was that all rules were defined as regex rules in a single IDEA inspection rule. As such, they were recompiled, re-evaluated and… they respected only current file content. It means that they could even produce incorrect validation results.

As a result of re-writing all the rules from scratch, performance improved a lot. For a file that required 10 minutes previously, now just 10-20 seconds will be enough to complete the validation cycle.

  • Dramatically improved performance of the items.xml Code Inspection
  • Introduced grouping for each Inspection
  • Introduced various new quick-fixes
  • Next deployment code suggestion, etc.
  • Introduced multiple new Inspections
  • Wise identification of the deployment table tag absence
  • Catalog Aware item Inspections

Type System – Models

Initially it was possible to navigate to Item Type declaration from the generated Model Java classes.

Developers always want more and this “more” will be satisfied with some new capabilities:

  • Navigate to attribute and relation & relation end declarations from the Item Model (method and field levels)
  • Navigate to value declaration from the Enum Model

Type System – Structure View

  • Re-implemented structure view for items.xml files
  • Improved build performance
  • Added new icons, nodes, information and details


Type System – Debugger Java Type Renderers (y’ll like it!)

Debugging is a mandatory skill and activity of every developer. Unfortunately, SAP Commerce Models are not easy to debug due fact that they have only single field ctx which is available in the Debug preview.This means that every time there is a need to get a value from the SAP Commerce Model’s attribute or relation, one must execute Code Evaluation.

I’m glad to announce that this is all in the past. Now it will be possible to preview all attributes/relations/collections/maps in the Debugger preview for SAP Commerce Models thanks to created on-the-fly custom Java Type Renderers.


Bean System

Bean System – Preview

What is not actually available is complete Bean System. It is not possible to get a complete picture of all beans or all events declared in the SAP Commerce via every beans.xml. At least, it was not possible before…

With this new Plugin release, the same Global Meta Model Concept was applied for the Bean System. This gave it the possibility to build a complete preview of everything declared via beans.xml.

To ensure that this preview will show valuable data, the following content and actions are available in read-only mode (for now):

  • DTOs, Enums, Event Beans, WS Beans
  • List all details, such as properties, hints & imports
  • Distinguish WS Beans from common DTO Beans via wsRelated hint declaration


Bean System – Commons

  • Introduced navigation for Enums and Beans within the beans.xml
  • Introduced navigation to declaration of the Enum values and Bean properties

Bean System – Structure View

In a similar way to what was done for the Type System

  • Introduced current beans.xml file structure representation as a tree
  • Both Bean and Enum rendered with all properties / values, hint / annotations
  • Description shown as a separate node
  • Custom icons introduced for every node

FlexibleSearch

FlexibleSearch – Language

Even if the FlexibleSearch Language model is not yet perfect it is always nice to have something in common with ImpEx or items.xml. Thinking of that, I added the following new capabilities:

  • Introduced Completion for Enum & Relation types
  • Introduced Completion for all attributes/relations for Enum & Relation types
  • Improved Language Theming support
  • FlexibleSearch Language theme aligned with ImpEx colors

FlexibleSearch – In Code

It was not always an easy task to understand or interpolate how FlexibleSearch Query would look like. Taking this as an inspiration:

  • Added the possibility to preview preformatted FlexibleSearch Queries and copy them to the clipboard
  • StringBuilder is not supported due to its runtime nature

ImpEx

ImpEx – Commons

When we are talking about SAP Commerce, it’s impossible not to touch ImpEx. Considering the fact that it plays crucial role in every SAP Commerce solution, it had to be enhanced, so it is:

  • New icon for ImpEx Monitor
  • Introduced completion for Enum & Relation types
  • Introduced completion for all attributes/relations for Enum & Relation types
  • Added icons for relation ends / attributes / Item Types to improve usability
  • Adjusted theme schema for ImpEx files, so it can be customized
  • Added extra information as a tail for suggestion, such as dynamic or abstract
  • Improved Type preview for Relations and Maps, introduced flatten type for each Type in the System
  • Added code completion for cell-decorator
  • Added code completion for translator
  • Inspection: Unknown type

ImpEx – Extras

  • Added code completion for cell-decorator
  • Added code completion for translator
  • Inspection: Unknown type

Cockpit NG System (Backoffice)

Cockpit NG System – Commons

Since the decommission of the hMC and the introduction of Backoffice as its replacement, each SAP Commerce developer has had to touch multiple configuration XML files, specify types, attributes and configure wizards. There was only one tiny issue – the Plugin did not support those configuration files so developers were not able to use wise code completions, validations and navigation.

With this new release, every developer can feel all the power of Intellij IDEA in combination with rich Plugin capabilities.

If there are multiple nested context the Plugin will respect it and pick up closest one with type attribute set.

  • Added complete DOM model support for config and widgets
  • Added code completion for component
  • Added navigation to action/editor/widget definition
  • Almost all element are navigable and will have code completion
  • New custom Configuration file icon
  • New custom Widgets file icon
  • New custom Single Widget file icon
  • New custom Action Definition file icon
  • New custom Editor Definition file icon
  • New custom Widget Definition file icon


Cockpit NG System – Integration with Type System

Without any doubts, integration with the Type System is a must-have when working with Cockpit NG configuration files.

Type System was integrated in multiple places of the configuration files in a way it will simplify work of the developer:

  • Added code completion & navigation for Types and Attributes
  • Added support of complex type references
  • Introduced various validation rules

Cockpit NG System – Wizards

To ensure that work with Cockpit NG Create Wizards will be easier, support was added for the complex target Type identification. The correct type will be used based on the specified root.

  • Added complex Wizards support with nested context tags
  • Respect of the ctx.TYPE_CODE for Wizards

Cockpit NG System – Widgets

Most of the Widgets functionality is supported, except navigation between Socket declarations.

  • Added code completion & navigation within Widgets
  • Ability to retrieve available settings for the widget definition
  • Wise suggestion of the STUBs
    • Can be editor/action, etc., not only widget

Business Process

Even Business Process files were updated with new functionality, and more is planned to be released in the upcoming version of the Plugin:

  • New custom file icon
  • Added complete DOM model support
  • Added highlighting if the Spring bean used in the Business Process is not available
  • Added code completion and enriched navigation

Extension Info

Let’s not forget about good ol’ extensioninfo.xml. it didn’t receive any updates for a while, so it’s right about the time to change it.

  • New custom file icon
  • Added complete DOM model support
  • Added code completion of the Required Extension
    • Already defined required extensions will be excluded
  • Inspection: Dependency on the same Extension declared multiple times

Local Extensions

  • New custom file icon
  • Added complete DOM model support
  • Inspection: Unknown Extension declared as dependency

Other

Intellij IDEA – Release Channels

It was sometimes difficult to align Plugin with Intellij IDEA’s release cycle since it had only one stable release channel.

For those who always want to be up-to-date with the latest IDEA releases and API changes, a new EAP release channel has been added.


Intellij IDEA – Improved API Usage

Deprecated API usage is unwelcome in every project as it leads to API incompatibility and complexity during migration to newer versions.
If migration to new API versions is not done on a regular basis, it will, for sure, lead to increased release cycle times.

With latest release of the Plugin, usage of deprecated APIs was significantly decreased.

IU-223.7571.182 (2022.3) and below

  • 8 internal API usages
  • 12 usages of scheduled for removal API
  • 89 deprecated API usages
  • 1 override-only API usage violation
  • Configuration of SAP Commerce Developers Toolset 2022.3.0 has 1 defect
  • 2 compatibility warnings
  • 4 experimental API usages

IU-223.8214.52 (2022.3.1)

  • 1 deprecated API usage
  • 1 compatibility warning
  • 43 experimental API usages

Fixes and Adjustments

  • Include gensrc folder under platform->bootstrap
  • Improved copy ImpEx/FlexibleSearch to Console API
  • Introduced Plugin Update Checker
  • Prefill new Remote Instance Wizard form with those values from SAP Commerce properties
  • FlexibleSearch code completion no longer considers case sensitivity for attributions
  • Improved identification of the Java docs URL for SAP Commerce, related to SAP’s migration to the help.sap.com domain
  • Register backoffice spring.xml files during project import (Ultimate only)
  • Upgraded gradle version
  • Project refresh removes all modules when Gradle module is part of the project
  • Business Process Diagram cannot be generated in some cases
  • ImpEx config processor inspection
  • Console ToolWindows are not properly disposed
  • Exception on copy to console if triggered on file without extension
  • Process diagram layout shows actions in reverse order
  • Incorrect text ranges in ImpEx & FlexibleSearch files which lead to issues with completion, navigation and other errors
  • SAP Commerce logo is incorrectly displayed with new IDEA UI theme
  • SAP Commerce menu is not available right away after import
  • Dozens of other minor fixes and improvements
  • Moving from Java to Kotlin
  • And much, much more…

Plans & Ideas

  • Introduce Type System diagram
  • Enhance Business Process and Model Diagram with details
  • CCv2 project structure support
  • manifest.json file format support
  • Add more places with find usages support
  • Introduce CockpitNG System preview
  • Edit mode for Type and Bean systems
  • New Inspection rules and quick-fixes
  • Adjust FlexibleSearch language (formatting, logic, structure)
  • Improve performance of the PSI references via PSI cache
  • Add support for properties files (information about overrides)
  • Show Type System Global Meta Model merge conflicts
    • eg. Multiple extends
  • Preserve selected node in the Type / Bean System preview Tree on Meta Model refresh
  • Anything else what will come to my mind or any other mind…

That’s all for now! Stay tuned, more is coming in part 2 of this article series… Submit your ideas and contribute!

Leave a Reply