Bug 67614 After "create field", additional text is inserted at multiple locations
I wrote the following method call: assertEquals(1.0d, blah(), delta); The field "delta" is not yet declared. I press Ctrl-1 and select "create field". The resulting line is: private Object delta; By typing the following sequence of keys: [Tab] double [Tab] [Right] = 0.0001d I change that manually to: private double delta = 0.00001d; Surprisingly, my original method call is now changed to: assertEquals(1.0d, blah(), delta = 0.00001d); And that is of course wrong. (BTW, I believe that the Ctrl-1 aid should guess the expected field type, but that's a different issue.)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LinkedCorrectionProposal.java
private ImportsStructure getImportStructure() throws CoreException {
			IPreferenceStore store= PreferenceConstants.getPreferenceStore();
			String[] prefOrder= JavaPreferencesSettings.getImportOrderPreference(store);
			int threshold= JavaPreferencesSettings.getImportNumberThreshold(store);					
			ImportsStructure impStructure= new ImportsStructure(fCompilationUnit, prefOrder, threshold, true);
			return impStructure;
		}
		
		/* (non-Javadoc)
		 * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
		 */
		public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
			IDocument document= viewer.getDocument();
			try {
				String replaceString= fProposal;
				ImportsStructure impStructure= null;
				if (fTypeProposal != null) {
					impStructure= getImportStructure();
					replaceString= impStructure.addImport(fTypeProposal);
				}
				IRegion region= getReplaceRegion(viewer, offset);
				document.replace(region.getOffset(), region.getLength(), replaceString);
			
				if (impStructure != null) {
					impStructure.create(false, null);
				}
			} catch (BadLocationException e) {
				JavaPlugin.log(e);
			} catch (CoreException e) {