Klasse CreateCompilationUnitOperation

java.lang.Object
org.aspectj.org.eclipse.jdt.internal.core.JavaModelOperation
org.aspectj.org.eclipse.jdt.internal.core.CreateCompilationUnitOperation
Alle implementierten Schnittstellen:
org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.ICoreRunnable, org.eclipse.core.runtime.IProgressMonitor

public class CreateCompilationUnitOperation extends JavaModelOperation

This operation creates a compilation unit (CU). If the CU doesn't exist yet, a new compilation unit will be created with the content provided. Otherwise the operation will override the contents of an existing CU with the new content.

Note: It is possible to create a CU automatically when creating a class or interface. Thus, the preferred method of creating a CU is to perform a create type operation rather than first creating a CU and secondly creating a type inside the CU.

Required Attributes:

  • The package fragment in which to create the compilation unit.
  • The name of the compilation unit. Do not include the ".java" suffix (ex. "Object" - the ".java" will be added for the name of the compilation unit.)
  • Felddetails

    • name

      protected String name
      The name of the compilation unit being created.
    • source

      protected String source
      The source code to use when creating the element.
  • Konstruktordetails

    • CreateCompilationUnitOperation

      public CreateCompilationUnitOperation(IPackageFragment parentElement, String name, String source, boolean force)
      When executed, this operation will create a compilation unit with the given name. The name should have the ".java" suffix.
  • Methodendetails