Bug 88313 [quick fix] Quickfix for qualifying field and inheritance
I'm using I20050219-1500. I have a Java project with the following two files: A.java 1 package xyz; 2 3 public class A 4 { 5 protected Object someObject = new Object(); 6 } B.java 1 package xyz; 2 3 public class B extends A 4 { 5 public void someCode() { 6 Object obj = new Object() { 7 public String toString() { 8 return someObject.getClass().getName(); 9 } 10 }; 11 } 12 } and the compiler settings are such that I get a warning for 'Unqualified access to instance field'. Now I get a warning and a quickfix to 'Qualify with A.this' at line 8. I trigger the quickfix and the result is 8 return A.this.someObject.getClass().getName(); which gives a compiler error ('No enclosing instance').
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/LocalCorrectionsQuickFixTest.java
buf.append("    public String goo() throws IOException {\n");
		buf.append("        return null;\n");
		buf.append("    }\n");
		buf.append("    /**\n");
		buf.append("     * Not much to say here.\n");
		buf.append("     */\n");
		buf.append("    public void foo() {\n");
		buf.append("        try {\n");		
		buf.append("            goo().substring(2);\n");
		buf.append("        } catch (IOException e) {\n");
		buf.append("        }\n");						
		buf.append("    }\n");
		buf.append("}\n");
		String expected2= buf.toString();
		
		assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 });		
	}
	
	public void testUncaughtException3() throws Exception {
		IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null);
		StringBuffer buf= new StringBuffer();
		buf.append("package test1;\n");
		buf.append("import java.io.IOException;\n");	
		buf.append("import java.text.ParseException;\n");	
		buf.append("public class E {\n");
		buf.append("    public String goo() throws IOException, ParseException {\n");
		buf.append("        return null;\n");
		buf.append("    }\n");
		buf.append("    /**\n");
		buf.append("     * Not much to say here.\n");