From 053a2744c6dfa339e004fbdab8994dc435e60b45 Mon Sep 17 00:00:00 2001 From: Luc Bourlier Date: Wed, 13 Nov 2013 17:24:59 +0100 Subject: [nomaster] SI-7280 Scope completion not returning members provided by imports Updates localeContext() to return the best context possible when there are none directly associated with the given position. It happens when an expression cannot be successfully typed, as no precise ContextTree covers the expression location, or if the position is not inside any expression. Adds corresponding tests (cherry picked from commit 3028327e2a2b553b12ee45519413515c8aa0865f) --- .../scope-completion-import/Test.scala | 3 + .../scope-completion-import/src/Completions.scala | 64 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 test/files/presentation/scope-completion-import/Test.scala create mode 100644 test/files/presentation/scope-completion-import/src/Completions.scala (limited to 'test/files/presentation/scope-completion-import') diff --git a/test/files/presentation/scope-completion-import/Test.scala b/test/files/presentation/scope-completion-import/Test.scala new file mode 100644 index 0000000000..bec1131c4c --- /dev/null +++ b/test/files/presentation/scope-completion-import/Test.scala @@ -0,0 +1,3 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest + +object Test extends InteractiveTest \ No newline at end of file diff --git a/test/files/presentation/scope-completion-import/src/Completions.scala b/test/files/presentation/scope-completion-import/src/Completions.scala new file mode 100644 index 0000000000..6e08321283 --- /dev/null +++ b/test/files/presentation/scope-completion-import/src/Completions.scala @@ -0,0 +1,64 @@ +package test + +class C { + def fCCC : Int = 0 +} + +object O extends C { + def fOOO : Int = 0 +} + +class Foo { + { + val o = O + import o._ + /*_*/ + } + { + import O._ + /*_*/ + } + { + val c = new C + import c._ + /*_*/ + } + { + f/*_*/ + val c = new C + import c._ + f/*_*/ + import O._ + f/*_*/ + } +} + +class Foo_1 { + + import O._ + + def bar { + /*_*/ + } +} + +class Foo_2 { + + val o = O + import o._ + + def bar { + /*_*/ + } +} + +class Foo_3 { + + val c = new C + import c._ + + def bar { + /*_*/ + } +} + -- cgit v1.2.3