-
Notifications
You must be signed in to change notification settings - Fork 316
/
GrammarUtil2.java
39 lines (34 loc) · 1.04 KB
/
GrammarUtil2.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
/**
* Copyright (c) 2015, 2020 itemis AG (http://www.itemis.eu) 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.util;
import java.util.Objects;
import org.eclipse.xtext.Grammar;
import org.eclipse.xtext.GrammarUtil;
public class GrammarUtil2 extends GrammarUtil {
public static final String TERMINALS = "org.eclipse.xtext.common.Terminals";
public static boolean inherits(Grammar grammar, String languageID) {
if (Objects.equals(grammar.getName(), languageID)) {
return true;
}
for (Grammar g : grammar.getUsedGrammars()) {
if (GrammarUtil2.inherits(g, languageID)) {
return true;
}
}
return false;
}
public static Grammar getNonTerminalsSuperGrammar(Grammar grammar) {
for (Grammar g : grammar.getUsedGrammars()) {
if (!TERMINALS.equals(g.getName())) {
return g;
}
}
return null;
}
}