Bug 7966 Class Creation Dialog generates syntax error
Build 20020115 If you create a class that will require import statements due to the interfaces it implements or the class it extends they will be created within the comment for the class. Here is an example of the comment of the generated class /* import org.eclipse.core.resources.IResourceChangeListener; import org.eclipse.jface.viewers.ITreeContentProvider; * (c) Copyright 2001 MyCorporation. * All Rights Reserved. */ Steps 1) Select the class creation dialog 2) Enter a class name 3) Choose an interface to have it inherit from 4) Hit OK - you will get an error from Eclipse 5) The class will be created - look at its definition
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/TypePage.java
if (root == null) {
			return null;
		}
		
		
		ArrayList elementsInScope= new ArrayList();
		try {
			IPackageFragmentRoot[] pfrs= root.getJavaProject().getPackageFragmentRoots();
			for (int i= 0; i < pfrs.length; i++) {
				if (pfrs[i].getKind() == IPackageFragmentRoot.K_SOURCE) {
					elementsInScope.add(pfrs[i]);
				}
			}
		} catch (JavaModelException e) {
			JavaPlugin.log(e);
		}
		IJavaElement[] elements= (IJavaElement[]) elementsInScope.toArray(new IJavaElement[elementsInScope.size()]);
		IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
			
		TypeSelectionDialog dialog= new TypeSelectionDialog(getShell(), getWizard().getContainer(), scope, IJavaElementSearchConstants.CONSIDER_TYPES);
		dialog.setTitle(NewWizardMessages.getString("TypePage.ChooseEnclosingTypeDialog.title")); 
		dialog.setMessage(NewWizardMessages.getString("TypePage.ChooseEnclosingTypeDialog.description")); 
		if (fCurrEnclosingType != null) {
			dialog.setInitialSelections(new Object[] { fCurrEnclosingType });
			dialog.setFilter(fCurrEnclosingType.getElementName().substring(0, 1));
		}
		
		if (dialog.open() == dialog.OK) {	
			return (IType) dialog.getFirstResult();
		}