blob: 8194d08a51d7ad8884d39a666ac343d4acd46429 [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="cb.html">org.eclipse.wst.xsl.ui.internal.contentassist</A>]</TD></TR></TABLE><H2>COVERAGE SUMMARY FOR SOURCE FILE [<SPAN CLASS="in">SelectAttributeContentAssist.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>SelectAttributeContentAssist.java</TD><TD>100% (1/1)</TD><TD>100% (14/14)</TD><TD>96%  (446/466)</TD><TD>94%  (94.4/100)</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">SelectAttributeContentAssist</A></TD><TD>100% (1/1)</TD><TD>100% (14/14)</TD><TD>96%  (446/466)</TD><TD>94%  (94.4/100)</TD></TR><TR><TD CLASS="f"><A HREF="#1">addVariablesProposals (String, Node, int): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>89%  (77/87)</TD><TD>83%  (14.9/18)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2">getXPathSeperatorPos (int, String): int</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>89%  (72/81)</TD><TD>87%  (9.6/11)</TD></TR><TR><TD CLASS="f"><A HREF="#3">adjustXPathStart (): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>98%  (45/46)</TD><TD>92%  (12/13)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#0">&lt;static initializer&gt;</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (4/4)</TD><TD>100% (2/2)</TD></TR><TR><TD CLASS="f"><A HREF="#5">SelectAttributeContentAssist (Node, IStructuredDocumentRegion, ITextRegion, i...</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (18/18)</TD><TD>100% (4/4)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#6">addContentModelProposals (int): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (30/30)</TD><TD>100% (5/5)</TD></TR><TR><TD CLASS="f"><A HREF="#7">addGlobalProposals (Node, int): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (11/11)</TD><TD>100% (3/3)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#8">addLocalProposals (Node, int): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (11/11)</TD><TD>100% (3/3)</TD></TR><TR><TD CLASS="f"><A HREF="#9">addSelectProposals (Element, int): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (29/29)</TD><TD>100% (8/8)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#a">addTemplates (String, int): void</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (58/58)</TD><TD>100% (13/13)</TD></TR><TR><TD CLASS="f"><A HREF="#b">extractXPathMatchString (IDOMAttr, ITextRegion, int): String</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (42/42)</TD><TD>100% (9/9)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#c">getAttribute (String): IDOMAttr</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (7/7)</TD><TD>100% (1/1)</TD></TR><TR><TD CLASS="f"><A HREF="#d">getCompletionProposals (): ArrayList</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (31/31)</TD><TD>100% (7/7)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#e">getTemplateCompletionProcessor (): XPathTemplateCompletionProcessor</A></TD><TD> </TD><TD>100% (1/1)</TD><TD>100% (11/11)</TD><TD>100% (3/3)</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) 2008, 2009 Standards for Technology in Automotive Retail 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> *    David Carver (STAR) - bug 240170 - initial API and implementation</TD></TR><TR><TD CLASS="l">10</TD><TD> *                          bug 259575 - fixed replacement issue and XPath tokenizer</TD></TR><TR><TD CLASS="l">11</TD><TD> *                                       position adjuster for matchString.</TD></TR><TR><TD CLASS="l">12</TD><TD> *******************************************************************************/</TD></TR><TR><TD CLASS="l">13</TD><TD>package org.eclipse.wst.xsl.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.List;</TD></TR><TR><TD CLASS="l">17</TD><TD> </TD></TR><TR><TD CLASS="l">18</TD><TD>import javax.xml.transform.TransformerException;</TD></TR><TR><TD CLASS="l">19</TD><TD> </TD></TR><TR><TD CLASS="l">20</TD><TD>import org.apache.xpath.compiler.XPathParser;</TD></TR><TR><TD CLASS="l">21</TD><TD>import org.eclipse.jface.text.ITextViewer;</TD></TR><TR><TD CLASS="l">22</TD><TD>import org.eclipse.jface.text.contentassist.ICompletionProposal;</TD></TR><TR><TD CLASS="l">23</TD><TD>import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;</TD></TR><TR><TD CLASS="l">24</TD><TD>import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;</TD></TR><TR><TD CLASS="l">25</TD><TD>import org.eclipse.wst.xsl.ui.internal.contentassist.CustomCompletionProposal;</TD></TR><TR><TD CLASS="l">26</TD><TD>import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;</TD></TR><TR><TD CLASS="l">27</TD><TD>import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;</TD></TR><TR><TD CLASS="l">28</TD><TD>import org.eclipse.wst.xml.xpath.core.util.XSLTXPathHelper;</TD></TR><TR><TD CLASS="l">29</TD><TD>import org.eclipse.wst.xml.xpath.ui.internal.contentassist.XPathTemplateCompletionProcessor;</TD></TR><TR><TD CLASS="l">30</TD><TD>import org.eclipse.wst.xml.xpath.ui.internal.templates.TemplateContextTypeIdsXPath;</TD></TR><TR><TD CLASS="l">31</TD><TD>import org.eclipse.wst.xsl.ui.internal.XSLUIPlugin;</TD></TR><TR><TD CLASS="l">32</TD><TD>import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImageHelper;</TD></TR><TR><TD CLASS="l">33</TD><TD>import org.eclipse.wst.xsl.ui.internal.util.XSLPluginImages;</TD></TR><TR><TD CLASS="l">34</TD><TD>import org.w3c.dom.Element;</TD></TR><TR><TD CLASS="l">35</TD><TD>import org.w3c.dom.Node;</TD></TR><TR><TD CLASS="l">36</TD><TD>import org.w3c.dom.NodeList;</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>/**</TD></TR><TR><TD CLASS="l">40</TD><TD> * This class provides content assistance for the XSL select attribute.</TD></TR><TR><TD CLASS="l">41</TD><TD> * </TD></TR><TR><TD CLASS="l">42</TD><TD> * @author dcarver</TD></TR><TR><TD CLASS="l">43</TD><TD> *</TD></TR><TR><TD CLASS="l">44</TD><TD> */</TD></TR><TR CLASS="c"><TD CLASS="l">45</TD><TD>public class SelectAttributeContentAssist extends AbstractXSLContentAssistRequest {</TD></TR><TR><TD CLASS="l">46</TD><TD>        </TD></TR><TR><TD CLASS="l">47</TD><TD>        private static final String XPATH_GLOBAL_VARIABLES = &#34;/xsl:stylesheet/xsl:variable&#34;; //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">48</TD><TD> </TD></TR><TR><TD CLASS="l">49</TD><TD>        /**</TD></TR><TR><TD CLASS="l">50</TD><TD>         * Retrieve all global parameters in the stylesheet.</TD></TR><TR><TD CLASS="l">51</TD><TD>         */</TD></TR><TR><TD CLASS="l">52</TD><TD>        private static final String XPATH_GLOBAL_PARAMS = &#34;/xsl:stylesheet/xsl:param&#34;; //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">53</TD><TD> </TD></TR><TR><TD CLASS="l">54</TD><TD>        /**</TD></TR><TR><TD CLASS="l">55</TD><TD>         * Limit selection of variables to those that are in the local scope.</TD></TR><TR><TD CLASS="l">56</TD><TD>         */</TD></TR><TR><TD CLASS="l">57</TD><TD>        private static final String XPATH_LOCAL_VARIABLES = &#34;ancestor::xsl:template/descendant::xsl:variable&#34;; //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">58</TD><TD> </TD></TR><TR><TD CLASS="l">59</TD><TD>        /**</TD></TR><TR><TD CLASS="l">60</TD><TD>         * Limit selection of params to those that are in the local scope.</TD></TR><TR><TD CLASS="l">61</TD><TD>         */</TD></TR><TR><TD CLASS="l"><A NAME="0">62</A></TD><TD>        private static final String XPATH_LOCAL_PARAMS = &#34;ancestor::xsl:template/descendant::xsl:param&#34;; //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">63</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">64</TD><TD>        private XPathTemplateCompletionProcessor fTemplateProcessor = null;</TD></TR><TR CLASS="c"><TD CLASS="l">65</TD><TD>        private List&lt;String&gt; fTemplateContexts = new ArrayList&lt;String&gt;();</TD></TR><TR CLASS="c"><TD CLASS="l">66</TD><TD>        private static final byte[] XPATH_LOCK = new byte[0];</TD></TR><TR><TD CLASS="l">67</TD><TD> </TD></TR><TR><TD CLASS="l">68</TD><TD>        /**</TD></TR><TR><TD CLASS="l">69</TD><TD>         * Handles Content Assistance requests for Select Attributes.  This is called an instantiated</TD></TR><TR><TD CLASS="l">70</TD><TD>         * through the use of the computeProposals method from the XSLContentAssistProcessor.  It will</TD></TR><TR><TD CLASS="l">71</TD><TD>         * calculate the available proposals that are available for the XSL select attribute.</TD></TR><TR><TD CLASS="l">72</TD><TD>         * </TD></TR><TR><TD CLASS="l">73</TD><TD>         * @param node</TD></TR><TR><TD CLASS="l">74</TD><TD>         * @param documentRegion</TD></TR><TR><TD CLASS="l">75</TD><TD>         * @param completionRegion</TD></TR><TR><TD CLASS="l">76</TD><TD>         * @param begin</TD></TR><TR><TD CLASS="l">77</TD><TD>         * @param length</TD></TR><TR><TD CLASS="l">78</TD><TD>         * @param filter</TD></TR><TR><TD CLASS="l">79</TD><TD>         * @param textViewer</TD></TR><TR><TD CLASS="l">80</TD><TD>         */</TD></TR><TR><TD CLASS="l"><A NAME="5">81</A></TD><TD>        public SelectAttributeContentAssist(Node node,</TD></TR><TR><TD CLASS="l">82</TD><TD>                        IStructuredDocumentRegion documentRegion,</TD></TR><TR><TD CLASS="l">83</TD><TD>                        ITextRegion completionRegion, int begin, int length, String filter,</TD></TR><TR><TD CLASS="l">84</TD><TD>                        ITextViewer textViewer) {</TD></TR><TR CLASS="c"><TD CLASS="l">85</TD><TD>                super(node, documentRegion, completionRegion, begin, length, filter, textViewer);</TD></TR><TR><TD CLASS="l">86</TD><TD>                // TODO Auto-generated constructor stub</TD></TR><TR CLASS="c"><TD CLASS="l">87</TD><TD>        }</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>         * (non-Javadoc)</TD></TR><TR><TD CLASS="l"><A NAME="d">92</A></TD><TD>         * @see org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest#getCompletionProposals()</TD></TR><TR><TD CLASS="l">93</TD><TD>         */</TD></TR><TR><TD CLASS="l">94</TD><TD>        @Override</TD></TR><TR><TD CLASS="l">95</TD><TD>        public ArrayList&lt;ICompletionProposal&gt; getCompletionProposals() {</TD></TR><TR CLASS="c"><TD CLASS="l">96</TD><TD>                proposals.clear();</TD></TR><TR><TD CLASS="l">97</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">98</TD><TD>                adjustXPathStart();</TD></TR><TR><TD CLASS="l">99</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">100</TD><TD>                int offset = getReplacementBeginPosition();</TD></TR><TR CLASS="c"><TD CLASS="l">101</TD><TD>                IDOMAttr attrNode = getAttribute(&#34;select&#34;);</TD></TR><TR><TD CLASS="l">102</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">103</TD><TD>                this.matchString = extractXPathMatchString(attrNode, getRegion(), getReplacementBeginPosition());</TD></TR><TR><TD CLASS="l">104</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">105</TD><TD>            addSelectProposals((Element)getNode().getParentNode(), offset);</TD></TR><TR><TD CLASS="l">106</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">107</TD><TD>                return  getAllCompletionProposals();</TD></TR><TR><TD CLASS="l"><A NAME="c">108</A></TD><TD>    }</TD></TR><TR><TD CLASS="l">109</TD><TD> </TD></TR><TR><TD CLASS="l">110</TD><TD> </TD></TR><TR><TD CLASS="l">111</TD><TD>        private IDOMAttr getAttribute(String attrName) {</TD></TR><TR CLASS="c"><TD CLASS="l">112</TD><TD>                return (IDOMAttr)((IDOMElement)getNode()).getAttributeNode(attrName);</TD></TR><TR><TD CLASS="l">113</TD><TD>        }</TD></TR><TR><TD CLASS="l">114</TD><TD>        </TD></TR><TR><TD CLASS="l">115</TD><TD>        </TD></TR><TR><TD CLASS="l">116</TD><TD> </TD></TR><TR><TD CLASS="l">117</TD><TD>        /**</TD></TR><TR><TD CLASS="l">118</TD><TD>         *  This needs to setup the content assistance correctly. Here is what needs to happen:</TD></TR><TR><TD CLASS="l">119</TD><TD>         *  1. Adjust the matchString (This should have been calculated earlier) </TD></TR><TR><TD CLASS="l"><A NAME="3">120</A></TD><TD>         *  2. Get the current tokens offset position..this will be the starting offset.</TD></TR><TR><TD CLASS="l">121</TD><TD>         *  3. Get the replacement length...this is the difference between the token offset and the next token or end of the string</TD></TR><TR><TD CLASS="l">122</TD><TD>         */</TD></TR><TR><TD CLASS="l">123</TD><TD>        protected void adjustXPathStart() {</TD></TR><TR CLASS="c"><TD CLASS="l">124</TD><TD>            IDOMElement elem = (IDOMElement)getNode();</TD></TR><TR CLASS="c"><TD CLASS="l">125</TD><TD>            IDOMAttr xpathNode = (IDOMAttr)elem.getAttributeNode(&#34;select&#34;);</TD></TR><TR CLASS="c"><TD CLASS="l">126</TD><TD>            if (xpathNode == null) {</TD></TR><TR CLASS="z"><TD CLASS="l">127</TD><TD>                    return;</TD></TR><TR><TD CLASS="l">128</TD><TD>            }</TD></TR><TR><TD CLASS="l">129</TD><TD>            </TD></TR><TR CLASS="c"><TD CLASS="l">130</TD><TD>                String xpathString = xpathNode.getValue();</TD></TR><TR CLASS="c"><TD CLASS="l">131</TD><TD>                if (xpathString.length() == 0) {</TD></TR><TR CLASS="c"><TD CLASS="l">132</TD><TD>                        return;</TD></TR><TR><TD CLASS="l">133</TD><TD>                }</TD></TR><TR><TD CLASS="l">134</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">135</TD><TD>                int startOffset = xpathNode.getValueRegionStartOffset();</TD></TR><TR CLASS="c"><TD CLASS="l">136</TD><TD>                int tokenOffset = getReplacementBeginPosition() - xpathNode.getValueRegionStartOffset();</TD></TR><TR CLASS="c"><TD CLASS="l">137</TD><TD>                int tokenPosition = getXPathSeperatorPos(tokenOffset - 1, xpathString);</TD></TR><TR CLASS="c"><TD CLASS="l">138</TD><TD>                int newStartOffset = startOffset + tokenPosition;</TD></TR><TR><TD CLASS="l">139</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l"><A NAME="b">140</A></TD><TD>                replacementLength = getReplacementBeginPosition() - startOffset;</TD></TR><TR CLASS="c"><TD CLASS="l">141</TD><TD>        }</TD></TR><TR><TD CLASS="l">142</TD><TD>                </TD></TR><TR><TD CLASS="l">143</TD><TD>        protected String extractXPathMatchString(IDOMAttr node, ITextRegion aRegion, int offset) {</TD></TR><TR CLASS="c"><TD CLASS="l">144</TD><TD>                if (node == null || node.getValue().length() == 0)        return &#34;&#34;;</TD></TR><TR><TD CLASS="l">145</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">146</TD><TD>                if (matchString.length() &lt; 1) {</TD></TR><TR CLASS="c"><TD CLASS="l">147</TD><TD>                        return matchString;</TD></TR><TR><TD CLASS="l">148</TD><TD>                }</TD></TR><TR><TD CLASS="l">149</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">150</TD><TD>                int column = offset - node.getValueRegionStartOffset() - 1;</TD></TR><TR CLASS="c"><TD CLASS="l">151</TD><TD>                String nodeValue = node.getValue();</TD></TR><TR><TD CLASS="l">152</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">153</TD><TD>                int seperatorPos = getXPathSeperatorPos(column, nodeValue);</TD></TR><TR><TD CLASS="l">154</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">155</TD><TD>                if (seperatorPos &gt;= column) {</TD></TR><TR CLASS="c"><TD CLASS="l">156</TD><TD>                        return &#34;&#34;;</TD></TR><TR><TD CLASS="l">157</TD><TD>                }</TD></TR><TR><TD CLASS="l">158</TD><TD>                                </TD></TR><TR CLASS="c"><TD CLASS="l">159</TD><TD>                return node.getValue().substring(seperatorPos, column);</TD></TR><TR><TD CLASS="l"><A NAME="2">160</A></TD><TD>        }</TD></TR><TR><TD CLASS="l">161</TD><TD> </TD></TR><TR><TD CLASS="l">162</TD><TD> </TD></TR><TR><TD CLASS="l">163</TD><TD>        protected int getXPathSeperatorPos(int column, String nodeValue) {</TD></TR><TR CLASS="c"><TD CLASS="l">164</TD><TD>                char [] keyTokens = { '/', '[', ']', '(', ')', ',', ' '};</TD></TR><TR><TD CLASS="l">165</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">166</TD><TD>                int seperatorPos = 0;</TD></TR><TR><TD CLASS="l">167</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">168</TD><TD>                String potentialMatchString = nodeValue.substring(0, column);</TD></TR><TR><TD CLASS="l">169</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">170</TD><TD>                for (int cnt = 0; cnt &lt; keyTokens.length; cnt++) {</TD></TR><TR CLASS="c"><TD CLASS="l">171</TD><TD>                        int keyPos = potentialMatchString.lastIndexOf(keyTokens[cnt]);</TD></TR><TR CLASS="c"><TD CLASS="l">172</TD><TD>                        if (keyPos &gt;= 0 &amp;&amp; keyPos &lt;= column - 1) {</TD></TR><TR CLASS="c"><TD CLASS="l">173</TD><TD>                                seperatorPos = keyPos + 1;</TD></TR><TR><TD CLASS="l">174</TD><TD>                        }</TD></TR><TR><TD CLASS="l">175</TD><TD>                }</TD></TR><TR><TD CLASS="l">176</TD><TD>                </TD></TR><TR CLASS="c"><TD CLASS="l">177</TD><TD>                int axisPos = nodeValue.indexOf(&#34;::&#34;);</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="58% line coverage (7 out of 12 instructions)">178</TD><TD TITLE="58% line coverage (7 out of 12 instructions)">                if (axisPos &gt; seperatorPos &amp;&amp; axisPos &lt;= column -1) {</TD></TR><TR CLASS="z"><TD CLASS="l">179</TD><TD>                        seperatorPos = axisPos + 1;</TD></TR><TR><TD CLASS="l">180</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">181</TD><TD>                return seperatorPos;</TD></TR><TR><TD CLASS="l"><A NAME="9">182</A></TD><TD>        }</TD></TR><TR><TD CLASS="l">183</TD><TD> </TD></TR><TR><TD CLASS="l">184</TD><TD> </TD></TR><TR><TD CLASS="l">185</TD><TD>        protected void addSelectProposals(Element rootElement, int offset) {</TD></TR><TR CLASS="c"><TD CLASS="l">186</TD><TD>                        addContentModelProposals(offset);</TD></TR><TR CLASS="c"><TD CLASS="l">187</TD><TD>                        addGlobalProposals(rootElement, offset);</TD></TR><TR CLASS="c"><TD CLASS="l">188</TD><TD>                        addLocalProposals(getNode(), offset);</TD></TR><TR CLASS="c"><TD CLASS="l">189</TD><TD>                        addTemplates(TemplateContextTypeIdsXPath.AXIS, offset);</TD></TR><TR CLASS="c"><TD CLASS="l">190</TD><TD>                        addTemplates(TemplateContextTypeIdsXPath.XPATH, offset);</TD></TR><TR CLASS="c"><TD CLASS="l">191</TD><TD>                        addTemplates(TemplateContextTypeIdsXPath.CUSTOM, offset);</TD></TR><TR CLASS="c"><TD CLASS="l">192</TD><TD>                        addTemplates(TemplateContextTypeIdsXPath.OPERATOR, offset);</TD></TR><TR CLASS="c"><TD CLASS="l">193</TD><TD>        }</TD></TR><TR><TD CLASS="l"><A NAME="6">194</A></TD><TD> </TD></TR><TR><TD CLASS="l">195</TD><TD> </TD></TR><TR><TD CLASS="l">196</TD><TD>        private void addContentModelProposals(int offset) {</TD></TR><TR CLASS="c"><TD CLASS="l">197</TD><TD>                AbstractXMLElementContentAssistRequest xpathXMLproposals =</TD></TR><TR CLASS="c"><TD CLASS="l">198</TD><TD>                        new XPathElementContentAssist(node, documentRegion, getRegion(), offset - getMatchString().length(), getReplacementLength(), getMatchString(), textViewer);</TD></TR><TR CLASS="c"><TD CLASS="l">199</TD><TD>                ArrayList&lt;ICompletionProposal&gt; xmlProposals = xpathXMLproposals.getCompletionProposals();</TD></TR><TR CLASS="c"><TD CLASS="l">200</TD><TD>                proposals.addAll(xmlProposals);</TD></TR><TR CLASS="c"><TD CLASS="l">201</TD><TD>        }</TD></TR><TR><TD CLASS="l">202</TD><TD>        </TD></TR><TR><TD CLASS="l">203</TD><TD>        </TD></TR><TR><TD CLASS="l">204</TD><TD>        </TD></TR><TR><TD CLASS="l">205</TD><TD>        /**</TD></TR><TR><TD CLASS="l">206</TD><TD>         * Adds XPath related templates to the list of proposals</TD></TR><TR><TD CLASS="l">207</TD><TD>         * </TD></TR><TR><TD CLASS="l">208</TD><TD>         * @param contentAssistRequest</TD></TR><TR><TD CLASS="l">209</TD><TD>         * @param context</TD></TR><TR><TD CLASS="l"><A NAME="a">210</A></TD><TD>         * @param startOffset</TD></TR><TR><TD CLASS="l">211</TD><TD>         */</TD></TR><TR><TD CLASS="l">212</TD><TD>        protected void addTemplates(String context, int startOffset) {</TD></TR><TR><TD CLASS="l">213</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">214</TD><TD>                if (!fTemplateContexts.contains(context)) {</TD></TR><TR CLASS="c"><TD CLASS="l">215</TD><TD>                        fTemplateContexts.add(context);</TD></TR><TR><TD CLASS="l">216</TD><TD>                        </TD></TR><TR CLASS="c"><TD CLASS="l">217</TD><TD>                        if (getTemplateCompletionProcessor() != null) {</TD></TR><TR CLASS="c"><TD CLASS="l">218</TD><TD>                                getTemplateCompletionProcessor().setContextType(context);</TD></TR><TR CLASS="c"><TD CLASS="l">219</TD><TD>                                ICompletionProposal[] proposals = getTemplateCompletionProcessor()</TD></TR><TR CLASS="c"><TD CLASS="l">220</TD><TD>                                                .computeCompletionProposals(textViewer, startOffset);</TD></TR><TR CLASS="c"><TD CLASS="l">221</TD><TD>                                for (int i = 0; i &lt; proposals.length; ++i) {</TD></TR><TR CLASS="c"><TD CLASS="l">222</TD><TD>                                        ICompletionProposal proposal = proposals[i];</TD></TR><TR CLASS="c"><TD CLASS="l">223</TD><TD>                                        if (matchString.length() &gt; 0) {</TD></TR><TR CLASS="c"><TD CLASS="l">224</TD><TD>                                                if (proposal.getDisplayString().startsWith(matchString) ) {</TD></TR><TR CLASS="c"><TD CLASS="l">225</TD><TD>                                                        addProposal(proposals[i]);</TD></TR><TR><TD CLASS="l">226</TD><TD>                                                }</TD></TR><TR><TD CLASS="l">227</TD><TD>                                        } else {</TD></TR><TR CLASS="c"><TD CLASS="l">228</TD><TD>                                                addProposal(proposals[i]);</TD></TR><TR><TD CLASS="l">229</TD><TD>                                        }</TD></TR><TR><TD CLASS="l">230</TD><TD>                                }</TD></TR><TR><TD CLASS="l">231</TD><TD>                        }</TD></TR><TR><TD CLASS="l">232</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">233</TD><TD>        }</TD></TR><TR><TD CLASS="l"><A NAME="8">234</A></TD><TD>        </TD></TR><TR><TD CLASS="l">235</TD><TD> </TD></TR><TR><TD CLASS="l">236</TD><TD> </TD></TR><TR><TD CLASS="l">237</TD><TD>        private void addLocalProposals(Node xpathnode, int offset) {</TD></TR><TR CLASS="c"><TD CLASS="l">238</TD><TD>                addVariablesProposals(XPATH_LOCAL_VARIABLES, xpathnode, offset);</TD></TR><TR CLASS="c"><TD CLASS="l"><A NAME="7">239</A></TD><TD>                addVariablesProposals(XPATH_LOCAL_PARAMS, xpathnode, offset);</TD></TR><TR CLASS="c"><TD CLASS="l">240</TD><TD>        }</TD></TR><TR><TD CLASS="l">241</TD><TD> </TD></TR><TR><TD CLASS="l">242</TD><TD>        private void addGlobalProposals(Node xpathnode, int offset) {</TD></TR><TR CLASS="c"><TD CLASS="l">243</TD><TD>                addVariablesProposals(XPATH_GLOBAL_VARIABLES, xpathnode, offset);</TD></TR><TR CLASS="c"><TD CLASS="l">244</TD><TD>                addVariablesProposals(XPATH_GLOBAL_PARAMS, xpathnode, offset);</TD></TR><TR CLASS="c"><TD CLASS="l">245</TD><TD>        }</TD></TR><TR><TD CLASS="l">246</TD><TD> </TD></TR><TR><TD CLASS="l">247</TD><TD>        /**</TD></TR><TR><TD CLASS="l">248</TD><TD>         * Adds Parameter and Variables as proposals. This</TD></TR><TR><TD CLASS="l">249</TD><TD>         * information is selected based on the XPath statement that is sent to it</TD></TR><TR><TD CLASS="l">250</TD><TD>         * and the input Node passed. It uses a custom composer to XSL Variable</TD></TR><TR><TD CLASS="l">251</TD><TD>         * proposal.</TD></TR><TR><TD CLASS="l">252</TD><TD>         * </TD></TR><TR><TD CLASS="l">253</TD><TD>         * @param xpath</TD></TR><TR><TD CLASS="l">254</TD><TD>         * @param xpathnode</TD></TR><TR><TD CLASS="l"><A NAME="1">255</A></TD><TD>         * @param contentAssistRequest</TD></TR><TR><TD CLASS="l">256</TD><TD>         * @param offset</TD></TR><TR><TD CLASS="l">257</TD><TD>         */</TD></TR><TR><TD CLASS="l">258</TD><TD>        private void addVariablesProposals(String xpath, Node xpathnode, int offset) {</TD></TR><TR CLASS="p"><TD CLASS="l" TITLE="87% line coverage (20 out of 23 instructions)">259</TD><TD TITLE="87% line coverage (20 out of 23 instructions)">                synchronized (XPATH_LOCK) {</TD></TR><TR><TD CLASS="l">260</TD><TD>                        try {</TD></TR><TR CLASS="c"><TD CLASS="l">261</TD><TD>                                NodeList nodes = XSLTXPathHelper.selectNodeList(xpathnode, xpath);</TD></TR><TR CLASS="c"><TD CLASS="l">262</TD><TD>                                int startLength = getCursorPosition() - offset;</TD></TR><TR><TD CLASS="l">263</TD><TD> </TD></TR><TR CLASS="c"><TD CLASS="l">264</TD><TD>                                if (hasNodes(nodes)) {</TD></TR><TR CLASS="c"><TD CLASS="l">265</TD><TD>                                        for (int nodecnt = 0; nodecnt &lt; nodes.getLength(); nodecnt++) {</TD></TR><TR CLASS="c"><TD CLASS="l">266</TD><TD>                                                Node node = nodes.item(nodecnt);</TD></TR><TR><TD CLASS="l">267</TD><TD>                                                </TD></TR><TR CLASS="c"><TD CLASS="l">268</TD><TD>                                                String variableName = &#34;$&#34; + node.getAttributes().getNamedItem(&#34;name&#34;).getNodeValue(); //$NON-NLS-1$ //$NON-NLS-2$</TD></TR><TR CLASS="c"><TD CLASS="l">269</TD><TD>                                                CustomCompletionProposal proposal = new CustomCompletionProposal(</TD></TR><TR CLASS="c"><TD CLASS="l">270</TD><TD>                                                                variableName, offset, 0, startLength + variableName.length(),</TD></TR><TR CLASS="c"><TD CLASS="l">271</TD><TD>                                                                XSLPluginImageHelper.getInstance().getImage(XSLPluginImages.IMG_VARIABLES),</TD></TR><TR CLASS="c"><TD CLASS="l">272</TD><TD>                                                                variableName, null, null, 0);</TD></TR><TR><TD CLASS="l">273</TD><TD>                                                </TD></TR><TR CLASS="c"><TD CLASS="l">274</TD><TD>                                                if (matchString.length() &gt; 0) {</TD></TR><TR CLASS="c"><TD CLASS="l">275</TD><TD>                                                        if (proposal.getDisplayString().startsWith(matchString)) {</TD></TR><TR CLASS="z"><TD CLASS="l">276</TD><TD>                                                                addProposal(proposal);</TD></TR><TR><TD CLASS="l">277</TD><TD>                                                        }</TD></TR><TR><TD CLASS="l">278</TD><TD>                                                } else {</TD></TR><TR CLASS="c"><TD CLASS="l">279</TD><TD>                                                        addProposal(proposal);</TD></TR><TR><TD CLASS="l">280</TD><TD>                                                }</TD></TR><TR><TD CLASS="l">281</TD><TD>                                        }</TD></TR><TR><TD CLASS="l">282</TD><TD>                                }</TD></TR><TR><TD CLASS="l">283</TD><TD> </TD></TR><TR CLASS="z"><TD CLASS="l">284</TD><TD>                        } catch (TransformerException ex) {</TD></TR><TR CLASS="z"><TD CLASS="l">285</TD><TD>                                XSLUIPlugin.log(ex);</TD></TR><TR><TD CLASS="l">286</TD><TD>                        }</TD></TR><TR><TD CLASS="l"><A NAME="e">287</A></TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">288</TD><TD>        }</TD></TR><TR><TD CLASS="l">289</TD><TD> </TD></TR><TR><TD CLASS="l">290</TD><TD>        private XPathTemplateCompletionProcessor getTemplateCompletionProcessor() {</TD></TR><TR CLASS="c"><TD CLASS="l">291</TD><TD>                if (fTemplateProcessor == null) {</TD></TR><TR CLASS="c"><TD CLASS="l">292</TD><TD>                        fTemplateProcessor = new XPathTemplateCompletionProcessor();</TD></TR><TR><TD CLASS="l">293</TD><TD>                }</TD></TR><TR CLASS="c"><TD CLASS="l">294</TD><TD>                return fTemplateProcessor;</TD></TR><TR><TD CLASS="l">295</TD><TD>        }</TD></TR><TR><TD CLASS="l">296</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="cb.html">org.eclipse.wst.xsl.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>