Package org.eclipse.ease.lang.javascript
Class JavaScriptCodeFactory
java.lang.Object
org.eclipse.ease.AbstractCodeFactory
org.eclipse.ease.lang.javascript.JavaScriptCodeFactory
- All Implemented Interfaces:
ICodeFactory
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.ease.ICodeFactory
ICodeFactory.Parameter
-
Field Summary
Fields inherited from class org.eclipse.ease.AbstractCodeFactory
LINE_DELIMITER
Fields inherited from interface org.eclipse.ease.ICodeFactory
RESULT_NAME, TRACE_MODULE_WRAPPER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclassInstantiation
(Class<?> clazz, String[] parameters) Create code to instantiate a java class.createCommentedString
(String comment, boolean addBlockComment) Create code for the provided comment.createWrapper
(IEnvironment environment, Object instance, String identifier, boolean customNamespace, IScriptEngine engine) Create script wrapper code for a given java instance.getSaveVariableName
(String variableName) Converts a given string to a save variable name for the target language.static boolean
isSaveName
(String identifier) Methods inherited from class org.eclipse.ease.AbstractCodeFactory
createFunctionCall, getDefaultValue, getMethodAliases, getMethodNames
-
Constructor Details
-
JavaScriptCodeFactory
public JavaScriptCodeFactory()
-
-
Method Details
-
isSaveName
-
classInstantiation
Description copied from interface:ICodeFactory
Create code to instantiate a java class.- Parameters:
clazz
- class to instantiateparameters
- parameters used for class instantiation- Returns:
- wrapped script code
-
getSaveVariableName
Description copied from interface:ICodeFactory
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
-
createCommentedString
Description copied from interface:ICodeFactory
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.- Specified by:
createCommentedString
in interfaceICodeFactory
- Overrides:
createCommentedString
in classAbstractCodeFactory
- Parameters:
comment
- the commentaddBlockComment
-true
for adding block comment orfalse
for adding (multiple) line comments- Returns:
- the comment string with comment tokens.
-
createWrapper
public String createWrapper(IEnvironment environment, Object instance, String identifier, boolean customNamespace, IScriptEngine engine) Description copied from interface:ICodeFactory
Create script wrapper code for a given java instance.- Specified by:
createWrapper
in interfaceICodeFactory
- Overrides:
createWrapper
in classAbstractCodeFactory
- 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
-