-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LSP Folding Ranges #79
Open
nhett
wants to merge
9
commits into
anytext
Choose a base branch
from
LSP-folding-ranges
base: anytext
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
075f2d5
Folding ranges for comments, imports, regions and other sequences enc…
nhett 2bb1a81
Comment change tests for folding ranges
nhett 7e70fd4
adjusted sequence rule to formatting refactoring
georghinkel 682baf2
Rebase fix
nhett 796f6a3
Consider multiple singleline comments in succession for folding range…
nhett 8e6a201
Add folding capabilities for other rules as well
nhett 0910f88
Move folding range parsing to rule applications, improved tests, docu…
nhett 3c4920e
Moved remaining case distinctions for folding ranges from rule applic…
nhett 6063a19
Minor folding range column fix
nhett File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NMF.AnyText | ||
{ | ||
/// <summary> | ||
/// Denotes a part in a parsed document that can be folded away (hidden). | ||
/// Analogous to the LspTypes FoldingRange interface. | ||
/// </summary> | ||
public class FoldingRange | ||
{ | ||
/// <summary> | ||
/// The zero-based start line of the range to fold. The folded area starts | ||
/// after the line's last character. To be valid, the end must be zero or | ||
/// larger and smaller than the number of lines in the document. | ||
/// </summary> | ||
public uint StartLine { get; set; } | ||
|
||
/// <summary> | ||
/// The zero-based character offset from where the folded range starts. | ||
/// If not defined, defaults to the length of the start line. | ||
/// </summary> | ||
public uint StartCharacter { get; set; } | ||
|
||
/// <summary> | ||
/// The zero-based end line of the range to fold. The folded area ends with | ||
/// the line's last character. To be valid, the end must be zero or larger | ||
/// and smaller than the number of lines in the document. | ||
/// </summary> | ||
public uint EndLine { get; set; } | ||
|
||
/// <summary> | ||
/// The zero-based character offset before the folded range ends. | ||
/// If not defined, defaults to the length of the end line. | ||
/// </summary> | ||
public uint EndCharacter { get; set; } | ||
|
||
/// <summary> | ||
/// Describes the kind of the folding range. | ||
/// Supports values "comment", "imports" and "region". | ||
/// </summary> | ||
public string Kind { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using NMF.AnyText.Model; | ||
using NMF.AnyText.Rules; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml.XPath; | ||
|
||
namespace NMF.AnyText | ||
{ | ||
public partial class Parser | ||
{ | ||
/// <summary> | ||
/// Parses folding ranges starting from the root rule application | ||
/// </summary> | ||
/// <returns>An IEnumerable of <see cref="FoldingRange"/> objects, each containing details on a folding range in the document.</returns> | ||
public IEnumerable<FoldingRange> GetFoldingRangesFromRoot() | ||
{ | ||
RuleApplication rootApplication = Context.RootRuleApplication; | ||
|
||
if (rootApplication.IsPositive) | ||
{ | ||
var result = new List<FoldingRange>(); | ||
rootApplication.AddFoldingRanges(result); | ||
return result; | ||
} | ||
|
||
return Enumerable.Empty<FoldingRange>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using LspTypes; | ||
using Newtonsoft.Json.Linq; | ||
using StreamJsonRpc; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NMF.AnyText | ||
{ | ||
public partial interface ILspServer | ||
{ | ||
/// <summary> | ||
/// Handles the <c>textDocument/foldingRange/full</c> request from the client. This is used to retrieve all folding ranges for a document. | ||
/// </summary> | ||
/// <param name="arg">The JSON token containing the parameters of the request. (FoldingRangeParams)</param> | ||
/// <returns>An array of <see cref="FoldingRange" /> objects, each containing details on a folding range in the document.</returns> | ||
[JsonRpcMethod(Methods.TextDocumentFoldingRangeName)] | ||
LspTypes.FoldingRange[] QueryFoldingRanges(JToken arg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sehe ich das richtig, dass wir hier davon ausgehen, wenn es ein Multiline Comment ist, dann gibt es genau einen, sonst könnte es mehrere geben?