Bug 48131 - Code assistance and format for ambiguous inner Java class name
Summary: Code assistance and format for ambiguous inner Java class name
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.0 M8   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-04 22:40 EST by markusle CLA
Modified: 2004-03-04 18:12 EST (History)
0 users

See Also:


Attachments
Actual result with the new code formatter (2.79 KB, text/plain)
2003-12-05 08:19 EST, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description markusle CLA 2003-12-04 22:40:53 EST
package de.neze.bugreport.eclipse;
//Code generator imported: import de.neze.bugreport.eclipse.GeneralConcept.Item;
//Code generator imported: import de.neze.bugreport.eclipse.GeneralConcept.Problem;
/**
 * Feature Missing in Eclispe M5:
 * 
 * I like to write code like as noted below, and it seams that eclispe 
 * handling of ambigouse inner class names is suboptimal during codeassistance.
 * And the code formater has problems with disambigouated names.
 * Note: The exampe below is optimzed for shortness and that make it look a 
 * little bit stupid, but "real world" exmples are much longer .. .
 */
public abstract class AssistMyStyle {
	public static final class Problem extends Exception {
	}
	public static final class Item {
	}
	public static interface Factory {
		AssistMyStyle newAssistMyStyle() throws Problem;
	}
	abstract Item someMethod() throws Problem;
}
/**
 * and
 */
interface GeneralConcept {
	public static final class Problem extends Exception {
	}
	public static final class Item {
	}
	abstract Item anotherMethodWithLongNameToForceCodeformaterToBreakTheLine()
		throws Problem;
}
/**
 * ... and as a result I have many inner classes with the names
 * "Problem", "Factory" or "Item".
 * Now I Use code completation to procduce method stubs and got errors
 * as note in the method comments below.
 * I use "Automatically add import instead of qualified name" in 
 * 		Window > Preferences > Java > Editor > Code Assist:
 */
class AssistMyStyleImpl extends AssistMyStyle implements GeneralConcept {
	public static final class Factory implements AssistMyStyle.Factory {
		public AssistMyStyle newAssistMyStyle() {
			return new AssistMyStyleImpl();
		}
	}
	/**
	 * <pre>
	 * 	Item someMethod() throws Problem {
	 *		return null;
	 *	}
	 * </pre>
	 * Implies errors:
	 *  [1] The exception type Problem is ambiguous for the method someMethod
	 *  [2] The return type Item is ambiguous for the method someMethod
	 * I fix this:
	 */
	AssistMyStyle.Item someMethod() throws AssistMyStyle.Problem {
		return null;
	}
	/**
	 * anotherMethodWithLongNameToForceCodeformaterToBreakTheLine()
	 * <pre>
	 * 	public Item anotherMethodWithLongNameToForceCodeformaterToBreakTheLine()
	 *	throws Problem {
	 *	// XXX Auto-generated method stub
	 *	return null;
	 *	}
	 * </pre>
	 * Implies error:
	 * [1] The exception type Problem is ambiguous for the method 
	 *      anotherMethodWithLongNameToForceCodeformaterToBreakTheLine()
	 * [2] The return type Item is ambiguous for the method 
	 *      anotherMethodWithLongNameToForceCodeformaterToBreakTheLine
	 * I fix this and used code format (looks ugly!!!!):
	 */
	public GeneralConcept
		.Item anotherMethodWithLongNameToForceCodeformaterToBreakTheLine()
		throws GeneralConcept.Problem {
		return null;
	}
}
/**
 * Note: There are more erros not noted here, you have to rewrite this example
 * to see all my struggles
 * Suggestion:
 * [1] In "Window > Preferences > Java > Editor > Code Assist" add an
 *     flag "Don't import inner classes" or "Import only toplevel classes"
 *     (and of course implemented it).
 * [2] Don't break disambigouated names above the line end during code format.
 * By the way: If you don't like "my style" the code generator has still a 
 * problem becuse it producess buggy code. 
 * So you may change this feature request to an bug report.
 * 
 * Kind regards
 * 
 * mle@neze.de
 **/
Comment 1 markusle CLA 2003-12-04 22:46:03 EST
Oh - Horror! I read my example again and I have the strong need 
to apologise for my bad english grammar and orthography: 
                    Please excuse me.
Comment 2 Olivier Thomann CLA 2003-12-05 08:19:46 EST
Created attachment 7075 [details]
Actual result with the new code formatter

Here is the actual result with the new formatter. You can enable it in
Preferences>Java>Work in progress. If you use the latest integration build,
then you can also set the preferences through the code formatter preferences
page.
Comment 3 markusle CLA 2003-12-06 00:57:48 EST
No word about my problems with the code assistant?
Comment 4 markusle CLA 2003-12-06 01:42:24 EST
Btw: The new code formater formats
	private final Object o(
		Object oBegin,
		Object oEnd,
		Object oSB //
	) throws Throwable { ...
as 
	/**
	 * openRelativePath()
	 */
	private final Object o(Object oBegin, Object oEnd,
		Object oSB //
	) throws Throwable { ...
and I don't like that (I tried that a few mont ago). Now I hope
that becomes configureable if its new options page are 
available ... . I will wait patient.
Comment 5 Olivier Thomann CLA 2003-12-09 12:32:25 EST
What do you expect? You have a line comment in the parameters of your method
declaration.
Comment 6 markusle CLA 2003-12-09 21:50:41 EST
First of all the code formater is not my (min) issue in this report,
I expect an code assist option
     "Import only toplevel classes"
for the code assist functinality
    "Automatically add import instead of qualified name".

Now to your (main?) issue: My line comments in my source code make the 
old code formater behave more as I like it .... . 
I hope the new code formaters option dialog makes that obsolete in 
the future.
Comment 7 markusle CLA 2003-12-10 22:09:17 EST
Remark to #5: Now I believe understand your question (sorry I'm late).
              My "argument tower" is not hand made but is
              formated with the old code formater
Comment 8 markusle CLA 2003-12-17 08:47:20 EST
Hello? Hello echo .. echoo oo oo oo (listen ... silence everywhere!).
Is somebody (other then myself) interested in this report?
Have I made a mistake or something like that?
Comment 9 Jerome Lanneluc CLA 2003-12-17 10:21:14 EST
You better reformulate your problem, as I read this bug report I don't 
understand what's you expectation. Is it a problem with code assit or with the 
formatter? If it is the latter, what are you currently seeing? What would you 
like to see?
Comment 10 markusle CLA 2003-12-17 10:42:56 EST
This report is a combined bug-report and feature request and it is not 
intended for readers but for rewriters. 
My intension was that somebody copies the source code, deletes the class
AssistMyStyleImpl and rewrittes it as outlined in the comments of class
AssistMyStyleImpl. 
The kind rewriter runs in many problems, each of this problems may become a
bug report of its own, but I have no time to write them.
At the end I suggest a feature for eclispe:

[1] In "Window > Preferences > Java > Editor > Code Assist" add an
 *     flag "Don't import inner classes" or "Import only toplevel classes"

I think this feature is self explanatory. 
If nobody is interested to rewrite my example you may close this report, 
because only people withthe same problems may understand it.
Comment 11 Philipe Mulet CLA 2004-03-04 18:12:33 EST
Closing then.
Please enter concise bug reports in the future trying to focus on one problem 
each.