Skip to content

Commit

Permalink
Fix Span of ProgramSyntax (Azure#954)
Browse files Browse the repository at this point in the history
  • Loading branch information
shenglol authored Nov 20, 2020
1 parent 14ef033 commit 3ceef99
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/Bicep.Core/Syntax/ProgramSyntax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ public ProgramSyntax(IEnumerable<SyntaxBase> children, Token endOfFile, IEnumera
public override void Accept(SyntaxVisitor visitor)
=> visitor.VisitProgramSyntax(this);

public override TextSpan Span => this.Children.Any()
? TextSpan.Between(this.Children.First(), this.EndOfFile)
: this.EndOfFile.Span;

public TextSpan FullSpan => TextSpan.Between(new TextSpan(0, 0), this.EndOfFile);
public override TextSpan Span => TextSpan.Between(new TextSpan(0, 0), this.EndOfFile);

// TODO: Should we have a DeclarationSyntax abstract class?
public IEnumerable<SyntaxBase> Declarations => this.Children.Where(c => c is INamedDeclarationSyntax);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public BicepDocumentFormattingHandler(ILogger<BicepDocumentSymbolHandler> logger

return Task.FromResult<TextEditContainer?>(new TextEditContainer(new TextEdit
{
Range = programSyntax.FullSpan.ToRange(context.LineStarts),
Range = programSyntax.Span.ToRange(context.LineStarts),
NewText = output
}));
}
Expand Down

0 comments on commit 3ceef99

Please sign in to comment.