- KT-1227 Can't see basic types in class completion
- Remove duplicated test
This commit is contained in:
@@ -74,10 +74,10 @@ public class JetCompletionContributor extends CompletionContributor {
|
|||||||
@NotNull final Project project) {
|
@NotNull final Project project) {
|
||||||
|
|
||||||
if (variant instanceof LookupElement) {
|
if (variant instanceof LookupElement) {
|
||||||
addCompletionToResult(result, (LookupElement) variant, positions, project);
|
addCompletionToResult(result, (LookupElement) variant, positions);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
addCompletionToResult(result, LookupElementBuilder.create(variant.toString()), positions, project);
|
addCompletionToResult(result, LookupElementBuilder.create(variant.toString()), positions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ public class JetCompletionContributor extends CompletionContributor {
|
|||||||
for (String name : functionNames) {
|
for (String name : functionNames) {
|
||||||
if (name.contains(actualPrefix)) {
|
if (name.contains(actualPrefix)) {
|
||||||
for (FunctionDescriptor function : namesCache.getTopLevelFunctionDescriptorsByName(name, scope)) {
|
for (FunctionDescriptor function : namesCache.getTopLevelFunctionDescriptorsByName(name, scope)) {
|
||||||
addCompletionToResult(result, DescriptorLookupConverter.createLookupElement(resolutionContext, function), positions, project);
|
addCompletionToResult(result, DescriptorLookupConverter.createLookupElement(resolutionContext, function), positions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ public class JetCompletionContributor extends CompletionContributor {
|
|||||||
javaPsiReferenceElement.setInsertHandler(JetJavaClassInsertHandler.JAVA_CLASS_INSERT_HANDLER);
|
javaPsiReferenceElement.setInsertHandler(JetJavaClassInsertHandler.JAVA_CLASS_INSERT_HANDLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
addCompletionToResult(result, element, positions, parameters.getPosition().getProject());
|
addCompletionToResult(result, element, positions);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -176,17 +176,23 @@ public class JetCompletionContributor extends CompletionContributor {
|
|||||||
private static void addCompletionToResult(
|
private static void addCompletionToResult(
|
||||||
@NotNull final CompletionResultSet result,
|
@NotNull final CompletionResultSet result,
|
||||||
@NotNull LookupElement element,
|
@NotNull LookupElement element,
|
||||||
@NotNull HashSet<LookupPositionObject> positions,
|
@NotNull HashSet<LookupPositionObject> positions) {
|
||||||
@NotNull Project project) {
|
|
||||||
|
|
||||||
final LookupPositionObject lookupPosition = getLookupPosition(element, project);
|
final LookupPositionObject lookupPosition = getLookupPosition(element);
|
||||||
if (lookupPosition != null && !positions.contains(lookupPosition)) {
|
if (lookupPosition != null) {
|
||||||
positions.add(lookupPosition);
|
if (!positions.contains(lookupPosition)) {
|
||||||
result.addElement(element);
|
positions.add(lookupPosition);
|
||||||
|
result.addElement(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
// There is already an element with same position - ignore duplicate
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.addElement(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LookupPositionObject getLookupPosition(LookupElement element, Project project) {
|
private static LookupPositionObject getLookupPosition(LookupElement element) {
|
||||||
final Object lookupObject = element.getObject();
|
final Object lookupObject = element.getObject();
|
||||||
if (lookupObject instanceof PsiElement) {
|
if (lookupObject instanceof PsiElement) {
|
||||||
return new LookupPositionObject((PsiElement) lookupObject);
|
return new LookupPositionObject((PsiElement) lookupObject);
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
var a : A<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: Any
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun some() {
|
||||||
|
var a : In<caret>
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: Int
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package testing.handlers
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
}
|
|
||||||
|
|
||||||
fun other() {
|
|
||||||
te<caret>()
|
|
||||||
}
|
|
||||||
|
|
||||||
// INSERT: test
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package testing.handlers
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
}
|
|
||||||
|
|
||||||
fun other() {
|
|
||||||
test()<caret>
|
|
||||||
}
|
|
||||||
|
|
||||||
// INSERT: test
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package testing.handlers
|
package testing.handlers
|
||||||
|
|
||||||
fun test() {
|
fun testFun() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun other() {
|
fun other() {
|
||||||
te<caret>
|
testFu<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// INSERT: test
|
// INSERT: test
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package testing.handlers
|
package testing.handlers
|
||||||
|
|
||||||
fun test() {
|
fun testFun() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun other() {
|
fun other() {
|
||||||
test()<caret>
|
testFun()<caret>
|
||||||
}
|
}
|
||||||
|
|
||||||
// INSERT: test
|
// INSERT: test
|
||||||
@@ -9,6 +9,14 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public class JetBasicCompletionTest extends JetCompletionTestBase {
|
public class JetBasicCompletionTest extends JetCompletionTestBase {
|
||||||
|
|
||||||
|
public void testBasicAny() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBasicInt() {
|
||||||
|
doTest();
|
||||||
|
}
|
||||||
|
|
||||||
public void testBeforeDotInCall() {
|
public void testBeforeDotInCall() {
|
||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,6 @@ import java.io.File;
|
|||||||
*/
|
*/
|
||||||
public class CompletionHandlerTest extends LightCompletionTestCase {
|
public class CompletionHandlerTest extends LightCompletionTestCase {
|
||||||
|
|
||||||
public void testExistingNoParamsFunction() {
|
|
||||||
doTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testNoParamsFunction() {
|
public void testNoParamsFunction() {
|
||||||
doTest();
|
doTest();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user