KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > text > AntEditorPartitionScanner


1 /*******************************************************************************
2  * Copyright (c) 2002, 2006 GEBIT Gesellschaft fuer EDV-Beratung
3  * und Informatik-Technologien mbH,
4  * Berlin, Duesseldorf, Frankfurt (Germany) and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * GEBIT Gesellschaft fuer EDV-Beratung und Informatik-Technologien mbH - initial API and implementation
12  * IBM Corporation - bug 32890, bug 24108, bug 111740
13  * John-Mason P. Shackelford - bug 57379
14  *******************************************************************************/

15
16 package org.eclipse.ant.internal.ui.editor.text;
17
18 /*
19  * This file originates from an internal package of Eclipse's
20  * Manifest Editor. It has been copied by GEBIT to here in order to
21  * permanently use those features. It has been renamed and edited by GEBIT
22  * after copying.
23  */

24
25 import org.eclipse.jface.text.rules.IPredicateRule;
26 import org.eclipse.jface.text.rules.IToken;
27 import org.eclipse.jface.text.rules.MultiLineRule;
28 import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
29 import org.eclipse.jface.text.rules.Token;
30
31 /**
32  * Scanner that scans the document and partitions the document into the four
33  * supported content types:
34  * <ul>
35  * <li>XML_COMMENT</li>
36  * <li>XML_TAG</li>
37  * <li>XML_CDATA</li>
38  * <li>XML_DTD</li>
39  * </ul>
40  */

41 public class AntEditorPartitionScanner extends RuleBasedPartitionScanner {
42
43     public final static String JavaDoc XML_COMMENT = "__xml_comment"; //$NON-NLS-1$
44
public final static String JavaDoc XML_TAG = "__xml_tag"; //$NON-NLS-1$
45
public final static String JavaDoc XML_CDATA = "__xml_cdata"; //$NON-NLS-1$
46
public final static String JavaDoc XML_DTD = "__xml_dtd"; //$NON-NLS-1$
47

48     /**
49      * Creates an instance.
50      */

51     public AntEditorPartitionScanner() {
52
53         IPredicateRule[] rules =new IPredicateRule[4];
54
55         IToken xmlCDATA = new Token(XML_CDATA);
56         rules[0]= new MultiLineRule("<![CDATA[", "]]>", xmlCDATA); //$NON-NLS-1$ //$NON-NLS-2$
57

58         IToken xmlComment = new Token(XML_COMMENT);
59         rules[1]= new MultiLineRule("<!--", "-->", xmlComment, '\\', true); //$NON-NLS-1$ //$NON-NLS-2$
60

61         IToken tag = new Token(XML_TAG);
62         rules[2]= new TagRule(tag);
63     
64         IToken xmlDTD = new Token(XML_DTD);
65         rules[3]= new DocTypeRule(xmlDTD);
66         
67         setPredicateRules(rules);
68     }
69 }
Popular Tags