Fix issue #115
This commit is contained in:
parent
fae2b6aac7
commit
e40786d727
1 changed files with 13 additions and 6 deletions
|
@ -7,7 +7,7 @@ var _isJavaObject = function(o){
|
||||||
var result = false;
|
var result = false;
|
||||||
try {
|
try {
|
||||||
o.hasOwnProperty( 'testForJava' );
|
o.hasOwnProperty( 'testForJava' );
|
||||||
}catch (e){
|
} catch (e) {
|
||||||
// java will throw an error when an attempt is made to access the
|
// java will throw an error when an attempt is made to access the
|
||||||
// hasOwnProperty method. (it won't exist for Java objects)
|
// hasOwnProperty method. (it won't exist for Java objects)
|
||||||
result = true;
|
result = true;
|
||||||
|
@ -34,6 +34,7 @@ var _getProperties = function( o ) {
|
||||||
j,
|
j,
|
||||||
isObjectMethod,
|
isObjectMethod,
|
||||||
typeofProperty;
|
typeofProperty;
|
||||||
|
|
||||||
if ( _isJavaObject( o ) ) {
|
if ( _isJavaObject( o ) ) {
|
||||||
propertyLoop:
|
propertyLoop:
|
||||||
for ( i in o ) {
|
for ( i in o ) {
|
||||||
|
@ -103,11 +104,12 @@ var onTabCompleteJS = function( result, cmdSender, pluginCmd, cmdAlias, cmdArgs
|
||||||
if ( pluginCmd.name == 'jsp' ) {
|
if ( pluginCmd.name == 'jsp' ) {
|
||||||
return tabCompleteJSP( result, cmdSender, pluginCmd, cmdAlias, cmdArgs );
|
return tabCompleteJSP( result, cmdSender, pluginCmd, cmdAlias, cmdArgs );
|
||||||
}
|
}
|
||||||
|
|
||||||
global.self = cmdSender; // bring in self just for autocomplete
|
global.self = cmdSender; // bring in self just for autocomplete
|
||||||
|
|
||||||
_globalSymbols = _getProperties(global);
|
_globalSymbols = _getProperties(global);
|
||||||
|
|
||||||
lastArg = cmdArgs.length?cmdArgs[cmdArgs.length-1]+'':null;
|
lastArg = cmdArgs.length ? cmdArgs[ cmdArgs.length - 1 ] + '' : null;
|
||||||
propsOfLastArg = [];
|
propsOfLastArg = [];
|
||||||
statement = cmdArgs.join(' ');
|
statement = cmdArgs.join(' ');
|
||||||
|
|
||||||
|
@ -117,6 +119,7 @@ var onTabCompleteJS = function( result, cmdSender, pluginCmd, cmdAlias, cmdArgs
|
||||||
propsOfLastArg = _globalSymbols;
|
propsOfLastArg = _globalSymbols;
|
||||||
} else {
|
} else {
|
||||||
statementSyms = statement.split(/[^\$a-zA-Z0-9_\.]/);
|
statementSyms = statement.split(/[^\$a-zA-Z0-9_\.]/);
|
||||||
|
|
||||||
lastSymbol = statementSyms[statementSyms.length-1];
|
lastSymbol = statementSyms[statementSyms.length-1];
|
||||||
//print('DEBUG: lastSymbol=[' + lastSymbol + ']');
|
//print('DEBUG: lastSymbol=[' + lastSymbol + ']');
|
||||||
//
|
//
|
||||||
|
@ -124,18 +127,22 @@ var onTabCompleteJS = function( result, cmdSender, pluginCmd, cmdAlias, cmdArgs
|
||||||
//
|
//
|
||||||
parts = lastSymbol.split(/\./);
|
parts = lastSymbol.split(/\./);
|
||||||
name = parts[0];
|
name = parts[0];
|
||||||
|
|
||||||
symbol = global[name];
|
symbol = global[name];
|
||||||
|
|
||||||
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++ ) {
|
||||||
name = parts[i];
|
name = parts[i];
|
||||||
symbol = symbol[name];
|
if ( !name ) { // fix issue #115
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
symbol = symbol[name]; // this causes problem in jre8 if name is ''
|
||||||
if ( typeof symbol == 'undefined' ) {
|
if ( typeof symbol == 'undefined' ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lastGoodSymbol = symbol;
|
lastGoodSymbol = symbol;
|
||||||
}
|
}
|
||||||
//print('debug:name['+name+']lastSymbol['+lastSymbol+']symbol['+symbol+']');
|
|
||||||
if ( typeof symbol == 'undefined' ) {
|
if ( typeof symbol == 'undefined' ) {
|
||||||
//
|
//
|
||||||
// look up partial matches against last good symbol
|
// look up partial matches against last good symbol
|
||||||
|
@ -146,7 +153,7 @@ var onTabCompleteJS = function( result, cmdSender, pluginCmd, cmdAlias, cmdArgs
|
||||||
// ScriptCraft.
|
// ScriptCraft.
|
||||||
//
|
//
|
||||||
|
|
||||||
for ( i =0; i < objectProps.length; i++ ) {
|
for ( i = 0; i < objectProps.length; i++ ) {
|
||||||
candidate = lastSymbol + objectProps[i];
|
candidate = lastSymbol + objectProps[i];
|
||||||
re = new RegExp( lastSymbol + '$', 'g' );
|
re = new RegExp( lastSymbol + '$', 'g' );
|
||||||
propsOfLastArg.push( lastArg.replace( re, candidate ) );
|
propsOfLastArg.push( lastArg.replace( re, candidate ) );
|
||||||
|
|
Reference in a new issue