Class RenameSourceElementHandler

  • All Implemented Interfaces:
    org.eclipse.core.commands.IHandler, org.eclipse.core.commands.IHandler2

    public class RenameSourceElementHandler
    extends org.eclipse.core.commands.AbstractHandler
    Starts rename refactoring for the currently selected Xtext-based source element.

    Note that this handler understands structured selections only; use CustomRenameElementHandler to activate rename refactoring from an Xtext editor.

    Also note that CustomRenameSupport must be bound for the language that declares the renamed source element, or else an NPE shall occur.

    See Also:
    IXtextFile, ISourceElement
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Object execute​(org.eclipse.core.commands.ExecutionEvent event)  
      protected boolean isEnabledFor​(org.eclipse.handly.model.ISourceElement targetElement)
      Returns whether rename refactoring can be started for the given source element.
      void setEnabled​(Object evaluationContext)  
      protected void startRenameElement​(org.eclipse.handly.model.ISourceElement targetElement)
      Starts rename refactoring for the given source element.
      • Methods inherited from class org.eclipse.core.commands.AbstractHandler

        addHandlerListener, dispose, fireHandlerChanged, hasListeners, isEnabled, isHandled, removeHandlerListener, setBaseEnabled
      • Methods inherited from class org.eclipse.core.commands.common.EventManager

        addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
    • Constructor Detail

      • RenameSourceElementHandler

        public RenameSourceElementHandler()
    • Method Detail

      • execute

        public Object execute​(org.eclipse.core.commands.ExecutionEvent event)
                       throws org.eclipse.core.commands.ExecutionException
        Throws:
        org.eclipse.core.commands.ExecutionException
      • setEnabled

        public void setEnabled​(Object evaluationContext)
        Specified by:
        setEnabled in interface org.eclipse.core.commands.IHandler2
        Overrides:
        setEnabled in class org.eclipse.core.commands.AbstractHandler
      • startRenameElement

        protected void startRenameElement​(org.eclipse.handly.model.ISourceElement targetElement)
                                   throws InterruptedException
        Starts rename refactoring for the given source element.
        Parameters:
        targetElement - not null
        Throws:
        InterruptedException - if the initial condition checking got canceled by the user
      • isEnabledFor

        protected boolean isEnabledFor​(org.eclipse.handly.model.ISourceElement targetElement)
        Returns whether rename refactoring can be started for the given source element.
        Parameters:
        targetElement - not null
        Returns:
        true if rename refactoring can be started; false otherwise