Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: edefd48b271fd792eca6e7567b7e249c3a10cc01 (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
61
62
63
64
65
66
67
/*******************************************************************************
 * Copyright (c) 2015 protos software gmbh (http://www.protos.de).
 * 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:
 * 		Juergen Haug (initial contribution)
 * 
 *******************************************************************************/

package org.eclipse.etrice.expressions.detailcode

import com.google.common.collect.ImmutableList
import java.util.List
import org.eclipse.xtend.lib.annotations.Accessors

/**
 * Defines detail expressions = <i>ExpressionFeature ('.' ExpressionFeature)* </i>
 */
interface IDetailExpressionProvider {

	static val char SEPARATOR = '.'

	/**
	 * A list of ExpressionFeatures, without preceding '.' and that can start a context
	 * @return not null
	 */
	def List<ExpressionFeature> getInitialFeatures()

	/**
	 * A list of ExpressionFeatures, that can follow ctx
	 * @param ctx having non-null entries
	 * @return not null
	 */
	def List<ExpressionFeature> getContextFeatures(ExpressionFeature ctx)

	/**
	 * ExpressionFeature = <i>id(postfix)?</i> with <i> postfix = '(' .* ')' | '[' .* ']'
	 */
	@Accessors // @Data
	static class ExpressionFeature {
		val String id
		val ExpressionPostfix postfix
		Object data
	}

	enum ExpressionPostfix {
		NONE,
		PARENTHESES,
		BRACKETS
	}
	
	static class EmptyDetailExpressionProvider implements IDetailExpressionProvider {

		val List<ExpressionFeature> EMPTY_LIST = ImmutableList.of

		override List<ExpressionFeature> getInitialFeatures() {
			return EMPTY_LIST;
		}

		override List<ExpressionFeature> getContextFeatures(ExpressionFeature ctx) {
			return EMPTY_LIST;
		}
	}
}

Back to the top