org.eclipse.wst.jsdt.core
Interface ISourceManipulation

All Known Subinterfaces:
IField, IFunction, IImportDeclaration, IInitializer, IJavaScriptUnit, IMember, IPackageFragment, IType

public interface ISourceManipulation

Common protocol for JavaScript elements that support source code manipulations such as copy, move, rename, and delete.

This interface is not intended to be implemented by clients.

Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.


Method Summary
 void copy(IJavaScriptElement container, IJavaScriptElement sibling, java.lang.String rename, boolean replace, IProgressMonitor monitor)
          Copies this element to the given container.
 void delete(boolean force, IProgressMonitor monitor)
          Deletes this element, forcing if specified and necessary.
 void move(IJavaScriptElement container, IJavaScriptElement sibling, java.lang.String rename, boolean replace, IProgressMonitor monitor)
          Moves this element to the given container.
 void rename(java.lang.String name, boolean replace, IProgressMonitor monitor)
          Renames this element to the given name.
 

Method Detail

copy

void copy(IJavaScriptElement container,
          IJavaScriptElement sibling,
          java.lang.String rename,
          boolean replace,
          IProgressMonitor monitor)
          throws JavaScriptModelException
Copies this element to the given container.

Parameters:
container - the container
sibling - the sibling element before which the copy should be inserted, or null if the copy should be inserted as the last child of the container
rename - the new name for the element, or null if the copy retains the name of this element
replace - true if any existing child in the container with the target name should be replaced, and false to throw an exception in the event of a name collision
monitor - a progress monitor
Throws:
JavaScriptModelException - if this element could not be copied. Reasons include:
  • This JavaScript element, container element, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)
  • A CoreException occurred while updating an underlying resource
  • The container is of an incompatible type (INVALID_DESTINATION)
  • The sibling is not a child of the given container (INVALID_SIBLING)
  • The new name is invalid (INVALID_NAME)
  • A child in the container already exists with the same name (NAME_COLLISION) and replace has been specified as false
  • The container or this element is read-only (READ_ONLY)
java.lang.IllegalArgumentException - if container is null

delete

void delete(boolean force,
            IProgressMonitor monitor)
            throws JavaScriptModelException
Deletes this element, forcing if specified and necessary.

Parameters:
force - a flag controlling whether underlying resources that are not in sync with the local file system will be tolerated (same as the force flag in IResource operations).
monitor - a progress monitor
Throws:
JavaScriptModelException - if this element could not be deleted. Reasons include:
  • This JavaScript element does not exist (ELEMENT_DOES_NOT_EXIST)
  • A CoreException occurred while updating an underlying resource (CORE_EXCEPTION)
  • This element is read-only (READ_ONLY)

move

void move(IJavaScriptElement container,
          IJavaScriptElement sibling,
          java.lang.String rename,
          boolean replace,
          IProgressMonitor monitor)
          throws JavaScriptModelException
Moves this element to the given container.

Parameters:
container - the container
sibling - the sibling element before which the element should be inserted, or null if the element should be inserted as the last child of the container
rename - the new name for the element, or null if the element retains its name
replace - true if any existing child in the container with the target name should be replaced, and false to throw an exception in the event of a name collision
monitor - a progress monitor
Throws:
JavaScriptModelException - if this element could not be moved. Reasons include:
  • This JavaScript element, container element, or sibling does not exist (ELEMENT_DOES_NOT_EXIST)
  • A CoreException occurred while updating an underlying resource
  • The container is of an incompatible type (INVALID_DESTINATION)
  • The sibling is not a child of the given container (INVALID_SIBLING)
  • The new name is invalid (INVALID_NAME)
  • A child in the container already exists with the same name (NAME_COLLISION) and replace has been specified as false
  • The container or this element is read-only (READ_ONLY)
java.lang.IllegalArgumentException - if container is null

rename

void rename(java.lang.String name,
            boolean replace,
            IProgressMonitor monitor)
            throws JavaScriptModelException
Renames this element to the given name.

Parameters:
name - the new name for the element
replace - true if any existing element with the target name should be replaced, and false to throw an exception in the event of a name collision
monitor - a progress monitor
Throws:
JavaScriptModelException - if this element could not be renamed. Reasons include:
  • This JavaScript element does not exist (ELEMENT_DOES_NOT_EXIST)
  • A CoreException occurred while updating an underlying resource
  • The new name is invalid (INVALID_NAME)
  • A child in the container already exists with the same name (NAME_COLLISION) and replace has been specified as false
  • This element is read-only (READ_ONLY)