use of org.absmodels.abs.plugin.editor.outline.PackageEntry in project abstools by abstools.
the class AbsNature method addPackagesForTypeChecking.
/**
* Add ABS package dependencies to {@link AbsNature#modelbuilder} for type checking
* @throws TypecheckInternalException
*/
private void addPackagesForTypeChecking() throws TypecheckInternalException {
try {
Main m = new Main();
m.setWithStdLib(true);
List<CompilationUnit> units = new ArrayList<CompilationUnit>();
for (PackageEntry entry : packageContainer.getPackages()) {
File file = new File(entry.getPath());
if (isABSPackage(file)) {
units.addAll(m.parseABSPackageFile(file));
}
}
modelbuilder.addCompilationUnits(units);
} catch (IOException e) {
throw new TypecheckInternalException(e);
} catch (NoModelException e) {
// ignore
}
}
use of org.absmodels.abs.plugin.editor.outline.PackageEntry in project abstools by abstools.
the class AbsNature method initDependencies.
public void initDependencies() {
try {
if (project != null) {
packageContainer.clear();
File file = new File(project.getFile(PACKAGE_DEPENDENCIES).getLocationURI());
Set<PackageEntry> entries = new HashSet<PackageEntry>();
if (file.exists()) {
Properties prop = new Properties();
prop.loadFromXML(new FileInputStream(file));
for (String qualified : prop.stringPropertyNames()) {
Boolean readonly = Boolean.valueOf(prop.getProperty(qualified));
File f = new File(qualified);
if (isABSPackage(f)) {
entries.add(new PackageEntry(packageContainer, f.getName(), qualified, readonly));
}
}
packageContainer.setPackages(entries);
packageContainer.setProject(project);
}
}
} catch (IOException e) {
Activator.logException(e);
}
}
use of org.absmodels.abs.plugin.editor.outline.PackageEntry 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;
}
Aggregations