e86f4918a8eb88bebc0fadc31695a7399531b12b
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / xml / ui / internal / text / NameDetector.java
1 /*
2  * Copyright (c) 2002-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
7  *
8  * Contributors:
9  *     Igor Malinin - initial contribution
10  *
11  * $Id: NameDetector.java,v 1.2 2006-10-21 23:14:13 pombredanne Exp $
12  */
13
14 package net.sourceforge.phpeclipse.xml.ui.internal.text;
15
16 import org.eclipse.jface.text.rules.IWordDetector;
17
18 /**
19  * XML Name detector.
20  * 
21  * @author Igor Malinin
22  */
23 public class NameDetector implements IWordDetector {
24
25         /**
26          * @see IWordDetector#isWordPart(char)
27          */
28         public boolean isWordPart(char ch) {
29                 if (Character.isUnicodeIdentifierPart(ch)) {
30                         return true;
31                 }
32                 switch (ch) {
33                 case '.':
34                 case '-':
35                 case '_':
36                 case ':':
37                         return true;
38                 }
39                 return false;
40         }
41
42         /**
43          * @see IWordDetector#isWordStart(char)
44          */
45         public boolean isWordStart(char ch) {
46                 if (Character.isUnicodeIdentifierStart(ch)) {
47                         return true;
48                 }
49                 switch (ch) {
50                 case '_':
51                 case ':':
52                         return true;
53                 }
54                 return false;
55         }
56
57 }