2 * Copyright (c) 2004 Widespace, OU and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * Igor Malinin - initial implementation
11 * $Id: XMLWordFinder.java,v 1.2 2006-10-21 23:14:13 pombredanne Exp $
13 package net.sourceforge.phpeclipse.xml.ui.internal.text;
15 import org.eclipse.jface.text.BadLocationException;
16 import org.eclipse.jface.text.IDocument;
17 import org.eclipse.jface.text.IRegion;
18 import org.eclipse.jface.text.Region;
23 * @author Igor Malinin
25 public class XMLWordFinder {
26 public static IRegion findWord(IDocument document, int offset) {
27 int length = document.getLength();
33 if (!Character.isUnicodeIdentifierPart(document.getChar(pos))) {
43 while (pos < length) {
44 if (!Character.isUnicodeIdentifierPart(document.getChar(pos))) {
52 if (start == offset) {
53 return new Region(start, end - start);
56 return new Region(start + 1, end - start - 1);
57 } catch (BadLocationException x) {