Example usage for org.eclipse.jdt.internal.core OpenableElementInfo addChild

List of usage examples for org.eclipse.jdt.internal.core OpenableElementInfo addChild

Introduction

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

Prototype

public void addChild(IJavaElement child) 

Source Link

Usage

From source file:org.eclipse.ajdt.core.javaelements.AJCompilationUnitManager.java

License:Open Source License

public boolean ensureUnitIsInModel(AJCompilationUnit unit) throws JavaModelException {
    //ensure unit is in the model
    OpenableElementInfo info = (OpenableElementInfo) ((JavaElement) unit.getParent()).getElementInfo();
    IJavaElement[] elems = info.getChildren();
    for (int i = 0; i < elems.length; i++) {
        IJavaElement element = elems[i];
        if (element == unit)
            return true;
    }/*from  w ww  .j  av a  2 s  .  co m*/
    info.addChild(unit);
    return false;
}

From source file:org.eclipse.ajdt.core.javaelements.AJCompilationUnitManager.java

License:Open Source License

private AJCompilationUnit createCU(IFile file) {
    AJCompilationUnit unit = new AJCompilationUnit(file);

    try {//from w  ww  . j ava 2s.c  o m
        OpenableElementInfo info = (OpenableElementInfo) ((JavaElement) unit.getParent()).getElementInfo();
        info.removeChild(unit); // Remove identical CompilationUnit if it exists
        info.addChild(unit);

        compilationUnitStore.put(file, unit);
    } catch (JavaModelException e) {
    }
    return unit;
}