KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > refactoring > PseudoJavaChangeElement


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 package org.eclipse.jdt.internal.ui.refactoring;
12
13 import org.eclipse.core.runtime.CoreException;
14
15 import org.eclipse.jface.util.Assert;
16
17 import org.eclipse.jface.text.IRegion;
18 import org.eclipse.jface.text.Region;
19
20 import org.eclipse.ltk.internal.ui.refactoring.ChangeElement;
21 import org.eclipse.ltk.internal.ui.refactoring.PseudoLanguageChangeElement;
22
23 import org.eclipse.jdt.core.IJavaElement;
24 import org.eclipse.jdt.core.ISourceRange;
25 import org.eclipse.jdt.core.ISourceReference;
26
27 /**
28  * TODO should remove dependency to JDT/Core
29  * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=61312)
30  */

31 public class PseudoJavaChangeElement extends PseudoLanguageChangeElement {
32
33     private IJavaElement fJavaElement;
34
35     public PseudoJavaChangeElement(ChangeElement parent, IJavaElement element) {
36         super(parent);
37         fJavaElement= element;
38         Assert.isNotNull(fJavaElement);
39     }
40     
41     /**
42      * Returns the Java element.
43      *
44      * @return the Java element managed by this node
45      */

46     public IJavaElement getJavaElement() {
47         return fJavaElement;
48     }
49     
50     public Object JavaDoc getModifiedElement() {
51         return fJavaElement;
52     }
53
54     public IRegion getTextRange() throws CoreException {
55         ISourceRange range= ((ISourceReference)fJavaElement).getSourceRange();
56         return new Region(range.getOffset(), range.getLength());
57     }
58 }
Popular Tags