use of org.absmodels.abs.plugin.editor.outline.PackageAbsFile in project abstools by abstools.
the class AbsNature method parseABSFile.
/**
* @deprecated unused
*/
public void parseABSFile(PackageAbsFile file, boolean withincomplete, Object monitor) {
Main m = new Main();
m.setWithStdLib(true);
List<CompilationUnit> units = new ArrayList<CompilationUnit>();
try {
final File f = new File(file.getAbsoluteFilePath());
assert f.exists();
units.addAll(m.parseABSPackageFile(f));
modelbuilder.addCompilationUnits(units);
} catch (IOException e) {
Activator.logException(e);
} catch (NoModelException e) {
}
}
use of org.absmodels.abs.plugin.editor.outline.PackageAbsFile in project abstools by abstools.
the class NavigatorUtils method openEditor.
/**
* Opens the file in an editor that corresponds to the given
* TreeSelection. Only the first element of the selection will be
* taken into account.
*
* @param ts TreeSelection that is used as a base to find an appropriate editor
* @throws PartInitException - if the editor could not be opened for highlighting
*/
public static void openEditor(TreeSelection ts) throws PartInitException {
if (!ts.equals(TreeSelection.EMPTY)) {
TreePath path = ts.getPaths()[0];
IProject project = getProject(path);
if (project != null) {
if (path.getLastSegment() instanceof InternalASTNode<?>) {
InternalASTNode<?> node = (InternalASTNode<?>) path.getLastSegment();
openAndHighlightEditor(node);
} else if (path.getLastSegment() instanceof ModulePath) {
ModulePath mp = (ModulePath) path.getLastSegment();
if (mp.hasModuleWithDecls()) {
InternalASTNode<ModuleDecl> moduleDecl = mp.getModuleDecl();
openAndHighlightEditor(moduleDecl);
}
} else if (path.getLastSegment() instanceof PackageAbsFile) {
openABSEditorForFile((PackageAbsFile) path.getLastSegment());
}
}
}
}
use of org.absmodels.abs.plugin.editor.outline.PackageAbsFile 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