Ticket #19875: 19875-remove-media.patch

File 19875-remove-media.patch, 3.8 KB (added by GerdP, 6 years ago)
  • src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

     
    77PARSER_BEGIN(MapCSSParser)
    88package org.openstreetmap.josm.gui.mappaint.mapcss.parsergen;
    99
    10 import static org.openstreetmap.josm.tools.I18n.tr;
    11 
    1210import java.io.InputStream;
    1311import java.io.Reader;
    1412import java.util.ArrayList;
     
    1513import java.util.Arrays;
    1614import java.util.Collections;
    1715import java.util.List;
    18 import java.util.Locale;
    1916
    2017import org.openstreetmap.josm.data.preferences.NamedColorProperty;
    2118import org.openstreetmap.josm.gui.mappaint.Keyword;
     
    5047 * Contains two independent grammars:
    5148 * (a) the preprocessor and (b) the main mapcss parser.
    5249 *
    53  * The preprocessor handles @supports and @media syntax (@media is deprecated).
     50 * The preprocessor handles @supports syntax.
    5451 * Basically this allows to write one style for different versions of JOSM (or different editors).
    5552 * When the @supports condition is not fulfilled, it should simply skip over
    5653 * the whole section and not attempt to parse the possibly unknown
     
    136133|   < PP_OR: "or" >
    137134|   < PP_NOT: "not" >
    138135|   < PP_SUPPORTS: "@supports" >
    139 |   < PP_MEDIA: "@media" >
    140136|   < PP_NEWLINECHAR: "\n" | "\r" | "\f" >
    141137|   < PP_WHITESPACE: " " | "\t" >
    142138|   < PP_COMMENT_START: "/*" > : PP_COMMENT
     
    293289        |
    294290            pp_supports(!write)
    295291        |
    296             pp_media(!write)
    297         |
    298292            t=<LBRACE> { if (write) sb.append(t.image); } pp_black_box(write) t=<RBRACE> { if (write) sb.append(t.image); }
    299293    )*
    300294}
     
    386380    { return this.sheet.evalSupportsDeclCondition(feature, val); }
    387381}
    388382
    389 // deprecated
    390 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 // deprecated
    415 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 fulfilled
    446  * @throws ParseException in case of parsing error
    447  */
    448 // deprecated
    449 boolean pp_media_expression():
    450 {
    451     Token t;
    452     String feature;
    453     Object val = null;
    454 }
    455 {
    456     <LPAR> pp_w() t=<IDENT> { feature = t.image; } pp_w() ( <COLON> pp_w() val=literal() )? <RPAR>
    457     { return this.sheet.evalSupportsDeclCondition(feature, val); }
    458 }
    459 
    460383void pp_w1():
    461384{
    462385    Token t;