mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-38947 (assert: JavaParserUtil.parseFragment)
This commit is contained in:
+5
@@ -52,6 +52,10 @@ public class ExternalizableWithoutPublicNoArgConstructorInspection extends BaseI
|
||||
final PsiMethod constructor = (PsiMethod)infos[1];
|
||||
if (constructor == null) {
|
||||
final PsiClass aClass = (PsiClass)infos[0];
|
||||
if (aClass instanceof PsiAnonymousClass) {
|
||||
// can't create constructor for anonymous class
|
||||
return null;
|
||||
}
|
||||
return new DelegatingFix(new AddDefaultConstructorFix(aClass, PsiModifier.PUBLIC));
|
||||
}
|
||||
else {
|
||||
@@ -73,6 +77,7 @@ public class ExternalizableWithoutPublicNoArgConstructorInspection extends BaseI
|
||||
|
||||
private static class MakeConstructorPublicFix extends InspectionGadgetsFix {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return InspectionGadgetsBundle.message("make.constructor.public");
|
||||
|
||||
+26
@@ -31,4 +31,30 @@ class eImpl2 extends e {
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
}
|
||||
}
|
||||
class AnonymousTest {
|
||||
public static void main(String[] args) throws IOException, ClassNotFoundException {
|
||||
final String h = "Hello World";
|
||||
final Externalizable externalizable = new Externalizable() {
|
||||
|
||||
private String string = h;
|
||||
|
||||
@Override
|
||||
public void writeExternal(ObjectOutput out) throws IOException {
|
||||
out.writeUTF(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||||
string = in.readUTF();
|
||||
}
|
||||
};
|
||||
final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
||||
final ObjectOutputStream out = new ObjectOutputStream(bytes);
|
||||
out.writeObject(externalizable);
|
||||
out.close();
|
||||
final ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()));
|
||||
final Object o = in.readObject();
|
||||
System.out.println("o = " + o);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -3,7 +3,6 @@
|
||||
<problem>
|
||||
<file>ExternalizableWithoutPublicNoArgConstructor.java</file>
|
||||
<line>9</line>
|
||||
<module>test_5975879954938100914</module>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Externalizable class without public no-arg constructor</problem_class>
|
||||
<description>Externalizable class <code>eImpl</code> has no public no-arg constructor</description>
|
||||
</problem>
|
||||
@@ -11,7 +10,6 @@
|
||||
<problem>
|
||||
<file>ExternalizableWithoutPublicNoArgConstructor.java</file>
|
||||
<line>16</line>
|
||||
<entry_point TYPE="class" FQNAME="com.siyeh.igtest.serialization.externalizable_without_public_no_arg_constructor.eImpl1" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Externalizable class without public no-arg constructor</problem_class>
|
||||
<description>Externalizable class <code>eImpl1</code> has no public no-arg constructor</description>
|
||||
</problem>
|
||||
@@ -19,8 +17,14 @@
|
||||
<problem>
|
||||
<file>ExternalizableWithoutPublicNoArgConstructor.java</file>
|
||||
<line>24</line>
|
||||
<entry_point TYPE="class" FQNAME="com.siyeh.igtest.serialization.externalizable_without_public_no_arg_constructor.eImpl2" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Externalizable class without public no-arg constructor</problem_class>
|
||||
<description>Externalizable class <code>eImpl2</code> has no public no-arg constructor</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>ExternalizableWithoutPublicNoArgConstructor.java</file>
|
||||
<line>37</line>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Externalizable class without public no-arg constructor</problem_class>
|
||||
<description>Externalizable class <code>Externalizable</code> has no public no-arg constructor #loc</description>
|
||||
</problem>
|
||||
</problems>
|
||||
Reference in New Issue
Block a user