protected static Set<String> computeRestrictedKeywords(Grammar grammar) { Set<String> keywords = new HashSet<String>(GrammarUtil.getAllKeywords(grammar)); Set<String> unrestrictedNames = getAllKeywords(grammar, "UnrestrictedName"); keywords.removeAll(unrestrictedNames); // printKeywords("Unrestricted", unrestrictedNames); return keywords; }
protected static Set<String> computeKeywords(Grammar grammar) { Set<String> keywords = new HashSet<String>(GrammarUtil.getAllKeywords(grammar)); keywords.removeAll(getAllKeywords(grammar, "UnrestrictedName")); keywords.removeAll(getAllKeywords(grammar, "EssentialOCLReservedKeyword")); keywords.removeAll(getAllKeywords(grammar, "RestrictedKeywords")); keywords.removeAll(getAllKeywords(grammar, "CollectionTypeIdentifier")); keywords.removeAll(getAllKeywords(grammar, "PrimitiveTypeIdentifier")); return keywords; }
public class IDConverter extends AbstractNullSafeConverter<String> { private Set<String> allKeywords = ImmutableSet.copyOf(GrammarUtil.getAllKeywords(getGrammar())); @Override protected String internalToValue(String string, INode node) { return string.replaceAll("[\\^\\s]", ""); } @Override protected String internalToString(String value) { if (allKeywords.contains(value)) return "^" + value; return value; } }
public IDConverter(Grammar grammar) { allKeywords = GrammarUtil.getAllKeywords(grammar); }
@Override protected Set<String> computeValuesToEscape(Grammar grammar) { Set<String> result = Sets.newHashSet(); for (String keyword : GrammarUtil.getAllKeywords(grammar)) result.add(keyword.toLowerCase()); return ImmutableSet.copyOf(result); }