blob: 131bdcd707485608c1bc004e6fffc7f4725dbf96 [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="8c.html">org.eclipse.wst.xml.core.internal.parser.regions</A>]</TD></TR></TABLE><H2>COVERAGE SUMMARY FOR SOURCE FILE [<SPAN CLASS="in">RegionUpdateRule.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>RegionUpdateRule.java</TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/8)</TD><TD CLASS="h">0%   (0/207)</TD><TD CLASS="h">0%   (0/54)</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">RegionUpdateRule</A></TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/8)</TD><TD CLASS="h">0%   (0/207)</TD><TD CLASS="h">0%   (0/54)</TD></TR><TR><TD CLASS="f"><A HREF="#0">RegionUpdateRule (): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/3)</TD><TD CLASS="h">0%   (0/1)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2">allLetterOrDigit (String): boolean</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/20)</TD><TD CLASS="h">0%   (0/6)</TD></TR><TR><TD CLASS="f"><A HREF="#3">allWhiteSpace (String): boolean</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/20)</TD><TD CLASS="h">0%   (0/6)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#4">canHandleAsLetterOrDigit (ITextRegion, IStructuredDocumentRegion, String, int...</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/22)</TD><TD CLASS="h">0%   (0/6)</TD></TR><TR><TD CLASS="f"><A HREF="#5">canHandleAsLetterOrDigit (ITextRegion, String, int, int): boolean</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/13)</TD><TD CLASS="h">0%   (0/4)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#6">canHandleAsWhiteSpace (ITextRegion, IStructuredDocumentRegion, String, int, i...</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/30)</TD><TD CLASS="h">0%   (0/9)</TD></TR><TR><TD CLASS="f"><A HREF="#7">canHandleAsWhiteSpace (ITextRegion, String, int, int): boolean</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/21)</TD><TD CLASS="h">0%   (0/7)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#8">updateModel (ITextRegion, Object, IStructuredDocumentRegion, String, int, int...</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/78)</TD><TD CLASS="h">0%   (0/15)</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) 2001, 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.xml.core.internal.parser.regions;</TD></TR><TR><TD CLASS="l">14</TD><TD> </TD></TR><TR><TD CLASS="l">15</TD><TD>import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;</TD></TR><TR><TD CLASS="l">16</TD><TD>import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;</TD></TR><TR><TD CLASS="l">17</TD><TD>import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;</TD></TR><TR><TD CLASS="l">18</TD><TD>import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;</TD></TR><TR><TD CLASS="l">19</TD><TD>import org.eclipse.wst.sse.core.internal.util.Debug;</TD></TR><TR><TD CLASS="l">20</TD><TD>import org.eclipse.wst.sse.core.internal.util.Utilities;</TD></TR><TR><TD CLASS="l">21</TD><TD> </TD></TR><TR><TD CLASS="l">22</TD><TD> </TD></TR><TR><TD CLASS="l">23</TD><TD>/**</TD></TR><TR><TD CLASS="l">24</TD><TD> * </TD></TR><TR><TD CLASS="l">25</TD><TD> * This is a utility class to centralize 'region' update. Note: care must be</TD></TR><TR><TD CLASS="l"><A NAME="0">26</A></TD><TD> * taken that is is not used for StructuredDocumentRegions, or container</TD></TR><TR><TD CLASS="l">27</TD><TD> * regions, its only for &#34;token regions&#34;</TD></TR><TR><TD CLASS="l">28</TD><TD> *  </TD></TR><TR><TD CLASS="l"><A NAME="2">29</A></TD><TD> */</TD></TR><TR CLASS="z"><TD CLASS="l">30</TD><TD>public class RegionUpdateRule {</TD></TR><TR><TD CLASS="l">31</TD><TD> </TD></TR><TR><TD CLASS="l">32</TD><TD>        static public boolean allLetterOrDigit(String changes) {</TD></TR><TR CLASS="z"><TD CLASS="l">33</TD><TD>                boolean result = true;</TD></TR><TR CLASS="z"><TD CLASS="l">34</TD><TD>                for (int i = 0; i &lt; changes.length(); i++) {</TD></TR><TR><TD CLASS="l">35</TD><TD>                        // TO_DO_FUTURE: check that a Java Letter or Digit is</TD></TR><TR><TD CLASS="l">36</TD><TD>                        // the same thing as an XML letter or digit</TD></TR><TR CLASS="z"><TD CLASS="l">37</TD><TD>                        if (!(Character.isLetterOrDigit(changes.charAt(i)))) {</TD></TR><TR CLASS="z"><TD CLASS="l">38</TD><TD>                                result = false;</TD></TR><TR CLASS="z"><TD CLASS="l">39</TD><TD>                                break;</TD></TR><TR><TD CLASS="l">40</TD><TD>                        }</TD></TR><TR><TD CLASS="l">41</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l"><A NAME="3">42</A></TD><TD>                return result;</TD></TR><TR><TD CLASS="l">43</TD><TD>        }</TD></TR><TR><TD CLASS="l">44</TD><TD> </TD></TR><TR><TD CLASS="l">45</TD><TD>        static public boolean allWhiteSpace(String changes) {</TD></TR><TR CLASS="z"><TD CLASS="l">46</TD><TD>                boolean result = true;</TD></TR><TR CLASS="z"><TD CLASS="l">47</TD><TD>                for (int i = 0; i &lt; changes.length(); i++) {</TD></TR><TR CLASS="z"><TD CLASS="l">48</TD><TD>                        if (!Character.isWhitespace(changes.charAt(i))) {</TD></TR><TR CLASS="z"><TD CLASS="l">49</TD><TD>                                result = false;</TD></TR><TR CLASS="z"><TD CLASS="l">50</TD><TD>                                break;</TD></TR><TR><TD CLASS="l">51</TD><TD>                        }</TD></TR><TR><TD CLASS="l">52</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l"><A NAME="4">53</A></TD><TD>                return result;</TD></TR><TR><TD CLASS="l">54</TD><TD>        }</TD></TR><TR><TD CLASS="l">55</TD><TD> </TD></TR><TR><TD CLASS="l">56</TD><TD>        static public boolean canHandleAsLetterOrDigit(ITextRegion region, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {</TD></TR><TR CLASS="z"><TD CLASS="l">57</TD><TD>                if (parent == null)</TD></TR><TR CLASS="z"><TD CLASS="l">58</TD><TD>                        return canHandleAsLetterOrDigit(region, changes, requestStart, lengthToReplace);</TD></TR><TR CLASS="z"><TD CLASS="l">59</TD><TD>                boolean result = false;</TD></TR><TR><TD CLASS="l">60</TD><TD>                // Make sure we are in a non-white space area</TD></TR><TR CLASS="z"><TD CLASS="l">61</TD><TD>                if ((requestStart &lt;= (parent.getTextEndOffset(region))) &amp;&amp; (allLetterOrDigit(changes))) {</TD></TR><TR CLASS="z"><TD CLASS="l">62</TD><TD>                        result = true;</TD></TR><TR><TD CLASS="l">63</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l"><A NAME="5">64</A></TD><TD>                return result;</TD></TR><TR><TD CLASS="l">65</TD><TD>        }</TD></TR><TR><TD CLASS="l">66</TD><TD> </TD></TR><TR><TD CLASS="l">67</TD><TD>        static public boolean canHandleAsLetterOrDigit(ITextRegion region, String changes, int requestStart, int lengthToReplace) {</TD></TR><TR CLASS="z"><TD CLASS="l">68</TD><TD>                boolean result = false;</TD></TR><TR><TD CLASS="l">69</TD><TD>                // Make sure we are in a non-white space area</TD></TR><TR CLASS="z"><TD CLASS="l">70</TD><TD>                if ((requestStart &lt;= (region.getTextEnd())) &amp;&amp; (allLetterOrDigit(changes))) {</TD></TR><TR CLASS="z"><TD CLASS="l">71</TD><TD>                        result = true;</TD></TR><TR><TD CLASS="l">72</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">73</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">74</TD><TD>        }</TD></TR><TR><TD CLASS="l">75</TD><TD> </TD></TR><TR><TD CLASS="l"><A NAME="6">76</A></TD><TD>        static public boolean canHandleAsWhiteSpace(ITextRegion region, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {</TD></TR><TR><TD CLASS="l">77</TD><TD>                // we don't explect a null parent, but just in case!</TD></TR><TR><TD CLASS="l">78</TD><TD>                // (in which case, we must be dealing with regions that are</TD></TR><TR><TD CLASS="l">79</TD><TD>                // structuredDocumentRegions).</TD></TR><TR CLASS="z"><TD CLASS="l">80</TD><TD>                if (parent == null)</TD></TR><TR CLASS="z"><TD CLASS="l">81</TD><TD>                        return canHandleAsWhiteSpace(region, changes, requestStart, lengthToReplace);</TD></TR><TR CLASS="z"><TD CLASS="l">82</TD><TD>                boolean result = false;</TD></TR><TR><TD CLASS="l">83</TD><TD>                // if we are in the &#34;white space&#34; area of a region, then</TD></TR><TR><TD CLASS="l">84</TD><TD>                // we don't want to handle, a reparse is needed.</TD></TR><TR><TD CLASS="l">85</TD><TD>                // the white space region is consider anywhere that would</TD></TR><TR><TD CLASS="l">86</TD><TD>                // leave whitespace between this character and the text part.</TD></TR><TR><TD CLASS="l">87</TD><TD>                // and of course, we can insert whitespace in whitespace region</TD></TR><TR><TD CLASS="l">88</TD><TD>                //</TD></TR><TR><TD CLASS="l">89</TD><TD>                // if there is no whitespace in this region, no need to look further</TD></TR><TR CLASS="z"><TD CLASS="l">90</TD><TD>                if (region.getEnd() &gt; region.getTextEnd()) {</TD></TR><TR><TD CLASS="l">91</TD><TD>                        // no need to add one to end of text, as we used to, since we</TD></TR><TR><TD CLASS="l">92</TD><TD>                        // change definition of length to equate to offset plus one.</TD></TR><TR><TD CLASS="l">93</TD><TD>                        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=105866</TD></TR><TR><TD CLASS="l">94</TD><TD>                        // watch out for whitespace at end of text</TD></TR><TR CLASS="z"><TD CLASS="l">95</TD><TD>                        if (requestStart &gt;= parent.getTextEndOffset(region)) {</TD></TR><TR><TD CLASS="l">96</TD><TD>                                // ok, we are in the whitespace region, so we can't handle,</TD></TR><TR><TD CLASS="l">97</TD><TD>                                // unless</TD></TR><TR><TD CLASS="l">98</TD><TD>                                // we are just inserting whitespace.</TD></TR><TR CLASS="z"><TD CLASS="l">99</TD><TD>                                if (allWhiteSpace(changes)) {</TD></TR><TR CLASS="z"><TD CLASS="l">100</TD><TD>                                        result = true;</TD></TR><TR><TD CLASS="l">101</TD><TD>                                } else {</TD></TR><TR CLASS="z"><TD CLASS="l">102</TD><TD>                                        result = false;</TD></TR><TR><TD CLASS="l">103</TD><TD>                                }</TD></TR><TR><TD CLASS="l">104</TD><TD>                        }</TD></TR><TR><TD CLASS="l">105</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l"><A NAME="7">106</A></TD><TD>                return result;</TD></TR><TR><TD CLASS="l">107</TD><TD>        }</TD></TR><TR><TD CLASS="l">108</TD><TD> </TD></TR><TR><TD CLASS="l">109</TD><TD>        static public boolean canHandleAsWhiteSpace(ITextRegion region, String changes, int requestStart, int lengthToReplace) {</TD></TR><TR CLASS="z"><TD CLASS="l">110</TD><TD>                boolean result = false;</TD></TR><TR><TD CLASS="l">111</TD><TD>                // if we are in the &#34;white space&#34; area of a region, then</TD></TR><TR><TD CLASS="l">112</TD><TD>                // we don't want to handle, a reparse is needed.</TD></TR><TR><TD CLASS="l">113</TD><TD>                // the white space region is consider anywhere that would</TD></TR><TR><TD CLASS="l">114</TD><TD>                // leave whitespace between this character and the text part.</TD></TR><TR><TD CLASS="l">115</TD><TD>                // and of course, we can insert whitespace in whitespace region</TD></TR><TR><TD CLASS="l">116</TD><TD>                //</TD></TR><TR><TD CLASS="l">117</TD><TD>                // if there is no whitespace in this region, no need to look further</TD></TR><TR CLASS="z"><TD CLASS="l">118</TD><TD>                if (region.getEnd() &gt; region.getTextEnd()) {</TD></TR><TR><TD CLASS="l">119</TD><TD>                        // no need to add one to end of text, as we used to, since we</TD></TR><TR><TD CLASS="l">120</TD><TD>                        // change definition of length to equate to offset plus one.</TD></TR><TR><TD CLASS="l">121</TD><TD>                        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=105866</TD></TR><TR><TD CLASS="l">122</TD><TD>                        // watch out for whitespace at end of text</TD></TR><TR CLASS="z"><TD CLASS="l">123</TD><TD>                        if (requestStart &gt;= region.getTextEnd()) {</TD></TR><TR><TD CLASS="l">124</TD><TD>                                // ok, we are in the whitespace region, so we can't handle,</TD></TR><TR><TD CLASS="l">125</TD><TD>                                // unless</TD></TR><TR><TD CLASS="l">126</TD><TD>                                // we are just inserting whitespace.</TD></TR><TR CLASS="z"><TD CLASS="l">127</TD><TD>                                if (allWhiteSpace(changes)) {</TD></TR><TR CLASS="z"><TD CLASS="l">128</TD><TD>                                        result = true;</TD></TR><TR><TD CLASS="l">129</TD><TD>                                } else {</TD></TR><TR CLASS="z"><TD CLASS="l">130</TD><TD>                                        result = false;</TD></TR><TR><TD CLASS="l">131</TD><TD>                                }</TD></TR><TR><TD CLASS="l">132</TD><TD>                        }</TD></TR><TR><TD CLASS="l">133</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">134</TD><TD>                return result;</TD></TR><TR><TD CLASS="l"><A NAME="8">135</A></TD><TD>        }</TD></TR><TR><TD CLASS="l">136</TD><TD> </TD></TR><TR><TD CLASS="l">137</TD><TD>        // need an adjust text length API before this can be used</TD></TR><TR><TD CLASS="l">138</TD><TD>        static public StructuredDocumentEvent updateModel(ITextRegion region, Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {</TD></TR><TR CLASS="z"><TD CLASS="l">139</TD><TD>                RegionChangedEvent result = null;</TD></TR><TR><TD CLASS="l">140</TD><TD>                // if the region is an easy type (e.g. attribute value),</TD></TR><TR><TD CLASS="l">141</TD><TD>                // and the requested changes are all</TD></TR><TR><TD CLASS="l">142</TD><TD>                // alphanumeric, then make the change here locally.</TD></TR><TR><TD CLASS="l">143</TD><TD>                // (This can obviously be made more sophisticated as the need arises,</TD></TR><TR><TD CLASS="l">144</TD><TD>                // but should</TD></TR><TR><TD CLASS="l">145</TD><TD>                // always follow this pattern.)</TD></TR><TR><TD CLASS="l">146</TD><TD>                if (Debug.debugStructuredDocument) {</TD></TR><TR><TD CLASS="l">147</TD><TD>                        System.out.println(&#34;\t\tContextRegion::updateModel&#34;); //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">148</TD><TD>                        System.out.println(&#34;\t\t\tregion type is &#34; + region.getType()); //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">149</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">150</TD><TD>                boolean canHandle = false;</TD></TR><TR><TD CLASS="l">151</TD><TD>                // note: we'll always handle deletes from these</TD></TR><TR><TD CLASS="l">152</TD><TD>                // regions ... if its already that region,</TD></TR><TR><TD CLASS="l">153</TD><TD>                // deleting something from it won't change its</TD></TR><TR><TD CLASS="l">154</TD><TD>                // type. (remember, the calling program needs</TD></TR><TR><TD CLASS="l">155</TD><TD>                // to insure we are not called, if not all contained</TD></TR><TR><TD CLASS="l">156</TD><TD>                // on one region.</TD></TR><TR CLASS="z"><TD CLASS="l">157</TD><TD>                if ((changes == null) || (changes.length() == 0)) {</TD></TR><TR><TD CLASS="l">158</TD><TD>                        // delete case</TD></TR><TR><TD CLASS="l">159</TD><TD>                        // We can not do the quick delete, if</TD></TR><TR><TD CLASS="l">160</TD><TD>                        // if all the text in a region is to be deleted.</TD></TR><TR><TD CLASS="l">161</TD><TD>                        // Or, if the delete starts in the white space region.</TD></TR><TR><TD CLASS="l">162</TD><TD>                        // In these cases, a reparse is needed.</TD></TR><TR><TD CLASS="l">163</TD><TD>                        // Minor note, we use textEnd-start since it always</TD></TR><TR><TD CLASS="l">164</TD><TD>                        // less than or equal to end-start. This might</TD></TR><TR><TD CLASS="l">165</TD><TD>                        // cause us to miss a few cases we could have handled,</TD></TR><TR><TD CLASS="l">166</TD><TD>                        // but will prevent us from trying to handle funning cases</TD></TR><TR><TD CLASS="l">167</TD><TD>                        // involving whitespace.</TD></TR><TR CLASS="z"><TD CLASS="l">168</TD><TD>                        if ((region.getStart() &gt;= region.getTextEnd()) || (Math.abs(lengthToReplace) &gt;= region.getTextEnd() - region.getStart())) {</TD></TR><TR CLASS="z"><TD CLASS="l">169</TD><TD>                                canHandle = false;</TD></TR><TR><TD CLASS="l">170</TD><TD>                        } else {</TD></TR><TR CLASS="z"><TD CLASS="l">171</TD><TD>                                canHandle = true;</TD></TR><TR><TD CLASS="l">172</TD><TD>                        }</TD></TR><TR><TD CLASS="l">173</TD><TD>                } else {</TD></TR><TR CLASS="z"><TD CLASS="l">174</TD><TD>                        if ((RegionUpdateRule.canHandleAsWhiteSpace(region, parent, changes, requestStart, lengthToReplace)) || RegionUpdateRule.canHandleAsLetterOrDigit(region, parent, changes, requestStart, lengthToReplace)) {</TD></TR><TR CLASS="z"><TD CLASS="l">175</TD><TD>                                canHandle = true;</TD></TR><TR><TD CLASS="l">176</TD><TD>                        } else {</TD></TR><TR CLASS="z"><TD CLASS="l">177</TD><TD>                                canHandle = false;</TD></TR><TR><TD CLASS="l">178</TD><TD>                        }</TD></TR><TR><TD CLASS="l">179</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">180</TD><TD>                if (canHandle) {</TD></TR><TR><TD CLASS="l">181</TD><TD>                        // at this point, we still have the old region. We won't create a</TD></TR><TR><TD CLASS="l">182</TD><TD>                        // new instance, we'll just update the one we have, by changing</TD></TR><TR><TD CLASS="l">183</TD><TD>                        // its end postion,</TD></TR><TR><TD CLASS="l">184</TD><TD>                        // The parent flatnode, upon return, has responsibility</TD></TR><TR><TD CLASS="l">185</TD><TD>                        // for updating sibling regions.</TD></TR><TR><TD CLASS="l">186</TD><TD>                        // and in turn, the structuredDocument itself has responsibility</TD></TR><TR><TD CLASS="l">187</TD><TD>                        // for</TD></TR><TR><TD CLASS="l">188</TD><TD>                        // updating the text store and down stream flatnodes.</TD></TR><TR><TD CLASS="l">189</TD><TD>                        if (Debug.debugStructuredDocument) {</TD></TR><TR><TD CLASS="l">190</TD><TD>                                System.out.println(&#34;change handled by region&#34;); //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">191</TD><TD>                        }</TD></TR><TR CLASS="z"><TD CLASS="l">192</TD><TD>                        int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);</TD></TR><TR><TD CLASS="l">193</TD><TD>                        // Note: we adjust both end and text end, because for any change</TD></TR><TR><TD CLASS="l">194</TD><TD>                        // that is in only the trailing whitespace region, we should not</TD></TR><TR><TD CLASS="l">195</TD><TD>                        // do a quick change,</TD></TR><TR><TD CLASS="l">196</TD><TD>                        // so 'canHandle' should have been false for those case.</TD></TR><TR CLASS="z"><TD CLASS="l">197</TD><TD>                        region.adjustLength(lengthDifference);</TD></TR><TR><TD CLASS="l">198</TD><TD>                        // TO_DO_FUTURE: cache value of canHandleAsWhiteSpace from above</TD></TR><TR><TD CLASS="l">199</TD><TD>                        // If we are handling as whitespace, there is no need to increase</TD></TR><TR><TD CLASS="l">200</TD><TD>                        // the text length, only</TD></TR><TR><TD CLASS="l">201</TD><TD>                        // the total length is changing.</TD></TR><TR CLASS="z"><TD CLASS="l">202</TD><TD>                        if (!RegionUpdateRule.canHandleAsWhiteSpace(region, parent, changes, region.getStart(), lengthToReplace)) {</TD></TR><TR><TD CLASS="l">203</TD><TD>                                //                                region.adjustTextLength(lengthDifference);</TD></TR><TR><TD CLASS="l">204</TD><TD>                        }</TD></TR><TR CLASS="z"><TD CLASS="l">205</TD><TD>                        result = new RegionChangedEvent(parent.getParentDocument(), requester, parent, region, changes, requestStart, lengthToReplace);</TD></TR><TR><TD CLASS="l">206</TD><TD>                }</TD></TR><TR CLASS="z"><TD CLASS="l">207</TD><TD>                return result;</TD></TR><TR><TD CLASS="l">208</TD><TD>        }</TD></TR><TR><TD CLASS="l">209</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="8c.html">org.eclipse.wst.xml.core.internal.parser.regions</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>