Skip to content

Commit 6a5a659

Browse files
Hide document symbols without spans (#1101)
During `ExplicitCapabilities`, we asssign some symbols for the explicitly passed capabilities (as additional block params). It might be interesting to add spans to them in the future and maybe even show them as (optional) inlay hints for educational purposes. However, in this PR, I just hide them from the list of document symbols for now, which has previously been cluttered by them.
1 parent 44bc7f4 commit 6a5a659

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

effekt/jvm/src/main/scala/effekt/Server.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import effekt.Intelligence.CaptureInfo
55
import effekt.context.Context
66
import effekt.source.Def.FunDef
77
import effekt.source.Term.Hole
8-
import effekt.source.{Span, Tree}
8+
import effekt.source.{Origin, Span, Tree}
99
import effekt.symbols.Binder.{ValBinder, VarBinder}
1010
import effekt.symbols.BlockTypeConstructor.{ExternInterface, Interface}
1111
import effekt.symbols.TypeConstructor.{DataType, ExternType}
@@ -289,10 +289,10 @@ class Server(config: EffektConfig, compileOnChange: Boolean=false) extends Langu
289289
decl <- getSourceTreeFor(sym)
290290
kind <- getSymbolKind(sym)
291291
detail <- getInfoOf(sym)(using context)
292+
if decl.span.origin != Origin.Missing
292293
declRange = convertRange(decl.span.range)
293294
idRange = convertRange(id.span.range)
294295
} yield new DocumentSymbol(sym.name.name, kind, declRange, idRange, detail.header)
295-
296296
val result = Collections.seqToJavaList(
297297
documentSymbols.map(sym => messages.Either.forRight[SymbolInformation, DocumentSymbol](sym))
298298
)

effekt/jvm/src/test/scala/effekt/LSPTests.scala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,8 @@ class LSPTests extends FunSuite {
625625

626626
val params = new DocumentSymbolParams()
627627
params.setTextDocument(textDoc.versionedTextDocumentIdentifier)
628-
629-
val documentSymbols = server.getTextDocumentService().documentSymbol(params).get()
630-
// FIXME: The server currently returns spurious symbols at position (0, 0) that we need to filter out.
631-
val filtered = server.getTextDocumentService().documentSymbol(params).get().asScala.filter {
632-
symbol => symbol.getRight.getRange.getStart != new Position(0, 0) && symbol.getRight.getRange.getEnd != new Position(0, 0)
633-
}.asJava
634-
635-
assertEquals(filtered, expectedSymbols.asJava)
628+
val actualSymbols = server.getTextDocumentService().documentSymbol(params).get()
629+
assertEquals(actualSymbols, expectedSymbols.asJava)
636630
}
637631
}
638632

0 commit comments

Comments
 (0)