How inject invisible javascript objects to be available for code completion?

Hi,

I want to edit for example this javascript code snippet:

function setArea(poiBean) {
  var l = poiBean.getNumber('len', 0);
  ...
}

How can I make the Object “poiBean” known to CodeMirror so
that its properties and functions (.getNumber() etc) are available for code-completions?

javascriptHint() does not know “poiBean” and delivers nothing.

Thank you
Marcel

javascriptHint is very simplistic, you might want to look into Tern if you’re going to do serious completions. But you can pass javascriptHint a globalScope option, which is an object to use instead of window when completing globals. For example {poiBean: {getNumber: {}}} would tell it about the object you describe.

Thanks.

I can’t find out how to set

 javascriptHint.globalScope={poiBean ...}

javascriptHint is no global variable …
How does such code look like?

I have in fact four beans to make completion aware.
The code
… global = options && options.globalScope || window;
seems to allow only one global object?
Or would it be

{
   poiBean: {getNumer:{}, setNumber:{} },
   secondBean: {...},
}

?

Thanks,
Marcel

Nowhere did I say that you have to set a property on javascriptHint. You have to pass it an option, as in the second argument to showHint.

Yes, there is only one global object. You can make your spec derive from window if you have to.