1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.internal.parser

File DefaultContentParser.java

 
parseWhenNoParser: Failed to find a parser for syntax [XWiki 2.1]
 

Coverage histogram

../../../../../img/srcFileCovDistChart9.png
41% of files have more coverage

Code metrics

4
8
3
1
92
51
6
0.75
2.67
3
2

Classes

Class Line # Actions
DefaultContentParser 50 8 0% 6 2
0.866666786.7%
 

Contributing tests

This file is covered by 45 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.internal.parser;
21   
22    import java.io.StringReader;
23   
24    import javax.inject.Inject;
25    import javax.inject.Named;
26    import javax.inject.Provider;
27    import javax.inject.Singleton;
28   
29    import org.xwiki.component.annotation.Component;
30    import org.xwiki.component.manager.ComponentLookupException;
31    import org.xwiki.component.manager.ComponentManager;
32    import org.xwiki.model.reference.EntityReference;
33    import org.xwiki.model.reference.EntityReferenceSerializer;
34    import org.xwiki.rendering.block.XDOM;
35    import org.xwiki.rendering.listener.MetaData;
36    import org.xwiki.rendering.parser.ContentParser;
37    import org.xwiki.rendering.parser.MissingParserException;
38    import org.xwiki.rendering.parser.ParseException;
39    import org.xwiki.rendering.parser.Parser;
40    import org.xwiki.rendering.syntax.Syntax;
41   
42    /**
43    * Default implementation of {@link ContentParser}.
44    *
45    * @version $Id: 36d116698ee5b7be9871d5605003430cc4d06dee $
46    * @since 6.0M2
47    */
48    @Component
49    @Singleton
 
50    public class DefaultContentParser implements ContentParser
51    {
52    @Inject
53    @Named("context")
54    private Provider<ComponentManager> componentManagerProvider;
55   
56    @Inject
57    private EntityReferenceSerializer<String> serializer;
58   
 
59  59769 toggle @Override
60    public XDOM parse(String content, Syntax syntax) throws ParseException, MissingParserException
61    {
62  59766 Test failure here return getParser(syntax).parse(new StringReader(content == null ? "" : content));
63    }
64   
 
65  59743 toggle @Override
66    public XDOM parse(String content, Syntax syntax, EntityReference source) throws ParseException,
67    MissingParserException
68    {
69  59743 Test failure here XDOM xdom = parse(content, syntax);
70  59743 if (source != null) {
71  59742 xdom.getMetaData().addMetaData(MetaData.SOURCE, serializer.serialize(source));
72    }
73  59743 return xdom;
74    }
75   
76    /**
77    * Return a parser for the given syntax.
78    *
79    * @param syntax the syntax.
80    * @return a parser.
81    * @throws MissingParserException when no parser where found for the given syntax.
82    * @since 6.0M2
83    */
 
84  59770 toggle private Parser getParser(Syntax syntax) throws MissingParserException
85    {
86  59771 try {
87  59769 Test failure here return this.componentManagerProvider.get().getInstance(Parser.class, syntax.toIdString());
88    } catch (ComponentLookupException e) {
89  0 Test failure here throw new MissingParserException(syntax, e);
90    }
91    }
92    }