override protected Raw NewRaw(string type)
    {
        string file = scanner.GetSyntaxFileByName(type);

        if (string.IsNullOrEmpty(file))
        {
            if (mainForm.Dialogs != null)
            {
                mainForm.Dialogs.ShowInfo("Syntax highlighting", "Missing syntax: " + type);
            }
            return(null);
        }
        XmlDocument xml = xmlLoader.Load(file, false);
        Raw         raw = Raw.Parse(xml);

        Raw.PrefixContexts(raw, type);
        Raw.InlineIncludeRules(raw, this);
        return(raw);
    }
Пример #2
0
        public void PrefixContexts()
        {
            XmlDocument xml = new XmlDocument();

            xml.LoadXml(@"<?xml version='1.0' encoding='UTF-8'?>
				<language name='test' extensions='*.test'>
				    <highlighting>
				        <list name='keywords0'>
				            <item>word0</item>
				            <item>word1</item>
				        </list>
				        <contexts>
				            <context attribute='a0' lineEndContext='#stay' name='Normal'>
				                <keyword attribute='a1' context='#stay' String='keywords0'/>
								<IncludeRules context='IncludeContext'/>
								<IncludeRules context='##Syntax file'/>
				            </context>
							<context attribute='a2' lineEndContext='#stay' name='IncludeContext'>
								<StringDetect attribute='a3' context='#pop!State name1' String='include'/>
							</context>
							<context attribute='a2' lineEndContext='State name2' name='State name1'>
								<StringDetect attribute='a3' context='#pop!State name1' String='include'/>
							</context>
				        </contexts>
				        <itemDatas>
				            <itemData name='a0' defStyleNum='dsNormal'/>
				            <itemData name='a1' defStyleNum='dsKeyword'/>
				            <itemData name='a2' defStyleNum='dsDataType'/>
				            <itemData name='a3' defStyleNum='dsChar'/>
				        </itemDatas>
				    </highlighting>
				</language>"                );
            Raw raw = Raw.Parse(xml);

            Raw.PrefixContexts(raw, "prefix_");
            Assert.AreEqual("<language>" +
                            "<highlighting>" +
                            "<list name='prefix_keywords0'>" +
                            "<item>word0</item>" +
                            "<item>word1</item>" +
                            "</list>" +
                            "<contexts>" +
                            "<context name='prefix_Normal' attribute='prefix_a0' lineEndContext='#stay'>" +
                            "<keyword attribute='prefix_a1' context='#stay' String='prefix_keywords0'/>" +
                            "<IncludeRules context='prefix_IncludeContext'/>" +
                            "<IncludeRules context='##Syntax file'/>" +
                            "</context>" +
                            "<context name='prefix_IncludeContext' attribute='prefix_a2' lineEndContext='#stay'>" +
                            "<StringDetect attribute='prefix_a3' context='#pop!prefix_State name1' String='include'/>" +
                            "</context>" +
                            "<context name='prefix_State name1' attribute='prefix_a2' lineEndContext='prefix_State name2'>" +
                            "<StringDetect attribute='prefix_a3' context='#pop!prefix_State name1' String='include'/>" +
                            "</context>" +
                            "</contexts>" +
                            "<itemDatas>" +
                            "<itemData name='prefix_a0' defStyleNum='dsNormal'/>" +
                            "<itemData name='prefix_a1' defStyleNum='dsKeyword'/>" +
                            "<itemData name='prefix_a2' defStyleNum='dsDataType'/>" +
                            "<itemData name='prefix_a3' defStyleNum='dsChar'/>" +
                            "</itemDatas>" +
                            "</highlighting>" +
                            "<general>" +
                            "<keywords/>" +
                            "</general>" +
                            "</language>", raw.ToString());
        }