EA-38865 Fail for convention functions names
This commit is contained in:
@@ -156,16 +156,23 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
@NotNull ResolveSession resolveSession,
|
||||
@NotNull GlobalSearchScope scope
|
||||
) {
|
||||
// name parameter can differ from expression.getReferenceName() when expression contains completion suffix
|
||||
Name referenceName = expression.getIdentifier() == null ? JetPsiUtil.getConventionName(expression) : Name.identifier(name);
|
||||
if (referenceName == null || referenceName.toString().isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
BindingContext context = ResolveSessionUtils.resolveToExpression(resolveSession, expression);
|
||||
JetScope jetScope = context.get(BindingContext.RESOLUTION_SCOPE, expression);
|
||||
|
||||
if (jetScope == null || name.isEmpty()) {
|
||||
if (jetScope == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Set<FunctionDescriptor> result = Sets.newHashSet();
|
||||
|
||||
Collection<PsiMethod> topLevelFunctionPrototypes = JetFromJavaDescriptorHelper.getTopLevelFunctionPrototypesByName(name, project, scope);
|
||||
Collection<PsiMethod> topLevelFunctionPrototypes = JetFromJavaDescriptorHelper.getTopLevelFunctionPrototypesByName(
|
||||
referenceName.getName(), project, scope);
|
||||
for (PsiMethod method : topLevelFunctionPrototypes) {
|
||||
FqName functionFQN = JetFromJavaDescriptorHelper.getJetTopLevelDeclarationFQN(method);
|
||||
if (functionFQN != null) {
|
||||
@@ -181,7 +188,7 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
}
|
||||
|
||||
Set<FqName> affectedPackages = Sets.newHashSet();
|
||||
Collection<JetNamedFunction> jetNamedFunctions = JetShortFunctionNameIndex.getInstance().get(name, project, scope);
|
||||
Collection<JetNamedFunction> jetNamedFunctions = JetShortFunctionNameIndex.getInstance().get(referenceName.getName(), project, scope);
|
||||
for (JetNamedFunction jetNamedFunction : jetNamedFunctions) {
|
||||
PsiFile containingFile = jetNamedFunction.getContainingFile();
|
||||
if (containingFile instanceof JetFile) {
|
||||
@@ -193,8 +200,6 @@ public class JetShortNamesCache extends PsiShortNamesCache {
|
||||
}
|
||||
}
|
||||
|
||||
Name referenceName = Name.identifier(name);
|
||||
|
||||
for (FqName affectedPackage : affectedPackages) {
|
||||
NamespaceDescriptor packageDescriptor = resolveSession.getPackageDescriptorByFqName(affectedPackage);
|
||||
assert packageDescriptor != null : "There's a function in stub index with invalid package";
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test
|
||||
|
||||
val localTest1 = Test() <error>-</error> 12
|
||||
val localTest2 = Test() <error>></error> 12
|
||||
val localTest3 = Test() <error><</error> 12
|
||||
@@ -15,15 +15,12 @@
|
||||
*/
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.checkers.AbstractJetPsiCheckerTest;
|
||||
import java.io.File;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.checkers.AbstractJetPsiCheckerTest}. DO NOT MODIFY MANUALLY */
|
||||
public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
|
||||
@@ -35,7 +32,8 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInChecker() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.checkers.AbstractJetPsiCheckerTest", new File("idea/testData/checker"), "jet", false);
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.checkers.AbstractJetPsiCheckerTest",
|
||||
new File("idea/testData/checker"), "jet", false);
|
||||
}
|
||||
|
||||
@TestMetadata("AnonymousInitializers.jet")
|
||||
@@ -153,6 +151,11 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
|
||||
doTest("idea/testData/checker/NestedObjects.jet");
|
||||
}
|
||||
|
||||
@TestMetadata("NotFinishedGenericDeclaration.jet")
|
||||
public void testNotFinishedGenericDeclaration() throws Exception {
|
||||
doTest("idea/testData/checker/NotFinishedGenericDeclaration.jet");
|
||||
}
|
||||
|
||||
@TestMetadata("Nullability.jet")
|
||||
public void testNullability() throws Exception {
|
||||
doTest("idea/testData/checker/Nullability.jet");
|
||||
|
||||
Reference in New Issue
Block a user