Skip to content

Commit

Permalink
Don't throw errors in CodeLensHandler if a node has no title token.
Browse files Browse the repository at this point in the history
Fixes #385.
  • Loading branch information
desplesda committed Dec 3, 2024
1 parent a16c4eb commit 12f6d9a
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public Task<CodeLensContainer> Handle(CodeLensParams request, CancellationToken

var results = yarnFile.NodeDefinitions.SelectMany(titleToken =>
{
if (titleToken.StartIndex == -1)
{
// This is an error token - the node doesn't actually
// have a valid title. Return an empty collection of code
// lenses.
return [];

Check failure on line 40 in YarnSpinner.LanguageServer/src/Server/Handlers/CodeLensHandler.cs

View workflow job for this annotation

GitHub Actions / build

Invalid expression term '['

Check failure on line 40 in YarnSpinner.LanguageServer/src/Server/Handlers/CodeLensHandler.cs

View workflow job for this annotation

GitHub Actions / build

Syntax error; value expected

Check failure on line 40 in YarnSpinner.LanguageServer/src/Server/Handlers/CodeLensHandler.cs

View workflow job for this annotation

GitHub Actions / build

Invalid expression term '['

Check failure on line 40 in YarnSpinner.LanguageServer/src/Server/Handlers/CodeLensHandler.cs

View workflow job for this annotation

GitHub Actions / build

Syntax error; value expected
}

var referenceLocations = ReferencesHandler.GetReferences(project, titleToken.Text, YarnSymbolType.Node);
var count = referenceLocations.Count() - 1; // This is a count of 'other' references, so don't include the declaration

Expand Down

0 comments on commit 12f6d9a

Please sign in to comment.