Example usage for org.eclipse.jdt.internal.core PackageFragmentRootInfo getSourceMapper

List of usage examples for org.eclipse.jdt.internal.core PackageFragmentRootInfo getSourceMapper

Introduction

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

Prototype

protected SourceMapper getSourceMapper() 

Source Link

Document

Retuns the SourceMapper for this root, or null if this root does not have attached source.

Usage

From source file:org.eclipse.che.jdt.internal.core.PackageFragmentRoot.java

License:Open Source License

/**
 * @see org.eclipse.jdt.internal.core.JavaElement
 *///www . j  av  a 2 s.  c  o m
public SourceMapper getSourceMapper() {
    SourceMapper mapper;
    try {
        PackageFragmentRootInfo rootInfo = (PackageFragmentRootInfo) getElementInfo();
        mapper = rootInfo.getSourceMapper();
        if (mapper == null) {
            // first call to this method
            IPath sourcePath = getSourceAttachmentPath();
            IPath rootPath = getSourceAttachmentRootPath();
            if (sourcePath == null)
                mapper = createSourceMapper(getPath(), rootPath); // attach root to itself
            else
                mapper = createSourceMapper(sourcePath, rootPath);
            rootInfo.setSourceMapper(mapper);
        }
    } catch (JavaModelException e) {
        // no source can be attached
        mapper = null;
    }
    return mapper;
}