public XmlHighlightingDefinition(XshdSyntaxDefinition xshd, IHighlightingDefinitionReferenceResolver resolver) { this.Name = xshd.Name; // Create HighlightingRuleSet instances var rnev = new RegisterNamedElementsVisitor(this); xshd.AcceptElements(rnev); // Assign MainRuleSet so that references can be resolved foreach (XshdElement element in xshd.Elements) { XshdRuleSet xrs = element as XshdRuleSet; if (xrs != null && xrs.Name == null) { if (MainRuleSet != null) { throw Error(element, "Duplicate main RuleSet. There must be only one nameless RuleSet!"); } else { MainRuleSet = rnev.ruleSets[xrs]; } } } if (MainRuleSet == null) { throw new HighlightingDefinitionInvalidException("Could not find main RuleSet."); } // Translate elements within the rulesets (resolving references and processing imports) xshd.AcceptElements(new TranslateElementVisitor(this, rnev.ruleSets, resolver)); foreach (var p in xshd.Elements.OfType <XshdProperty>()) { propDict.Add(p.Name, p.Value); } }
public XmlHighlightingDefinition(XshdSyntaxDefinition xshd, IHighlightingDefinitionReferenceResolver resolver) { this.Name = xshd.Name; xshd.AcceptElements(new RegisterNamedElementsVisitor(this)); TranslateElementVisitor translateVisitor = new TranslateElementVisitor(this, resolver); foreach (XshdElement element in xshd.Elements) { HighlightingRuleSet rs = element.AcceptVisitor(translateVisitor) as HighlightingRuleSet; XshdRuleSet xrs = element as XshdRuleSet; if (rs != null && xrs != null && xrs.Name == null) { if (MainRuleSet != null) { throw Error(element, "Duplicate main RuleSet. There must be only one nameless RuleSet!"); } else { MainRuleSet = rs; } } } if (MainRuleSet == null) { throw new HighlightingDefinitionInvalidException("Could not find main RuleSet."); } }
public XmlHighlightingDefinition(XshdSyntaxDefinition xshd, IHighlightingDefinitionReferenceResolver resolver) { this.Name = xshd.Name; // Create HighlightingRuleSet instances var rnev = new RegisterNamedElementsVisitor(this); xshd.AcceptElements(rnev); // Assign MainRuleSet so that references can be resolved foreach (XshdElement element in xshd.Elements) { XshdRuleSet xrs = element as XshdRuleSet; if (xrs != null && xrs.Name == null) { if (MainRuleSet != null) throw Error(element, "Duplicate main RuleSet. There must be only one nameless RuleSet!"); else MainRuleSet = rnev.ruleSets[xrs]; } } if (MainRuleSet == null) throw new HighlightingDefinitionInvalidException("Could not find main RuleSet."); // Translate elements within the rulesets (resolving references and processing imports) xshd.AcceptElements(new TranslateElementVisitor(this, rnev.ruleSets, resolver)); }
/// <summary> /// Writes the specified syntax definition. /// </summary> public void WriteDefinition(XshdSyntaxDefinition definition) { if (definition == null) throw new ArgumentNullException("definition"); writer.WriteStartElement("SyntaxDefinition", Namespace); if (definition.Name != null) writer.WriteAttributeString("name", definition.Name); if (definition.Extensions != null) writer.WriteAttributeString("extensions", string.Join(";", definition.Extensions.ToArray())); definition.AcceptElements(this); writer.WriteEndElement(); }
public XmlHighlightingDefinition(XshdSyntaxDefinition xshd, IHighlightingDefinitionReferenceResolver resolver) { this.Name = xshd.Name; xshd.AcceptElements(new RegisterNamedElementsVisitor(this)); TranslateElementVisitor translateVisitor = new TranslateElementVisitor(this, resolver); foreach (XshdElement element in xshd.Elements) { HighlightingRuleSet rs = element.AcceptVisitor(translateVisitor) as HighlightingRuleSet; XshdRuleSet xrs = element as XshdRuleSet; if (rs != null && xrs != null && xrs.Name == null) { if (MainRuleSet != null) throw Error(element, "Duplicate main RuleSet. There must be only one nameless RuleSet!"); else MainRuleSet = rs; } } if (MainRuleSet == null) throw new HighlightingDefinitionInvalidException("Could not find main RuleSet."); }
/// <summary> /// Writes the specified syntax definition. /// </summary> public void WriteDefinition(XshdSyntaxDefinition definition) { if (definition == null) { throw new ArgumentNullException("definition"); } writer.WriteStartElement("SyntaxDefinition", Namespace); if (definition.Name != null) { writer.WriteAttributeString("name", definition.Name); } if (definition.Extensions != null) { writer.WriteAttributeString("extensions", string.Join(";", definition.Extensions.ToArray())); } definition.AcceptElements(this); writer.WriteEndElement(); }