예제 #1
0
        public LuaSyntaxMode()
        {
            DocumentSet += delegate {
                if (Document == null)
                {
                    return;
                }

                Document.FileNameChanged += delegate {
                    var provider = new ResourceStreamProvider(typeof(LuaSyntaxMode).Assembly, GetSyntaxMode());

                    var reader   = provider.Open();
                    var basemode = SyntaxMode.Read(reader);

                    rules         = new List <Rule>(basemode.Rules);
                    keywords      = new List <Keywords>(basemode.Keywords);
                    spans         = basemode.Spans;
                    matches       = basemode.Matches;
                    prevMarker    = basemode.PrevMarker;
                    SemanticRules = basemode.SemanticRules;
                    keywordTable  = basemode.keywordTable;
                    properties    = basemode.Properties;
                };
            };
        }
예제 #2
0
        public CSharpSyntaxMode()
        {
            var provider = new ResourceXmlProvider(typeof(IXmlProvider).Assembly, typeof(IXmlProvider).Assembly.GetManifestResourceNames().First(s => s.Contains("CSharpSyntaxMode")));

            using (XmlReader reader = provider.Open()) {
                SyntaxMode baseMode = SyntaxMode.Read(reader);
                rules                  = new List <Rule> (baseMode.Rules);
                keywords               = new List <Keywords> (baseMode.Keywords);
                spans                  = new List <Span> (baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
                matches                = baseMode.Matches;
                prevMarker             = baseMode.PrevMarker;
                SemanticRules          = new List <SemanticRule> (baseMode.SemanticRules);
                keywordTable           = baseMode.keywordTable;
                keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
                properties             = baseMode.Properties;
            }

            foreach (var word in ContextualHighlightKeywordList)
            {
                contextualHighlightKeywords[word] = keywordTable[word].Color;
                keywordTable.Remove(word);
            }

            AddSemanticRule("Comment", new HighlightUrlSemanticRule("comment"));
            AddSemanticRule("XmlDocumentation", new HighlightUrlSemanticRule("comment"));
            AddSemanticRule("String", new HighlightUrlSemanticRule("string"));
        }
예제 #3
0
        public DietTemplateSyntaxMode()
        {
            var matches = new List <Match>();

            if (baseMode == null)
            {
                var provider = new ResourceStreamProvider(
                    typeof(DietTemplateSyntaxMode).Assembly,
                    typeof(DietTemplateSyntaxMode).Assembly.GetManifestResourceNames().First(s => s.Contains("DietTemplateSyntaxDefinition")));
                using (var s = provider.Open())
                    baseMode = SyntaxMode.Read(s);
            }

            this.rules    = new List <Rule>(baseMode.Rules);
            this.keywords = new List <Keywords>(baseMode.Keywords);
            this.spans    = new List <Span>(baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
            matches.AddRange(baseMode.Matches);
            this.prevMarker    = baseMode.PrevMarker;
            this.SemanticRules = new List <SemanticRule>(baseMode.SemanticRules);
            SemanticRules.Add(InlineDHighlighting.Instance);
            this.keywordTable           = baseMode.keywordTable;
            this.keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
            this.properties             = baseMode.Properties;

            // D Number literals
            matches.Add(DSyntaxMode.workaroundMatchCtor(
                            "Number"
                            , @"				(?<!\w)(0((x|X)[0-9a-fA-F_]+|(b|B)[0-1_]+)|([0-9]+[_0-9]*)[L|U|u|f|i]*)"));

            this.matches = matches.ToArray();
        }
예제 #4
0
        /// <summary>
        /// Performs a one-time registration of the report syntax highlighting rules.
        /// This will only run once, the first time the user clicks on a report node.
        /// </summary>
        private void LoadReportSyntaxMode()
        {
            string resource = "ApsimNG.Resources.SyntaxHighlighting.Report.xml";

            using (System.IO.Stream s = GetType().Assembly.GetManifestResourceStream(resource))
            {
                ProtoTypeSyntaxModeProvider p = new ProtoTypeSyntaxModeProvider(SyntaxMode.Read(s));
                SyntaxModeService.InstallSyntaxMode("text/x-apsimreport", p);
            }
        }
예제 #5
0
        public AspNetSyntaxMode()
        {
            ResourceXmlProvider provider = new ResourceXmlProvider(typeof(IXmlProvider).Assembly, "AspNetSyntaxMode.xml");

            using (XmlReader reader = provider.Open()) {
                SyntaxMode baseMode = SyntaxMode.Read(reader);
                this.rules         = new List <Rule> (baseMode.Rules);
                this.keywords      = new List <Keywords> (baseMode.Keywords);
                this.spans         = baseMode.Spans;
                this.matches       = baseMode.Matches;
                this.prevMarker    = baseMode.PrevMarker;
                this.SemanticRules = new List <SemanticRule> (baseMode.SemanticRules);
                this.table         = baseMode.Table;
            }
        }
예제 #6
0
        public GherkinSyntaxMode()
        {
            ResourceStreamProvider provider = new ResourceStreamProvider(typeof(GherkinSyntaxMode).Assembly, "GherkinSyntaxHighlightingMode.xml");

            using (var reader = provider.Open()) {
                SyntaxMode baseMode = SyntaxMode.Read(reader);
                this.rules                  = new List <Rule> (baseMode.Rules);
                this.keywords               = new List <Keywords> (baseMode.Keywords);
                this.spans                  = baseMode.Spans;
                this.matches                = baseMode.Matches;
                this.prevMarker             = baseMode.PrevMarker;
                this.SemanticRules          = new List <SemanticRule> (baseMode.SemanticRules);
                this.keywordTable           = baseMode.keywordTable;
                this.keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
            }
        }
        void Init()
        {
            var provider = new ResourceStreamProvider(typeof(CoffeeScriptSyntaxMode).Assembly, "MonoDevelop.CoffeeScript.CoffeeScriptSyntaxMode.xml");

            using (var reader = provider.Open()) {
                var baseMode = SyntaxMode.Read(reader);

                this.rules         = new System.Collections.Generic.List <Rule> (baseMode.Rules);
                this.keywords      = new System.Collections.Generic.List <Mono.TextEditor.Highlighting.Keywords> (baseMode.Keywords);
                this.spans         = baseMode.Spans;
                this.matches       = baseMode.Matches;
                this.prevMarker    = baseMode.PrevMarker;
                this.SemanticRules = new System.Collections.Generic.List <Mono.TextEditor.SemanticRule>(baseMode.SemanticRules);
                this.keywordTable  = baseMode.keywordTable;
                this.properties    = baseMode.Properties;
            }
        }
예제 #8
0
        public RazorSyntaxMode(Document doc)
        {
            this.guiDocument            = doc;
            guiDocument.DocumentParsed += HandleDocumentParsed;
            ResourceStreamProvider provider = new ResourceStreamProvider(typeof(ResourceStreamProvider).Assembly, "RazorSyntaxMode.xml");

            using (var reader = provider.Open()) {
                SyntaxMode baseMode = SyntaxMode.Read(reader);
                this.rules                  = new List <Rule> (baseMode.Rules);
                this.keywords               = new List <Keywords> (baseMode.Keywords);
                this.spans                  = baseMode.Spans;
                this.matches                = baseMode.Matches;
                this.prevMarker             = baseMode.PrevMarker;
                this.SemanticRules          = new List <SemanticRule> (baseMode.SemanticRules);
                this.keywordTable           = baseMode.keywordTable;
                this.keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
            }
        }
예제 #9
0
        public DSyntaxMode()
        {
            var matches = new List <Match>();

            if (baseMode == null)
            {
                var provider = new ResourceStreamProvider(
                    typeof(DSyntaxMode).Assembly,
                    typeof(DSyntaxMode).Assembly.GetManifestResourceNames().First(s => s.Contains("DSyntaxHighlightingMode")));
                using (Stream s = provider.Open())
                    baseMode = SyntaxMode.Read(s);
            }

            this.rules    = new List <Rule>(baseMode.Rules);
            this.keywords = new List <Keywords>(baseMode.Keywords);
            this.spans    = new List <Span>(baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
            matches.AddRange(baseMode.Matches);
            this.prevMarker             = baseMode.PrevMarker;
            this.SemanticRules          = new List <SemanticRule>(baseMode.SemanticRules);
            this.keywordTable           = baseMode.keywordTable;
            this.keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
            this.properties             = baseMode.Properties;

            // D Number literals
            matches.Add(workaroundMatchCtor(
                            "Number"
                            , @"(?<!\w)(0((x|X)[0-9a-fA-F_]+|(b|B)[0-1_]+)|([0-9]+[_0-9]*)[L|U|u|f|i]*)"));

            // extern linkages attributes
            //matches.Add(workaroundMatchCtor("constant.digit", "(?<=extern[\\s]*\\()[\\s]*(C(\\+\\+)?|D|Windows|System|Pascal|Java)[\\s]*(?=\\))"));

            // version checks
            //matches.Add(workaroundMatchCtor("constant.digit", @"(?<=version[\s]*\()[\s]*(DigitalMars|GNU|LDC|Windows|OSX|linux|FreeBSD|OpenBSD|BSD|Solaris|Posix|D_Version2)[\s]*(?=\))"));

            // type declaration names
            //matches.Add(workaroundMatchCtor("keyword.semantic.type", @"(?<=(class|struct|union|interface|template)[\s]+)[\w]+"));

            SemanticHighlightingEnabled         = PropertyService.Get("EnableSemanticHighlighting", true);
            PropertyService.PropertyChanged    += HandlePropertyChanged;
            GlobalParseCache.ParseTaskFinished += GlobalParseCacheFilled;

            this.matches = matches.ToArray();
        }
예제 #10
0
        public CSharpSyntaxMode()
        {
            ResourceXmlProvider provider = new ResourceXmlProvider(typeof(IXmlProvider).Assembly, typeof(IXmlProvider).Assembly.GetManifestResourceNames().First(s => s.Contains("CSharpSyntaxMode")));

            using (XmlReader reader = provider.Open()) {
                SyntaxMode baseMode = SyntaxMode.Read(reader);
                this.rules         = new List <Rule> (baseMode.Rules);
                this.keywords      = new List <Keywords> (baseMode.Keywords);
                this.spans         = new List <Span> (baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
                this.matches       = baseMode.Matches;
                this.prevMarker    = baseMode.PrevMarker;
                this.SemanticRules = new List <SemanticRule> (baseMode.SemanticRules);
                this.table         = baseMode.Table;
                this.properties    = baseMode.Properties;
            }

            AddSemanticRule("Comment", new HighlightUrlSemanticRule("comment"));
            AddSemanticRule("XmlDocumentation", new HighlightUrlSemanticRule("comment"));
            AddSemanticRule("String", new HighlightUrlSemanticRule("string"));
            AddSemanticRule(new HighlightCSharpSemanticRule());
        }
예제 #11
0
        public SlimTemplateSyntaxMode()
        {
            List <Match> list = new List <Match>();

            if (SlimTemplateSyntaxMode.baseMode == null)
            {
                ResourceStreamProvider resourceStreamProvider = new ResourceStreamProvider(typeof(SlimTemplateSyntaxMode).Assembly, typeof(SlimTemplateSyntaxMode).Assembly.GetManifestResourceNames().First(s => s.Contains("SlimTemplateSyntaxMode")));
                using (Stream stream = resourceStreamProvider.Open())
                {
                    SlimTemplateSyntaxMode.baseMode = SyntaxMode.Read(stream);
                }
            }
            this.rules    = new List <Rule>(SlimTemplateSyntaxMode.baseMode.Rules);
            this.keywords = new List <Keywords>(SlimTemplateSyntaxMode.baseMode.Keywords);
            this.spans    = SlimTemplateSyntaxMode.baseMode.Spans.Where(s => s.Begin.Pattern != "#").ToArray();
            list.AddRange(SlimTemplateSyntaxMode.baseMode.Matches);
            this.prevMarker             = SlimTemplateSyntaxMode.baseMode.PrevMarker;
            this.SemanticRules          = new List <SemanticRule> (SlimTemplateSyntaxMode.baseMode.SemanticRules);
            this.keywordTable           = SlimTemplateSyntaxMode.baseMode.keywordTable;
            this.keywordTableIgnoreCase = SlimTemplateSyntaxMode.baseMode.keywordTableIgnoreCase;
            this.properties             = SlimTemplateSyntaxMode.baseMode.Properties;
            list.Add(DSyntaxMode.workaroundMatchCtor("Number", "\t\t\t\t(?<!\\w)(0((x|X)[0-9a-fA-F_]+|(b|B)[0-1_]+)|([0-9]+[_0-9]*)[L|U|u|f|i]*)"));
            this.matches = list.ToArray();
        }
예제 #12
0
        public CSharpSyntaxMode(Document document)
        {
            this.guiDocument                 = document;
            guiDocument.DocumentParsed      += HandleDocumentParsed;
            SemanticHighlightingEnabled      = PropertyService.Get("EnableSemanticHighlighting", true);
            PropertyService.PropertyChanged += HandlePropertyChanged;
            if (guiDocument.ParsedDocument != null)
            {
                HandleDocumentParsed(this, EventArgs.Empty);
            }

            bool loadRules = _rules == null;

            if (loadRules)
            {
                var provider = new ResourceStreamProvider(typeof(ResourceStreamProvider).Assembly, typeof(ResourceStreamProvider).Assembly.GetManifestResourceNames().First(s => s.Contains("CSharpSyntaxMode")));
                using (var reader = provider.Open()) {
                    SyntaxMode baseMode = SyntaxMode.Read(reader);
                    _rules = new List <Rule> (baseMode.Rules.Where(r => r.Name != "Comment"));
                    _rules.Add(new Rule {
                        Name = "PreProcessorComment"
                    });

                    _commentRule = new Rule {
                        Name       = "Comment",
                        IgnoreCase = true
                    };
                    UpdateCommentRule();

                    _rules.Add(_commentRule);
                    _keywords               = new List <Keywords> (baseMode.Keywords);
                    _spans                  = new List <Span> (baseMode.Spans.Where(span => span.Begin.Pattern != "#")).ToArray();
                    _matches                = baseMode.Matches;
                    _prevMarker             = baseMode.PrevMarker;
                    _SemanticRules          = new List <SemanticRule> (baseMode.SemanticRules);
                    _keywordTable           = baseMode.keywordTable;
                    _keywordTableIgnoreCase = baseMode.keywordTableIgnoreCase;
                    _properties             = baseMode.Properties;
                }

                contextualHighlightKeywords = new Dictionary <string, string> ();
                foreach (var word in ContextualKeywords)
                {
                    if (_keywordTable.ContainsKey(word))
                    {
                        contextualHighlightKeywords[word] = _keywordTable[word].Color;
                    }
                    else
                    {
                        Console.WriteLine("missing keyword:" + word);
                    }
                }

                foreach (var word in ContextualKeywords)
                {
                    _keywordTable.Remove(word);
                }
            }

            rules                  = _rules;
            keywords               = _keywords;
            spans                  = _spans;
            matches                = _matches;
            prevMarker             = _prevMarker;
            SemanticRules          = _SemanticRules;
            keywordTable           = _keywordTable;
            keywordTableIgnoreCase = _keywordTableIgnoreCase;
            properties             = _properties;

            if (loadRules)
            {
                AddSemanticRule("Comment", new HighlightUrlSemanticRule("Comment(Line)"));
                AddSemanticRule("XmlDocumentation", new HighlightUrlSemanticRule("Comment(Doc)"));
                AddSemanticRule("String", new HighlightUrlSemanticRule("String"));
            }
        }
예제 #13
0
파일: SqlEditor.cs 프로젝트: aaberg/DbUtils
        private SyntaxMode loadSyntaxMode()
        {
            var syntaxModeStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DbUtils.UI.SyntaxModes.SqliteSyntaxMode.xml");

            return(SyntaxMode.Read(syntaxModeStream));
        }