/**********************************************************************
-Copyright (c) 2000, 2002 IBM Corp. and others.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Common Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/cpl-v10.html
-
-Contributors:
- IBM Corporation - Initial implementation
- Klaus Hartlage - www.eclipseproject.de
-**********************************************************************/
+ Copyright (c) 2000, 2002 IBM Corp. and others.
+ All rights reserved. This program and the accompanying materials
+ are made available under the terms of the Common Public License v1.0
+ which accompanies this distribution, and is available at
+ http://www.eclipse.org/legal/cpl-v10.html
+
+ Contributors:
+ IBM Corporation - Initial implementation
+ www.phpeclipse.de
+ **********************************************************************/
package net.sourceforge.phpeclipse.phpeditor.php;
+import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
public class PHPDoubleClickSelector implements ITextDoubleClickStrategy {
protected ITextViewer fText;
+
protected int fPos;
+
protected int fStartPos;
+
protected int fEndPos;
- protected static char[] fgBrackets = { '{', '}', '(', ')', '[', ']', '"', '"' };
+ protected static char[] fgBrackets = { '{', '}', '(', ')', '[', ']', '"',
+ '"' };
- /*
+ /*
* Create a PHPDoubleClickSelector.
*/
public PHPDoubleClickSelector() {
super();
}
- /* (non-Javadoc)
- * Method declared on ITextDoubleClickStrategy
+ /*
+ * (non-Javadoc) Method declared on ITextDoubleClickStrategy
*/
public void doubleClicked(ITextViewer text) {
}
if (fStartPos > -1 && bracketIndex1 < bracketIndex2) {
- fEndPos = searchForClosingBracket(fStartPos, prevChar, fgBrackets[bracketIndex1 + 1], doc);
+ fEndPos = searchForClosingBracket(fStartPos, prevChar,
+ fgBrackets[bracketIndex1 + 1], doc);
if (fEndPos > -1)
return true;
else
fStartPos = -1;
} else if (fEndPos > -1) {
- fStartPos = searchForOpenBracket(fEndPos, fgBrackets[bracketIndex2 - 1], nextChar, doc);
+ fStartPos = searchForOpenBracket(fEndPos,
+ fgBrackets[bracketIndex2 - 1], nextChar, doc);
if (fStartPos > -1)
return true;
else
while (pos >= 0) {
c = doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c) && (c != '$')) {
+ if (!Scanner.isPHPIdentifierPart(c) && (c != '$')) {
break;
}
--pos;
while (pos < length) {
c = doc.getChar(pos);
- if (!Character.isJavaIdentifierPart(c) && (c != '$'))
+ if (!Scanner.isPHPIdentifierPart(c) && (c != '$'))
break;
++pos;
}
/**
* Returns the position of the closing bracket after startPosition.
+ *
* @returns the location of the closing bracket.
- * @param startPosition - the beginning position
- * @param openBracket - the character that represents the open bracket
- * @param closeBracket - the character that represents the close bracket
- * @param document - the document being searched
+ * @param startPosition -
+ * the beginning position
+ * @param openBracket -
+ * the character that represents the open bracket
+ * @param closeBracket -
+ * the character that represents the close bracket
+ * @param document -
+ * the document being searched
*/
- protected int searchForClosingBracket(int startPosition, char openBracket, char closeBracket, IDocument document)
- throws BadLocationException {
+ protected int searchForClosingBracket(int startPosition, char openBracket,
+ char closeBracket, IDocument document) throws BadLocationException {
int stack = 1;
int closePosition = startPosition + 1;
int length = document.getLength();
/**
* Returns the position of the open bracket before startPosition.
+ *
* @returns the location of the starting bracket.
- * @param startPosition - the beginning position
- * @param openBracket - the character that represents the open bracket
- * @param closeBracket - the character that represents the close bracket
- * @param document - the document being searched
+ * @param startPosition -
+ * the beginning position
+ * @param openBracket -
+ * the character that represents the open bracket
+ * @param closeBracket -
+ * the character that represents the close bracket
+ * @param document -
+ * the document being searched
*/
- protected int searchForOpenBracket(int startPosition, char openBracket, char closeBracket, IDocument document)
- throws BadLocationException {
+ protected int searchForOpenBracket(int startPosition, char openBracket,
+ char closeBracket, IDocument document) throws BadLocationException {
int stack = 1;
int openPos = startPosition - 1;
char nextChar;
}
/**
- * Select the area between the selected bracket and the closing bracket. Return
- * true if successful.
+ * Select the area between the selected bracket and the closing bracket.
+ * Return true if successful.
*/
protected boolean selectBracketBlock() {
if (matchBracketsAt()) {
}
/**
- * Select the word at the current selection.
+ * Select the word at the current selection.
*/
protected void selectWord() {
if (matchWord()) {