Changeset 17208 in josm for trunk/src/org
- Timestamp:
- 2020-10-15T17:00:31+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj
r15988 r17208 7 7 PARSER_BEGIN(MapCSSParser) 8 8 package org.openstreetmap.josm.gui.mappaint.mapcss.parsergen; 9 10 import static org.openstreetmap.josm.tools.I18n.tr;11 9 12 10 import java.io.InputStream; … … 16 14 import java.util.Collections; 17 15 import java.util.List; 18 import java.util.Locale;19 16 20 17 import org.openstreetmap.josm.data.preferences.NamedColorProperty; … … 51 48 * (a) the preprocessor and (b) the main mapcss parser. 52 49 * 53 * The preprocessor handles @supports and @media syntax (@media is deprecated).50 * The preprocessor handles @supports syntax. 54 51 * Basically this allows to write one style for different versions of JOSM (or different editors). 55 52 * When the @supports condition is not fulfilled, it should simply skip over … … 137 134 | < PP_NOT: "not" > 138 135 | < PP_SUPPORTS: "@supports" > 139 | < PP_MEDIA: "@media" >140 136 | < PP_NEWLINECHAR: "\n" | "\r" | "\f" > 141 137 | < PP_WHITESPACE: " " | "\t" > … … 294 290 pp_supports(!write) 295 291 | 296 pp_media(!write)297 |298 292 t=<LBRACE> { if (write) sb.append(t.image); } pp_black_box(write) t=<RBRACE> { if (write) sb.append(t.image); } 299 293 )* … … 377 371 */ 378 372 boolean pp_supports_declaration_condition(): 379 {380 Token t;381 String feature;382 Object val = null;383 }384 {385 <LPAR> pp_w() t=<IDENT> { feature = t.image; } pp_w() ( <COLON> pp_w() val=literal() )? <RPAR>386 { return this.sheet.evalSupportsDeclCondition(feature, val); }387 }388 389 // deprecated390 void pp_media(boolean ignore):391 {392 boolean pass = false;393 boolean q;394 boolean empty = true;395 }396 {397 {398 if (sheet != null) {399 String msg = tr("Detected deprecated ''{0}'' in ''{1}'' which will be removed shortly. Use ''{2}'' instead.",400 "@media", sheet.getDisplayString(), "@supports");401 Logging.error(msg);402 sheet.logWarning(msg);403 }404 }405 <PP_MEDIA> pp_w()406 ( q=pp_media_query() { pass = pass || q; empty = false; }407 ( <COMMA> pp_w() q=pp_media_query() { pass = pass || q; } )*408 )?409 <LBRACE>410 pp_black_box((empty || pass) && !ignore)411 <RBRACE>412 }413 414 // deprecated415 boolean pp_media_query():416 {417 Token t;418 String mediatype = "all";419 boolean pass = true;420 boolean invert = false;421 boolean e;422 }423 {424 ( <PP_NOT> { invert = true; } pp_w() )?425 (426 t=<IDENT> { mediatype = t.image.toLowerCase(Locale.ENGLISH); } pp_w()427 ( <PP_AND> pp_w() e=pp_media_expression() { pass = pass && e; } pp_w() )*428 |429 e=pp_media_expression() { pass = pass && e; } pp_w()430 ( <PP_AND> pp_w() e=pp_media_expression() { pass = pass && e; } pp_w() )*431 )432 {433 if (!"all".equals(mediatype)) {434 pass = false;435 }436 return invert ? (!pass) : pass;437 }438 }439 440 /**441 * Parse an @media expression.442 *443 * The parsing rule {@link #literal()} from the main mapcss parser is reused here.444 *445 * @return true if the condition is fulfilled446 * @throws ParseException in case of parsing error447 */448 // deprecated449 boolean pp_media_expression():450 373 { 451 374 Token t;
Note:
See TracChangeset
for help on using the changeset viewer.