1 package net.sourceforge.phpeclipse.editors;
3 import org.eclipse.jface.text.*;
5 public class PHPDoubleClickStrategy implements ITextDoubleClickStrategy {
6 protected ITextViewer fText;
8 public PHPDoubleClickStrategy() {
11 public void doubleClicked(ITextViewer part) {
12 int pos = part.getSelectedRange().x;
19 if (!selectComment(pos)) {
23 protected boolean selectComment(int caretPos) {
24 IDocument doc = fText.getDocument();
37 if (c == Character.LINE_SEPARATOR || c == '\"')
48 int length = doc.getLength();
51 while (pos < length) {
53 if (c == Character.LINE_SEPARATOR || c == '\"')
62 int offset = startPos + 1;
63 int len = endPos - offset;
64 fText.setSelectedRange(offset, len);
66 } catch (BadLocationException x) {
71 protected boolean selectWord(int caretPos) {
73 IDocument doc = fText.getDocument();
83 if (!Character.isJavaIdentifierPart(c))
91 int length = doc.getLength();
93 while (pos < length) {
95 if (!Character.isJavaIdentifierPart(c))
101 selectRange(startPos, endPos);
104 } catch (BadLocationException x) {
110 private void selectRange(int startPos, int stopPos) {
111 int offset = startPos + 1;
112 int length = stopPos - offset;
113 fText.setSelectedRange(offset, length);