Community
Participate
Working Groups
I've got a TestingMyClass.java file : ------------------------------------ package stdjavatest; import junit.framework.*; import mypackage.MyClass; public class TestingMyClass extends TestCase { public void test_method() { MyClass objA = null; objA = new MyClass(); objA.method(); } } ------------------------------------ If I format this file either with right-click->Source->Format, or programmatically thanks to a CodeFormatter, nothing happens. If I change my import "import mypackage.MyClass;" to "import mypackage.*;" then it works ! After some debug session, I figured out that the issue is coming from the method visit(ImportReference importRef, CompilationUnitScope scope) in org.eclipse.jdt.internal.formatter.CodeFormatterVisitor. In this method, it seems that the call to scribe.printQualifiedReference(importRef.sourceEnd); with an importRef which is not on-demand returns "mypackage." instead of "mypackage.MyClass" !
What build are you using? I cannot reproduce with M7. This looks like an old bug, but I cannot find the previous bug report.
Close as WORKSFORME. Please reopen if you can reproduce it with M7 or above.
Dear Olivier, That's M7 : Eclipse Platform Version: 3.0.0 Build id: 200402122000 I think I know why you didn't reproduce it : my mistake ! It seems that the bug occurs if the imported class is one-byte length. The example I've sent you before was working, but this one doesn't : --------------------------------------- import com.ibm.rational.test.ct.A; public class Foo extends A { public Foo() { super(); } } --------------------------------------- It doesn't work if you try to format this source. Sorry for the mistake and the extra work ! /Bertrand
Reproduced. Fixed and released in HEAD. Regression test added.
Verified for 3.0 using build I200403250010.