Skip to content

Fix #5237: Do not list <xyz> in scala package completions #5716

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 5 commits into from
Jan 15, 2019
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Definitions {
denot.info = ClassInfo(ScalaPackageClass.thisType, cls, parents, paramDecls)
}
}
newClassSymbol(ScalaPackageClass, name, EmptyFlags, completer).entered
newClassSymbol(ScalaPackageClass, name, Artifact, completer).entered
}

/** The trait FunctionN, ImplicitFunctionN, ErasedFunctionN or ErasedImplicitFunction, for some N
Expand Down
8 changes: 6 additions & 2 deletions compiler/src/dotty/tools/dotc/interactive/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ object Completion {
private[this] val completions = new RenameAwareScope

/**
* Return the list of symbols that shoudl be included in completion results.
* Return the list of symbols that should be included in completion results.
*
* If several symbols share the same name, the type symbols appear before term symbols inside
* the same `Completion`.
Expand Down Expand Up @@ -240,7 +240,9 @@ object Completion {
* 4. have an existing source symbol,
* 5. are the module class in case of packages,
* 6. are mutable accessors, to exclude setters for `var`,
* 7. have same term/type kind as name prefix given so far
* 7. symbol is not a package object
* 8. symbol is not an artifact of the compiler
* 9. have same term/type kind as name prefix given so far
*/
private def include(sym: Symbol, nameInScope: Name)(implicit ctx: Context): Boolean =
nameInScope.startsWith(prefix) &&
Expand All @@ -249,6 +251,8 @@ object Completion {
sym.sourceSymbol.exists &&
(!sym.is(Package) || !sym.moduleClass.exists) &&
!sym.is(allOf(Mutable, Accessor)) &&
!sym.isPackageObject &&
!sym.is(Artifact) &&
(
(mode.is(Mode.Term) && sym.isTerm)
|| (mode.is(Mode.Type) && (sym.isType || sym.isStable))
Expand Down
7 changes: 7 additions & 0 deletions compiler/test/dotty/tools/repl/TabcompleteTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,11 @@ class TabcompleteTests extends ReplTest {
val expected = List("Renamed")
assertEquals(expected, tabComplete("val foo: Rena"))
}

@Test def importScala = fromInitialState { implicit s =>
val comp = tabComplete("import scala.")
// check that there are no special symbols leaked: <byname>, <special-ops>, ...
assertEquals(comp.find(_.startsWith("<")), None)
assert(!comp.contains("package"))
}
}