Skip to content

IDE: Strip module suffix, show modules as such #5369

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

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ object DottyLanguageServer {
SK.Package
else if (sym.isConstructor)
SK.Constructor
else if (sym.is(Module))
SK.Module
else if (sym.isClass)
SK.Class
else if (sym.is(Mutable))
Expand All @@ -630,7 +632,7 @@ object DottyLanguageServer {
SK.Field
}

val name = sym.name.show
val name = sym.name.stripModuleClassSuffix.show
val containerName =
if (sym.owner.exists && !sym.owner.isEmptyPackage)
sym.owner.name.show
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,16 @@ class DocumentSymbolTest {
) .documentSymbol(m1, (m1 to m2).symInfo("Foo", SymbolKind.Class))
.documentSymbol(m3, (m3 to m4).symInfo("Bar", SymbolKind.Class))
}

@Test def documentSymbolShowModule: Unit = {
code"""object ${m1}Foo${m2}""".withSource
.documentSymbol(m1, (m1 to m2).symInfo("Foo", SymbolKind.Module))
}

@Test def documentSymbolShowClassAndCompanion: Unit = {
code"""object ${m1}Foo${m2}
class ${m3}Foo${m4}""".withSource
.documentSymbol(m1, (m1 to m2).symInfo("Foo", SymbolKind.Module),
(m3 to m4).symInfo("Foo", SymbolKind.Class))
}
}
12 changes: 12 additions & 0 deletions language-server/test/dotty/tools/languageserver/SymbolTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ class SymbolTest {
) .symbol("Foo", Foo.range.symInfo("Foo", SymbolKind.Class), fooFoo.range.symInfo("Foo", SymbolKind.Class, "foo"))
.symbol("Bar", Bar.range.symInfo("Bar", SymbolKind.Class))
}

@Test def symbolShowModule: Unit = {
code"""object ${m1}Foo${m2}""".withSource
.symbol("Foo", (m1 to m2).symInfo("Foo", SymbolKind.Module))
}

@Test def symbolShowClassAndCompanion: Unit = {
code"""object ${m1}Foo${m2}
class ${m3}Foo${m4}""".withSource
.symbol("Foo", (m1 to m2).symInfo("Foo", SymbolKind.Module),
(m3 to m4).symInfo("Foo", SymbolKind.Class))
}
}