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
 private void ExtractFromLine(IBraceStacker pairs, ITextSnapshotLine line, int lineOffset)
 {
     var lc = new LineChars(line, lineOffset);
       CharPos cp = CharPos.Empty;
       while ( !lc.EndOfLine ) {
     if ( !this.braceScanner.Extract(lc, ref cp) )
       continue;
     MatchBrace(pairs, cp);
       }
       this.LastParsedPosition = line.End;
 }
Ejemplo n.º 3
0
 private void ExtractFromLine(Stack<BracePos> pairs, ITextSnapshotLine line, int lineOffset)
 {
     var lc = new LineChars(line, lineOffset);
       var bracesInLine = this.braceExtractor.Extract(lc) /*.ToArray() */;
       foreach ( var cp in bracesInLine ) {
     if ( IsOpeningBrace(cp) ) {
       BracePos p = cp.AsBrace(pairs.Count);
       pairs.Push(p);
       Add(p);
       // we don't need to check if it's a closing brace
       // because the extractor won't return anything else
     } else if ( pairs.Count > 0 ) {
       BracePos p = pairs.Peek();
       if ( braceList[p.Brace] == cp.Char ) {
     // yield closing brace
     pairs.Pop();
     BracePos c = cp.AsBrace(p.Depth);
     Add(c);
       }
     }
       }
       this.LastParsedPosition = line.End;
 }