IDEA-152033 Suggest current class for Class<?> parameter (for logging-related stuff)

This commit is contained in:
peter
2016-02-24 13:59:25 +01:00
parent eed9e7e7fb
commit f567f9d2f8
3 changed files with 12 additions and 1 deletions
@@ -1154,7 +1154,8 @@ public class ExpectedTypesProvider {
}
}
}
if ("Logger".equals(containingClass.getName()) || "Log".equals(containingClass.getName())) {
String className = containingClass.getName();
if (className != null && className.startsWith("Log")) {
if (parameterType instanceof PsiClassType) {
PsiType typeArg = PsiUtil.substituteTypeParameter(parameterType, CommonClassNames.JAVA_LANG_CLASS, 0, true);
if (typeArg != null && TypeConversionUtil.erasure(typeArg).equalsToText(CommonClassNames.JAVA_LANG_OBJECT)) {
@@ -0,0 +1,7 @@
public class Foo {
public static final Logger LOG = LoggerFactory.getLogger(<caret>)
}
class LoggerFactory {
static Logger getLogger(Class<?> c) {}
}
@@ -324,6 +324,9 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
public void testGetWildcardLogger() {
checkPreferredItems 0, 'Foo.class', 'forName'
}
public void testGetWildcardFactoryLogger() {
checkPreferredItems 0, 'Foo.class', 'forName'
}
public void testPreferLocalWildcardClassOverObject() {
checkPreferredItems 0, 'type', 'Object.class'
}