Search in sources :

Example 1 with PackageAbsFile

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) {
    }
}
Also used : CompilationUnit(abs.frontend.ast.CompilationUnit) NoModelException(org.absmodels.abs.plugin.internal.NoModelException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Main(abs.frontend.parser.Main) PackageAbsFile(org.absmodels.abs.plugin.editor.outline.PackageAbsFile) File(java.io.File)

Example 2 with PackageAbsFile

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());
            }
        }
    }
}
Also used : TreePath(org.eclipse.jface.viewers.TreePath) InternalASTNode(org.absmodels.abs.plugin.util.InternalASTNode) IProject(org.eclipse.core.resources.IProject) PackageAbsFile(org.absmodels.abs.plugin.editor.outline.PackageAbsFile)

Example 3 with PackageAbsFile

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;
}
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

PackageAbsFile (org.absmodels.abs.plugin.editor.outline.PackageAbsFile)3 CompilationUnit (abs.frontend.ast.CompilationUnit)1 ABSPackageFile (abs.frontend.parser.ABSPackageFile)1 Main (abs.frontend.parser.Main)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 AbsNature (org.absmodels.abs.plugin.builder.AbsNature)1 PackageContainer (org.absmodels.abs.plugin.editor.outline.PackageContainer)1 PackageEntry (org.absmodels.abs.plugin.editor.outline.PackageEntry)1 NoModelException (org.absmodels.abs.plugin.internal.NoModelException)1 InternalASTNode (org.absmodels.abs.plugin.util.InternalASTNode)1 IProject (org.eclipse.core.resources.IProject)1 TreePath (org.eclipse.jface.viewers.TreePath)1