use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class NavigatorContentProvider method getChildren.
@Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof InternalASTNode) {
return outlineProvider.getChildren(parentElement);
} else if (parentElement instanceof IProject) {
if (((IProject) parentElement).isOpen()) {
AbsNature nature = UtilityFunctions.getAbsNature((IProject) parentElement);
assert nature != null;
return ModulePath.getRootHierarchy(nature).toArray();
}
} else if (parentElement instanceof ModulePath) {
ModulePath mPath = (ModulePath) parentElement;
ArrayList<Object> children = new ArrayList<Object>();
children.addAll(mPath.getChildModulePathsAndModuleDecls());
InternalASTNode<ModuleDecl> intNode = mPath.getModuleDecl();
// if the module path has a matching module declaration unfold its content..
if (intNode != null) {
ModuleDecl md = intNode.getASTNode();
ArrayList<ASTNode<?>> chld = getChildrenOf(md);
ASTNode<?>[] chldArr = chld.toArray(new ASTNode<?>[chld.size()]);
List<InternalASTNode<ASTNode<?>>> wrapASTNodes = InternalASTNode.wrapASTNodes(chldArr, mPath.getNature());
children.addAll(wrapASTNodes);
return (children.toArray());
}
return children.toArray();
}
return super.getChildren(parentElement);
}
use of org.absmodels.abs.plugin.builder.AbsNature 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;
}
use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class NewABSFileWizard method getProjectSelectionFromModulePath.
private IStructuredSelection getProjectSelectionFromModulePath(IStructuredSelection sel) {
ModulePath mp = getLastModulePathElement(sel);
if (mp != null) {
AbsNature nature = mp.getNature();
IProject project = nature.getProject();
Set<InternalASTNode<ModuleDecl>> modulesForPrefix = mp.getModulesForPrefix();
// Get first the of element in the HashSet
InternalASTNode<ModuleDecl> m = modulesForPrefix.isEmpty() ? null : modulesForPrefix.iterator().next();
List<IResource> folders = new ArrayList<IResource>();
folders.add(project);
if (m != null) {
CompilationUnit compilationUnit = m.getASTNode().getCompilationUnit();
IPath path = new Path(compilationUnit.getFileName());
path = path.makeRelativeTo(project.getLocation());
for (int i = 0; i < path.segmentCount() - 1; i++) {
folders.add(project.getFolder(path.segment(i)));
}
}
TreePath treePath = new TreePath(folders.toArray());
TreeSelection treeSelection = new TreeSelection(new TreePath[] { treePath });
return treeSelection;
}
return sel;
}
use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class LinkHelper method findSelection.
/**
* {@inheritDoc}
*/
@Override
public IStructuredSelection findSelection(IEditorInput anInput) {
if (anInput instanceof FileEditorInput) {
FileEditorInput fileInput = (FileEditorInput) anInput;
IProject project = getProject(fileInput);
AbsNature nature = getAbsNature(project);
// If we did not get back an ABS nature, do nothing.
if (nature == null) {
return null;
}
ITextEditor editor = UtilityFunctions.openABSEditorForFile(fileInput.getPath(), project);
IFile file = fileInput.getFile();
ModuleDecl md = getModuleDeclAtCurrentCursor(file, nature, editor);
return buildTreeSelection(nature, project, new InternalASTNode<ModuleDecl>(md, nature));
}
return null;
}
use of org.absmodels.abs.plugin.builder.AbsNature in project abstools by abstools.
the class NavigatorUtils method updateDependencies.
public static void updateDependencies(TreeSelection ts) {
IProject project = getProject(ts);
if (project != null) {
AbsNature nature = getAbsNature(project);
nature.initDependencies();
}
}
Aggregations