Example #1
0
        List <NewFolding> CreateNewFoldings(SyntaxTree syntaxTree, IDocument document)
        {
            FoldingVisitor v = new FoldingVisitor();

            v.document = document;
            syntaxTree.AcceptVisitor(v);
            return(v.foldings);
        }
    protected override CodeFoldingResult GetCodeFoldingResult(out int firstErrorOffset) {
      var document = codeEditor.TextEditor.Document;
      var result = new CodeFoldingResult();

      try {
        var foldingContext = new CSharpCodeFoldingContext(document);
        var v = new FoldingVisitor();
        v.document = foldingContext.Document;
        foldingContext.SyntaxTree.AcceptVisitor(v);
        result.FoldingData = v.foldings.OrderBy(x => x.StartOffset).ToList();

        var firstError = foldingContext.SyntaxTree.Errors.FirstOrDefault();
        firstErrorOffset = firstError != null
          ? foldingContext.Document.GetOffset(firstError.Region.Begin)
          : int.MaxValue;
      } catch {
        // ignore exceptions thrown during code folding
        firstErrorOffset = int.MaxValue;
      }

      return result;
    }
Example #3
0
		List<NewFolding> CreateNewFoldings(SyntaxTree syntaxTree, IDocument document)
		{
			FoldingVisitor v = new FoldingVisitor();
			v.document = document;
			syntaxTree.AcceptVisitor(v);
			return v.foldings;
		}