Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7b75091395ce600fde3b7ae5ce05e76022d863b3 (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
58
59
60
/*******************************************************************************
 * Copyright (c) 2006, 2015 Red Hat, Inc.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Red Hat Incorporated - initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.autotools.ui.editors;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.jface.text.rules.EndOfLineRule;
import org.eclipse.jface.text.rules.IPredicateRule;
import org.eclipse.jface.text.rules.IRule;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
import org.eclipse.jface.text.rules.SingleLineRule;
import org.eclipse.jface.text.rules.Token;

public class AutoconfPartitionScanner extends RuleBasedPartitionScanner {
	
	public final static String AUTOCONF_MACRO = "autoconf_macro"; //$NON-NLS-1$
	public final static String AUTOCONF_COMMENT = "autoconf_comment"; //$NON-NLS-1$
	final static String[] AUTOCONF_PARTITION_TYPES= 
		new String[] { AUTOCONF_MACRO, AUTOCONF_COMMENT };
	
	/**
	 * Creates the partitioner and sets up the appropriate rules.
	 */
	public AutoconfPartitionScanner() {
		super();
		
		List<IRule> rules= new ArrayList<>();
		Token macro = new Token(AUTOCONF_MACRO);
		Token comment = new Token(AUTOCONF_COMMENT);

		// Add rule for target bodies.
		rules.add(new AutoconfMacroPartitionRule(macro));
		

		rules.add(new EndOfLineRule("dnl", comment)); //$NON-NLS-1$
		rules.add(new SingleLineRule("\\#", null, Token.UNDEFINED));
		rules.add(new EndOfLineRule("#", comment, '\\')); //$NON-NLS-1$
		
		// We want to process identifiers that might have macro
		// names inside them.
		rules.add(new AutoconfIdentifierRule(Token.UNDEFINED));

		IPredicateRule[] result= new IPredicateRule[rules.size()];
		rules.toArray(result);
		setPredicateRules(result);
	}
	
}

Back to the top