Package org.erlide.engine.model.erlang

Examples of org.erlide.engine.model.erlang.IErlModule


    }

    private IErlFunctionClause extractFunction(final OtpErlangTuple fTuple)
            throws OtpErlangRangeException, ErlModelException {
        final IErlModule mod = extractModule(fTuple.elementAt(0));
        final String function = ((OtpErlangAtom) fTuple.elementAt(1)).atomValue();
        final int arity = ((OtpErlangLong) fTuple.elementAt(2)).intValue();
        final IErlFunctionClause f = ErlangEngine.getInstance().getModel()
                .findFunction(new FunctionRef(mod.getModuleName(), function, arity));
        return f;
    }
View Full Code Here


    }

    private ArrayList<IErlElement> createErlModuleList(final OtpErlangList modList) {
        final ArrayList<IErlElement> modules = new ArrayList<IErlElement>();
        for (int i = 0; i < modList.arity(); ++i) {
            IErlModule m;
            try {
                m = extractModule(modList.elementAt(i));
                modules.add(m);
            } catch (final ErlModelException e) {
            }
View Full Code Here

        } else if (m instanceof OtpErlangAtom) {
            final OtpErlangAtom atom = (OtpErlangAtom) m;
            name = atom.atomValue();
        }
        final String[] modNameParts = name.split("/");
        final IErlModule mod = ErlangEngine.getInstance().getModel()
                .findModule(modNameParts[modNameParts.length - 1]);
        return mod;
    }
View Full Code Here

            return;
        }

        IEditorPart part = null;
        final IErlElementLocator model = ErlangEngine.getInstance().getModel();
        IErlModule module;
        try {
            module = model.findModule(moduleName);
        } catch (final ErlModelException e) {
            ErlLogger.error(e);
            return;
View Full Code Here

    public void addModules(final Collection<String> interpret) {
        final IErlModel model = ErlangEngine.getInstance().getModel();
        for (final String projectColonModule : interpret) {
            // project:module | module
            final String[] projectModule = projectColonModule.split(":");
            IErlModule module = null;
            if (projectModule.length > 1) {
                final IErlProject project = (IErlProject) model
                        .getChildNamed(projectModule[0]);
                if (project != null) {
                    final String mName = projectModule[1];
View Full Code Here

        } else if (commandId.equals(DEINTERPRET_COMMAND_ID)) {
            final ISelection selection = HandlerUtil.getCurrentSelection(event);
            if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
                final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
                for (final Object o : structuredSelection.toArray()) {
                    final IErlModule module = (IErlModule) o;
                    view.interpretOrDeinterpret(module, false);
                }
            }
        } else {
            throw new ExecutionException("bad command id");
View Full Code Here

        }
        if (element instanceof LocalFileStorage) {
            final LocalFileStorage lfs = (LocalFileStorage) element;
            try {
                final IErlElementLocator model = ErlangEngine.getInstance().getModel();
                final IErlModule module = ErlangEngine
                        .getInstance()
                        .getModelFindService()
                        .findModule(model, null, null, lfs.getFullPath().toString(),
                                IErlElementLocator.Scope.ALL_PROJECTS);
                return EditorUtility.getEditorInput(module);
View Full Code Here

    @Test
    public void getImportsAsListTest() throws Exception {
        // given
        // an Erlang module with imports
        final IErlModule moduleA = createModule(project1, "ax.erl",
                "-module(ax).\n-import(lists, [reverse/1, foldl/3].\n");
        moduleA.open(null);
        // when
        // fetching imports as list of OtpErlangTuple
        final Collection<IErlElement> children = moduleA.getChildren();
        final Collection<IErlImport> imports2 = moduleA.getImports();
        final List<OtpErlangObject> imports = modelUtilService.getImportsAsList(moduleA);
        // then
        // they should be returned
        assertEquals(2, children.size());
        assertEquals(1, imports2.size());
View Full Code Here

    @Test
    public void findExternalTypeTest() throws Exception {
        // given
        // an Erlang module with typedef
        final IErlModule moduleB = createModule(project1, "bx.erl",
                "-module(bx).\n-type concat_thing() :: atom() | integer() | float() | string().\n");
        // final IErlModule moduleC =
        // createErlModule(projects[1],
        // "c.erl", "-module(c).\n-type cc() :: b:concat_thing().\n");
        final ScannerService scanner = moduleB.getScanner();
        try {
            moduleB.open(null);
            project1.open(null);
            // moduleC.open(null);
            // when
            // looking for it
            // within project
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();

            final IErlElement element1 = modelFindService.findTypeDef(model, project1,
                    moduleB, "bx", "concat_thing", moduleB.getResource().getLocation()
                            .toPortableString(), IErlElementLocator.Scope.PROJECT_ONLY);
            // in other project but path given
            final IErlElement element2 = modelFindService.findTypeDef(model, project2,
                    moduleB, "bx", "concat_thing", moduleB.getResource().getLocation()
                            .toPortableString(), IErlElementLocator.Scope.PROJECT_ONLY);
            // in other project no path given, search all projects true
            final IErlElement element3 = modelFindService.findTypeDef(model, project2,
                    moduleB, "bx", "concat_thing", null,
                    IErlElementLocator.Scope.ALL_PROJECTS);
View Full Code Here

    @Test
    public void findExternalFunctionModuleTest() throws Exception {
        // given
        // a module with functions and functions
        final IErlModule moduleD = createModule(project1, "d.erl",
                "-module(d).\n-export([f/0]).\nf() ->\n    ok.\ng() ->\n    ?MODULE:f().\n");
        moduleD.open(null);
        // when
        // looking for it with ?MODULE
        final IErlElementLocator model = ErlangEngine.getInstance().getModel();
        final IErlElement element1 = modelFindService.findFunction(model, project1,
                moduleD, "?MODULE", null, new ErlangFunction("f", 0),
View Full Code Here

TOP

Related Classes of org.erlide.engine.model.erlang.IErlModule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.