Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
20   118   8   4
2   61   0.4   5
5     1.6  
1    
 
  LoadDirectlyRequiredModulesExecutor       Line # 39 20 8 100% 1.0
 
  (84)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program 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
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.service.dependency;
17   
18    import org.qedeq.base.io.Parameters;
19    import org.qedeq.base.trace.Trace;
20    import org.qedeq.kernel.bo.module.ControlVisitor;
21    import org.qedeq.kernel.bo.module.InternalServiceCall;
22    import org.qedeq.kernel.bo.module.KernelModuleReferenceList;
23    import org.qedeq.kernel.bo.module.KernelQedeqBo;
24    import org.qedeq.kernel.bo.module.PluginExecutor;
25    import org.qedeq.kernel.se.base.module.Import;
26    import org.qedeq.kernel.se.base.module.ImportList;
27    import org.qedeq.kernel.se.common.ModuleContext;
28    import org.qedeq.kernel.se.common.ModuleDataException;
29    import org.qedeq.kernel.se.common.Plugin;
30    import org.qedeq.kernel.se.common.SourceFileExceptionList;
31    import org.qedeq.kernel.se.state.LoadingImportsState;
32   
33   
34    /**
35    * Load all directly imported QEDEQ modules.
36    *
37    * @author Michael Meyling
38    */
 
39    public final class LoadDirectlyRequiredModulesExecutor extends ControlVisitor
40    implements PluginExecutor {
41   
42    /** This class. */
43    private static final Class CLASS = LoadDirectlyRequiredModulesExecutor.class;
44   
45    /** List of required QEDEQ modules. */
46    private KernelModuleReferenceList required;
47   
48    /**
49    * Constructor.
50    *
51    * @param plugin Plugin we work for.
52    * @param prop Internal QedeqBo.
53    * @param parameter Currently ignored.
54    */
 
55  529 toggle public LoadDirectlyRequiredModulesExecutor(final Plugin plugin, final KernelQedeqBo prop,
56    final Parameters parameter) {
57  529 super(plugin, prop);
58    }
59   
 
60  529 toggle public Object executePlugin(final InternalServiceCall call, final Object data) {
61  529 if (getQedeqBo().hasLoadedImports()) {
62  181 return getQedeqBo().getRequiredModules();
63    }
64  348 this.required = new KernelModuleReferenceList();
65  348 try {
66  348 super.traverse(call.getInternalServiceProcess());
67  347 getQedeqBo().setLoadedImports(required);
68    } catch (final SourceFileExceptionList sfl) {
69  1 getQedeqBo().setLoadingImportsFailureState(
70    LoadingImportsState.STATE_LOADING_IMPORTS_FAILED, sfl);
71    }
72  348 return required;
73    }
74   
75    /**
76    * Get list of directly referenced modules.
77    *
78    * @return List of directly required modules.
79    */
 
80  227 toggle public KernelModuleReferenceList getRequired() {
81  227 return required;
82    }
83   
84    /**
85    * Visit import. Loads referenced QEDEQ module and saves reference.
86    *
87    * @param imp Begin visit of this element.
88    * @throws ModuleDataException Major problem occurred.
89    */
 
90  229 toggle public void visitEnter(final Import imp) throws ModuleDataException {
91  229 final ModuleContext context = getCurrentContext();
92  229 context.setLocationWithinModule(context.getLocationWithinModule() + ".getLabel()");
93  229 try {
94  229 final KernelQedeqBo propNew = getQedeqBo().getKernelServices().loadModule(
95    getInternalServiceCall().getInternalServiceProcess(),
96    getQedeqBo().getModuleAddress(), imp.getSpecification());
97  227 getRequired().addLabelUnique(context, imp.getLabel(), propNew);
98  227 Trace.param(CLASS, "visitEnter(Import)", "adding context", getCurrentContext());
99    } catch (SourceFileExceptionList e) {
100  2 final ModuleDataException me = new LoadRequiredModuleException(e.get(0).getErrorCode(),
101    "import of module with label \"" + imp.getLabel() + "\" failed: "
102    + e.get(0).getMessage(), context);
103    // TODO mime 20080227: also include reference area in sf creation?
104  2 addError(me);
105  2 Trace.trace(CLASS, this, "visitEnter(Import)", e);
106    }
107    }
108   
109    /**
110    * End of visit of import list. Blocks further visits.
111    *
112    * @param imports This visit has just ended.
113    */
 
114  171 toggle public void visitLeave(final ImportList imports) {
115  171 setBlocked(true); // block further traverse
116    }
117   
118    }