KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > correction > ReplaceCorrectionProposal


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jdt.internal.ui.text.correction;
13
14 import org.eclipse.text.edits.ReplaceEdit;
15 import org.eclipse.text.edits.TextEdit;
16
17 import org.eclipse.core.runtime.CoreException;
18
19 import org.eclipse.jface.text.IDocument;
20
21 import org.eclipse.jdt.core.ICompilationUnit;
22
23 import org.eclipse.jdt.internal.ui.JavaPluginImages;
24
25 public class ReplaceCorrectionProposal extends CUCorrectionProposal {
26
27     private String JavaDoc fReplacementString;
28     private int fOffset;
29     private int fLength;
30
31     public ReplaceCorrectionProposal(String JavaDoc name, ICompilationUnit cu, int offset, int length, String JavaDoc replacementString, int relevance) {
32         super(name, cu, relevance, JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE));
33         fReplacementString= replacementString;
34         fOffset= offset;
35         fLength= length;
36     }
37
38     /* (non-Javadoc)
39      * @see org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal#addEdits(org.eclipse.jface.text.IDocument)
40      */

41     protected void addEdits(IDocument doc, TextEdit rootEdit) throws CoreException {
42         super.addEdits(doc, rootEdit);
43
44         TextEdit edit= new ReplaceEdit(fOffset, fLength, fReplacementString);
45         rootEdit.addChild(edit);
46     }
47
48 }
49
Popular Tags