lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.generator.GeneratorUtils Class Reference

A helper class with functions that may be useful for code generators. More...

Static Public Member Functions

static void accommodatePhysicalActionsIfPresent (Set< Resource > resources, boolean setsKeepAliveOptionAutomatically, TargetConfig targetConfig, MessageReporter messageReporter)
 Look for physical actions in 'resource'.
static boolean canGenerate (Boolean errorsOccurred, Instantiation mainDef, MessageReporter messageReporter, LFGeneratorContext context)
 Check whether code can be generated; report any problems and inform the context accordingly.
static< T > Iterable< T > findAll (Resource resource, Class< T > nodeType)
 Return all instances of eObjectType in resource.
static TargetDecl findTargetDecl (Resource resource)
 Return the target declaration found in the given resource.
static Set< Resource > getResources (Iterable< Reactor > reactors)
 Return the resources that provide the given reactors and their ancestors.
static boolean isHostWindows ()
 Return whether the operating system is Windows.
static void refreshProject (Resource resource, Mode compilerMode)
 If the mode is Mode.EPOCH (the code generator is running in an Eclipse IDE), then refresh the project.

Detailed Description

A helper class with functions that may be useful for code generators.

This is created to ease our transition from Xtend and possibly Eclipse. All functions in this class should instead be in GeneratorUtils.kt, but Eclipse cannot handle Kotlin files.

Member Function Documentation

◆ accommodatePhysicalActionsIfPresent()

void org.lflang.generator.GeneratorUtils.accommodatePhysicalActionsIfPresent ( Set< Resource > resources,
boolean setsKeepAliveOptionAutomatically,
TargetConfig targetConfig,
MessageReporter messageReporter )
static

Look for physical actions in 'resource'.

If appropriate, set keepalive to true in targetConfig. This is a helper function for setTargetConfig. It should not be used elsewhere.

◆ canGenerate()

boolean org.lflang.generator.GeneratorUtils.canGenerate ( Boolean errorsOccurred,
Instantiation mainDef,
MessageReporter messageReporter,
LFGeneratorContext context )
static

Check whether code can be generated; report any problems and inform the context accordingly.

Returns
Whether it is possible to generate code.

◆ findAll()

static< T > Iterable< T > org.lflang.generator.GeneratorUtils.findAll ( Resource resource,
Class< T > nodeType )
static

Return all instances of eObjectType in resource.

Parameters
resourceA resource to be searched.
nodeTypeThe type of the desired parse tree nodes.
<T>The type of the desired parse tree nodes.
Returns
all instances of eObjectType in resource

◆ findTargetDecl()

TargetDecl org.lflang.generator.GeneratorUtils.findTargetDecl ( Resource resource)
static

Return the target declaration found in the given resource.

◆ getResources()

Set< Resource > org.lflang.generator.GeneratorUtils.getResources ( Iterable< Reactor > reactors)
static

Return the resources that provide the given reactors and their ancestors.

Parameters
reactorsThe reactors for which to find containing resources.
Returns
the resources that provide the given reactors.

◆ isHostWindows()

boolean org.lflang.generator.GeneratorUtils.isHostWindows ( )
static

Return whether the operating system is Windows.

◆ refreshProject()

void org.lflang.generator.GeneratorUtils.refreshProject ( Resource resource,
Mode compilerMode )
static

If the mode is Mode.EPOCH (the code generator is running in an Eclipse IDE), then refresh the project.

This will ensure that any generated files become visible in the project.

Parameters
resourceThe resource.
compilerModeAn indicator of whether Epoch is running.

The documentation for this class was generated from the following file:
  • /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/generator/GeneratorUtils.java