Discussion:
build warning:.. first argument is not a string literal
(too old to reply)
media
2016-04-21 19:26:25 UTC
Permalink
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 */
}

Thank you all and greetings
media




--
View this message in context: http://qooxdoo.678.n2.nabble.com/build-warning-first-argument-is-not-a-string-literal-tp7588280.html
Sent from the qooxdoo mailing list archive at Nabble.com.
thron7
2016-04-21 20:53:59 UTC
Permalink
Hi Media,
Post by media
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.
media
2016-04-21 21:22:25 UTC
Permalink
Hi thron7,
well it works!
thank you for your quick help.

the FeatureConfigEditor is exactly what I Need.

regards
media



--
View this message in context: http://qooxdoo.678.n2.nabble.com/build-warning-first-argument-is-not-a-string-literal-tp7588280p7588282.html
Sent from the qooxdoo mailing list archive at Nabble.com.

Loading...