Package org.eclipse.ease
Interface ICodeFactory
- All Known Implementing Classes:
AbstractCodeFactory
,GroovyCodeFactory
,JavaScriptCodeFactory
,PythonCodeFactory
,RubyCodeFactory
public interface ICodeFactory
An ICodeFactory is capable of generating code fragments for a dedicated target language.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Parameter definition class. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
intermediate name of original method call return value.static final boolean
Trace enablement for module wrappers. -
Method Summary
Modifier and TypeMethodDescriptionclassInstantiation
(Class<?> clazz, String[] parameters) Create code to instantiate a java class.createCommentedString
(String comment, boolean blockComment) Create code for the provided comment.createFunctionCall
(Method method, Object... parameters) Create code to call a wrapped function.createWrapper
(IEnvironment environment, Object instance, String identifier, boolean customNamespace, IScriptEngine engine) Create script wrapper code for a given java instance.getDefaultValue
(ICodeFactory.Parameter parameter) Get the default value for a given parameter.getSaveVariableName
(String variableName) Converts a given string to a save variable name for the target language.
-
Field Details
-
RESULT_NAME
intermediate name of original method call return value.- See Also:
-
TRACE_MODULE_WRAPPER
static final boolean TRACE_MODULE_WRAPPERTrace enablement for module wrappers.
-
-
Method Details
-
getSaveVariableName
Converts a given string to a save variable name for the target language. Typically filters invalid characters and verifies that the returned string does not match any reserved keyword. Does not verify if the returned name is already in use.- Parameters:
variableName
- variable name candidate- Returns:
- converted variable name
-
classInstantiation
Create code to instantiate a java class.- Parameters:
clazz
- class to instantiateparameters
- parameters used for class instantiation- Returns:
- wrapped script code
-
createFunctionCall
Create code to call a wrapped function.- Parameters:
method
- method to be calledparameters
- call parameters- Returns:
- script code to call function
-
getDefaultValue
Get the default value for a given parameter.- Parameters:
parameter
- parameter to get default value for- Returns:
- String representation of default value
-
createCommentedString
Create code for the provided comment. Typically line or block comment tokens will be added around the comment. Start block comment token will be added immediately before comment and end block comment token will be added immediately after comment. Format comment properly to get proper result.- Parameters:
comment
- the commentblockComment
-true
for adding block comment orfalse
for adding (multiple) line comments- Returns:
- the comment string with comment tokens.
-
createWrapper
String createWrapper(IEnvironment environment, Object instance, String identifier, boolean customNamespace, IScriptEngine engine) Create script wrapper code for a given java instance.- Parameters:
environment
- environment module instanceinstance
- object instance to wrapidentifier
- script variable name for wrapped Java objectcustomNamespace
- whether to store methods to the global namespace or to create a custom objectengine
- script engine- Returns:
- create wrapped script code
-