blob: 83c7d249cf5d81a7353f3c867ff6d7765f77bdf3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
/*******************************************************************************
* Copyright (c) 2009 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat Incorporated - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.changelog.core.editors;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.MultiLineRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;
public class GNUPartitionScanner extends RuleBasedPartitionScanner {
// We partition into sections we want to parse from the beginning every time
// a change occurs within the area. In this case, we are only interested in
// email entries which are surrounded by < and > and source entries which
// have one or more file names which may extend across lines.
public final static String CHANGELOG_EMAIL = "changelog_email"; //$NON-NLS-1$
public final static String CHANGELOG_SRC_ENTRY = "changelog_src_entry"; //$NON-NLS-1$
public final static String[] CHANGELOG_PARTITION_TYPES=
new String[] { CHANGELOG_EMAIL, CHANGELOG_SRC_ENTRY };
/**
* Creates the partitioner and sets up the appropriate rules.
*/
public GNUPartitionScanner() {
super();
List<IPredicateRule> rules= new ArrayList<IPredicateRule>();
Token email = new Token(CHANGELOG_EMAIL);
Token srcEntry = new Token(CHANGELOG_SRC_ENTRY);
rules.add(new SingleLineRule("<", ">", email, '\\'));
rules.add(new MultiLineRule("* ", ":", srcEntry, '\\', true));
IPredicateRule[] result= new IPredicateRule[rules.size()];
rules.toArray(result);
setPredicateRules(result);
}
@Override
public IToken nextToken() {
return super.nextToken();
}
}
|