aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzzhongwei2012-12-18 09:46:47 (EST)
committerzzhongwei2012-12-18 09:48:09 (EST)
commit79629c5a7b5d0561ec1c244207c074b6d2b322c8 (patch)
treec428df5afa11b9f432dd42304d10c22da4cea636
parentb29f4d1b95ddb00abf84c8724456c0b7651cedb2 (diff)
downloadorg.eclipse.pdt-79629c5a7b5d0561ec1c244207c074b6d2b322c8.zip
org.eclipse.pdt-79629c5a7b5d0561ec1c244207c074b6d2b322c8.tar.gz
org.eclipse.pdt-79629c5a7b5d0561ec1c244207c074b6d2b322c8.tar.bz2
396841: After toggle comment and uncomment the // remain before the
opening php tag: <?php https://bugs.eclipse.org/bugs/show_bug.cgi?id=396841
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/PHPToggleLineCommentHandler.java16
-rw-r--r--plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java8
2 files changed, 16 insertions, 8 deletions
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/PHPToggleLineCommentHandler.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/PHPToggleLineCommentHandler.java
index 35bcd82..7be286e 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/PHPToggleLineCommentHandler.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/actions/PHPToggleLineCommentHandler.java
@@ -190,15 +190,15 @@ public class PHPToggleLineCommentHandler extends AbstractCommentHandler {
String string = document
.get(region.getOffset(), region.getLength()).trim();
boolean phpStrat = false;
- if (isSingleLine) {
- if (string.startsWith(PHP)) {
- string = string.substring(PHP.length()).trim();
- phpStrat = true;
- } else if (string.startsWith(SHORT_TAG)) {
- string = string.substring(SHORT_TAG.length()).trim();
- phpStrat = true;
- }
+ // if (isSingleLine) {
+ if (string.startsWith(PHP)) {
+ string = string.substring(PHP.length()).trim();
+ phpStrat = true;
+ } else if (string.startsWith(SHORT_TAG)) {
+ string = string.substring(SHORT_TAG.length()).trim();
+ phpStrat = true;
}
+ // }
isComment = !phpStrat
&& string.trim().length() == 0
diff --git a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
index a1d6cd2..1a45635 100644
--- a/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
+++ b/plugins/org.eclipse.php.ui/src/org/eclipse/php/internal/ui/editor/PHPStructuredEditor.java
@@ -15,6 +15,7 @@ import java.io.IOException;
import java.text.CharacterIterator;
import java.util.*;
+import org.eclipse.core.commands.IHandler;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.IFileBufferStatusCodes;
import org.eclipse.core.filebuffers.ITextFileBuffer;
@@ -114,6 +115,7 @@ import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.dnd.IDragAndDropService;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.IFoldingCommandIds;
+import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.texteditor.*;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
@@ -1976,6 +1978,12 @@ public class PHPStructuredEditor extends StructuredTextEditor implements
protected void createActions() {
super.createActions();
+ // add handlers to handler service
+ IHandlerService handlerService = (IHandlerService) getSite()
+ .getService(IHandlerService.class);
+ IHandler toggleCommentHandler = new PHPToggleLineCommentHandler();
+ handlerService.activateHandler(ActionDefinitionIds.TOGGLE_COMMENT,
+ toggleCommentHandler);
final ResourceBundle resourceBundle = PHPUIMessages.getResourceBundle();
Action action = new GotoMatchingBracketAction(this);