01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.text;
11:
12: import org.eclipse.jface.text.rules.ICharacterScanner;
13: import org.eclipse.jface.text.rules.IToken;
14: import org.eclipse.jface.text.rules.MultiLineRule;
15:
16: public class XMLTagRule extends MultiLineRule {
17:
18: public XMLTagRule(IToken token) {
19: super ("<", ">", token); //$NON-NLS-1$ //$NON-NLS-2$
20: }
21:
22: protected boolean sequenceDetected(ICharacterScanner scanner,
23: char[] sequence, boolean eofAllowed) {
24: int c = scanner.read();
25: if (sequence[0] == '<') {
26: if (c == '?') {
27: // processing instruction - abort
28: scanner.unread();
29: return false;
30: }
31: if (c == '!') {
32: scanner.unread();
33: // comment - abort
34: return false;
35: }
36: } else if (sequence[0] == '>') {
37: scanner.unread();
38: }
39:
40: return super.sequenceDetected(scanner, sequence, eofAllowed);
41: }
42: }
|