Debian Codegraph @

net/sf/saxon/trace/TimingCodeInjector.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.trace;
9
10 import net.sf.saxon.expr.Expression;
11 import net.sf.saxon.expr.StaticContext;
12 import net.sf.saxon.expr.flwor.Clause;
13 import net.sf.saxon.om.StandardNames;
14 import net.sf.saxon.om.StructuredQName;
15
16 /**
17 * A code injector that wraps the body of a template or function in a TraceExpression, which causes
18 * the TimingTraceListener to be notified at the start and end of the function/template evaluation
19 */
20 public class TimingCodeInjector extends TraceCodeInjector {
21
22 /**
23 * If tracing, wrap an expression in a trace instruction
24 *
25 * @param exp the expression to be wrapped
26 * @param env the static context
27 * @param construct integer constant identifying the kind of construct
28 * @param qName the name of the construct (if applicable)
29 * @return the expression that does the tracing
30 */
31
32 public Expression inject(Expression exp, StaticContext env, int construct, StructuredQName qName) {
33 if (construct == StandardNames.XSL_FUNCTION || construct == StandardNames.XSL_TEMPLATE || construct == StandardNames.XSL_VARIABLE) {
34 return super.inject(exp, env, construct, qName);
35 } else {
36 return exp;
37 }
38 }
39
40 public Clause injectClause(Clause target, StaticContext env) {
41 return null;
42 }
43 }
44