.. ******************************************************************************* * MetaFactory.io R2 * Technical Documentation * * File name : Configure-IntelliJ.rst * Created by : MetaFactory (Marnix) * Last update : 26-03-2021 * Updated by : Niels de Nies * * MetaFactory BV Amsterdam ******************************************************************************* .. include:: /external-links.txt .. include:: /inline-images.txt Configuring IntelliJ IDEA ------------------------- For optimal use of MetaFactory with IntelliJ some configuration is required. .. toctree:: :maxdepth: 1 :caption: Plugin configuration Configure-IntelliJ-Plugin Resolving XML errors ~~~~~~~~~~~~~~~~~~~~ When opening a MetaFactory pattern.xml, the namespace and schemalocation will be marked in red, as shown in the screenshot below: .. todo:: Update namespaces in text and images .. figure:: images/IntelliJPatternXmlError-768x613.png :name: PatternXmlError :scale: 100% Now move your cursor to the red marked namespace and press ALT-ENTER to resolve the issue. Choose the option “Manually setup external resources”. .. figure:: images/IntelliJPatternFixXmlError-768x613.png :name: FixXmlError :scale: 100% Subsequently navigate to the MetaFactory installation folder and select the right XSD in the support sub folder. .. figure:: images/IntelliJExternalResourceSelection.png :name: ResourceSelection :scale: 100% ..rubric:: Namespaces** .. list-table:: :widths: 2 6 4 :header-rows: 1 :class: tight-table * - file - namespace - xsd * - metafactory.xml - http://www.firstbase.nl/xsd/personaliom/project - personal-iom-project.xsd * - pattern.xml - http://www.firstbase.nl/xsd/personaliom/pattern - pattern.xsd * - model.xml - https://metafactory.io/xsd/v1/model - model.xsd Live Templates ~~~~~~~~~~~~~~ In order to use the live templates with MetaFactory you need to copy the file Freemarker.xml from the support/idea folder of the installation path to the ‘Settings’ folder of IntelliJ. .. list-table:: :widths: 20 50 :class: tight-table * - OSX - ~/Library/Preferences/IntelliJIdea14/templates/Freemarker.xml * - Windows - /.IntelliJIdea14/config/templates/Freemarker.xml |Exclam M| If the folder ‘templates’ does not exist, please create it. The result will look as follows: .. figure:: images/IntelliJLiveTemplates-730x768.png :name: LiveTemplates :scale: 100% Implicit objects in Freemarker or Velocity templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MetaFactory places a number of objects inside the context of Freemarker or Velocity. IntelliJ will need to know about these objects so that the error messages such as the ones shown below will disappear: .. figure:: images/IntelliJUnknownObjects-768x277.png :name: UnknownObjects :scale: 100% The first step to achieve this is to add 2 jars from the MetaFactory installation as a Global Library inside the project: .. figure:: images/IntelliJAddGlobalLibrary-768x735.png :name: AddGlobalLibrary :scale: 100% Add *metafactory-api-.jar, jdom2-.jar and commons-lang3-.jar* as a Global Library. Copy the files freemarker_implicit.ftl and velocity_implicit.vm from the support/idea sub folder of the MetaFactory installation to the snippets section of the MetaFactory project. After copying these files to the sources root of IntelliJ they will be automatically detected and used. Whether the sources root is located at the module level or as a sub folder of that depends on the module. In some cases sources root doesn’t exist yet at all, then the directory will have to be explicitly marked as such: .. figure:: images/IntelliJMarkDirectoryAsSourcesRoot-608x768.png :name: DirectoryAsSourcesRoot :scale: 100% |Check M| When all of this has been done, the error messages will disappear from the Freemarker en Velocity editor and auto complete can now be used on its objects.