|
What this is
Other links
The source code/* * CreateMethodElement.java * * Created on September 3, 2003, 4:50 PM */ package org.netbeans.modules.refactoring; import java.text.MessageFormat; import java.util.List; import java.util.ListIterator; import javax.swing.text.Position; import org.netbeans.api.mdr.MDRepository; import org.netbeans.modules.refactoring.api.RefactoringElement; import org.netbeans.jmi.javamodel.*; import org.netbeans.modules.javacore.internalapi.JavaMetamodel; import org.openide.text.CloneableEditorSupport; import org.openide.text.PositionBounds; import org.openide.text.PositionRef; import org.openide.util.NbBundle; /** * * @author Tomas Hurka */ public class CreateMethodElement implements RefactoringElement { private int modifiers; private String name; private TypeReference returnType; private String methodBody; private ClassDefinition declaringClass; private boolean enabled=true; private JavaModelPackage modelExtent; private List parameters; private Method newMethod; private PositionBounds bounds; private ClassMember insertPoint; /** Creates a new instance of CreateMethodElement */ public CreateMethodElement(int mod,String n,TypeReference rdesc,List pars,String body,ClassMember insertPoint,ClassDefinition jcls) { modifiers=mod; name=n; returnType=rdesc; parameters=pars; methodBody=body; declaringClass=jcls; this.insertPoint=insertPoint; modelExtent=(JavaModelPackage)jcls.refOutermostPackage(); } /** Returns text describing the refactoring formatted for display (using HTML tags). * @return Formatted text. * */ public String getDisplayText() { return new MessageFormat(NbBundle.getMessage(CreateMethodElement.class, "DSC_CreateMethod")).format ( new Object[] {name} ); } /** Returns Java element associated with this refactoring element. * @return MDR Java element. * */ public Element getJavaElement() { return declaringClass; } /** Returns position bounds of the text to be affected by this refactoring element. * */ public PositionBounds getPosition() { if (bounds==null) { PositionBounds b=JavaMetamodel.getManager().getElementPosition(declaringClass); CloneableEditorSupport ed=b.getBegin().getCloneableEditorSupport(); PositionRef start=ed.createPositionRef(0, Position.Bias.Forward); PositionRef end=ed.createPositionRef(0, Position.Bias.Backward); bounds=new PositionBounds(start,end); } return bounds; } /** Returns the status of this refactoring element (whether it is a normal element, * or a warning. * @return Status of this element. * */ public int getStatus() { return RefactoringElement.NORMAL; } /** Returns text describing the refactoring element. * @return Text. * */ public String getText() { throw new UnsupportedOperationException(); } /** Indicates whether this refactoring element is enabled. * @return |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.