Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #93 from scala-ide/issue/show-only-accessible-memb…

…ers-1000784

Only show accessible members in the completion lists.
  • Loading branch information...
commit 88040b7aa65e44f4e1d5eef9076c812f7d4868b0 2 parents 2d75b85 + 578c268
@dragos dragos authored
View
28 org.scala-ide.sdt.core.tests/src/scala/tools/eclipse/completion/CompletionTests.scala
@@ -119,6 +119,34 @@ class CompletionTests {
str.replace("(", "").replace(")", "").replace("java.lang.String", "String")
}
+ /**
+ * Test that completion shows only accessible members.
+ */
+ @Test
+ def accessibilityTests() {
+ val oraclePos14 = List("secretPrivate: Unit",
+ "secretProtected: Unit",
+ "secretProtectedInPackage: Unit",
+ "secretPublic: Unit")
+
+ val oraclePos16 = List("secretPrivate: Unit",
+ "secretPrivateThis: Unit",
+ "secretProtected: Unit",
+ "secretProtectedInPackage: Unit",
+ "secretPublic: Unit")
+ val oraclePos22 = List(
+ "secretProtected: Unit",
+ "secretProtectedInPackage: Unit",
+ "secretPublic: Unit")
+ val oraclePos28 = List(
+ "secretProtectedInPackage: Unit",
+ "secretPublic: Unit")
+ val oraclePos37 = List(
+ "secretPublic: Unit")
+
+ runTest("accessibility/AccessibilityTest.scala", true)(oraclePos14, oraclePos16, oraclePos22, oraclePos28, oraclePos37)
+ }
+
@Test
def ticket1000475() {
val oraclePos73 = List("toString(): String")
View
40 ...la-ide.sdt.core.tests/test-workspace/completion/src/accessibility/AccessibilityTest.scala
@@ -0,0 +1,40 @@
+package accessibility {
+
+ class Foo {
+ private def secretPrivate(): Unit
+ private[this] def secretPrivateThis(): Unit
+
+ protected def secretProtected(): Unit
+
+ protected[accessibility] def secretProtectedInPackage(): Unit
+
+ def secretPublic(): Unit
+
+ def someTests(other: Foo) {
+ other.secr /*!*/ // should be all but scretThis
+
+ this.secr /*!*/ // should hit five completions
+ }
+ }
+
+ class AccessibilityChecks extends Foo {
+ def someTests {
+ this.secr /*!*/ // should not list secretPrivate*
+ }
+ }
+
+ class UnrelatedClass {
+ def someTests(foo: Foo) {
+ foo.secr /*!*/ // should list public and protected[accessiblity]
+ }
+ }
+
+}
+
+package other {
+ class SomeChecsk {
+ def foo(o: accessibility.Foo) {
+ o.secr /*!*/ // should only match secretPublic
+ }
+ }
+}
View
4 org.scala-ide.sdt.core/src/scala/tools/eclipse/completion/ScalaCompletions.scala
@@ -60,11 +60,11 @@ class ScalaCompletions extends HasLogger {
compiler.askOption { () =>
for (completion <- completions) {
completion match {
- case compiler.TypeMember(sym, tpe, accessible, inherited, viaView) if !sym.isConstructor && nameMatches(sym) =>
+ case compiler.TypeMember(sym, tpe, true, inherited, viaView) if !sym.isConstructor && nameMatches(sym) =>
val completionProposal= compiler.mkCompletionProposal(start, sym, tpe, inherited, viaView)
if (!isCompletionAlreadyListed(completionProposal))
buff += completionProposal
- case compiler.ScopeMember(sym, tpe, accessible, _) if !sym.isConstructor && nameMatches(sym) =>
+ case compiler.ScopeMember(sym, tpe, true, _) if !sym.isConstructor && nameMatches(sym) =>
val completionProposal= compiler.mkCompletionProposal(start, sym, tpe, false, compiler.NoSymbol)
if (!isCompletionAlreadyListed(completionProposal))
buff += completionProposal
Please sign in to comment.
Something went wrong with that request. Please try again.