Ejemplo n.º 1
0
        public void ParseModeline(int numLine)
        {
            ITextBuffer buffer   = this.theView.TextBuffer;
            var         snapshot = buffer.CurrentSnapshot;

            if (snapshot.LineCount <= numLine)
            {
                return;
            }
            ILanguage language = langFactory.TryCreateLanguage(snapshot);

            if (language == null)
            {
                return;
            }

            var firstLine = snapshot.GetLineFromLineNumber(numLine);

            ITextChars tc          = new LineChars(firstLine);
            String     commentText = language.NewFirstLineCommentParser().Parse(tc);

            if (String.IsNullOrEmpty(commentText))
            {
                return;
            }
            VsfPackage.LogInfo("Found possible modeline: {0}", commentText);

            var modelineParser = new ModeLineParser();
            var options        = modelineParser.Parse(commentText);

            ApplyModelines(options);
        }
Ejemplo n.º 2
0
        public static ILanguage TryCreateLanguage(this ILanguageFactory factory, IContentType contentType)
        {
            Func <String, bool> matcher = (String lang) => contentType.IsOfType(lang);

            return(factory.TryCreateLanguage(matcher));
        }
Ejemplo n.º 3
0
 public static ILanguage TryCreateLanguage(this ILanguageFactory factory, ITextSnapshot snapshot)
 {
     return(factory.TryCreateLanguage(snapshot.ContentType));
 }
Ejemplo n.º 4
0
 public static ILanguage TryCreateLanguage(this ILanguageFactory factory, ITextBuffer buffer)
 {
     return(factory.TryCreateLanguage(buffer.ContentType));
 }