///////////////////////////////////////////////////////////////////////////////////////////////////// // OBJECT ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes a new instance of the <c>SimpleOutliningSource</c> class. /// </summary> /// <param name="snapshot">The <see cref="ITextSnapshot"/> to use for this outlining source.</param> /// <param name="parseData">The <see cref="ILLParseData"/> containing AST data.</param> public SimpleOutliningSource(ITextSnapshot snapshot, ILLParseData parseData) : base(snapshot) { if (parseData == null) { throw new ArgumentNullException("parseData"); } // Create a 'Function' outlining node definition if one hasn't yet been created if (functionDefinition == null) { functionDefinition = new OutliningNodeDefinition("Function"); functionDefinition.IsImplementation = true; } Step4d.CompilationUnit compilationUnit = parseData.Ast as Step4d.CompilationUnit; if ((compilationUnit != null) && (compilationUnit.HasMembers)) { // Loop through AST nodes foreach (Step4d.FunctionDeclaration functionAstNode in compilationUnit.Members) { // If the function declaration has a body with a text range... if ((functionAstNode.Body != null) && (functionAstNode.Body.StartOffset.HasValue) && (functionAstNode.Body.EndOffset.HasValue)) { // Add an outlining node this.AddNode(new TextRange(functionAstNode.Body.StartOffset.Value, functionAstNode.Body.EndOffset.Value), functionDefinition); } } } }
///////////////////////////////////////////////////////////////////////////////////////////////////// // OBJECT ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes the <c>JavascriptOutliningSource</c> class. /// </summary> static JavascriptOutliningSource() { // Create the outlining node definitions that will be used by this outlining source to // tell the document's outlining manager how to create new outlining nodes... curlyBraceDefinition = new OutliningNodeDefinition("CurlyBrace"); curlyBraceDefinition.IsImplementation = true; multiLineCommentDefinition = new MultiLineCommentNodeDefinition(); }
private void AddOutliningNode(ITextSnapshot snapshot, IAstNode node, OutliningNodeDefinition outliningNodeDefinition) { if (!node.StartOffset.HasValue || !node.EndOffset.HasValue) return; var startPosition = snapshot.OffsetToPosition(node.StartOffset.Value); var endPosition = snapshot.OffsetToPosition(node.EndOffset.Value); if (startPosition.Line != endPosition.Line) AddNode(new TextRange(node.StartOffset.Value + 1, node.EndOffset.Value - 1), outliningNodeDefinition); }
private void AddOutliningNode(ITextSnapshot snapshot, IAstNode node, OutliningNodeDefinition outliningNodeDefinition) { if (!node.StartOffset.HasValue || !node.EndOffset.HasValue) { return; } var startPosition = snapshot.OffsetToPosition(node.StartOffset.Value); var endPosition = snapshot.OffsetToPosition(node.EndOffset.Value); if (startPosition.Line != endPosition.Line) { AddNode(new TextRange(node.StartOffset.Value + 1, node.EndOffset.Value - 1), outliningNodeDefinition); } }
///////////////////////////////////////////////////////////////////////////////////////////////////// // OBJECT ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes the <c>JavascriptOutliningSource</c> class. /// </summary> static JavascriptOutliningSource() { // Create the outlining node definitions that will be used by this outlining source to // tell the document's outlining manager how to create new outlining nodes... // Each definition can indicate options such as: // 1) Whether the node is an implementation and will be collapsed when "Collapse to Definitions" is clicked // 2) The default collapsed content for the node that appears in the in-line collapsed node box // 3) If the node should be collapsed by default when loading a file, such as for #region type nodes // 4) If the node is collapsible... when false, no UI appears for the node in the margin curlyBraceDefinition = new OutliningNodeDefinition("CurlyBrace"); curlyBraceDefinition.IsImplementation = true; multiLineCommentDefinition = new OutliningNodeDefinition("MultiLineComment"); multiLineCommentDefinition.DefaultCollapsedContent = "/**/"; multiLineCommentDefinition.IsImplementation = true; }
public NQueryOutliningSource(ITextSnapshot snapshot, SyntaxTree syntaxTree, ImmutableArray <IOutliner> outliners) : base(snapshot) { var text = syntaxTree.Text; var result = syntaxTree.Root.FindRegions(outliners); foreach (var regionSpan in result) { var range = text.ToSnapshotRange(regionSpan.Span); IOutliningNodeDefinition nodeDefinition = new OutliningNodeDefinition(@"NQueryNode") { DefaultCollapsedContent = regionSpan.Text, IsImplementation = false }; AddNode(range, nodeDefinition); } }
static JsonOutliningSource() { squareBraceDefinition = new OutliningNodeDefinition("SquareBrace"); curlyBraceDefinition = new OutliningNodeDefinition("CurlyBrace"); }