aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2013-07-12 16:09:18 (EDT)
committerAlexander Kurtakov2013-07-30 09:27:27 (EDT)
commit5b764a7ac7d944eb92d7d94d549c63489165b835 (patch)
tree439db65481693e097c6fb9a4f7d56def05cba126
parent28a08969e77fb1a1752c8e966c71618795e8f1cd (diff)
downloadorg.eclipse.linuxtools-5b764a7ac7d944eb92d7d94d549c63489165b835.zip
org.eclipse.linuxtools-5b764a7ac7d944eb92d7d94d549c63489165b835.tar.gz
org.eclipse.linuxtools-5b764a7ac7d944eb92d7d94d549c63489165b835.tar.bz2
Systemtap: Minor clean up of toggle comment handler and test.refs/changes/21/14521/5
Change-Id: Ia058f1304a6d458dd48c1967626f32a2d162a34c Reviewed-on: https://git.eclipse.org/r/14521 Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> IP-Clean: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPToggleCommentTest.java11
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ToggleCommentHandler.java10
2 files changed, 8 insertions, 13 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPToggleCommentTest.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPToggleCommentTest.java
index f4e2402..bd21333 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPToggleCommentTest.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPToggleCommentTest.java
@@ -99,12 +99,13 @@ public class STPToggleCommentTest {
public void isBlockCommentedTest() {
MockSTPDocumentProvider provider = new MockSTPDocumentProvider(new Document(stpScript));
IDocument document = provider.createDocument(null);
- String curLine;
- for (int i = 0; i < PARTITIONED_SCRIPT.length; i++) {
- curLine = PARTITIONED_SCRIPT[i];
+ int i = 0;
+ for( String scriptLine : PARTITIONED_SCRIPT){
// for the purposes of this test, commented blocks start with "//"
- assertEquals(curLine.startsWith("//"), cmdHandler.isBlockCommented(i, i, "//", document));
+ assertEquals(scriptLine.startsWith("//"), cmdHandler.isBlockCommented(i, i, "//", document));
+
+ i++;
}
}
@@ -117,7 +118,6 @@ public class STPToggleCommentTest {
int offset = stpScript.indexOf(scriptLine, curPos);
ITextSelection selection = new MockTextSelection(offset, lineLength, i, i, scriptLine);
- IDocument document = new Document(stpScript);
IRegion actualRegion = cmdHandler.getTextBlockFromSelection( selection, document);
IRegion expectedRegion = new Region(offset, lineLength);
assertEquals(scriptLine + " :", expectedRegion, actualRegion);
@@ -134,7 +134,6 @@ public class STPToggleCommentTest {
for (String scriptLine : PARTITIONED_SCRIPT) {
int lineLength = scriptLine.length();
int offset = stpScript.indexOf(scriptLine, curPos);
-
ITextSelection selection = new MockTextSelection(offset, lineLength, i, i, scriptLine);
MockSTPDocumentProvider provider = new MockSTPDocumentProvider(new Document(stpScript));
IDocument document = provider.createDocument(null);
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ToggleCommentHandler.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ToggleCommentHandler.java
index 5370dc1..a5601bb 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ToggleCommentHandler.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ToggleCommentHandler.java
@@ -21,7 +21,6 @@ import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.Localization;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.editors.stp.STPPartitionScanner;
@@ -79,8 +78,9 @@ public class ToggleCommentHandler extends AbstractHandler {
}
Display display = null;
- if (shell != null && !shell.isDisposed())
+ if (shell != null && !shell.isDisposed()) {
display = shell.getDisplay();
+ }
BusyIndicator.showWhile(display, new Runnable() {
@Override
@@ -96,7 +96,7 @@ public class ToggleCommentHandler extends AbstractHandler {
* Creates a region describing the text block (something that starts at the
* beginning of a line) completely containing the current selection.
*
- * Note, the implementation has to match {@link TextViewer}
+ * Note, the implementation has to match org.eclipse.jface.text.TextViewer;
* .getTextBlockFromSelection().
*
* @param selection The selection to use
@@ -167,10 +167,6 @@ public class ToggleCommentHandler extends AbstractHandler {
lines[j + 1] = (lines[j] == -1 ? -1 : document
.getLineOfOffset(offset));
- // We could count the number of lines that are selected in this
- // region
- // lineCount += lines[j + 1] - lines[j] + 1;
-
assert i < regions.length;
assert j < regions.length * 2;
}