Opened 22 months ago
Last modified 3 hours ago
#19648 new enhancement
[patch] Show warning on invalid MapCSS validator rule parsing
Reported by: | skyper | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core | Version: | |
Keywords: | template_report rule validation mapcss class | Cc: |
Description
What steps will reproduce the problem?
- Have a typo in a validator mapcss rule file, like the missing
y
below:way[highway =~ /^(motorway|motorway_link|trunk|trunk_link)$/] { set MotorwayTrunk; } way.MotorwaTrunk[lanes][turn:lanes ][tag(lanes)!=eval(count(split("|", tag("turn:lanes"))))], way.MotorwaTrunk[lanes][change:lanes ][tag(lanes)!=eval(count(split("|", tag("change:lanes"))))], way.MotorwaTrunk[lanes][maxspeed:lanes ][tag(lanes)!=eval(count(split("|", tag("maxspeed:lanes"))))], way.MotorwaTrunk[lanes][minspeed:lanes ][tag(lanes)!=eval(count(split("|", tag("minspeed:lanes"))))], way.MotorwaTrunk[lanes][destination:lanes ][tag(lanes)!=eval(count(split("|", tag("destination:lanes"))))], way.MotorwaTrunk[lanes][destination:ref:lanes ][tag(lanes)!=eval(count(split("|", tag("destination:ref:lanes"))))], way.MotorwaTrunk[lanes][destination:symbol:lanes][tag(lanes)!=eval(count(split("|", tag("destination:symbol:lanes"))))] { throwWarning: tr("Different number of lanes in the keys {0} and {1}", "{1.key}", "{2.key}"); group: tr("suspicious tag combination"); }
- (Re-)Load file
What is the expected result?
A warning about an unknown class in use.
What happens instead?
No warning
Please provide any additional information below. Attach a screenshot if possible.
Some Information about existing but not use classes would be nice, too.
Relative:URL: ^/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2020-08-06 21:47:58 +0200 (Thu, 06 Aug 2020) Revision:16851 Build-Date:2020-08-07 01:30:47 URL:https://josm.openstreetmap.de/svn/trunk
Attachments (1)
Change History (10)
comment:1 Changed 4 months ago by
Summary: | MapCSS Rule validation: Warn about unknown class. → Show warning on invalid MapCSS validator rule parsing |
---|
comment:2 Changed 4 months ago by
comment:3 Changed 4 months ago by
The issue is coming from the MapCSSParser.jj
file. I have a patch that makes JOSM print the messages but at the same time introduces some GUI exceptions (EDT violations).
comment:4 Changed 4 months ago by
Summary: | Show warning on invalid MapCSS validator rule parsing → [WIP patch] Show warning on invalid MapCSS validator rule parsing |
---|
-
src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
14 14 import java.util.Collections; 15 15 import java.util.List; 16 16 17 import javax.swing.JOptionPane; 18 17 19 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 20 import org.openstreetmap.josm.gui.MainApplication; 18 21 import org.openstreetmap.josm.gui.mappaint.Keyword; 19 22 import org.openstreetmap.josm.gui.mappaint.Range; 20 23 import org.openstreetmap.josm.gui.mappaint.mapcss.Condition; … … 78 81 this.idx = idx; 79 82 } 80 83 } 81 84 82 85 /** 83 86 * Constructor which initializes the parser with a certain lexical state. 84 87 * @param in input … … 1164 1167 1165 1168 Logging.error("Skipping to the next rule, because of an error:"); 1166 1169 Logging.error(e); 1170 1171 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), e.getMessage(), "MapCSS rule parsing error", JOptionPane.ERROR_MESSAGE); 1167 1172 if (sheet != null) { 1168 1173 sheet.logError(e); 1169 1174 }
The patch introduces some EDT violations, which needs to be solved first. If someone knows how to fix it, please do it.
Changed 4 months ago by
Attachment: | josm_19648.patch added |
---|
comment:6 Changed 4 months ago by
Summary: | [WIP patch] Show warning on invalid MapCSS validator rule parsing → [patch] Show warning on invalid MapCSS validator rule parsing |
---|
Thank you @GerdP! Now the EDT violations are gone. I think the patch is good enough, but please review it.
comment:7 Changed 4 months ago by
You can simplify that to GuiHelper.runInEDT(() -> JOptionPane.showMessageDialog(..));
like in MainLayerManager:
GuiHelper.runInEDT(() -> JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Trying to delete the layer with background upload. Please wait until the upload is finished."))); }
comment:9 Changed 3 hours ago by
Looking at the release-notes.md, v7.0.5 "[added] support for Java7 language features". So I don't think Java 8 language features are supported.
While experimenting with a custom MapCSS rule, I noticed parsing of invalid rules silently fail on the GUI side. In case of error, the console prints detailed information. Add this or parts to a warning dialog to help diagnose the problem.