Example usage for org.eclipse.jdt.internal.core CreateImportOperation CreateImportOperation

List of usage examples for org.eclipse.jdt.internal.core CreateImportOperation CreateImportOperation

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core CreateImportOperation CreateImportOperation.

Prototype

public CreateImportOperation(String importName, ICompilationUnit parentElement, int flags) 

Source Link

Document

When executed, this operation will add an import to the given compilation unit.

Usage

From source file:org.eclipse.jdt.internal.core.CompilationUnit.java

License:Open Source License

/**
 * @see ICompilationUnit#createImport(String, IJavaElement, int, IProgressMonitor)
 * @since 3.0/* w w w  .j  a  v a  2  s .  c  o m*/
 */
public IImportDeclaration createImport(String importName, IJavaElement sibling, int flags,
        IProgressMonitor monitor) throws JavaModelException {
    CreateImportOperation op = new CreateImportOperation(importName, this, flags);
    if (sibling != null) {
        op.createBefore(sibling);
    }
    op.runOperation(monitor);
    return getImport(importName);
}