mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
hardcode log4j Level expected type (IDEA-201783)
This commit is contained in:
@@ -33,7 +33,16 @@ private interface DefaultTypeProvider {
|
||||
private val providers = createProviders()
|
||||
|
||||
private fun createProviders(): MultiMap<MethodArgument, DefaultTypeProvider> {
|
||||
val providers = listOf<Pair<MethodArgument, DefaultTypeProvider>>(
|
||||
val providers = listOf(
|
||||
MethodArgument("log", 0) to object : DefaultTypeProvider {
|
||||
override fun getDefaultType(method: PsiMethod, substitutor: PsiSubstitutor, argument: PsiExpression): PsiType? {
|
||||
if (isDefinedInClass(method, "org.apache.log4j.Category")) {
|
||||
return JavaPsiFacade.getElementFactory(method.project).createTypeFromText("org.apache.log4j.Level", argument)
|
||||
}
|
||||
return null
|
||||
}
|
||||
},
|
||||
|
||||
MethodArgument("contains", 0) to takeClassTypeArgument(CommonClassNames.JAVA_UTIL_COLLECTION, 0),
|
||||
MethodArgument("remove", 0) to takeClassTypeArgument(CommonClassNames.JAVA_UTIL_COLLECTION, 0),
|
||||
MethodArgument("indexOf", 0) to takeClassTypeArgument(CommonClassNames.JAVA_UTIL_LIST, 0),
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import org.apache.log4j.Level;
|
||||
|
||||
class Foo {
|
||||
{
|
||||
org.apache.log4j.Category logger;
|
||||
logger.log(Level.FATAL, <caret>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
{
|
||||
org.apache.log4j.Category logger;
|
||||
logger.log(F<caret>)
|
||||
}
|
||||
}
|
||||
+14
@@ -1315,4 +1315,18 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
configureByTestName();
|
||||
assertOrderedEquals(myFixture.getLookupElementStrings(), "this");
|
||||
}
|
||||
|
||||
public void testLog4jLevel() {
|
||||
myFixture.addClass("package org.apache.log4j; " +
|
||||
"public class Category { " +
|
||||
" public void log(Priority priority, Object message); " +
|
||||
"}" +
|
||||
"public class Priority { " +
|
||||
" final static public Priority FATAL;" + //deprecated
|
||||
"}" +
|
||||
"public class Level extends Priority { " +
|
||||
" final static public Level FATAL;" +
|
||||
"}");
|
||||
doTest('\n');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user