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

File MacroBlock.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
3
3
1
78
20
3
1
1
3
1

Classes

Class Line # Actions
MacroBlock 37 3 0% 3 0
1.0100%
 

Contributing tests

This file is covered by 360 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.block;
21   
22    import java.util.Collections;
23    import java.util.Map;
24   
25    import org.xwiki.rendering.listener.Listener;
26   
27    /**
28    * Represents a Macro (standalone or inline) defined in a page.
29    * <p>
30    * Note: You can get macro parameters using {@link #getParameters()} for example. Macro block is reusing Block standard
31    * custom parameters API since macro by definition already have parameters and don't need also block parameters. So in
32    * this case MacroBlock parameters and Block parameters are the same thing.
33    *
34    * @version $Id: 7d323433124ae72fd49076eb0e96b057bed18e09 $
35    * @since 1.8M2
36    */
 
37    public class MacroBlock extends AbstractMacroBlock
38    {
39    /**
40    * @param id the id of the macro
41    * @param parameters the parameters of the macro
42    * @param isInline indicate if the macro is located in a inline content (like paragraph, etc.)
43    */
 
44  82 toggle public MacroBlock(String id, Map<String, String> parameters, boolean isInline)
45    {
46  82 this(id, parameters, null, isInline);
47    }
48   
49    /**
50    * @param id the id of the macro
51    * @param parameters the parameters of the macro
52    * @param content the content of the macro. Null if the macro does not have content
53    * @param isInline indicate if the macro is located in a inline content (like paragraph, etc.)
54    */
 
55  260159 toggle public MacroBlock(String id, Map<String, String> parameters, String content, boolean isInline)
56    {
57  260155 super(Collections.<Block>emptyList(), parameters, id, content, isInline);
58    }
59   
 
60  6562 toggle @Override
61    public void traverse(Listener listener)
62    {
63    // Don't do anything here since we want the Macro Transformer component to take in charge
64    // Macro execution. This is because Macro execution is a complex process that involves:
65    // * computing the order in which the macros should be evaluated. For example the TOC macro
66    // should evaluate last since other macros can contribute headers/sections blocks.
67    // * some macros need to modify blocks in the XDOM object
68    // * macro execution is a multi-pass process
69    // In essence the Macro Transformer will replace all MacroBlock blocks with other Blocks
70    // generated from the execution of the Macros when XDOM.traverse() is called there
71    // won't be any MacroBlock.traverse() method called at all.
72   
73    // Note: We're calling the event to let other listener downstream decide what to do with it.
74    // In practice as described above this method will never get called when the whole rendering
75    // process is executed. This does get called during our unit tests though.
76  6562 listener.onMacro(getId(), getParameters(), getContent(), isInline());
77    }
78    }