-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement to add ECMAScript 6 support (#1574) #1682
Merged
speckyspooky
merged 2 commits into
eclipse-birt:master
from
speckyspooky:enhance_javascript_es6
May 13, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
...ne.script.javascript/src/org/eclipse/birt/report/engine/javascript/JavascriptVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
package org.eclipse.birt.report.engine.javascript; | ||
|
||
/** | ||
* Copyright (c) 2024 Thomas Gutmann. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Handling of the JavaScript version evaluation | ||
* | ||
* Contributors: Thomas Gutmann - initial implementation | ||
* | ||
* @since 4.16 | ||
* | ||
*/ | ||
public class JavascriptVersion { | ||
|
||
/** | ||
* Constructor | ||
*/ | ||
public JavascriptVersion() { | ||
evaluateEcmaScriptVersion(); | ||
} | ||
|
||
/** Valid JavaScript versions */ | ||
/** JavaScript 1.0 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_0 = 100; | ||
/** JavaScript 1.1 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_1 = 110; | ||
/** JavaScript 1.2 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_2 = 120; | ||
/** JavaScript 1.3 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_3 = 130; | ||
/** JavaScript 1.4 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_4 = 140; | ||
/** JavaScript 1.5 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_5 = 150; | ||
/** JavaScript 1.6 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_6 = 160; | ||
/** JavaScript 1.7 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_7 = 170; | ||
/** JavaScript 1.8 */ | ||
private static final int ECMA_SCRIPT_VERSION_1_8 = 180; | ||
/** JavaScript 1.8 */ | ||
private static final int ECMA_SCRIPT_VERSION_ES6 = 200; | ||
|
||
/** System property of the JavaScript version */ | ||
private static final String ECMA_SCRIPT_VERSION_PROPERTY_KEY = "birt.ecmascript.version"; //$NON-NLS-1$ | ||
|
||
/** Valid keys of the system property */ | ||
private static final String ECMA_SCRIPT_VERSION_1_0_KEY = "1.0"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_1_1_KEY = "1.1"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_1_2_KEY = "1.2"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_1_3_KEY = "1.3"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_1_4_KEY = "1.4"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_1_5_KEY = "1.5"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_1_6_KEY = "1.6"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_1_7_KEY = "1.7"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_1_8_KEY = "1.8"; //$NON-NLS-1$ | ||
private static final String ECMA_SCRIPT_VERSION_ES6_KEY = "ES6"; //$NON-NLS-1$ | ||
|
||
private int valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_ES6; | ||
|
||
private String configuredECMAScriptVersion; | ||
|
||
/** | ||
* Get the EMCAScript version number | ||
* | ||
* @return the ECMAScript version number | ||
*/ | ||
public int getECMAScriptVersion() { | ||
return this.valueEcmaScriptVersion; | ||
} | ||
|
||
/** | ||
* Get the configured EMCAScript version of JVM | ||
* | ||
* @return the ECMAScript version configured at JVM | ||
*/ | ||
public String getConfiguredECMAScriptVersion() { | ||
return this.configuredECMAScriptVersion; | ||
} | ||
|
||
/** | ||
* Evaluate the system property to set the version number of the Rhino engine | ||
*/ | ||
private void evaluateEcmaScriptVersion() { | ||
|
||
/* System property: -Dbirt.ecmascript.version */ | ||
configuredECMAScriptVersion = System.getProperty(ECMA_SCRIPT_VERSION_PROPERTY_KEY); | ||
if (configuredECMAScriptVersion != null) { | ||
switch (configuredECMAScriptVersion) { | ||
case ECMA_SCRIPT_VERSION_1_0_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_0; | ||
break; | ||
case ECMA_SCRIPT_VERSION_1_1_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_1; | ||
break; | ||
case ECMA_SCRIPT_VERSION_1_2_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_2; | ||
break; | ||
case ECMA_SCRIPT_VERSION_1_3_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_3; | ||
break; | ||
case ECMA_SCRIPT_VERSION_1_4_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_4; | ||
break; | ||
case ECMA_SCRIPT_VERSION_1_5_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_5; | ||
break; | ||
case ECMA_SCRIPT_VERSION_1_6_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_6; | ||
break; | ||
case ECMA_SCRIPT_VERSION_1_7_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_7; | ||
break; | ||
case ECMA_SCRIPT_VERSION_1_8_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_1_8; | ||
break; | ||
case ECMA_SCRIPT_VERSION_ES6_KEY: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_ES6; | ||
break; | ||
default: | ||
this.valueEcmaScriptVersion = ECMA_SCRIPT_VERSION_ES6; | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ngine.script.javascript/src/org/eclipse/birt/report/engine/javascript/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Eclipse BIRT | ||
Introduction to use the configuration of the JavaScript language version. | ||
|
||
## Reason | ||
The JavaScript engine of BIRT is based on the Rhino engine. The default language version of the Rhino engine is JavaScript version 1.6. Rhino supports different language versions of JavaScript including the latest version ECMAScript 6. | ||
|
||
On **BIRT** side the Rhino engine will be run with the latest version **ECMAScript 6**. | ||
To be compatible with earlier JavaScript versions a global system property is given which can be set at JVM level to change the JavaScript language version. | ||
|
||
All supported JavaScript language versions of the Rhino engine can be configured. | ||
|
||
### JVM configuration of the JavaScript language version | ||
|
||
The configuration will be done as a global starting parameter of the JVM. | ||
|
||
**birt.ecmascript.version** | ||
|
||
Content configuration of the JavaScript language version | ||
Parameter -Dbirt.ecmascript.version | ||
Location JVM | ||
Data type string | ||
Values value of the supported language version | ||
Supported 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, ES6 | ||
Default ES6 (= EMCAScript 6) | ||
Version 4.16 | ||
|
||
** Function reference of Rhino** | ||
|
||
- An overview of Rhino engine supported functions are listed here: [Rhino ES2015 Support](https://mozilla.github.io/rhino/compat/engines.html) | ||
|
||
|
||
- The Rhino engine will be integrated at BIRT through the Orbit-project: [Orbit Aggregation Summary](https://download.eclipse.org/tools/orbit/simrel/orbit-aggregation/table.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The markdown file contains HTML break elements. Why? I think it's better to just use an empty line to create paragraphs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed.