org.sweble.wikitext.engine.utils.LogPrinter.apt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swc-engine Show documentation
Show all versions of swc-engine Show documentation
A minimal engine using the Sweble Wikitext Parser to
process articles in the context of a MediaWiki-like configuration.
%*
* Copyright 2011 The Open Source Research Group,
* University of Erlangen-Nürnberg
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*%
%Name LogPrinter;
%Package org.sweble.wikitext.engine.utils;
%CtorParams boolean descend;
%Header {
import org.sweble.wikitext.engine.log.*;
import org.sweble.wikitext.lazy.utils.WikitextPrinter;
}
%Body {
private boolean descend = false;
public LogPrinter(Writer writer, boolean descend)
{
super(writer);
this.descend = descend;
}
public static String print(AstNode node)
{
return print(node, true);
}
}
%* ========================================================================== *%
%visit(CompilerLog n)%
Compilation
-----------
Title : {=n.getTitle()}
Revision : {=n.getRevision().toString()}
{if(descend)}
{!iterate(n.getContent())}
{/if}
%visit(ValidatorLog n)%
Validation
----------
Processing time : {=n.getTimeNeeded().toString()}ms
{if(descend)}
{!iterate(n.getContent())}
{/if}
%visit(PreprocessorLog n)%
Preprocessing
-------------
For inclusion : {=(n.getForInclusion() ? "yes" : "no")}
Processing time : {=n.getTimeNeeded().toString()}ms
{if(descend)}
{!iterate(n.getContent())}
{/if}
%visit(PpResolverLog n)%
Expansion
---------
Processing time : {=n.getTimeNeeded().toString()}ms
{if(descend)}
{!iterate(n.getContent())}
{/if}
%visit(ParserLog n)%
Parsing
-------
Processing time : {=n.getTimeNeeded().toString()}ms
{if(descend)}
{!iterate(n.getContent())}
{/if}
%visit(PostprocessorLog n)%
Postprocessing
--------------
Processing time : {=n.getTimeNeeded().toString()}ms
{if(descend)}
{!iterate(n.getContent())}
{/if}
%visit(ResolveRedirectLog n)%
Redirection
-----------
Processing time : {=n.getTimeNeeded().toString()}ms
Success : {=(n.getSuccess() ? "yes" : "no")}
Target : {=n.getTarget()}
Canonical target : {=n.getCanonical()}
{if(descend)}
{!iterate(n.getContent())}
{/if}
%visit(ResolveTransclusionLog n)%
Transclusion
------------
Processing time : {=n.getTimeNeeded().toString()}ms
Success : {=(n.getSuccess() ? "yes" : "no")}
Target : {=n.getTarget()}
Canonical target : {=n.getCanonical()}
{if(descend)}
{!iterate(n.getContent())}
{/if}
%* ========================================================================== *%
%visit(ParseException n)%
Parse Exception (EXCEPTION)
---------------
{=n.getMessage()}
%visit(IllegalNameException n)%
Illegal Name Exception (EXCEPTION)
----------------------
{=n.getMessage()}
Offending name:
{=WikitextPrinter.print(n.getName())}
%visit(UnhandledException n)%
Unhandled Exception (EXCEPTION)
-------------------
Dump:
{=n.getDump()}
%* ========================================================================== *%