Hi Media,

On Thu, Apr 21, 2016 at 9:26 PM, media <ptie...@web.de> wrote:

> Hi everybody,
>
> I always get a build message "- Warning:  .. first argument is not a string
> literal."
> how it is programmed correctly or
> is it possible  to disable the warning?
>
> var checks = qx.core.Environment.getChecks();
> var keys = Object.keys(checks);
>
> for (var i = 0; i < keys.length; i++)
>   {
>     var key = keys[i];
>     var value = qx.core.Environment.get(key);    /* <--- problem line */
>

First off, to program correctly you shouldn't do this at all :-). There is
no clean and idiomatic way to do what you are trying. The whole concept of
the Environment class is to avoid loading all the environment checks as it
would bloat application code, but rather to pick only the checks that are
necessary for an application. Here is some background ...

Each Environment key depends on a specific qooxdoo module that calculates
its value (or, that implements its "check"). For an application the
Generator infers  this module from the argument to the Environment.get()
call, but can only do so if the argument is a string literal like "
browser.name" or "css.borderradius". As you are using a variable the
Generator cannot make this inference, and your program will end up throwing
a run time exception because of a missing module.

BTW: Environment.getChecks() is an internal method and you shouldn't call
it, and you won't usually be able to call it in the build version of your
code.

That's being said, there is a demo application that does just that, which
you might want to look at: http://qooxdoo.github.io/FeatureConfigEditor/?ria
https://github.com/qooxdoo/FeatureConfigEditor/

To disable the warning you should do two things:
a) Load all Environment modules upfront. This will avoid the run time
exception. Add this compiler hint to your class comment:
@require(feature-checks)

Again, this shouldn't be used in normal application code, see
http://manual.qooxdoo.org/current/pages/development/api_jsdoc_ref.html#require
.

b) Silence the warning. Add this compiler hint in the function/method
comment above your code:
@lint environmentNonLiteralKey(key)

(Actually, your code already looks like you have seen the
FeatureConfigEditor?!)

T.
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to