blob: 6d619bb34ef698298b92c3744579635e6775d635 [file] [log] [blame]
<HTML><HEAD><META CONTENT="text/html; charset=UTF-8" HTTP-EQUIV="Content-Type"/><TITLE>EMMA Coverage Report</TITLE><STYLE TYPE="text/css"> TABLE,TD,TH {border-style:solid; border-color:black;} TD,TH {background:white;margin:0;line-height:100%;padding-left:0.5em;padding-right:0.5em;} TD {border-width:0 1px 0 0;} TH {border-width:1px 1px 1px 0;} TR TD.h {color:red;} TABLE {border-spacing:0; border-collapse:collapse;border-width:0 0 1px 1px;} P,H1,H2,H3,TH {font-family:verdana,arial,sans-serif;font-size:10pt;} TD {font-family:courier,monospace;font-size:10pt;} TABLE.hdft {border-spacing:0;border-collapse:collapse;border-style:none;} TABLE.hdft TH,TABLE.hdft TD {border-style:none;line-height:normal;} TABLE.hdft TH.tl,TABLE.hdft TD.tl {background:#6699CC;color:white;} TABLE.hdft TD.nv {background:#6633DD;color:white;} .nv A:link {color:white;} .nv A:visited {color:white;} .nv A:active {color:yellow;} TABLE.hdft A:link {color:white;} TABLE.hdft A:visited {color:white;} TABLE.hdft A:active {color:yellow;} .in {color:#356085;} TABLE.s TD {padding-left:0.25em;padding-right:0.25em;} TABLE.s TD.l {padding-left:0.25em;padding-right:0.25em;text-align:right;background:#F0F0F0;} TABLE.s TR.z TD {background:#FF9999;} TABLE.s TR.p TD {background:#FFFF88;} TABLE.s TR.c TD {background:#CCFFCC;} A:link {color:#0000EE;text-decoration:none;} A:visited {color:#0000EE;text-decoration:none;} A:hover {color:#0000EE;text-decoration:underline;} TABLE.cn {border-width:0 0 1px 0;} TABLE.s {border-width:1px 0 1px 1px;} TD.h {color:red;border-width:0 1px 0 0;} TD.f {border-width:0 1px 0 1px;} TD.hf {color:red;border-width:0 1px 0 1px;} TH.f {border-width:1px 1px 1px 1px;} TR.cis TD {background:#F0F0F0;} TR.cis TD {border-width:1px 1px 1px 0;} TR.cis TD.h {color:red;border-width:1px 1px 1px 0;} TR.cis TD.f {border-width:1px 1px 1px 1px;} TR.cis TD.hf {color:red;border-width:1px 1px 1px 1px;} TD.b {border-style:none;background:transparent;line-height:50%;} TD.bt {border-width:1px 0 0 0;background:transparent;line-height:50%;} TR.o TD {background:#F0F0F0;}TABLE.it {border-style:none;}TABLE.it TD,TABLE.it TH {border-style:none;}</STYLE></HEAD><BODY><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="tl"><A HREF="http://www.eclemma.org/">EMMA</A> Coverage Report (generated Fri Feb 20 18:44:54 GMT 2009)</TH></TR><TR><TD CLASS="nv">[<A HREF="../xslUnitTestCoverage.html">all classes</A>][<A HREF="8b.html">org.eclipse.wst.sse.ui.internal.contentassist</A>]</TD></TR></TABLE><H2>COVERAGE SUMMARY FOR SOURCE FILE [<SPAN CLASS="in">StructuredContentAssistant.java</SPAN>]</H2><TABLE CELLSPACING="0" WIDTH="100%"><TR><TH>name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD>StructuredContentAssistant.java</TD><TD>100% (1/1)</TD><TD>100% (6/6)</TD><TD CLASS="h">71%  (120/168)</TD><TD CLASS="h">74%  (33.8/46)</TD></TR></TABLE><H3>COVERAGE BREAKDOWN BY CLASS AND METHOD</H3><TABLE CLASS="cn" CELLSPACING="0" WIDTH="100%"><TR><TH CLASS="f">name</TH><TH>class, %</TH><TH>method, %</TH><TH>block, %</TH><TH>line, %</TH></TR><TR><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD><TD CLASS="b"> </TD></TR><TR CLASS="cis"><TD CLASS="f">class <A HREF="#0">StructuredContentAssistant</A></TD><TD>100% (1/1)</TD><TD>100% (6/6)</TD><TD CLASS="h">71%  (120/168)</TD><TD CLASS="h">74%  (33.8/46)</TD></TR><TR><TD CLASS="f"><A HREF="#1">getExistingContentAssistProcessor (String): CompoundContentAssistProcessor</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">45%  (10/22)</TD><TD CLASS="h">57%  (4/7)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2">getContentAssistProcessor (String): IContentAssistProcessor</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">62%  (32/52)</TD><TD CLASS="h">61%  (7.4/12)</TD></TR><TR><TD CLASS="f"><A HREF="#3">isInitialized (): boolean</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">71%  (5/7)</TD><TD CLASS="h">71%  (0.7/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#4">setContentAssistProcessor (IContentAssistProcessor, String): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD CLASS="h">77%  (36/47)</TD><TD CLASS="h">77%  (10.8/14)</TD></TR><TR><TD CLASS="f"><A HREF="#5">uninstall (): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>92%  (34/37)</TD><TD>91%  (10/11)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#0">StructuredContentAssistant (): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (3/3)</TD><TD>100% (1/1)</TD></TR></TABLE><P></P><TABLE CLASS="s" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="l">1</TD><TD>/*******************************************************************************</TD></TR><TR><TD CLASS="l">2</TD><TD> * Copyright (c) 2005, 2007 IBM Corporation and others.</TD></TR><TR><TD CLASS="l">3</TD><TD> * All rights reserved. This program and the accompanying materials</TD></TR><TR><TD CLASS="l">4</TD><TD> * are made available under the terms of the Eclipse Public License v1.0</TD></TR><TR><TD CLASS="l">5</TD><TD> * which accompanies this distribution, and is available at</TD></TR><TR><TD CLASS="l">6</TD><TD> * http://www.eclipse.org/legal/epl-v10.html</TD></TR><TR><TD CLASS="l">7</TD><TD> *</TD></TR><TR><TD CLASS="l">8</TD><TD> * Contributors:</TD></TR><TR><TD CLASS="l">9</TD><TD> *     IBM Corporation - initial API and implementation</TD></TR><TR><TD CLASS="l">10</TD><TD> *     Jens Lukowski/Innoopract - initial renaming/restructuring</TD></TR><TR><TD CLASS="l">11</TD><TD> *     </TD></TR><TR><TD CLASS="l">12</TD><TD> *******************************************************************************/</TD></TR><TR><TD CLASS="l">13</TD><TD>package org.eclipse.wst.sse.ui.internal.contentassist;</TD></TR><TR><TD CLASS="l">14</TD><TD> </TD></TR><TR><TD CLASS="l">15</TD><TD>import java.util.ArrayList;</TD></TR><TR><TD CLASS="l">16</TD><TD>import java.util.Collection;</TD></TR><TR><TD CLASS="l">17</TD><TD>import java.util.HashMap;</TD></TR><TR><TD CLASS="l">18</TD><TD>import java.util.Iterator;</TD></TR><TR><TD CLASS="l">19</TD><TD>import java.util.List;</TD></TR><TR><TD CLASS="l">20</TD><TD>import java.util.Map;</TD></TR><TR><TD CLASS="l">21</TD><TD> </TD></TR><TR><TD CLASS="l"><A NAME="0">22</A></TD><TD>import org.eclipse.jface.text.contentassist.ContentAssistant;</TD></TR><TR><TD CLASS="l">23</TD><TD>import org.eclipse.jface.text.contentassist.IContentAssistProcessor;</TD></TR><TR><TD CLASS="l">24</TD><TD>import org.eclipse.wst.sse.ui.internal.ExtendedConfigurationBuilder;</TD></TR><TR><TD CLASS="l">25</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">26</TD><TD>public class StructuredContentAssistant extends ContentAssistant {</TD></TR><TR><TD CLASS="l">27</TD><TD>        private static final String CONTENT_ASSIST_PROCESSOR_EXTENDED_ID = &#34;contentassistprocessor&#34;; //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">28</TD><TD> </TD></TR><TR><TD CLASS="l">29</TD><TD>        /**</TD></TR><TR><TD CLASS="l">30</TD><TD>         * personal list of content assist processors</TD></TR><TR><TD CLASS="l">31</TD><TD>         */</TD></TR><TR><TD CLASS="l">32</TD><TD>        private Map fProcessors;</TD></TR><TR><TD CLASS="l">33</TD><TD>        /**</TD></TR><TR><TD CLASS="l">34</TD><TD>         * list of partition types where extended processors have been installed</TD></TR><TR><TD CLASS="l">35</TD><TD>         */</TD></TR><TR><TD CLASS="l">36</TD><TD>        private List fInstalledExtendedContentTypes;</TD></TR><TR><TD CLASS="l">37</TD><TD> </TD></TR><TR><TD CLASS="l">38</TD><TD>        /**</TD></TR><TR><TD CLASS="l">39</TD><TD>         * Each set content assist processor is placed inside a</TD></TR><TR><TD CLASS="l">40</TD><TD>         * CompoundContentAssistProcessor which allows multiple processors per</TD></TR><TR><TD CLASS="l">41</TD><TD>         * partition type</TD></TR><TR><TD CLASS="l">42</TD><TD>         * </TD></TR><TR><TD CLASS="l">43</TD><TD>         * @param processor</TD></TR><TR><TD CLASS="l">44</TD><TD>         *            the content assist processor to register, or</TD></TR><TR><TD CLASS="l">45</TD><TD>         *            &lt;code&gt;null&lt;/code&gt; to remove an existing one</TD></TR><TR><TD CLASS="l"><A NAME="4">46</A></TD><TD>         * @param contentType</TD></TR><TR><TD CLASS="l">47</TD><TD>         *            the content type under which to register</TD></TR><TR><TD CLASS="l">48</TD><TD>         */</TD></TR><TR><TD CLASS="l">49</TD><TD>        public void setContentAssistProcessor(IContentAssistProcessor processor, String partitionType) {</TD></TR><TR CLASS="c"><TD CLASS="l">50</TD><TD>                if (fProcessors == null)</TD></TR><TR CLASS="c"><TD CLASS="l">51</TD><TD>                        fProcessors = new HashMap();</TD></TR><TR><TD CLASS="l">52</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">53</TD><TD>                CompoundContentAssistProcessor compoundProcessor = getExistingContentAssistProcessor(partitionType);</TD></TR><TR><TD CLASS="l">54</TD><TD> </TD></TR><TR><TD CLASS="l">55</TD><TD>                // if processor is null, you want to remove all processors of</TD></TR><TR><TD CLASS="l">56</TD><TD>                // contentType</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="75% line coverage (6 out of 8 instructions)">57</TD><TD TITLE="75% line coverage (6 out of 8 instructions)">                if (processor == null &amp;&amp; compoundProcessor != null) {</TD></TR><TR CLASS="z"><TD CLASS="l">58</TD><TD>                        compoundProcessor.dispose();</TD></TR><TR CLASS="z"><TD CLASS="l">59</TD><TD>                        fProcessors.remove(partitionType);</TD></TR><TR CLASS="z"><TD CLASS="l">60</TD><TD>                        compoundProcessor = null;</TD></TR><TR><TD CLASS="l">61</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">62</TD><TD>                if (processor != null) {</TD></TR><TR><TD CLASS="l">63</TD><TD>                        // create a new compoundprocess if there already isnt one</TD></TR><TR CLASS="c"><TD CLASS="l">64</TD><TD>                        if (compoundProcessor == null) {</TD></TR><TR CLASS="c"><TD CLASS="l">65</TD><TD>                                compoundProcessor = new CompoundContentAssistProcessor();</TD></TR><TR><TD CLASS="l">66</TD><TD>                        }</TD></TR><TR><TD CLASS="l">67</TD><TD>                        // add processor to compound processor</TD></TR><TR CLASS="c"><TD CLASS="l">68</TD><TD>                        compoundProcessor.add(processor);</TD></TR><TR><TD CLASS="l">69</TD><TD>                        // add compound procesor to processors list (will replace old one,</TD></TR><TR><TD CLASS="l">70</TD><TD>                        // even if same instance)</TD></TR><TR CLASS="c"><TD CLASS="l">71</TD><TD>                        fProcessors.put(partitionType, compoundProcessor);</TD></TR><TR><TD CLASS="l">72</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l"><A NAME="1">73</A></TD><TD>                super.setContentAssistProcessor(compoundProcessor, partitionType);</TD></TR><TR CLASS="c"><TD CLASS="l">74</TD><TD>        }</TD></TR><TR><TD CLASS="l">75</TD><TD> </TD></TR><TR><TD CLASS="l">76</TD><TD>        private CompoundContentAssistProcessor getExistingContentAssistProcessor(String partitionType) {</TD></TR><TR CLASS="c"><TD CLASS="l">77</TD><TD>                CompoundContentAssistProcessor compoundContentAssistProcessor = null;</TD></TR><TR CLASS="c"><TD CLASS="l">78</TD><TD>                IContentAssistProcessor processor = super.getContentAssistProcessor(partitionType);</TD></TR><TR CLASS="c"><TD CLASS="l">79</TD><TD>                if (processor != null) {</TD></TR><TR CLASS="z"><TD CLASS="l">80</TD><TD>                        if (processor instanceof CompoundContentAssistProcessor) {</TD></TR><TR CLASS="z"><TD CLASS="l">81</TD><TD>                                compoundContentAssistProcessor = (CompoundContentAssistProcessor) processor;</TD></TR><TR><TD CLASS="l">82</TD><TD>                        }</TD></TR><TR><TD CLASS="l">83</TD><TD>                        else {</TD></TR><TR CLASS="z"><TD CLASS="l">84</TD><TD>                                throw new IllegalStateException(&#34;StructuredContentAssistant use CompoundContentAssistProcessor&#34;); //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">85</TD><TD>                        }</TD></TR><TR><TD CLASS="l">86</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">87</TD><TD>                return compoundContentAssistProcessor;</TD></TR><TR><TD CLASS="l">88</TD><TD> </TD></TR><TR><TD CLASS="l">89</TD><TD>        }</TD></TR><TR><TD CLASS="l">90</TD><TD> </TD></TR><TR><TD CLASS="l">91</TD><TD>        /**</TD></TR><TR><TD CLASS="l">92</TD><TD>         * Returns the content assist processor to be used for the given content</TD></TR><TR><TD CLASS="l">93</TD><TD>         * type. Also installs any content assist processors that were added by</TD></TR><TR><TD CLASS="l">94</TD><TD>         * extension point.</TD></TR><TR><TD CLASS="l">95</TD><TD>         * </TD></TR><TR><TD CLASS="l">96</TD><TD>         * @param contentType</TD></TR><TR><TD CLASS="l">97</TD><TD>         *            the type of the content for which this content assistant is</TD></TR><TR><TD CLASS="l">98</TD><TD>         *            to be requested</TD></TR><TR><TD CLASS="l"><A NAME="2">99</A></TD><TD>         * @return an instance content assist processor or &lt;code&gt;null&lt;/code&gt; if</TD></TR><TR><TD CLASS="l">100</TD><TD>         *         none exists for the specified content type</TD></TR><TR><TD CLASS="l">101</TD><TD>         */</TD></TR><TR><TD CLASS="l">102</TD><TD>        public IContentAssistProcessor getContentAssistProcessor(String partitionType) {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="38% line coverage (3 out of 8 instructions)">103</TD><TD TITLE="38% line coverage (3 out of 8 instructions)">                if (fInstalledExtendedContentTypes == null || !fInstalledExtendedContentTypes.contains(partitionType)) {</TD></TR><TR><TD CLASS="l">104</TD><TD>                        // get extended content assist processors that have not already</TD></TR><TR><TD CLASS="l">105</TD><TD>                        // been set</TD></TR><TR CLASS="c"><TD CLASS="l">106</TD><TD>                        List processors = ExtendedConfigurationBuilder.getInstance().getConfigurations(CONTENT_ASSIST_PROCESSOR_EXTENDED_ID, partitionType);</TD></TR><TR CLASS="c"><TD CLASS="l">107</TD><TD>                        if (processors != null &amp;&amp; !processors.isEmpty()) {</TD></TR><TR CLASS="z"><TD CLASS="l">108</TD><TD>                                Iterator iter = processors.iterator();</TD></TR><TR CLASS="z"><TD CLASS="l">109</TD><TD>                                while (iter.hasNext()) {</TD></TR><TR CLASS="z"><TD CLASS="l">110</TD><TD>                                        IContentAssistProcessor processor = (IContentAssistProcessor) iter.next();</TD></TR><TR CLASS="z"><TD CLASS="l">111</TD><TD>                                        setContentAssistProcessor(processor, partitionType);</TD></TR><TR><TD CLASS="l">112</TD><TD>                                }</TD></TR><TR><TD CLASS="l">113</TD><TD>                        }</TD></TR><TR><TD CLASS="l">114</TD><TD>                        // add partition type to list of extended partition types</TD></TR><TR><TD CLASS="l">115</TD><TD>                        // installed (regardless of whether or not any extended content</TD></TR><TR><TD CLASS="l">116</TD><TD>                        // assist processors were installed because dont want to look it</TD></TR><TR><TD CLASS="l">117</TD><TD>                        // up every time)</TD></TR><TR CLASS="c"><TD CLASS="l">118</TD><TD>                        if (fInstalledExtendedContentTypes == null)</TD></TR><TR CLASS="c"><TD CLASS="l">119</TD><TD>                                fInstalledExtendedContentTypes = new ArrayList();</TD></TR><TR CLASS="c"><TD CLASS="l">120</TD><TD>                        fInstalledExtendedContentTypes.add(partitionType);</TD></TR><TR><TD CLASS="l">121</TD><TD>                }</TD></TR><TR><TD CLASS="l">122</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">123</TD><TD>                IContentAssistProcessor processor = super.getContentAssistProcessor(partitionType);</TD></TR><TR CLASS="c"><TD CLASS="l">124</TD><TD>                return processor;</TD></TR><TR><TD CLASS="l"><A NAME="5">125</A></TD><TD>        }</TD></TR><TR><TD CLASS="l">126</TD><TD> </TD></TR><TR><TD CLASS="l">127</TD><TD>        public void uninstall() {</TD></TR><TR><TD CLASS="l">128</TD><TD>                // dispose of all content assist processors</TD></TR><TR CLASS="c"><TD CLASS="l">129</TD><TD>                if (fProcessors != null &amp;&amp; !fProcessors.isEmpty()) {</TD></TR><TR CLASS="c"><TD CLASS="l">130</TD><TD>                        Collection collection = fProcessors.values();</TD></TR><TR CLASS="c"><TD CLASS="l">131</TD><TD>                        Iterator iter = collection.iterator();</TD></TR><TR CLASS="c"><TD CLASS="l">132</TD><TD>                        while (iter.hasNext()) {</TD></TR><TR CLASS="c"><TD CLASS="l">133</TD><TD>                                ((CompoundContentAssistProcessor) iter.next()).dispose();</TD></TR><TR><TD CLASS="l">134</TD><TD>                        }</TD></TR><TR CLASS="c"><TD CLASS="l">135</TD><TD>                        fProcessors.clear();</TD></TR><TR><TD CLASS="l">136</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">137</TD><TD>                fProcessors = null;</TD></TR><TR><TD CLASS="l">138</TD><TD> </TD></TR><TR><TD CLASS="l">139</TD><TD>                // clear out list of installed content types</TD></TR><TR CLASS="c"><TD CLASS="l">140</TD><TD>                if (fInstalledExtendedContentTypes != null) {</TD></TR><TR CLASS="z"><TD CLASS="l">141</TD><TD>                        fInstalledExtendedContentTypes.clear();</TD></TR><TR><TD CLASS="l">142</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">143</TD><TD>                super.uninstall();</TD></TR><TR CLASS="c"><TD CLASS="l">144</TD><TD>        }</TD></TR><TR><TD CLASS="l">145</TD><TD> </TD></TR><TR><TD CLASS="l">146</TD><TD>        /**</TD></TR><TR><TD CLASS="l">147</TD><TD>         * Returns true if content assist has been initialized with some content</TD></TR><TR><TD CLASS="l">148</TD><TD>         * assist processors. False otherwise.</TD></TR><TR><TD CLASS="l"><A NAME="3">149</A></TD><TD>         * </TD></TR><TR><TD CLASS="l">150</TD><TD>         * @return true if content assistant has been initialized</TD></TR><TR><TD CLASS="l">151</TD><TD>         */</TD></TR><TR><TD CLASS="l">152</TD><TD>        public boolean isInitialized() {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="71% line coverage (5 out of 7 instructions)">153</TD><TD TITLE="71% line coverage (5 out of 7 instructions)">                return (fProcessors != null);</TD></TR><TR><TD CLASS="l">154</TD><TD>        }</TD></TR><TR><TD CLASS="l">155</TD><TD>}</TD></TR></TABLE><P></P><TABLE CLASS="hdft" CELLSPACING="0" WIDTH="100%"><TR><TD CLASS="nv">[<A HREF="../xslUnitTestCoverage.html">all classes</A>][<A HREF="8b.html">org.eclipse.wst.sse.ui.internal.contentassist</A>]</TD></TR><TR><TD CLASS="tl"><A HREF="http://www.eclemma.org/support.html">EMMA 2.0.5312 EclEmma Fix 1</A> (C) Vladimir Roubtsov</TD></TR></TABLE></BODY></HTML>