X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java index 7c950b0..9968341 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/HTMLWordExtractor.java @@ -1,14 +1,14 @@ /********************************************************************** -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 + 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 -**********************************************************************/ + Contributors: + IBM Corporation - Initial implementation + www.phpeclipse.de + **********************************************************************/ package net.sourceforge.phpeclipse.phpeditor.php; import net.sourceforge.phpdt.internal.compiler.parser.Scanner; @@ -22,67 +22,70 @@ import org.eclipse.swt.graphics.Point; */ public class HTMLWordExtractor { - /** - * Find the location of the word at offset in document. - * @returns Point - x is the start position, y is the end position. - * Return null if it is not found. - * @param document the document being searched. - * @param offset - the position to start searching from. - */ - public static Point findWord(IDocument document, int offset) { + /** + * Find the location of the word at offset in document. + * + * @returns Point - x is the start position, y is the end position. Return + * null if it is not found. + * @param document + * the document being searched. + * @param offset - + * the position to start searching from. + */ + public static Point findWord(IDocument document, int offset) { - int start = -1; - int end = -1; + int start = -1; + int end = -1; - try { + try { - int position = offset; - char character = ' '; + int position = offset; + char character = ' '; - while (position >= 0) { - character = document.getChar(position); - if (!Scanner.isPHPIdentifierPart(character)) - break; - --position; - } - if ((position > 0) && (character == '<')) { - --position; - } - if ((position > 1) && (character == '/')) { - character = document.getChar(position - 1); - if (character == '<') { - --position; - --position; - } - } - if (position==offset) { - return null; - } + while (position >= 0) { + character = document.getChar(position); + if (!Scanner.isPHPIdentifierPart(character)) + break; + --position; + } + if ((position > 0) && (character == '<')) { + --position; + } + if ((position > 1) && (character == '/')) { + character = document.getChar(position - 1); + if (character == '<') { + --position; + --position; + } + } + if (position == offset) { + return null; + } - start = position; + start = position; - position = offset; - int length = document.getLength(); - character = ' '; + position = offset; + int length = document.getLength(); + character = ' '; - while (position < length) { - character = document.getChar(position); - if (!Scanner.isPHPIdentifierPart(character)) - break; - ++position; - } - if ((position < length) && (character == '>')) { - ++position; - } - start++; - end = position; + while (position < length) { + character = document.getChar(position); + if (!Scanner.isPHPIdentifierPart(character)) + break; + ++position; + } + if ((position < length) && (character == '>')) { + ++position; + } + start++; + end = position; - if (end > start) - return new Point(start, end - start); + if (end > start) + return new Point(start, end - start); - } catch (BadLocationException x) { - } + } catch (BadLocationException x) { + } - return null; - } + return null; + } }