-
Notifications
You must be signed in to change notification settings - Fork 316
/
BeginEndRule.java
109 lines (92 loc) · 2.39 KB
/
BeginEndRule.java
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Copyright (c) 2024 Sigasi (http://www.sigasi.com) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.eclipse.xtext.xtext.generator.textmate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.eclipse.emf.mwe2.runtime.Mandatory;
import com.google.gson.annotations.Expose;
/**
* See the <a href="https://macromates.com/manual/en/language_grammars#rule_keys">TextMate specification</a>.
*
* @author David Medina
* @author Sebastian Zarnekow
* @since 2.35
*/
public class BeginEndRule extends TextMateRule {
@Expose private List<TextMateRule> patterns;
@Expose private String begin;
@Expose private String end;
@Expose private String contentName;
@Expose private Map<Integer, Capture> captures;
@Expose private Map<Integer, Capture> beginCaptures;
@Expose private Map<Integer, Capture> endCaptures;
@Mandatory
@Override
public void setName(String name) {
super.setName(name);
}
public String getBegin() {
return begin;
}
@Mandatory
public void setBegin(String begin) {
this.begin = begin;
}
public String getEnd() {
return end;
}
@Mandatory
public void setEnd(String end) {
this.end = end;
}
public void addMatchPattern(MatchRule rule) {
if (patterns == null) {
patterns = new ArrayList<>();
}
this.patterns.add(rule);
}
public void addBeginEndPattern(BeginEndRule rule) {
if (patterns == null) {
patterns = new ArrayList<>();
}
this.patterns.add(rule);
}
public String getContentName() {
return contentName;
}
public void setContentName(String contentName) {
this.contentName = contentName;
}
public void addInclude(String include) {
if (patterns == null) {
patterns = new ArrayList<>();
}
this.patterns.add(new IncludeRule(include));
}
public void addBeginEndCapture(Capture c) {
if (beginCaptures == null) {
beginCaptures = new TreeMap<>();
}
beginCaptures.put(c.getGroup(), c);
}
public void addEndCapture(Capture c) {
if (endCaptures == null) {
endCaptures = new TreeMap<>();
}
endCaptures.put(c.getGroup(), c);
}
public void addCapture(Capture c) {
if (captures == null) {
captures = new TreeMap<>();
}
captures.put(c.getGroup(), c);
}
}