IDEA-155183 Class autocomplete in META-INF.services duplicate packages
authorpeter <peter@jetbrains.com>
Fri, 29 Apr 2016 20:29:24 +0000 (22:29 +0200)
committerpeter <peter@jetbrains.com>
Fri, 29 Apr 2016 20:56:21 +0000 (22:56 +0200)
java/java-impl/src/com/intellij/spi/psi/SPIClassProviderReferenceElement.java
java/java-tests/testSrc/com/intellij/lang/spi/SPICompletionTest.java [new file with mode: 0644]

index 1563adae7bc5c897d2ff872253b16ae9c50be1a5..a4b8f3a8d250e523092387d8abed7273ff55d5d4 100644 (file)
@@ -17,6 +17,7 @@ package com.intellij.spi.psi;
 
 import com.intellij.codeInsight.lookup.LookupElementBuilder;
 import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
 import com.intellij.psi.search.searches.ClassInheritorsSearch;
 import com.intellij.psi.util.ClassUtil;
@@ -35,6 +36,11 @@ public class SPIClassProviderReferenceElement extends SPIPackageOrClassReference
     super(node);
   }
 
+  @Override
+  public TextRange getRangeInElement() {
+    return TextRange.from(0, getTextLength());
+  }
+
   @NotNull
   @Override
   public Object[] getVariants() {
diff --git a/java/java-tests/testSrc/com/intellij/lang/spi/SPICompletionTest.java b/java/java-tests/testSrc/com/intellij/lang/spi/SPICompletionTest.java
new file mode 100644 (file)
index 0000000..3ad0ea4
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.lang.spi;
+
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
+
+/**
+ * @author peter
+ */
+public class SPICompletionTest extends LightCodeInsightFixtureTestCase {
+
+  public void testQualifiedReference() {
+    myFixture.addClass("package com.foo; public class Interface {}");
+    myFixture.addClass("package com.foo; public class Implementation extends Interface {}");
+    myFixture.configureFromExistingVirtualFile(
+      myFixture.addFileToProject("META-INF/services/com.foo.Interface", "com.f<caret>").getVirtualFile());
+    myFixture.completeBasic();
+    myFixture.checkResult("com.foo.Implementation");
+  }
+
+}