Modify

Opened 10 years ago

Closed 10 years ago

#9566 closed defect (fixed)

Small glitches/improvements in MapCSS validator

Reported by: naoliv Owned by: team
Priority: normal Milestone: 14.01
Component: Core validator Version:
Keywords: Cc:

Description

First issue:
Using a test with quotes like this:

*[name = *"addr:housename"] {
        throwWarning: tr("{0} and {1} are the same", "{0.key}", "{0.value}");
}

and validating something that fits on this rule we can see a duplicated warning message:

name and addr:housename are the same - name and addr:housename are the same (1)

This also happens when using (?i) for case insensitive matching, like this:

*[highway $= _link][name =~ /^(?i)acesso.*/] {
        throwWarning: tr("Don't use acesso in link highways");
}

we we also get a duplicated message:

Dont use acesso in link highways - Dont use acesso in link highways (1)

Second issue:
Instead doing this:

*[highway=motorway_link],
*[highway=trunk_link],
*[highway=primary_link],
*[highway=secondary_link],
*[highway=tertiary_link] (…)

I can use this:

*[highway $= _link] (…)

But I can't get the real value of this key:
"{0}.value" gives me only "_link" and "{0}.tag" gives me the full rule "highway=_link" (but still without the real value of the highway key)
Isn't it possible to get the real value?

It's similar with this other case:

*[name][source] {
        throwWarning: tr("name: {0} source: {1}", "{0.value}", "{1.value}");
}

It's not possible to use the real values of name or source.

Third issue:

It seems that the validator doesn't display single quotes like this:

*[highway] {
        throwWarning: tr("foo 'something' foo");
}

Using this:

*[highway] {
        throwWarning: tr("foo \'something\' foo");
}

It gives this as the output:

tr("foo \'something\'foo") - tr("foo \'something\'foo") (1)

Using double quotes also gives a wrong output:

*[highway] {
        throwWarning: tr("foo "something" foo");
}

Attachments (0)

Change History (6)

comment:1 by simon04, 10 years ago

In 6675/josm:

see #9566 - MapCSS validator: fix duplicated messages

comment:2 by simon04, 10 years ago

Resolution: fixed
Status: newclosed
  1. fixed in r6675
  2. This has to be done differently: use the tag(key_name) MapCSS function, see Help/Styles/MapCSSImplementation#Evalexpressions – making "{0.value}" work as you expect, is quite some work
  3. Single quotes have to be written as '', see Translations#Softwaretranslation

Feel free to improve Help/Validator/MapCSSTagChecker :-)

comment:3 by naoliv, 10 years ago

(sorry to ask things like this here, but I really don't know if there is a better place (and if there is I would like to know))

About 2, I did try this:

*[highway] {
        throwWarning: tr("foo: {0}", tag(highway)));
}

with and without quotes on highway inside tr but I only see "foo: null" at the warning message.
I also tried

throwWarning: tr(concat("foo: ", tag(highway)));

with and without quotes.

I don't see any error on console.

comment:4 by simon04, 10 years ago

Resolution: fixed
Status: closedreopened

Sorry for the incorrect hint. Currently, the throwWarning string is computed while initializing the checker. Thus, any access to a tag yields null. I'll think about whether/how to change this.

comment:5 by Don-vip, 10 years ago

Milestone: 14.01

comment:6 by simon04, 10 years ago

Resolution: fixed
Status: reopenedclosed

In 6677/josm:

see #9414 fix #9566: MapCSS validator: allow error message to access tags of primitive

For instance, throwWarning: tr("{0} is bad", tag("highway")).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.