public CodeTabView()
        {
            InitializeComponent();

            _shaderTextEditor          = CreateTextEditor();
            _shaderTextEditor.Encoding = System.Text.Encoding.ASCII;
            //	_shaderTextEditor.TextChanged += new EventHandler(_shaderTextEditor_TextChanged);
            //	_shaderTextEditor.Document.TextContentChanged += new EventHandler(Document_TextContentChanged);
            _shaderTextEditor.Document.DocumentChanged += new DocumentEventHandler(Document_DocumentChanged);
            using (var stream = typeof(CodeTabView).Assembly.GetManifestResourceStream("Shazzam.Resources.HLSLSyntax.xshd"))
            {
                using (var reader = new XmlTextReader(stream))
                {
                    var sm = new SyntaxMode("HLSL.xshd", "HLSL", ".fx");
                    _hlslHS = HighlightingDefinitionParser.Parse(sm, reader);
                    _hlslHS.ResolveReferences(); // don't forget this!
                    reader.Close();
                }
            }

            _shaderTextEditor.Document.HighlightingStrategy = _hlslHS;
            this.formsHost.Child = _shaderTextEditor;

            _csTextEditor          = CreateTextEditor();
            this.formsHostCs.Child = _csTextEditor;

            _vbTextEditor          = CreateTextEditor();
            this.formsHostVb.Child = _vbTextEditor;

            _compiler = new ShaderCompiler();
            _compiler.Reset();
            outputTextBox.DataContext = _compiler;
            this.Loaded += CodeTabView_Loaded;
        }
Esempio n. 2
0
        public CodeTabView()
        {
            this.InitializeComponent();

            this.shaderTextEditor          = this.CreateTextEditor();
            this.shaderTextEditor.Encoding = System.Text.Encoding.ASCII;
            //// _shaderTextEditor.TextChanged += new EventHandler(_shaderTextEditor_TextChanged);
            //// _shaderTextEditor.Document.TextContentChanged += new EventHandler(Document_TextContentChanged);
            this.shaderTextEditor.Document.DocumentChanged += this.DocumentDocumentChanged;
            using (var stream = typeof(CodeTabView).Assembly.GetManifestResourceStream("Shazzam.Resources.HLSLSyntax.xshd"))
            {
                if (stream != null)
                {
                    using (var reader = new XmlTextReader(stream))
                    {
                        var sm = new SyntaxMode("HLSL.xshd", "HLSL", ".fx");
                        this.hlslHs = HighlightingDefinitionParser.Parse(sm, reader);
                        this.hlslHs.ResolveReferences(); // don't forget this!
                        reader.Close();
                    }
                }
            }

            this.shaderTextEditor.Document.HighlightingStrategy = this.hlslHs;
            this.FormsHost.Child = this.shaderTextEditor;

            this.csTextEditor      = this.CreateTextEditor();
            this.FormsHostCs.Child = this.csTextEditor;

            this.compiler = new ShaderCompiler();
            this.compiler.Reset();
            this.OutputTextBox.DataContext = this.compiler;
            this.Loaded += this.CodeTabViewLoaded;
        }
Esempio n. 3
0
        IHighlightingStrategy LoadDefinition(DictionaryEntry entry)
        {
            SyntaxMode syntaxMode = (SyntaxMode)entry.Key;
            ISyntaxModeFileProvider syntaxModeFileProvider = (ISyntaxModeFileProvider)entry.Value;

            DefaultHighlightingStrategy highlightingStrategy = null;

            try
            {
                highlightingStrategy = HighlightingDefinitionParser.Parse(syntaxMode, syntaxModeFileProvider.GetSyntaxModeFile(syntaxMode));
                if (highlightingStrategy.Name != syntaxMode.Name)
                {
                    throw new HighlightingDefinitionInvalidException("The name specified in the .xshd '" + highlightingStrategy.Name + "' must be equal the syntax mode name '" + syntaxMode.Name + "'");
                }
            }
            finally
            {
                if (highlightingStrategy == null)
                {
                    highlightingStrategy = DefaultHighlighting;
                }
                highlightingDefs[syntaxMode.Name] = highlightingStrategy;
                highlightingStrategy.ResolveReferences();
            }
            return(highlightingStrategy);
        }
Esempio n. 4
0
        void CreateDefaultHighlightingStrategy()
        {
            DefaultHighlightingStrategy defaultHighlightingStrategy = new DefaultHighlightingStrategy();

            defaultHighlightingStrategy.Extensions = new string[] { };
            defaultHighlightingStrategy.Rules.Add(new HighlightRuleSet());
            highlightingDefs["Default"] = defaultHighlightingStrategy;
        }
Esempio n. 5
0
 public AdvancedHighlightingStrategy(DefaultHighlightingStrategy baseStrategy, IAdvancedHighlighter highlighter)
 {
     if (highlighter == null)
     {
         throw new ArgumentNullException("highlighter");
     }
     ImportSettingsFrom(baseStrategy);
     this.highlighter = highlighter;
 }
Esempio n. 6
0
        public f_main()
        {
            InitializeComponent();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(f_main));
            DefaultHighlightingStrategy defaultHighlightingStrategy1 = new DefaultHighlightingStrategy();
            DefaultTextEditorProperties defaultTextEditorProperties1 = new DefaultTextEditorProperties();

            this.Code_TextEditorControl = new ICSharpCode.TextEditor.TextEditorControl
            {
                Anchor               = (((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right))),
                Encoding             = ((Encoding)(resources.GetObject("Code_TextEditorControl.Encoding"))),
                Location             = new System.Drawing.Point(300, 239),
                Name                 = "Code_TextEditorControl",
                ShowEOLMarkers       = true,
                ShowSpaces           = true,
                ShowTabs             = true,
                ShowVRuler           = true,
                Size                 = new System.Drawing.Size(1050, 500),
                TabIndex             = 4,
                TextEditorProperties = defaultTextEditorProperties1
            };
            defaultHighlightingStrategy1.Extensions             = new string[0];
            defaultTextEditorProperties1.AllowCaretBeyondEOL    = false;
            defaultTextEditorProperties1.AutoInsertCurlyBracket = true;
            defaultTextEditorProperties1.BracketMatchingStyle   = BracketMatchingStyle.After;
            defaultTextEditorProperties1.ConvertTabsToSpaces    = false;
            defaultTextEditorProperties1.CreateBackupCopy       = false;
            defaultTextEditorProperties1.DocumentSelectionMode  = DocumentSelectionMode.Normal;
            defaultTextEditorProperties1.EnableFolding          = true;
            defaultTextEditorProperties1.Encoding             = ((System.Text.Encoding)(resources.GetObject("defaultTextEditorProperties1.Encoding")));
            defaultTextEditorProperties1.Font                 = new System.Drawing.Font("Courier New", 10F);
            defaultTextEditorProperties1.HideMouseCursor      = false;
            defaultTextEditorProperties1.IndentStyle          = IndentStyle.Smart;
            defaultTextEditorProperties1.IsIconBarVisible     = true;
            defaultTextEditorProperties1.LineTerminator       = "\r\n";
            defaultTextEditorProperties1.LineViewerStyle      = LineViewerStyle.None;
            defaultTextEditorProperties1.MouseWheelScrollDown = true;
            defaultTextEditorProperties1.MouseWheelTextZoom   = true;
            defaultTextEditorProperties1.ShowEOLMarker        = true;
            defaultTextEditorProperties1.ShowHorizontalRuler  = false;
            defaultTextEditorProperties1.ShowInvalidLines     = true;
            defaultTextEditorProperties1.ShowLineNumbers      = true;
            defaultTextEditorProperties1.ShowMatchingBracket  = true;
            defaultTextEditorProperties1.ShowSpaces           = true;
            defaultTextEditorProperties1.ShowTabs             = true;
            defaultTextEditorProperties1.ShowVerticalRuler    = true;
            defaultTextEditorProperties1.TabIndent            = 4;
            defaultTextEditorProperties1.UseAntiAliasedFont   = false;
            defaultTextEditorProperties1.UseCustomLine        = false;
            defaultTextEditorProperties1.VerticalRulerRow     = 80;
            this.Controls.Add(this.Code_TextEditorControl);
            this.Code_TextEditorControl.Document.HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("C#");
            this.Code_TextEditorControl.Encoding = Encoding.Default;
            autoConfigSetting = new AutoConfigSetting();
        }
Esempio n. 7
0
        /// <summary>
        /// KAG3独自のカラー設定部分を読み込む
        /// </summary>
        /// <param name="type">設定するカラータイプ</param>
        /// <param name="hs">カラー情報</param>
        private void loadKagTypeColor(KagColorType type, DefaultHighlightingStrategy hs)
        {
            HighlightRuleSet rule;
            ArrayList        spanList;

            //デフォルトルールセットから取得する
            rule     = hs.GetRuleSet(null);
            spanList = rule.Spans;
            foreach (Span span in spanList)
            {
                switch (span.Name)
                {
                case "LineComment":
                    type.Comment = span.Color.Color;
                    break;

                case "TJS2Tag":
                    type.TjsScript = span.Color.Color;
                    break;

                case "KAG3Tag":
                    type.TagName = span.Color.Color;
                    break;

                case "KAG3Label":
                    type.Label = span.Color.Color;
                    break;
                }
            }

            //Kag3Tagルールセットから取得する
            rule     = hs.FindHighlightRuleSet("KAG3TagRuleSet");
            spanList = rule.Spans;
            foreach (Span span in spanList)
            {
                switch (span.Name)
                {
                case "String":
                    type.AttributeValue = span.Color.Color;
                    break;
                }
            }

            //プレマークリストから属性名カラーを取得する
            List <PrevMarker> pmList = rule.PrevMarkList;

            if (pmList.Count > 0)
            {
                type.AttributeName = pmList[0].Color.Color;
            }
        }
Esempio n. 8
0
        private static DefaultHighlightingStrategy GetHighlightingStrategy(string name, XmlDocument doc)
        {
            DefaultHighlightingStrategy highlighter = new DefaultHighlightingStrategy(name);

            if (doc.DocumentElement.HasAttribute("extensions"))
            {
                highlighter.Extensions = doc.DocumentElement.GetAttribute("extensions").Split(new char[] { ';', '|' });
            }

            XmlElement environment = doc.DocumentElement["Environment"];

            if (environment != null)
            {
                foreach (XmlNode node in environment.ChildNodes)
                {
                    if (node is XmlElement)
                    {
                        XmlElement el = (XmlElement)node;
                        if (el.Name == "Custom")
                        {
                            highlighter.SetColorFor(el.GetAttribute("name"), el.HasAttribute("bgcolor") ? new ICSharpCode.TextEditor.Document.HighlightBackground(el) : new ICSharpCode.TextEditor.Document.HighlightColor(el));
                        }
                        else
                        {
                            highlighter.SetColorFor(el.Name, el.HasAttribute("bgcolor") ? new ICSharpCode.TextEditor.Document.HighlightBackground(el) : new ICSharpCode.TextEditor.Document.HighlightColor(el));
                        }
                    }
                }
            }
            if (doc.DocumentElement["Properties"] != null)
            {
                foreach (XmlElement propertyElement in doc.DocumentElement["Properties"].ChildNodes)
                {
                    highlighter.Properties[propertyElement.Attributes["name"].InnerText] = propertyElement.Attributes["value"].InnerText;
                }
            }
            if (doc.DocumentElement["Digits"] != null)
            {
                highlighter.DigitColor = new ICSharpCode.TextEditor.Document.HighlightColor(doc.DocumentElement["Digits"]);
            }
            XmlNodeList nodes = doc.DocumentElement.GetElementsByTagName("RuleSet");

            foreach (XmlElement element in nodes)
            {
                highlighter.AddRuleSet(new ICSharpCode.TextEditor.Document.HighlightRuleSet(element));
            }
            highlighter.ResolveReferences();
            return(highlighter);
        }
Esempio n. 9
0
        /// <summary>
        /// TJS独自のカラーを読み込む
        /// </summary>
        /// <param name="type">セットするカラータイプ</param>
        /// <param name="hs">情報を読み取るカラー情報</param>
        private void loadTjsTypeColor(TjsColorType type, DefaultHighlightingStrategy hs)
        {
            HighlightRuleSet rule;
            ArrayList        spanList;
            HighlightColor   color;

            //デフォルトルールセットから取得する
            rule     = hs.GetRuleSet(null);
            spanList = rule.Spans;
            foreach (Span span in spanList)
            {
                switch (span.Name)
                {
                case "LineComment":
                    type.Comment = span.Color.Color;
                    break;

                case "String":
                    type.String = span.Color.Color;
                    break;

                case "Regexp":
                    type.Regexp = span.Color.Color;
                    break;

                case "Octet":
                    type.Octet = span.Color.Color;
                    break;
                }
            }

            //キーワードの色を取得する
            Dictionary <string, HighlightColor> keywordsList = rule.KeyWordsList;

            color = keywordsList["TJSPreProcessorWords"];
            if (color != null)
            {
                type.PreProcessorKeyWord = color.Color;
            }
            color = keywordsList["TJSKeyWords"];
            if (color != null)
            {
                type.KeyWord = color.Color;
            }
        }
Esempio n. 10
0
        public ICompletionData[] GenerateCompletionList(char key)
        {
            List <ICompletionData> data = new List <ICompletionData>();

            if (key == '#')
            {
                defaultIndex = 0;
                data.Add(new DefaultCompletionData("#import", "import a library (under Lib folder of PAT installation path): #import \"PAT.Lib.Hashtable\";", 1));
                data.Add(new DefaultCompletionData("#include", "include a model (with absolute path or relative path) to the current model: #include \"C:\\example.csp\";", 1));
                data.Add(new DefaultCompletionData("#assert", "define an assertion: #assert process property;", 1));
                data.Add(new DefaultCompletionData("#define", "define a constant or condition: #assert process property", 1));
                data.Add(new DefaultCompletionData("#alphabet", "define an alphabet of a process: #alphabet P {event1, event2,...};", 1));

                if (mainForm.CodeEditor.Document.HighlightingStrategy.Name == "Parameterized Real-Time System Model")
                {
                    data.Add(new DefaultCompletionData("#synthesize", "synthesize the constraints of a model which satisfies a property.", 1));
                }
                else if (mainForm.CodeEditor.Document.HighlightingStrategy.Name == "Probability CSP Model" || mainForm.CodeEditor.Document.HighlightingStrategy.Name == "Probabilistic Real-Time System Model")
                {
                    data.Add(new DefaultCompletionData("#reward", "decleare the rewards of the model.", 1));
                }
            }
            else
            {
                wordTyped    = wordTyped + key;
                defaultIndex = -1;

                DefaultHighlightingStrategy strategy = mainForm.CodeEditor.Document.HighlightingStrategy as DefaultHighlightingStrategy;

                List <LookupTable.Node> keywords = new List <LookupTable.Node>();
                foreach (HighlightRuleSet rule in strategy.Rules)
                {
                    foreach (LookupTable.Node node in rule.KeyWords.GetAllWords())
                    {
                        if (!keywords.Contains(node))
                        {
                            keywords.Add(node);
                        }
                    }
                }

                if (mainForm.Specification != null)
                {
                    if (mainForm.Specification.DeclarationDatabase != null)
                    {
                        foreach (KeyValuePair <string, Expression> pair in mainForm.Specification.DeclarationDatabase)
                        {
                            if (pair.Key.StartsWith(wordTyped) && defaultIndex == -1)
                            {
                                defaultIndex = data.Count;
                            }
                            data.Add(new DefaultCompletionData(pair.Key, pair.Value.ToString(), 3));
                        }
                    }

                    if (mainForm.Specification.GlobalConstantDatabase != null)
                    {
                        foreach (KeyValuePair <string, Expression> pair in mainForm.Specification.GlobalConstantDatabase)
                        {
                            if (pair.Key.StartsWith(wordTyped) && defaultIndex == -1)
                            {
                                defaultIndex = data.Count;
                            }
                            data.Add(new DefaultCompletionData(pair.Key, pair.Value.ToString(), 6));
                        }
                    }


                    foreach (string pair in mainForm.Specification.GetAllProcessNames())
                    {
                        if (pair.StartsWith(wordTyped) && defaultIndex == -1)
                        {
                            defaultIndex = data.Count;
                        }
                        data.Add(new DefaultCompletionData(pair, "Process " + pair, 0));
                    }


                    foreach (string pair in mainForm.Specification.GetGlobalVarNames())
                    {
                        if (pair.StartsWith(wordTyped) && defaultIndex == -1)
                        {
                            defaultIndex = data.Count;
                        }
                        data.Add(new DefaultCompletionData(pair, "Global variable " + pair, 1));
                    }

                    foreach (string pair in mainForm.Specification.GetChannelNames())
                    {
                        if (pair.StartsWith(wordTyped) && defaultIndex == -1)
                        {
                            defaultIndex = data.Count;
                        }
                        data.Add(new DefaultCompletionData(pair, "Global channel " + pair, 2));
                    }
                }

                Color c = Color.FromArgb(43, 145, 175);
                foreach (LookupTable.Node keyword in keywords)
                {
                    if (keyword.word.Length > 1 && keyword.word != "import" && keyword.word != "define" && keyword.word != "alphabet")
                    {
                        if (keyword.word.StartsWith(wordTyped) && defaultIndex == -1)
                        {
                            defaultIndex = data.Count;
                        }

                        if (((HighlightColor)keyword.color).Color == Color.MidnightBlue)
                        {
                            data.Add(new DefaultCompletionData(keyword.word, keyword.description, 0));
                        }
                        else if (((HighlightColor)keyword.color).Color == c)
                        {
                            data.Add(new DefaultCompletionData(keyword.word, keyword.description, 5));
                        }
                        else
                        {
                            data.Add(new DefaultCompletionData(keyword.word, keyword.description, 4));
                        }
                    }
                }
            }

            if (defaultIndex != -1)
            {
                return(data.ToArray());
            }

            return(null);
        }
        /// <summary>
        /// Parses a highlighting definition.
        /// </summary>
        /// <param name="highlighter">The highlighting strategy, which is set.</param>
        /// <param name="syntaxMode">The syntax highlighting mode.</param>
        /// <param name="xmlReader">The XML reader.</param>
        /// <returns></returns>
        private static DefaultHighlightingStrategy Parse(DefaultHighlightingStrategy highlighter, SyntaxMode syntaxMode, XmlReader xmlReader)
        {
            if (syntaxMode == null)
            {
                throw new ArgumentNullException("syntaxMode");
            }

            if (xmlReader == null)
            {
                throw new ArgumentNullException("xmlReader");
            }

            try
            {
                List <ValidationEventArgs> errors   = null;
                XmlReaderSettings          settings = new XmlReaderSettings();
                Stream shemaStream = typeof(HighlightingDefinitionParser).Assembly.GetManifestResourceStream("DigitalRune.Windows.TextEditor.Resources.Mode.xsd");
                settings.Schemas.Add("", new XmlTextReader(shemaStream));
                settings.Schemas.ValidationEventHandler += delegate(object sender, ValidationEventArgs args)
                {
                    if (errors == null)
                    {
                        errors = new List <ValidationEventArgs>();
                    }
                    errors.Add(args);
                };
                settings.ValidationType = ValidationType.Schema;
                XmlReader validatingReader = XmlReader.Create(xmlReader, settings);

                XmlDocument doc = new XmlDocument();
                doc.Load(validatingReader);

                if (highlighter == null)
                {
                    highlighter = new DefaultHighlightingStrategy(doc.DocumentElement.Attributes["name"].InnerText);
                }

                if (doc.DocumentElement.HasAttribute("extends"))
                {
                    KeyValuePair <SyntaxMode, ISyntaxModeFileProvider> entry = HighlightingManager.Manager.FindHighlighterEntry(doc.DocumentElement.GetAttribute("extends"));
                    if (entry.Key == null)
                    {
                        throw new HighlightingDefinitionInvalidException("Cannot find referenced highlighting source " + doc.DocumentElement.GetAttribute("extends"));
                    }
                    else
                    {
                        highlighter = Parse(highlighter, entry.Key, entry.Value.GetSyntaxModeFile(entry.Key));
                        if (highlighter == null)
                        {
                            return(null);
                        }
                    }
                }
                if (doc.DocumentElement.HasAttribute("extensions"))
                {
                    highlighter.Extensions = doc.DocumentElement.GetAttribute("extensions").Split(new char[] { ';', '|' });
                }

                XmlElement environment = doc.DocumentElement["Environment"];
                if (environment != null)
                {
                    foreach (XmlNode node in environment.ChildNodes)
                    {
                        if (node is XmlElement)
                        {
                            XmlElement el = (XmlElement)node;
                            if (el.Name == "Custom")
                            {
                                highlighter.SetColorFor(el.GetAttribute("name"), el.HasAttribute("bgcolor") ? new HighlightBackground(el) : new HighlightColor(el));
                            }
                            else
                            {
                                highlighter.SetColorFor(el.Name, el.HasAttribute("bgcolor") ? new HighlightBackground(el) : new HighlightColor(el));
                            }
                        }
                    }
                }

                // parse properties
                if (doc.DocumentElement["Properties"] != null)
                {
                    foreach (XmlElement propertyElement in doc.DocumentElement["Properties"].ChildNodes)
                    {
                        highlighter.Properties[propertyElement.Attributes["name"].InnerText] = propertyElement.Attributes["value"].InnerText;
                    }
                }

                if (doc.DocumentElement["Digits"] != null)
                {
                    highlighter.DigitColor = new HighlightColor(doc.DocumentElement["Digits"]);
                }

                XmlNodeList nodes = doc.DocumentElement.GetElementsByTagName("RuleSet");
                foreach (XmlElement element in nodes)
                {
                    highlighter.AddRuleSet(new HighlightRuleSet(element));
                }

                xmlReader.Close();

                if (errors != null)
                {
                    StringBuilder msg = new StringBuilder();
                    foreach (ValidationEventArgs args in errors)
                    {
                        msg.AppendLine(args.Message);
                    }
                    throw new HighlightingDefinitionInvalidException(msg.ToString());
                }
                else
                {
                    return(highlighter);
                }
            }
            catch (Exception e)
            {
                throw new HighlightingDefinitionInvalidException("Could not load mode definition file '" + syntaxMode.FileName + "'.\n", e);
            }
        }
Esempio n. 12
0
        public void SetupFixture()
        {
            // Add forms designer addin to the AddInTree.
            bool formsDesignerAddInExists = false;

            foreach (AddIn addIn in AddInTree.AddIns)
            {
                if (addIn.Manifest.Identities.ContainsKey("ICSharpCode.FormsDesigner"))
                {
                    formsDesignerAddInExists = true;
                    break;
                }
            }

            if (!formsDesignerAddInExists)
            {
                formsDesignerAddIn         = AddIn.Load(new StringReader(GetFormsDesignerAddInFile()));
                formsDesignerAddIn.Enabled = true;

                string codeBase = typeof(PythonSyntaxModeTestFixture).Assembly.CodeBase.Replace("file:///", String.Empty);
                string folder   = Path.GetDirectoryName(codeBase);

                Type      type      = formsDesignerAddIn.GetType();
                FieldInfo fieldInfo = type.GetField("addInFileName", BindingFlags.NonPublic | BindingFlags.Instance);
                fieldInfo.SetValue(formsDesignerAddIn, Path.Combine(folder, "FormsDesigner.addin"));
                AddInTree.InsertAddIn(formsDesignerAddIn);
            }

            using (TextReader reader = PythonBindingAddInFile.ReadAddInFile()) {
                addin = AddIn.Load(reader, String.Empty);

                // Get syntax mode codon.
                syntaxModeCodon = null;
                ExtensionPath path = addin.Paths[SyntaxModePath];
                foreach (Codon codon in path.Codons)
                {
                    if (codon.Id == "Python.SyntaxMode")
                    {
                        syntaxModeCodon = codon;
                        break;
                    }
                }

                // Get syntax mode.
                highlightingStrategy = null;
                if (syntaxModeCodon != null)
                {
                    SyntaxModeDoozer    doozer     = new SyntaxModeDoozer();
                    AddInTreeSyntaxMode syntaxMode = (AddInTreeSyntaxMode)doozer.BuildItem(null, syntaxModeCodon, null);
                    highlightingStrategy = HighlightingDefinitionParser.Parse(syntaxMode, syntaxMode.CreateTextReader());

                    // Load Python syntax file into XML document since
                    // we cannot get all the information stored in this
                    // document through the HighlightRuleSet class. For
                    // example KeyWords are only accessible through a
                    // LookupTable does not have a getter which is easy
                    // to use.
                    syntaxModeDocument = new XmlDocument();
                    syntaxModeDocument.Load(syntaxMode.CreateTextReader());

                    // Get default ruleset.
                    foreach (HighlightRuleSet ruleSet in highlightingStrategy.Rules)
                    {
                        if (String.IsNullOrEmpty(ruleSet.Name))
                        {
                            defaultRuleSet = ruleSet;
                            break;
                        }
                    }

                    // Get keywords elements.
                    importsKeyWordsElement             = GetKeyWordsElement("Imports");
                    iterationStatementsKeyWordsElement = GetKeyWordsElement("IterationStatements");
                    jumpStatementsKeyWordsElement      = GetKeyWordsElement("JumpStatements");
                    operatorStatementsKeyWordsElement  = GetKeyWordsElement("OperatorStatements");
                    selectionStatementsKeyWordsElement = GetKeyWordsElement("SelectionStatements");
                    functionDefinitionKeyWordsElement  = GetKeyWordsElement("FunctionDefinition");
                    exceptionHandlingKeyWordsElement   = GetKeyWordsElement("ExceptionHandlingStatements");
                    withStatementKeyWordsElement       = GetKeyWordsElement("WithStatement");
                    passStatementKeyWordsElement       = GetKeyWordsElement("PassStatement");
                    classStatementKeyWordsElement      = GetKeyWordsElement("ClassStatement");
                    builtInStatementsKeyWordsElement   = GetKeyWordsElement("BuiltInStatements");

                    // Get mark previous.
                    markPreviousElement = syntaxModeDocument.SelectSingleNode("//MarkPrevious") as XmlElement;
                }

                // Get line comment span.
                if (defaultRuleSet != null)
                {
                    foreach (Span s in defaultRuleSet.Spans)
                    {
                        if (s.Name == "LineComment")
                        {
                            lineCommentSpan = s;
                        }
                        else if (s.Name == "String")
                        {
                            stringSpan = s;
                        }
                        else if (s.Name == "Char")
                        {
                            charSpan = s;
                        }
                        else if (s.Name == "DocComment")
                        {
                            docCommentSpan = s;
                        }
                        else if (s.Name == "SingleQuoteDocComment")
                        {
                            singleQuoteDocCommentSpan = s;
                        }
                    }
                }
            }
        }