mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
unused symbol: should not apply to the public constructors of Externalizable classes (IDEA-120639 )
This commit is contained in:
+15
-2
@@ -27,13 +27,26 @@ import java.util.List;
|
||||
|
||||
public class JavaHighlightUtil {
|
||||
public static boolean isSerializable(@NotNull PsiClass aClass) {
|
||||
return isSerializable(aClass, "java.io.Serializable");
|
||||
}
|
||||
|
||||
public static boolean isSerializable(@NotNull PsiClass aClass,
|
||||
String serializableClassName) {
|
||||
Project project = aClass.getManager().getProject();
|
||||
PsiClass serializableClass = JavaPsiFacade.getInstance(project).findClass("java.io.Serializable", aClass.getResolveScope());
|
||||
PsiClass serializableClass = JavaPsiFacade.getInstance(project).findClass(serializableClassName, aClass.getResolveScope());
|
||||
return serializableClass != null && aClass.isInheritor(serializableClass, true);
|
||||
}
|
||||
|
||||
public static boolean isSerializationRelatedMethod(PsiMethod method, PsiClass containingClass) {
|
||||
if (containingClass == null || method.isConstructor()) return false;
|
||||
if (containingClass == null) return false;
|
||||
if (method.isConstructor()) {
|
||||
if (isSerializable(containingClass, "java.io.Externalizable") &&
|
||||
method.getParameterList().getParametersCount() == 0 &&
|
||||
method.hasModifierProperty(PsiModifier.PUBLIC)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (method.hasModifierProperty(PsiModifier.STATIC)) return false;
|
||||
@NonNls String name = method.getName();
|
||||
PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import java.io.Externalizable;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInput;
|
||||
import java.io.ObjectOutput;
|
||||
|
||||
class SerializationProxy implements Externalizable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Object object;
|
||||
|
||||
public SerializationProxy()
|
||||
{
|
||||
// Empty constructor for Externalizable class
|
||||
}
|
||||
|
||||
private <warning descr="Private constructor 'SerializationProxy(java.lang.Object)' is never used">SerializationProxy</warning>(Object object)
|
||||
{
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public void writeExternal(ObjectOutput out) throws IOException
|
||||
{
|
||||
out.writeObject(this.object);
|
||||
}
|
||||
|
||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
|
||||
{
|
||||
this.object = in.readObject();
|
||||
}
|
||||
|
||||
protected Object readResolve()
|
||||
{
|
||||
return this.object;
|
||||
}
|
||||
}
|
||||
+1
@@ -180,4 +180,5 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA78916() { doTest(false, false); }
|
||||
public void testIDEA111420() { doTest(false, false); }
|
||||
public void testIDEA111450() { doTest(true, false); }
|
||||
public void testExternalizable() { doTest(true, false); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user