blob: f6318e07e398d3249cdc5bcb0bca805527dc828c [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 Tue Jun 09 19:59:05 GMT 2009)</TH></TR><TR><TD CLASS="nv">[<A HREF="../xslUnitTestCoverage.html">all classes</A>][<A HREF="157.html">org.eclipse.wst.jsdt.internal.ui.actions</A>]</TD></TR></TABLE><H2>COVERAGE SUMMARY FOR SOURCE FILE [<SPAN CLASS="in">AddBlockCommentAction.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>AddBlockCommentAction.java</TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/7)</TD><TD CLASS="h">0%   (0/249)</TD><TD CLASS="h">0%   (0/49)</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">AddBlockCommentAction</A></TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/7)</TD><TD CLASS="h">0%   (0/249)</TD><TD CLASS="h">0%   (0/49)</TD></TR><TR><TD CLASS="f"><A HREF="#0">AddBlockCommentAction (ResourceBundle, String, ITextEditor): void</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/6)</TD><TD CLASS="h">0%   (0/2)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#2">handleFirstPartition (ITypedRegion, List, BlockCommentAction$Edit$EditFactory...</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/42)</TD><TD CLASS="h">0%   (0/8)</TD></TR><TR><TD CLASS="f"><A HREF="#3">handleInteriorPartition (ITypedRegion, List, BlockCommentAction$Edit$EditFact...</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/93)</TD><TD CLASS="h">0%   (0/19)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#4">handleLastPartition (ITypedRegion, List, BlockCommentAction$Edit$EditFactory,...</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/34)</TD><TD CLASS="h">0%   (0/6)</TD></TR><TR><TD CLASS="f"><A HREF="#5">isSpecialPartition (String): boolean</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/13)</TD><TD CLASS="h">0%   (0/3)</TD></TR><TR CLASS="o"><TD CLASS="f"><A HREF="#6">isValidSelection (ITextSelection): boolean</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/12)</TD><TD CLASS="h">0%   (0/1)</TD></TR><TR><TD CLASS="f"><A HREF="#7">runInternal (ITextSelection, IDocumentExtension3, BlockCommentAction$Edit$Edi...</A></TD><TD> </TD><TD CLASS="h">0%   (0/1)</TD><TD CLASS="h">0%   (0/49)</TD><TD CLASS="h">0%   (0/10)</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) 2000, 2008 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> *******************************************************************************/</TD></TR><TR><TD CLASS="l">11</TD><TD>package org.eclipse.wst.jsdt.internal.ui.actions;</TD></TR><TR><TD CLASS="l">12</TD><TD> </TD></TR><TR><TD CLASS="l">13</TD><TD>import java.util.LinkedList;</TD></TR><TR><TD CLASS="l">14</TD><TD>import java.util.List;</TD></TR><TR><TD CLASS="l">15</TD><TD>import java.util.ResourceBundle;</TD></TR><TR><TD CLASS="l">16</TD><TD> </TD></TR><TR><TD CLASS="l">17</TD><TD>import org.eclipse.core.runtime.Assert;</TD></TR><TR><TD CLASS="l">18</TD><TD>import org.eclipse.jface.text.BadLocationException;</TD></TR><TR><TD CLASS="l">19</TD><TD>import org.eclipse.jface.text.BadPartitioningException;</TD></TR><TR><TD CLASS="l">20</TD><TD>import org.eclipse.jface.text.IDocument;</TD></TR><TR><TD CLASS="l">21</TD><TD>import org.eclipse.jface.text.IDocumentExtension3;</TD></TR><TR><TD CLASS="l">22</TD><TD>import org.eclipse.jface.text.ITextSelection;</TD></TR><TR><TD CLASS="l">23</TD><TD>import org.eclipse.jface.text.ITypedRegion;</TD></TR><TR><TD CLASS="l">24</TD><TD>import org.eclipse.ui.texteditor.ITextEditor;</TD></TR><TR><TD CLASS="l">25</TD><TD>import org.eclipse.wst.jsdt.ui.text.IJavaScriptPartitions;</TD></TR><TR><TD CLASS="l">26</TD><TD> </TD></TR><TR><TD CLASS="l">27</TD><TD> </TD></TR><TR><TD CLASS="l">28</TD><TD>/**</TD></TR><TR><TD CLASS="l">29</TD><TD> * Action that encloses the editor's current selection with Java block comment terminators</TD></TR><TR><TD CLASS="l">30</TD><TD> * (&lt;code&gt;&amp;#47;&amp;#42;&lt;/code&gt; and &lt;code&gt;&amp;#42;&amp;#47;&lt;/code&gt;).</TD></TR><TR><TD CLASS="l">31</TD><TD> * </TD></TR><TR><TD CLASS="l">32</TD><TD> * </TD></TR><TR><TD CLASS="l">33</TD><TD> */</TD></TR><TR><TD CLASS="l">34</TD><TD>public class AddBlockCommentAction extends BlockCommentAction {</TD></TR><TR><TD CLASS="l">35</TD><TD> </TD></TR><TR><TD CLASS="l">36</TD><TD>        /**</TD></TR><TR><TD CLASS="l">37</TD><TD>         * Creates a new instance.</TD></TR><TR><TD CLASS="l">38</TD><TD>         * </TD></TR><TR><TD CLASS="l">39</TD><TD>         * @param bundle the resource bundle</TD></TR><TR><TD CLASS="l">40</TD><TD>         * @param prefix a prefix to be prepended to the various resource keys</TD></TR><TR><TD CLASS="l">41</TD><TD>         *   (described in &lt;code&gt;ResourceAction&lt;/code&gt; constructor), or </TD></TR><TR><TD CLASS="l"><A NAME="0">42</A></TD><TD>         *   &lt;code&gt;null&lt;/code&gt; if none</TD></TR><TR><TD CLASS="l">43</TD><TD>         * @param editor the text editor</TD></TR><TR><TD CLASS="l">44</TD><TD>         */</TD></TR><TR><TD CLASS="l">45</TD><TD>        public AddBlockCommentAction(ResourceBundle bundle, String prefix, ITextEditor editor) {</TD></TR><TR CLASS="z"><TD CLASS="l">46</TD><TD>                super(bundle, prefix, editor);</TD></TR><TR CLASS="z"><TD CLASS="l">47</TD><TD>        }</TD></TR><TR><TD CLASS="l">48</TD><TD>        </TD></TR><TR><TD CLASS="l"><A NAME="7">49</A></TD><TD>        /*</TD></TR><TR><TD CLASS="l">50</TD><TD>         * @see org.eclipse.wst.jsdt.internal.ui.actions.BlockCommentAction#runInternal(org.eclipse.jface.text.ITextSelection, org.eclipse.jface.text.IDocumentExtension3, org.eclipse.wst.jsdt.internal.ui.actions.BlockCommentAction.Edit.EditFactory)</TD></TR><TR><TD CLASS="l">51</TD><TD>         */</TD></TR><TR><TD CLASS="l">52</TD><TD>        protected void runInternal(ITextSelection selection, IDocumentExtension3 docExtension, Edit.EditFactory factory) throws BadLocationException, BadPartitioningException {</TD></TR><TR CLASS="z"><TD CLASS="l">53</TD><TD>                int selectionOffset= selection.getOffset();</TD></TR><TR CLASS="z"><TD CLASS="l">54</TD><TD>                int selectionEndOffset= selectionOffset + selection.getLength();</TD></TR><TR CLASS="z"><TD CLASS="l">55</TD><TD>                List edits= new LinkedList();</TD></TR><TR CLASS="z"><TD CLASS="l">56</TD><TD>                ITypedRegion partition= docExtension.getPartition(IJavaScriptPartitions.JAVA_PARTITIONING, selectionOffset, false);</TD></TR><TR><TD CLASS="l">57</TD><TD> </TD></TR><TR CLASS="z"><TD CLASS="l">58</TD><TD>                handleFirstPartition(partition, edits, factory, selectionOffset);</TD></TR><TR><TD CLASS="l">59</TD><TD> </TD></TR><TR CLASS="z"><TD CLASS="l">60</TD><TD>                while (partition.getOffset() + partition.getLength() &lt; selectionEndOffset) {</TD></TR><TR CLASS="z"><TD CLASS="l">61</TD><TD>                        partition= handleInteriorPartition(partition, edits, factory, docExtension);</TD></TR><TR><TD CLASS="l">62</TD><TD>                }</TD></TR><TR><TD CLASS="l">63</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">64</TD><TD>                handleLastPartition(partition, edits, factory, selectionEndOffset);</TD></TR><TR><TD CLASS="l">65</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">66</TD><TD>                executeEdits(edits);</TD></TR><TR CLASS="z"><TD CLASS="l">67</TD><TD>        }</TD></TR><TR><TD CLASS="l">68</TD><TD> </TD></TR><TR><TD CLASS="l">69</TD><TD>        /**</TD></TR><TR><TD CLASS="l">70</TD><TD>         * Handle the partition under the start offset of the selection.</TD></TR><TR><TD CLASS="l">71</TD><TD>         * </TD></TR><TR><TD CLASS="l">72</TD><TD>         * @param partition the partition under the start of the selection</TD></TR><TR><TD CLASS="l">73</TD><TD>         * @param edits the list of edits to later execute</TD></TR><TR><TD CLASS="l">74</TD><TD>         * @param factory the factory for edits</TD></TR><TR><TD CLASS="l">75</TD><TD>         * @param offset the start of the selection, which must lie inside</TD></TR><TR><TD CLASS="l"><A NAME="2">76</A></TD><TD>         *        &lt;code&gt;partition&lt;/code&gt;</TD></TR><TR><TD CLASS="l">77</TD><TD>         */</TD></TR><TR><TD CLASS="l">78</TD><TD>        private void handleFirstPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, int offset) throws BadLocationException {</TD></TR><TR><TD CLASS="l">79</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">80</TD><TD>                int partOffset= partition.getOffset();</TD></TR><TR CLASS="z"><TD CLASS="l">81</TD><TD>                String partType= partition.getType();</TD></TR><TR><TD CLASS="l">82</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">83</TD><TD>                Assert.isTrue(partOffset &lt;= offset, &#34;illegal partition&#34;); //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">84</TD><TD>                </TD></TR><TR><TD CLASS="l">85</TD><TD>                // first partition: mark start of comment</TD></TR><TR CLASS="z"><TD CLASS="l">86</TD><TD>                if (partType == IDocument.DEFAULT_CONTENT_TYPE) {</TD></TR><TR><TD CLASS="l">87</TD><TD>                        // Java code: right where selection starts</TD></TR><TR CLASS="z"><TD CLASS="l">88</TD><TD>                        edits.add(factory.createEdit(offset, 0, getCommentStart()));</TD></TR><TR CLASS="z"><TD CLASS="l">89</TD><TD>                } else if (isSpecialPartition(partType)) {</TD></TR><TR><TD CLASS="l">90</TD><TD>                        // special types: include the entire partition</TD></TR><TR CLASS="z"><TD CLASS="l">91</TD><TD>                        edits.add(factory.createEdit(partOffset, 0, getCommentStart()));</TD></TR><TR><TD CLASS="l">92</TD><TD>                }        // javadoc: no mark, will only start after comment</TD></TR><TR><TD CLASS="l">93</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">94</TD><TD>        }</TD></TR><TR><TD CLASS="l">95</TD><TD> </TD></TR><TR><TD CLASS="l">96</TD><TD>        /**</TD></TR><TR><TD CLASS="l">97</TD><TD>         * Handles partition boundaries within the selection. The end of the current</TD></TR><TR><TD CLASS="l">98</TD><TD>         * partition and the start of the next partition are examined for whether</TD></TR><TR><TD CLASS="l">99</TD><TD>         * they contain comment tokens that interfere with the created comment.</TD></TR><TR><TD CLASS="l">100</TD><TD>         * &lt;p&gt;</TD></TR><TR><TD CLASS="l">101</TD><TD>         * Comment tokens are removed from interior multi-line comments. Javadoc</TD></TR><TR><TD CLASS="l">102</TD><TD>         * comments are left as is; instead, multi-line comment tokens are inserted</TD></TR><TR><TD CLASS="l">103</TD><TD>         * before and after Javadoc partitions to ensure that the entire selected</TD></TR><TR><TD CLASS="l">104</TD><TD>         * area is commented.</TD></TR><TR><TD CLASS="l">105</TD><TD>         * &lt;/p&gt;</TD></TR><TR><TD CLASS="l">106</TD><TD>         * &lt;p&gt;</TD></TR><TR><TD CLASS="l">107</TD><TD>         * The next partition is returned.</TD></TR><TR><TD CLASS="l">108</TD><TD>         * &lt;/p&gt;</TD></TR><TR><TD CLASS="l">109</TD><TD>         * </TD></TR><TR><TD CLASS="l">110</TD><TD>         * @param partition the current partition</TD></TR><TR><TD CLASS="l">111</TD><TD>         * @param edits the list of edits to add to</TD></TR><TR><TD CLASS="l">112</TD><TD>         * @param factory the edit factory</TD></TR><TR><TD CLASS="l">113</TD><TD>         * @param docExtension the document to get the partitions from</TD></TR><TR><TD CLASS="l">114</TD><TD>         * @return the next partition after the current</TD></TR><TR><TD CLASS="l">115</TD><TD>         * @throws BadLocationException if accessing the document fails - this can</TD></TR><TR><TD CLASS="l">116</TD><TD>         *         only happen if the document gets modified concurrently</TD></TR><TR><TD CLASS="l">117</TD><TD>         * @throws BadPartitioningException if the document does not have a Java</TD></TR><TR><TD CLASS="l">118</TD><TD>         *         partitioning</TD></TR><TR><TD CLASS="l"><A NAME="3">119</A></TD><TD>         */</TD></TR><TR><TD CLASS="l">120</TD><TD>        private ITypedRegion handleInteriorPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, IDocumentExtension3 docExtension) throws BadPartitioningException, BadLocationException {</TD></TR><TR><TD CLASS="l">121</TD><TD> </TD></TR><TR><TD CLASS="l">122</TD><TD>                // end of previous partition</TD></TR><TR CLASS="z"><TD CLASS="l">123</TD><TD>                String partType= partition.getType();</TD></TR><TR CLASS="z"><TD CLASS="l">124</TD><TD>                int partEndOffset= partition.getOffset() + partition.getLength();</TD></TR><TR CLASS="z"><TD CLASS="l">125</TD><TD>                int tokenLength= getCommentStart().length();</TD></TR><TR><TD CLASS="l">126</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">127</TD><TD>                boolean wasJavadoc= false; // true if the previous partition is javadoc</TD></TR><TR><TD CLASS="l">128</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">129</TD><TD>                if (partType == IJavaScriptPartitions.JAVA_DOC) {</TD></TR><TR><TD CLASS="l">130</TD><TD>                        </TD></TR><TR CLASS="z"><TD CLASS="l">131</TD><TD>                        wasJavadoc= true;</TD></TR><TR><TD CLASS="l">132</TD><TD>                        </TD></TR><TR CLASS="z"><TD CLASS="l">133</TD><TD>                } else if (partType == IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT) {</TD></TR><TR><TD CLASS="l">134</TD><TD>                        </TD></TR><TR><TD CLASS="l">135</TD><TD>                        // already in a comment - remove ending mark</TD></TR><TR CLASS="z"><TD CLASS="l">136</TD><TD>                        edits.add(factory.createEdit(partEndOffset - tokenLength, tokenLength, &#34;&#34;)); //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">137</TD><TD>                        </TD></TR><TR><TD CLASS="l">138</TD><TD>                }</TD></TR><TR><TD CLASS="l">139</TD><TD> </TD></TR><TR><TD CLASS="l">140</TD><TD>                // advance to next partition</TD></TR><TR CLASS="z"><TD CLASS="l">141</TD><TD>                partition= docExtension.getPartition(IJavaScriptPartitions.JAVA_PARTITIONING, partEndOffset, false);</TD></TR><TR CLASS="z"><TD CLASS="l">142</TD><TD>                partType= partition.getType();</TD></TR><TR><TD CLASS="l">143</TD><TD> </TD></TR><TR><TD CLASS="l">144</TD><TD>                // start of next partition</TD></TR><TR CLASS="z"><TD CLASS="l">145</TD><TD>                if (wasJavadoc) {</TD></TR><TR><TD CLASS="l">146</TD><TD>                        </TD></TR><TR><TD CLASS="l">147</TD><TD>                        // if previous was javadoc, and the current one is not a comment,</TD></TR><TR><TD CLASS="l">148</TD><TD>                        // then add a block comment start</TD></TR><TR CLASS="z"><TD CLASS="l">149</TD><TD>                        if (partType == IDocument.DEFAULT_CONTENT_TYPE</TD></TR><TR CLASS="z"><TD CLASS="l">150</TD><TD>                                        || isSpecialPartition(partType)) {</TD></TR><TR CLASS="z"><TD CLASS="l">151</TD><TD>                                edits.add(factory.createEdit(partition.getOffset(), 0, getCommentStart()));</TD></TR><TR><TD CLASS="l">152</TD><TD>                        }</TD></TR><TR><TD CLASS="l">153</TD><TD>                        </TD></TR><TR><TD CLASS="l">154</TD><TD>                } else { // !wasJavadoc</TD></TR><TR><TD CLASS="l">155</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">156</TD><TD>                        if (partType == IJavaScriptPartitions.JAVA_DOC) {</TD></TR><TR><TD CLASS="l">157</TD><TD>                                // if next is javadoc, end block comment before</TD></TR><TR CLASS="z"><TD CLASS="l">158</TD><TD>                                edits.add(factory.createEdit(partition.getOffset(), 0, getCommentEnd()));</TD></TR><TR CLASS="z"><TD CLASS="l">159</TD><TD>                        } else if (partType == IJavaScriptPartitions.JAVA_MULTI_LINE_COMMENT) {</TD></TR><TR><TD CLASS="l">160</TD><TD>                                // already in a comment - remove startToken</TD></TR><TR CLASS="z"><TD CLASS="l">161</TD><TD>                                edits.add(factory.createEdit(partition.getOffset(), getCommentStart().length(), &#34;&#34;)); //$NON-NLS-1$</TD></TR><TR><TD CLASS="l">162</TD><TD>                        }</TD></TR><TR><TD CLASS="l">163</TD><TD>                }</TD></TR><TR><TD CLASS="l">164</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">165</TD><TD>                return partition;</TD></TR><TR><TD CLASS="l">166</TD><TD>        }</TD></TR><TR><TD CLASS="l">167</TD><TD> </TD></TR><TR><TD CLASS="l">168</TD><TD>        /**</TD></TR><TR><TD CLASS="l">169</TD><TD>         * Handles the partition under the end of the selection. For normal java</TD></TR><TR><TD CLASS="l">170</TD><TD>         * code, the comment end token is inserted at the selection end; if the</TD></TR><TR><TD CLASS="l">171</TD><TD>         * selection ends inside a special (i.e. string, character, line comment)</TD></TR><TR><TD CLASS="l">172</TD><TD>         * partition, the entire partition is included inside the comment.</TD></TR><TR><TD CLASS="l">173</TD><TD>         * </TD></TR><TR><TD CLASS="l">174</TD><TD>         * @param partition the partition under the selection end offset</TD></TR><TR><TD CLASS="l">175</TD><TD>         * @param edits the list of edits to add to</TD></TR><TR><TD CLASS="l">176</TD><TD>         * @param factory the edit factory</TD></TR><TR><TD CLASS="l"><A NAME="4">177</A></TD><TD>         * @param endOffset the end offset of the selection</TD></TR><TR><TD CLASS="l">178</TD><TD>         */</TD></TR><TR><TD CLASS="l">179</TD><TD>        private void handleLastPartition(ITypedRegion partition, List edits, Edit.EditFactory factory, int endOffset) throws BadLocationException {</TD></TR><TR><TD CLASS="l">180</TD><TD> </TD></TR><TR CLASS="z"><TD CLASS="l">181</TD><TD>                String partType= partition.getType();</TD></TR><TR><TD CLASS="l">182</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">183</TD><TD>                if (partType == IDocument.DEFAULT_CONTENT_TYPE) {</TD></TR><TR><TD CLASS="l">184</TD><TD>                        // normal java: end comment where selection ends</TD></TR><TR CLASS="z"><TD CLASS="l">185</TD><TD>                        edits.add(factory.createEdit(endOffset, 0, getCommentEnd()));</TD></TR><TR CLASS="z"><TD CLASS="l">186</TD><TD>                } else if (isSpecialPartition(partType)) {</TD></TR><TR><TD CLASS="l">187</TD><TD>                        // special types: consume entire partition</TD></TR><TR CLASS="z"><TD CLASS="l">188</TD><TD>                        edits.add(factory.createEdit(partition.getOffset() + partition.getLength(), 0, getCommentEnd()));</TD></TR><TR><TD CLASS="l">189</TD><TD>                }</TD></TR><TR><TD CLASS="l">190</TD><TD>                </TD></TR><TR CLASS="z"><TD CLASS="l">191</TD><TD>        }</TD></TR><TR><TD CLASS="l">192</TD><TD> </TD></TR><TR><TD CLASS="l">193</TD><TD>        /**</TD></TR><TR><TD CLASS="l">194</TD><TD>         * Returns whether &lt;code&gt;partType&lt;/code&gt; is special, i.e. a Java</TD></TR><TR><TD CLASS="l">195</TD><TD>         * &lt;code&gt;String&lt;/code&gt;,&lt;code&gt;Character&lt;/code&gt;, or</TD></TR><TR><TD CLASS="l">196</TD><TD>         * &lt;code&gt;Line End Comment&lt;/code&gt; partition.</TD></TR><TR><TD CLASS="l">197</TD><TD>         * </TD></TR><TR><TD CLASS="l">198</TD><TD>         * @param partType the partition type to check</TD></TR><TR><TD CLASS="l"><A NAME="5">199</A></TD><TD>         * @return &lt;code&gt;true&lt;/code&gt; if &lt;code&gt;partType&lt;/code&gt; is special,</TD></TR><TR><TD CLASS="l">200</TD><TD>         *         &lt;code&gt;false&lt;/code&gt; otherwise</TD></TR><TR><TD CLASS="l">201</TD><TD>         */</TD></TR><TR><TD CLASS="l">202</TD><TD>        private boolean isSpecialPartition(String partType) {</TD></TR><TR CLASS="z"><TD CLASS="l">203</TD><TD>                return partType == IJavaScriptPartitions.JAVA_CHARACTER</TD></TR><TR CLASS="z"><TD CLASS="l">204</TD><TD>                                || partType == IJavaScriptPartitions.JAVA_STRING</TD></TR><TR CLASS="z"><TD CLASS="l">205</TD><TD>                                || partType == IJavaScriptPartitions.JAVA_SINGLE_LINE_COMMENT;</TD></TR><TR><TD CLASS="l">206</TD><TD>        }</TD></TR><TR><TD CLASS="l">207</TD><TD> </TD></TR><TR><TD CLASS="l"><A NAME="6">208</A></TD><TD>        /*</TD></TR><TR><TD CLASS="l">209</TD><TD>         * @see org.eclipse.wst.jsdt.internal.ui.actions.BlockCommentAction#validSelection(org.eclipse.jface.text.ITextSelection)</TD></TR><TR><TD CLASS="l">210</TD><TD>         */</TD></TR><TR><TD CLASS="l">211</TD><TD>        protected boolean isValidSelection(ITextSelection selection) {</TD></TR><TR CLASS="z"><TD CLASS="l">212</TD><TD>                return selection != null &amp;&amp; !selection.isEmpty() &amp;&amp; selection.getLength() &gt; 0;</TD></TR><TR><TD CLASS="l">213</TD><TD>        }</TD></TR><TR><TD CLASS="l">214</TD><TD> </TD></TR><TR><TD CLASS="l">215</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="157.html">org.eclipse.wst.jsdt.internal.ui.actions</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>