From eb02e6cb1d861f8ea63aa9c9006708412126280c Mon Sep 17 00:00:00 2001 From: bryankenote Date: Fri, 1 Dec 2023 08:18:16 -0800 Subject: [PATCH] increase range of field to include type --- .../FsdDocumentSymbolHandler.cs | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Facility.LanguageServer/FsdDocumentSymbolHandler.cs b/src/Facility.LanguageServer/FsdDocumentSymbolHandler.cs index 565e4ec..9acb9f3 100644 --- a/src/Facility.LanguageServer/FsdDocumentSymbolHandler.cs +++ b/src/Facility.LanguageServer/FsdDocumentSymbolHandler.cs @@ -51,12 +51,23 @@ public async Task Handle(DocumentSym maxColumn = Math.Max(maxColumn, childNamePart.EndPosition.ColumnNumber); maxLine = Math.Max(maxLine, childNamePart.EndPosition.LineNumber); + + var childTypePart = child.GetPart(ServicePartKind.TypeName); + var childSymbol = new DocumentSymbol { Name = child.Name, Kind = SymbolKind.Field, - Range = new Range(new Position(childNamePart.Position), new Position(childNamePart.EndPosition)), - SelectionRange = new Range(new Position(childNamePart.Position), new Position(childNamePart.EndPosition)), + Range = new Range( + new Position(childNamePart.Position), + new Position( + new ServiceDefinitionPosition( + child.Name, + childTypePart?.EndPosition.LineNumber ?? childNamePart.EndPosition.LineNumber, + childTypePart?.EndPosition.ColumnNumber ?? childNamePart.EndPosition.ColumnNumber))), + SelectionRange = new Range( + new Position(childNamePart.Position), + new Position(childNamePart.EndPosition)), }; childSymbols.Add(childSymbol); } @@ -73,8 +84,12 @@ public async Task Handle(DocumentSym { Name = child.Name, Kind = SymbolKind.EnumMember, - Range = new Range(new Position(childNamePart.Position), new Position(childNamePart.EndPosition)), - SelectionRange = new Range(new Position(childNamePart.Position), new Position(childNamePart.EndPosition)), + Range = new Range( + new Position(childNamePart.Position), + new Position(childNamePart.EndPosition)), + SelectionRange = new Range( + new Position(childNamePart.Position), + new Position(childNamePart.EndPosition)), }; childSymbols.Add(childSymbol); } @@ -88,8 +103,14 @@ public async Task Handle(DocumentSym Name = member.Name, Kind = symbolKind, - Range = new Range(new Position(new ServiceDefinitionPosition(member.Name, minLine, minColumn)), new Position(new ServiceDefinitionPosition(member.Name, maxLine + 1, maxColumn))), - SelectionRange = new Range(new Position(memberNamePart.Position), new Position(memberNamePart.EndPosition)), + Range = new Range( + new Position( + new ServiceDefinitionPosition(member.Name, minLine, minColumn)), + new Position( + new ServiceDefinitionPosition(member.Name, maxLine + 1, maxColumn))), + SelectionRange = new Range( + new Position(memberNamePart.Position), + new Position(memberNamePart.EndPosition)), Children = childSymbols, }; symbols.Add(symbol);