Search in sources :

Example 1 with PackageContainer

use of org.absmodels.abs.plugin.editor.outline.PackageContainer in project abstools by abstools.

the class UtilityFunctions method getPackageAbsFile.

/**
 * A convenient method to reconstruct a {@link PackageAbsFile} from the absolute
 * path to the ABS package and the name to the specific entry in the package.
 * @param proj the project which the package belongs to
 * @param pak
 * @param entry
 * @return
 */
public static PackageAbsFile getPackageAbsFile(IProject proj, String pak, String entry) {
    File file = new File(pak);
    try {
        if (new ABSPackageFile(file).isABSPackage()) {
            PackageEntry pentry = null;
            if (proj != null) {
                AbsNature nature = getAbsNature(proj);
                for (PackageEntry e : nature.getPackages().getPackages()) {
                    if (e.getPath().equals(file.getAbsolutePath())) {
                        pentry = e;
                        break;
                    }
                }
            }
            if (pentry == null) {
                PackageContainer container = new PackageContainer();
                container.setProject(proj);
                pentry = new PackageEntry(container, file.getName(), file.getAbsolutePath(), true);
            }
            return new PackageAbsFile(pentry, entry);
        }
    } catch (IOException e) {
    }
    return null;
}
Also used : ABSPackageFile(abs.frontend.parser.ABSPackageFile) PackageEntry(org.absmodels.abs.plugin.editor.outline.PackageEntry) PackageContainer(org.absmodels.abs.plugin.editor.outline.PackageContainer) PackageAbsFile(org.absmodels.abs.plugin.editor.outline.PackageAbsFile) ABSPackageFile(abs.frontend.parser.ABSPackageFile) AbsNature(org.absmodels.abs.plugin.builder.AbsNature) PackageAbsFile(org.absmodels.abs.plugin.editor.outline.PackageAbsFile)

Aggregations

ABSPackageFile (abs.frontend.parser.ABSPackageFile)1 AbsNature (org.absmodels.abs.plugin.builder.AbsNature)1 PackageAbsFile (org.absmodels.abs.plugin.editor.outline.PackageAbsFile)1 PackageContainer (org.absmodels.abs.plugin.editor.outline.PackageContainer)1 PackageEntry (org.absmodels.abs.plugin.editor.outline.PackageEntry)1