Bug 844475 - NPE in code completion on Array object
Summary: NPE in code completion on Array object
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: CLI
Version: 4.4
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
: RHQ 4.5.0
Assignee: Lukas Krejci
QA Contact: Mike Foley
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-07-30 19:54 UTC by Libor Zoubek
Modified: 2015-11-02 00:43 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-08-31 10:13:22 UTC
Embargoed:


Attachments (Terms of Use)

Description Libor Zoubek 2012-07-30 19:54:06 UTC
Description of problem: I am getting NPE on codecompletion


Version-Release number of selected component (if applicable):
RHQ-4.5.0 master

How reproducible: always

Steps to Reproduce:
1.execute following steps in CLI:
var a = [1,2,3];
a.0.<pres tab for code completion>
  
Actual results:

java.lang.NullPointerException
	at org.rhq.scripting.javascript.JavascriptCompletor.getContextMatches(JavascriptCompletor.java:451)
	at org.rhq.scripting.javascript.JavascriptCompletor.contextComplete(JavascriptCompletor.java:203)
	at org.rhq.scripting.javascript.JavascriptCompletor.contextComplete(JavascriptCompletor.java:196)
	at org.rhq.scripting.javascript.JavascriptCompletor.complete(JavascriptCompletor.java:131)
	at org.rhq.enterprise.client.utility.CodeCompletionCompletorWrapper.complete(CodeCompletionCompletorWrapper.java:34)
	at jline.MultiCompletor.complete(MultiCompletor.java:53)
	at jline.ConsoleReader.complete(ConsoleReader.java:832)
	at jline.ConsoleReader.readLine(ConsoleReader.java:518)
	at jline.ConsoleReader.readLine(ConsoleReader.java:448)
	at org.rhq.enterprise.client.ClientMain.getUserInput(ClientMain.java:278)
	at org.rhq.enterprise.client.ClientMain$1.run(ClientMain.java:319)
	at java.lang.Thread.run(Thread.java:636)


Expected results:


Additional info: I think than code-completion is incorrect in the way then if you type a<tab> you get a. and pressing another tab you get a.{0,1,2} - indexes of array which is kinda invalid, you should get a[{0,1,2}] to access member of array.

Comment 1 Lukas Krejci 2013-01-02 11:14:06 UTC
Our code completion is far from perfect and modifying it to differentiate between objects and arrays and offer different completion hints for each would only open up more questions for the missing features like, for example, the missing completions on the javascript's built-in functions and objects.

I.e. one could argue that both "." and "[" are valid "continuations" for an expression for all objects and that code completion on "a." should return all the built-in methods of the Array object, while completion on "a[" should return the quoted names of the built-in methods + the indices. To better understand the above, consider following examples:

var a = [1,2,3];
a.length;
a["length"];
a[0];


To avoid such complexity for which our code completion is just not ready, I've modified the completor to not offer the array indices as a completion hint on "a." type of expressions.

commit http://git.fedorahosted.org/cgit/rhq/rhq.git/commit/?id=af81247744ec551bd411435d2f3d0913bfe0ee95
Author: Lukas Krejci <lkrejci>
Date:   Wed Jan 2 11:57:44 2013 +0100

    [BZ 844475] - Don't try to do code completion on native javascript arrays.

Comment 2 Heiko W. Rupp 2013-08-31 10:13:22 UTC
Bulk close of old bugs in VERIFIED state.


Note You need to log in before you can comment on or make changes to this bug.