Child pages
  • Run Configurations
Skip to end of metadata
Go to start of metadata

Run Configurations

Introduction

Run configurations allow you to define how to execute programs, written in your language.

An existing run configuration can be executed either from run configurations box, positioned on the main toolbar,

by the "Run" menu item in the main menu

or through the run/debug popup (Alt+Shift+F10/Alt+Shift+F9).

Also run configurations could be executed/created for nodes, models, modules and project. For example, JUnit run configuration could run all tests in selected project, module or model. See Run configurations creators on how to implement such behavior for you run configurations.

To summarize, run configurations define the following things:

  • On creation stage:
    • configurations name, caption, icon;
    • configurations kind;
    • how to create a configuration from node(s), model(s), module(s), project.
  • On configuration stage:
    • persistent parameters;
    • editor for persistent parameters;
    • checker of persistent parameters validity.
  • On execution stage:
    • proccess which is actually executed;
    • console with all its tabs, action buttons and actual console window;
    • things required for debugging this configuration (if it is possible).

General purpose run configurations

In order to create a run configuration, you must create an instance of RunConfigurationTypeDeclaration concept to define a kind of your new run configuration and then create one or several instances of RunConfigurationDeclaration concept, defining the specific run configuration.

RunConfigurationDeclaration has the following structure:

Name

Is Required

Description

type

yes

Type of run configuration. Should be defined in the same model as the configuration itself.

caption

yes

The caption of run configuration in "Run/Debug Configurations".

icon

no, if icon is defined for a type or in config icon block

Path to an icon.

is debuggable

 

Whether a configuration can be executed under debugger.

persistent properties

 

Run configuration data, like which node it runs or what the command line parameters are.

editor

yes

The configuration editor. Should contain an expression creating a new editor. Also might have:

  • apply block - method applying changes in editor to the configuration;
  • reset block - method reseting changes in editor from configurations;
  • dispose block - methods destroing editor component, when it is no longer needed.

check block

no

Method checking if the configuration is valid. To display an error use report error statement.

execute block

yes

Code which actually executes the configuration. You can create process, execution console, actions on the toolbar.

Run configurations creators

Run configuration creators allow to specify how you run configurations could be created from context menu. To create run configuration creator use UniversalRunConfigCreator. Its elements are described in the following table:

Name

Is Required

Description

name

yes

Name of the creator.

config type

yes

Reference to a type of created run configuration.

create from

yes

Type of target to create configuration for. Possible values are model, module, nlist, node, project.

create

yes

Concept function that actually creates run configuration. parameter is the target to create it for (so it has the type specified as create from). This function must define two things:

  • main context item - the item for which this configuration is created, for example a class or a test;
  • createRunConfig statement, which creates the run configuration. This statement has several parameters:
    • reference to run configuration it's creating;
    • assignments of persistence properties for this configuration;
    • configurations name;
    • configurations suggested name, i.e. text that will appear in the context menu.

Here is the example of run configuration creator written for JUnit run configuration:

In this example we see JUnitConfigFromModel creator created for JUnit type from a model. The create function at first check that there are tests in the model, gets model name, sets the model as context parameter and creates an instance of the DefaultJUnit run configuration. In the createRunConfig statement two persistent properties of configuration are set which specify the type of configuration and the model it runs tests for. The configuration name is set to model name and suggested name is set to "Tests in 'name'".

Run configurations for languages generated into java

Language jetbrains.mps.baseLanguage.runConfigurations define two special kinds of run configurations: JavaRunConfiguration and JavaNodeRunConfiguration. JavaRunConfiguration provides an editor for standart java run parameters: virtual machine options, program arguments, java location, working directory. JavaNodeRunConfiguration in addition to that defines the node to run.

General purpose java run configurations

Use JavaRunConfiguration concept if you want to create run configuration which runs java machine but not for a one specific node. It is in general the same as RunConfigurationDeclaration. The biggest difference is additional parameter in apply and reset block of the editor and in parametrized execute. It's javaParameter of type ConfigRunParameters. It contains:

  • virtual machine parameters;
  • program parameters;
  • working directory;
  • information whether to make before generation;
  • alternative jre path.

JavaRunConfiguration generates an editor for this parameters automatically, so you do not have to worry about them. Use this parameters to start your java machine.

Java run configurations for a single node

If what you want to run is a single node, you can use JavaNodeRunConfiguration concept. Here is a run configuration written for lambda calculus language:

This configuration is quite simple. It runs nodes of concept Program, as specified in target concept block. parametrized execute has only process part defined. As you can see, the process creation function receives an additional node parameter. This is the node, selected by user. In this configuration we use ClassRunner class to execute the given node and create DefaultProcessHandler - a process handler for java. Also note is debuggable parameter set to true - this means this configuration could be executed under debugger. generate before run parameter means that configuration will automatically check whether user checked "Make Before Run" in configuration editor and generate selected node if he did. Setting this option to false means you have to do it yourself (for example if you want to use a non-standart way of generation).

Note that DefaultLambdaCalculusProgram does not define an editor. It is generated automatically. Check block is also not required. This is how the configuration editor look like:

Previous Next

  • No labels

1 Comment

  1. Anonymous