Changeset 8331 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2015-05-05T22:08:03+02:00 (10 years ago)
Author:
simon04
Message:

fix #10278 - MapCSSTagChecker: preprocess MapCSS for media queries support

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

    r8318 r8331  
    88import java.io.InputStream;
    99import java.io.Reader;
     10import java.io.StringReader;
    1011import java.text.MessageFormat;
    1112import java.util.ArrayList;
     
    317318        static List<TagCheck> readMapCSS(Reader css) throws ParseException {
    318319            CheckParameterUtil.ensureParameterNotNull(css, "css");
    319             return readMapCSS(new MapCSSParser(css));
    320         }
    321 
    322         static List<TagCheck> readMapCSS(MapCSSParser css) throws ParseException {
    323             CheckParameterUtil.ensureParameterNotNull(css, "css");
     320
    324321            final MapCSSStyleSource source = new MapCSSStyleSource("");
    325             css.sheet(source);
     322            final MapCSSParser preprocessor = new MapCSSParser(css, MapCSSParser.LexicalState.PREPROCESSOR);
     323
     324            css = new StringReader(preprocessor.pp_root(source));
     325            final MapCSSParser parser = new MapCSSParser(css, MapCSSParser.LexicalState.DEFAULT);
     326            parser.sheet(source);
    326327            assert source.getErrors().isEmpty();
    327328            // Ignore "meta" rule(s) from external rules of JOSM wiki
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r8260 r8331  
    99
    1010import java.io.InputStream;
     11import java.io.Reader;
    1112import java.util.ArrayList;
    1213import java.util.Arrays;
     
    8788            throw new RuntimeException(e);
    8889        }
     90        return new MapCSSParserTokenManager(scs, initState.idx);
     91    }
     92
     93    /**
     94     * Constructor which initializes the parser with a certain lexical state.
     95     */
     96    public MapCSSParser(Reader in, LexicalState initState) {
     97        this(createTokenManager(in, initState));
     98        declarationCounter = 0;
     99    }
     100
     101    protected static MapCSSParserTokenManager createTokenManager(Reader in, LexicalState initState) {
     102        final SimpleCharStream scs = new SimpleCharStream(in, 1, 1);
    89103        return new MapCSSParserTokenManager(scs, initState.idx);
    90104    }
Note: See TracChangeset for help on using the changeset viewer.