aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2013-06-25 14:37:16 (EDT)
committerJeff Johnston2013-07-10 14:56:23 (EDT)
commit4d85f3e2fc95fc9b17f41c67a0b24007ef10843c (patch)
tree2cd618c394199c025ead6641629e0992f2db766a
parente6731720e185db3377b02dbfd39504b40b4ed60f (diff)
downloadorg.eclipse.linuxtools-4d85f3e2fc95fc9b17f41c67a0b24007ef10843c.zip
org.eclipse.linuxtools-4d85f3e2fc95fc9b17f41c67a0b24007ef10843c.tar.gz
org.eclipse.linuxtools-4d85f3e2fc95fc9b17f41c67a0b24007ef10843c.tar.bz2
Systemtap: Add toggle comment command to IDErefs/changes/13/14413/4
* Bind command to CTRL-/ key short cut. * Show command in editor's context menu. * Add default prefixes to IDE configuration. * Behaviour mirrors that of the CDT editor. * Add test cases. Change-Id: I1d01ceca9996976eb3eace738b6345b838cf30d4 Reviewed-on: https://git.eclipse.org/r/14413 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> IP-Clean: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java6
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPToggleCommentTest.java182
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties3
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml25
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ToggleCommentHandler.java313
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java6
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties3
7 files changed, 536 insertions, 2 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java
index ecf63fa..b70d59a 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/AllTests.java
@@ -12,6 +12,7 @@
package org.eclipse.linuxtools.systemtap.ui.ide.test;
import org.eclipse.linuxtools.systemtap.ui.ide.test.editors.stp.STPCompletionProcessorTest;
+import org.eclipse.linuxtools.systemtap.ui.ide.test.editors.stp.STPToggleCommentTest;
import org.eclipse.linuxtools.systemtap.ui.ide.test.structures.StapErrorParserTest;
import org.eclipse.linuxtools.systemtap.ui.ide.test.structures.TreeSettingsTest;
import org.eclipse.linuxtools.systemtap.ui.ide.test.swtbot.TestCreateSystemtapScript;
@@ -21,7 +22,8 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({ StapErrorParserTest.class, TreeSettingsTest.class,
- STPCompletionProcessorTest.class, TestCreateSystemtapScript.class,
- ConditionalExpressionValidatorTest.class, DirectoryValidatorTest.class })
+ STPCompletionProcessorTest.class, STPToggleCommentTest.class,
+ TestCreateSystemtapScript.class, ConditionalExpressionValidatorTest.class,
+ DirectoryValidatorTest.class })
public class AllTests {
}
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
new file mode 100644
index 0000000..b7bcd1e
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/editors/stp/STPToggleCommentTest.java
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.systemtap.ui.ide.test.editors.stp;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Region;
+import org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.ToggleCommentHandler;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test class for {@link ToggleCommentHandler}.
+ */
+public class STPToggleCommentTest {
+ private static final String[] PARTITIONED_SCRIPT = new String[]{
+ "//comment\n", // line 0
+ "probe syscall.write{\n", // line 1
+ "// Some comment inside a probe\n", // line 2
+ " printf(\"write syscall\")\n", // line 3
+ "not//a//commented//block\n", // line 4
+ "}\n", // line 5
+ "\n", // line 6
+ "" // line 7
+ };
+ private static String stpScript;
+ private static ToggleCommentHandler cmdHandler;
+ private static IDocument document;
+
+ @BeforeClass
+ public static void setUp() {
+ StringBuffer stpScriptBuff = new StringBuffer();
+ for (String scriptLine : PARTITIONED_SCRIPT) {
+ stpScriptBuff.append(scriptLine);
+ }
+ stpScript = stpScriptBuff.toString();
+ cmdHandler = new ToggleCommentHandler();
+ document = new Document(stpScript);
+ }
+
+ @Test
+ public void getFirstCompleteLineOfRegionTest() {
+ IRegion scriptRegion;
+ int i = 0;
+ int curPos = 0;
+ for (String scriptLine : PARTITIONED_SCRIPT) {
+ int lineLength = scriptLine.length();
+ int offset = stpScript.indexOf(scriptLine, curPos);
+ scriptRegion = new Region(offset, lineLength);
+ int actualIndex = cmdHandler.getFirstCompleteLineOfRegion(scriptRegion, document);
+ assertEquals(i, actualIndex);
+
+ curPos = offset + lineLength;
+ i++;
+ }
+ }
+
+ @Test
+ public void isBlockEmptyTest() {
+ int i = 0;
+ for(String scriptLine : PARTITIONED_SCRIPT){
+ // new lines are considered empty blocks
+ boolean expected = "\n".equals(scriptLine) ? true : scriptLine.isEmpty();
+ assertEquals(expected, cmdHandler.isBlockEmpty(i, i, document));
+
+ i++;
+ }
+ }
+
+ @Test
+ public void isBlockCommentedTest() {
+ IDocument document = new Document(stpScript);
+ String curLine;
+ for (int i = 0; i < PARTITIONED_SCRIPT.length; i++) {
+ curLine = PARTITIONED_SCRIPT[i];
+
+ // for the purposes of this test, commented blocks start with "//"
+ assertEquals(curLine.startsWith("//"), cmdHandler.isBlockCommented(i, i, "//", document));
+ }
+ }
+
+ @Test
+ public void getTextBlockFromSelectionTest() throws BadLocationException {
+ int i = 0;
+ int curPos = 0;
+ for (String scriptLine : PARTITIONED_SCRIPT) {
+ int lineLength = scriptLine.length();
+ 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);
+
+ curPos = offset + lineLength;
+ i++;
+ }
+ }
+
+ @Test
+ public void isSelectionCommentedTest() {
+ int i = 0;
+ int curPos = 0;
+ for (String scriptLine : PARTITIONED_SCRIPT) {
+ int lineLength = scriptLine.length();
+ int offset = stpScript.indexOf(scriptLine, curPos);
+
+ ITextSelection selection = new MockTextSelection(offset, lineLength, i, i, scriptLine);
+ IDocument document = new Document(stpScript);
+
+ // for the purposes of this test, commented blocks start with "//"
+ assertEquals(scriptLine.startsWith("//"), cmdHandler.isSelectionCommented(selection, document));
+
+ curPos = offset + lineLength;
+ i++;
+ }
+ }
+
+ /**
+ * Mock {@link ITextSelection} implementation.
+ */
+ private static class MockTextSelection implements ITextSelection {
+ private int offset;
+ private int length;
+ private int startLine;
+ private int endLine;
+ private String text;
+
+ public MockTextSelection(int offset, int length, int startLine,
+ int endLine, String text) {
+ this.offset = offset;
+ this.length = length;
+ this.startLine = startLine;
+ this.endLine = endLine;
+ this.text = text;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return false;
+ }
+
+ @Override
+ public int getOffset() {
+ return offset;
+ }
+
+ @Override
+ public int getLength() {
+ return length;
+ }
+
+ @Override
+ public int getStartLine() {
+ return startLine;
+ }
+
+ @Override
+ public int getEndLine() {
+ return endLine;
+ }
+
+ @Override
+ public String getText() {
+ return text;
+ }
+ }
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
index d63a744..25ed7d1 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.properties
@@ -77,3 +77,6 @@ action.addStapProbe.label = Add SystemTap probe
command.runChart.name=Run w/C&hart
command.runChart.desc=Run the Script w/Chart
+command.toggleComment.name=Toggle Comment
+command.toggleComment.desc=Toggle Single Line SystemTap Comment
+command.toggleComment.mne=Tog&gle Comment \ No newline at end of file
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
index af9b475..6264a91 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/plugin.xml
@@ -65,6 +65,16 @@
style="push">
</command>
</menuContribution>
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:#TextEditorContext?after=additions">
+ <command
+ commandId="org.eclipse.linuxtools.systemtap.ui.ide.toggleComment"
+ label="%command.toggleComment.name"
+ mnemonic="%command.toggleComment.mne"
+ style="push">
+ </command>
+ </menuContribution>
</extension>
<extension
@@ -183,6 +193,12 @@
id="org.eclipse.linuxtools.systemtap.ui.ide.RunScriptCommand"
name="%action.run.name">
</command>
+ <command
+ defaultHandler="org.eclipse.linuxtools.internal.systemtap.ui.ide.actions.ToggleCommentHandler"
+ description="%command.toggleComment.desc"
+ id="org.eclipse.linuxtools.systemtap.ui.ide.toggleComment"
+ name="%command.toggleComment.name">
+ </command>
</extension>
<extension
point="org.eclipse.ui.actionSets">
@@ -337,4 +353,13 @@
type="org.eclipse.linuxtools.systemtap.ui.ide.SystemTapLaunchConfigurationType">
</launchConfigurationTabGroup>
</extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="org.eclipse.linuxtools.systemtap.ui.ide.toggleComment"
+ contextId="org.eclipse.ui.textEditorScope"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="CTRL+/">
+ </key>
+ </extension>
</plugin>
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
new file mode 100644
index 0000000..395a5b4
--- /dev/null
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/actions/ToggleCommentHandler.java
@@ -0,0 +1,313 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.systemtap.ui.ide.actions;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentExtension3;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextOperationTarget;
+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.systemtap.graphingapi.ui.widgets.ExceptionErrorDialog;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Handler for command in charge of toggling comment prefixes. Based on
+ * org.eclipse.cdt.internal.ui.actions.ToggleCommentAction.
+ */
+public class ToggleCommentHandler extends AbstractHandler {
+
+ /** The text operation target */
+ private ITextOperationTarget operationTarget;
+
+ /**
+ * Checks if the selected lines are all commented or not and
+ * uncomments/comments them respectively.
+ */
+ @Override
+ public Object execute(ExecutionEvent event) {
+ ITextEditor editor = (ITextEditor) HandlerUtil.getActiveEditor(event);
+ if (editor == null || !editor.isEditable()) {
+ return null;
+ }
+
+ updateOpTarget(editor);
+ if (operationTarget == null) {
+ return null;
+ }
+
+ ISelection selection = editor.getSelectionProvider().getSelection();
+ IDocument document = editor.getDocumentProvider().getDocument(
+ editor.getEditorInput());
+
+ final int operationCode;
+ if (isSelectionCommented(selection, document)) {
+ operationCode = ITextOperationTarget.STRIP_PREFIX;
+ } else {
+ operationCode = ITextOperationTarget.PREFIX;
+ }
+
+ Shell shell = editor.getSite().getShell();
+ if (!operationTarget.canDoOperation(operationCode)) {
+ if (shell != null) {
+ MessageDialog.openError(shell,
+ Localization.getString("ToggleComment_error_title"), //$NON-NLS-1$
+ Localization.getString("ToggleComment_error_message")); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ Display display = null;
+ if (shell != null && !shell.isDisposed())
+ display = shell.getDisplay();
+
+ BusyIndicator.showWhile(display, new Runnable() {
+ @Override
+ public void run() {
+ operationTarget.doOperation(operationCode);
+ }
+ });
+
+ return null;
+ }
+
+ /**
+ * 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}
+ * .getTextBlockFromSelection().
+ *
+ * @param selection The selection to use
+ * @param document The document
+ * @return the region describing the text block comprising the given
+ * selection
+ * @throws BadLocationException
+ */
+ public IRegion getTextBlockFromSelection(ITextSelection selection,
+ IDocument document) throws BadLocationException {
+ int start = document.getLineOffset(selection.getStartLine());
+ int end;
+ int endLine = selection.getEndLine();
+ if (document.getNumberOfLines() > endLine + 1) {
+ end = document.getLineOffset(endLine + 1);
+ } else {
+ end = document.getLength();
+ }
+ return new Region(start, end - start);
+ }
+
+ /**
+ * Is the given selection on the specified document single-line commented?
+ *
+ * @param selection Selection to check
+ * @param document The document
+ * @return <code>true</code> iff all selected lines are commented
+ */
+ public boolean isSelectionCommented(ISelection selection,
+ IDocument document) {
+
+ if (!(selection instanceof ITextSelection)) {
+ return false;
+ }
+
+ ITextSelection textSelection = (ITextSelection) selection;
+ if (textSelection.getStartLine() < 0 || textSelection.getEndLine() < 0) {
+ return false;
+ }
+
+ try {
+ IRegion block = getTextBlockFromSelection(textSelection, document);
+ ITypedRegion[] regions = TextUtilities.computePartitioning(
+ document, IDocumentExtension3.DEFAULT_PARTITIONING,
+ block.getOffset(), block.getLength(), false);
+
+ int[] lines = new int[regions.length * 2]; // [startline, endline,
+ // startline, endline,
+ // ...]
+
+ // For each partition in the text selection, figure out the
+ // startline and endline.
+ // Count the number of lines that are selected.
+ for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
+ // Start line of region
+ lines[j] = getFirstCompleteLineOfRegion(regions[i], document);
+ // End line of region
+ int length = regions[i].getLength();
+ int offset = regions[i].getOffset() + length;
+ if (length > 0) {
+ offset--;
+ }
+
+ // If there is no startline for this region (startline = -1),
+ // then there is no endline,
+ // otherwise, get the line number of the endline and store it in
+ // the array.
+ 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;
+ }
+
+ // Perform the check
+ boolean hasComment = false;
+ for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
+ String prefix = "//"; //$NON-NLS-1$
+ if (lines[j] >= 0 && lines[j + 1] >= 0) {
+ if (isBlockCommented(lines[j], lines[j + 1], prefix,
+ document)) {
+ hasComment = true;
+ } else if (!isBlockEmpty(lines[j], lines[j + 1], document)) {
+ return false;
+ }
+ }
+ }
+ return hasComment;
+ } catch (BadLocationException e) {
+ ExceptionErrorDialog.openError(e.getLocalizedMessage(), e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns the index of the first line whose start offset is in the given
+ * text range.
+ *
+ * @param region the text range in characters where to find the line
+ * @param document The document
+ * @return the first line whose start index is in the given range, -1 if
+ * there is no such line
+ */
+ public int getFirstCompleteLineOfRegion(IRegion region, IDocument document) {
+ try {
+ int startLine = document.getLineOfOffset(region.getOffset());
+
+ int offset = document.getLineOffset(startLine);
+ if (offset >= region.getOffset()) {
+ return startLine;
+ }
+
+ offset = document.getLineOffset(startLine + 1);
+ return (offset > region.getOffset() + region.getLength() ? -1
+ : startLine + 1);
+ } catch (BadLocationException e) {
+ ExceptionErrorDialog.openError(e.getLocalizedMessage(), e);
+ }
+
+ return -1;
+ }
+
+ /**
+ * Determines whether each line is empty
+ *
+ * @param startLine Start line in document
+ * @param endLine End line in document
+ * @param document The document
+ * @return <code>true</code> if each line from <code>startLine</code> to and
+ * including <code>endLine</code> is empty
+ */
+ public boolean isBlockEmpty(int startLine, int endLine, IDocument document) {
+ try {
+ for (int i = startLine; i <= endLine; i++) {
+ IRegion line = document.getLineInformation(i);
+ String text = document.get(line.getOffset(), line.getLength());
+
+ boolean isEmptyLine = text.trim().length() == 0;
+ if (!isEmptyLine) {
+ return false;
+ }
+ }
+ return true;
+ } catch (BadLocationException e) {
+ ExceptionErrorDialog.openError(e.getLocalizedMessage(), e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Determines whether each line is prefixed by one of the prefixes.
+ *
+ * @param startLine Start line in document
+ * @param endLine End line in document
+ * @param prefix Comment prefix
+ * @param document The document
+ * @return <code>true</code> iff each line from <code>startLine</code> to
+ * and including <code>endLine</code> is prepended by the
+ * <code>prefix</code>, ignoring whitespace at the begin of line
+ */
+ public boolean isBlockCommented(int startLine, int endLine, String prefix,
+ IDocument document) {
+ try {
+ // Check for occurrences of prefixes in the given lines
+ boolean hasComment = false;
+ for (int i = startLine; i <= endLine; i++) {
+ IRegion line = document.getLineInformation(i);
+ String text = document.get(line.getOffset(), line.getLength());
+
+ boolean isEmptyLine = text.trim().length() == 0;
+ if (isEmptyLine) {
+ continue;
+ }
+
+ int prefixIndex = text.indexOf(prefix, 0);
+
+ if (prefixIndex == -1) {
+ // Found a line which is not commented
+ return false;
+ }
+ String s = document.get(line.getOffset(), prefixIndex);
+ s = s.trim();
+ if (s.length() != 0) {
+ // Found a line which is not commented
+ return false;
+ }
+ hasComment = true;
+ }
+ return hasComment;
+ } catch (BadLocationException e) {
+ ExceptionErrorDialog.openError(e.getLocalizedMessage(), e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Update text operation target based on the specified text editor.
+ *
+ * @param editor ITextEditor editor to associate operation target to.
+ */
+ public void updateOpTarget(ITextEditor editor) {
+ if (editor != null) {
+ operationTarget = (ITextOperationTarget) editor
+ .getAdapter(ITextOperationTarget.class);
+ }
+ }
+}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java
index 8d83e50..0b357b7 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/editors/stp/STPConfiguration.java
@@ -165,4 +165,10 @@ public class STPConfiguration extends SourceViewerConfiguration {
return processor;
}
+ @Override
+ public String[] getDefaultPrefixes(ISourceViewer sourceViewer,
+ String contentType) {
+ return new String[] { "//", "" }; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
} \ No newline at end of file
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
index 4b5ff23..27d5729 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/internal/systemtap/ui/ide/localization.properties
@@ -81,3 +81,6 @@ KernelBrowserView.NoKernelSourceFound=The kernel source directory was not define
KernelBrowserView.KernelSourceDirNotFound=Kernel Source Directory not found
KernelBrowserView.CouldNotInitializeTree=Could not initialize kernel source tree
+
+ToggleComment_error_title=Comment/Uncomment
+ToggleComment_error_message=An error occurred while commenting/uncommenting.