This commit is contained in:
walterhiggins 2014-03-11 19:57:40 +00:00
parent 30d1d89e91
commit 360b7df75b
3 changed files with 31 additions and 19 deletions

View file

@ -2,7 +2,7 @@
## Version 2.0.6 ## Version 2.0.6
Fixed issues #122 #123 Fixed issues #115 #122 #123
Improved background processing of Drone build commands. Improved background processing of Drone build commands.

View file

@ -640,15 +640,7 @@ function __onEnable ( __engine, __plugin, __script )
global.self = sender; global.self = sender;
global.__engine = __engine; global.__engine = __engine;
try { try {
if ( typeof eval == 'undefined' ) { jsResult = __engine.eval(fnBody);
jsResult = __engine.eval(fnBody);
} else {
/*
nashorn
https://bugs.openjdk.java.net/browse/JDK-8034055
*/
jsResult = eval( fnBody );
}
if ( typeof jsResult != 'undefined' ) { if ( typeof jsResult != 'undefined' ) {
if ( jsResult == null) { if ( jsResult == null) {
sender.sendMessage('(null)'); sender.sendMessage('(null)');
@ -661,8 +653,13 @@ function __onEnable ( __engine, __plugin, __script )
sender.sendMessage( 'Error while trying to evaluate javascript: ' + fnBody + ', Error: '+ e ); sender.sendMessage( 'Error while trying to evaluate javascript: ' + fnBody + ', Error: '+ e );
throw e; throw e;
} finally { } finally {
delete global.self; /*
delete global.__engine; wph 20140312 don't delete self on nashorn until https://bugs.openjdk.java.net/browse/JDK-8034055 is fixed
*/
if ( typeof Java === 'undefined' ) { // Java is an object in Nashorn
delete global.self;
delete global.__engine;
}
} }
} }
if ( cmdName == 'jsp' ) { if ( cmdName == 'jsp' ) {

View file

@ -36,6 +36,15 @@ var _getProperties = function( o ) {
typeofProperty; typeofProperty;
if ( _isJavaObject( o ) ) { if ( _isJavaObject( o ) ) {
/*
fix for issue #115 - java objects are not iterable
see: http://mail.openjdk.java.net/pipermail/nashorn-dev/2014-March/002790.html
*/
if ( typeof Object.bindProperties === 'function' ) {
var placeholder = {};
Object.bindProperties(placeholder, o);
o = placeholder;
}
propertyLoop: propertyLoop:
for ( i in o ) { for ( i in o ) {
// //
@ -45,7 +54,7 @@ var _getProperties = function( o ) {
for ( j = 0; j < _javaLangObjectMethods.length; j++ ) { for ( j = 0; j < _javaLangObjectMethods.length; j++ ) {
if ( _javaLangObjectMethods[j] == i ) { if ( _javaLangObjectMethods[j] == i ) {
continue propertyLoop; continue propertyLoop;
} }
} }
typeofProperty = null; typeofProperty = null;
try { try {
@ -71,9 +80,9 @@ var _getProperties = function( o ) {
if ( i.match( /^[^_]/ ) ) { if ( i.match( /^[^_]/ ) ) {
if ( typeof o[i] == 'function' ) { if ( typeof o[i] == 'function' ) {
result.push( i+'()' ); result.push( i+'()' );
} else { } else {
result.push( i ); result.push( i );
} }
} }
} }
} }
@ -130,6 +139,8 @@ var onTabCompleteJS = function( result, cmdSender, pluginCmd, cmdAlias, cmdArgs
symbol = global[name]; symbol = global[name];
//print('DEBUG: name=' + name + ',symbol=' + symbol);
lastGoodSymbol = symbol; lastGoodSymbol = symbol;
if ( typeof symbol !== 'undefined' ) { if ( typeof symbol !== 'undefined' ) {
for ( i = 1; i < parts.length; i++ ) { for ( i = 1; i < parts.length; i++ ) {
@ -140,10 +151,14 @@ var onTabCompleteJS = function( result, cmdSender, pluginCmd, cmdAlias, cmdArgs
symbol = symbol[name]; // this causes problem in jre8 if name is '' symbol = symbol[name]; // this causes problem in jre8 if name is ''
if ( typeof symbol == 'undefined' ) { if ( typeof symbol == 'undefined' ) {
break; break;
} }
// nashorn - object[missingProperty] returns null not undefined
if ( symbol == null ) {
break;
}
lastGoodSymbol = symbol; lastGoodSymbol = symbol;
} }
if ( typeof symbol == 'undefined' ) { if ( typeof symbol == 'undefined' || symbol === null) {
// //
// look up partial matches against last good symbol // look up partial matches against last good symbol
// //
@ -165,8 +180,8 @@ var onTabCompleteJS = function( result, cmdSender, pluginCmd, cmdAlias, cmdArgs
// //
//print('debug:case Y: ScriptCraft.co'); //print('debug:case Y: ScriptCraft.co');
li = statement.lastIndexOf(name); li = statement.lastIndexOf(name);
for ( i = 0; i < objectProps.length; i++ ) { for ( i = 0; i < objectProps.length; i++ ) {
if ( objectProps[i].indexOf(name) == 0 ) { if ( objectProps[i].indexOf(name) == 0 ) {
candidate = lastSymbol.substring( 0, lastSymbol.lastIndexOf( name ) ); candidate = lastSymbol.substring( 0, lastSymbol.lastIndexOf( name ) );
candidate = candidate + objectProps[i]; candidate = candidate + objectProps[i];