Package org.erlide.engine.model.erlang

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


    @Test
    public void findPreprocessorDefTest() throws Exception {
        // given
        // a module with includes and record
        final IErlProject project = project1;
        final IErlModule include = createInclude(project, "a.hrl",
                "-record(rec1, {field, another=def}).\n-define(MACRO(A), lists:reverse(A)).\n");
        final IErlModule module = createModule(
                project,
                "f.erl",
                "-module(f).\n-include(\"a.hrl\").\n-export([f/0]).\n-record(rec2, {a, b}).\n"
                        + "f() ->\n    lists:reverse([1, 0]),\n    lists:reverse([1, 0], [2]).\n");
        module.open(null);
        project.open(null);
        final IErlPreprocessorDef preprocessorDef1 = modelFindService
                .findPreprocessorDef(module, "rec1", ErlElementKind.RECORD_DEF);
        final IErlPreprocessorDef preprocessorDef2 = modelFindService
                .findPreprocessorDef(include, "rec1", ErlElementKind.RECORD_DEF);
View Full Code Here


    @Test
    public void findPreprocessorDefOtpIncludeTest() throws Exception {
        // given
        // a module with includes and record
        final IErlProject project = project1;
        final IErlModule module = createModule(
                project,
                "g.erl",
                "-module(g).\n-include_lib(\"kernel/include/file.hrl\").\n-export([f/0]).\n-record(rec2, {a, b}).\n"
                        + "f() ->\n    lists:reverse([1, 0]),\n    lists:reverse([1, 0], [2]).\n");
        module.open(null);
        // when
        // looking for the record
        final IErlPreprocessorDef preprocessorDef = modelFindService.findPreprocessorDef(
                module, "file_info", ErlElementKind.RECORD_DEF);
        // then
View Full Code Here

    }

    @Test
    public void getPreprocessorDefs() throws Exception {
        final IErlProject project = project1;
        final IErlModule module = createModule(project, "a.erl", "-module(g).\n"
                + "-include_lib(\"kernel/include/file.hrl\").\n" + "-export([f/0]).\n"
                + "-define(A(B), '++B++').\n" + "-record(rec2, {a, b}).\n" + "f() ->\n"
                + "    lists:reverse([1, 0]),\n" + "    lists:reverse([1, 0], [2]).\n");
        module.open(null);
        final List<IErlPreprocessorDef> macroDefs = modelUtilService
                .getAllPreprocessorDefs(module, ErlElementKind.MACRO_DEF);
        final List<IErlPreprocessorDef> recordDefs = modelUtilService
                .getAllPreprocessorDefs(module, ErlElementKind.RECORD_DEF);
        assertEquals(2, macroDefs.size());
View Full Code Here

                    .setExternalModulesFile(externalsFile.getAbsolutePath());
            project.open(null);
            // when
            // looking for it
            final IErlElementLocator model = getModel();
            final IErlModule module = modelFindService.findModule(model, null, null,
                    absolutePath, IErlElementLocator.Scope.ALL_PROJECTS);
            // then
            // we should find it
            assertNotNull(module);
            assertEquals(externalFileName, module.getName());
        } finally {
            if (externalFile != null && externalFile.exists()) {
                externalFile.delete();
            }
            if (project != null) {
View Full Code Here

                    .getAbsolutePath());
            project.open(null);
            // when
            // looking for it
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();
            final IErlModule module = modelFindService.findInclude(model, project, null,
                    externalFileName, absolutePath);
            // then
            // we should find it
            assertNotNull(module);
            assertEquals(externalFileName, module.getName());
        } finally {
            if (externalFile != null && externalFile.exists()) {
                externalFile.delete();
            }
            if (project != null) {
View Full Code Here

        final IProject project = project1.getWorkspaceProject();
        final IProjectDescription description = project.getDescription();
        final IProject[] refs = new IProject[] { project2.getWorkspaceProject() };
        description.setReferencedProjects(refs);
        project.setDescription(description, null);
        final IErlModule module = createModule(project2, "abc.erl",
                "-module(abc).\n-export(f/0)\nf() ->\n   {abc, ok}.\n");
        createModule(project1, "bbc.erl",
                "-module(bbc).\n-export(f/0)\nf() ->\n   {abc, ok}.\n");
        // when
        // looking for module with prefix, it should be found
        final List<String> moduleNames = modelUtilService.findUnitsWithPrefix("a",
                project1, false, false);
        // then
        // we should find it
        assertNotNull(moduleNames);
        assertEquals(1, moduleNames.size());
        assertEquals(module.getModuleName(), moduleNames.get(0));
    }
View Full Code Here

                    .setExternalModulesFile(externalsFile.getAbsolutePath());
            project.open(null);
            // when
            // looking for it with its external module path
            final IErlModel model = ErlangEngine.getInstance().getModel();
            final IErlModule module = modelFindService.findModule(model, null, null,
                    absolutePath, IErlElementLocator.Scope.ALL_PROJECTS);
            assertNotNull(module);
            final String externalModulePath = ErlangEngine.getInstance()
                    .getModelUtilService().getExternalModulePath(module);
            ErlLogger.debug(" >> %s", externalModulePath);
            final IErlModule module2 = modelUtilService.getModuleFromExternalModulePath(
                    model, externalModulePath);
            // then
            // we should find it
            assertNotNull(module2);
            assertEquals(externalFileName, module.getName());
View Full Code Here

    public void findTypespec() throws Exception {
        // given
        // a project with a module and an include with a typespec
        final IErlProject project = project1;
        final String includeName = "a.hrl";
        final IErlModule include = createModule(project, includeName,
                "-type date() :: {pos_integer(), pos_integer(), pos_integer()}.\n");
        include.open(null);
        final IErlModule module = createModule(
                project,
                "f.erl",
                "-module(f).\n-include(\"a.hrl\").\n-export([f/0]).\n-record(rec2, {a, b}).\n"
                        + "f() ->\n    lists:reverse([1, 0]),\n    lists:reverse([1, 0], [2]).\n");
        module.open(null);
        // when
        // looking for the typespec
        final IErlTypespec typespec = modelFindService.findTypespec(module, "date");
        // then
        // it should be found
View Full Code Here

        try {
            // ErlModelCache.getDefault().setNoModelCache(true);
            // ErlModelCache.getDefault().clearModelCache();
            final String projectName = "testprojectx";
            project = createProject(projectName, getTmpPath(projectName));
            final IErlModule module = createModule(project, "a.erl",
                    "-include(\"x.hrl\").\n");
            final String includeName = "x.hrl";
            externalInclude = createTmpFile(includeName,
                    "-record(rec2, {field, another=def}.");
            final String includePath = externalInclude.getAbsolutePath();
View Full Code Here

                try {
                    final IErlElementLocator model = ErlangEngine.getInstance()
                            .getModel();
                    final IErlProject erlProject = model.findProject(project);
                    if (erlProject != null) {
                        final IErlModule includeFile = model.findIncludeFromProject(
                                erlProject, fileName, fileName,
                                IErlElementLocator.Scope.REFERENCED_PROJECTS);

                        if (includeFile == null) {
                            result = resource;
                        } else {
                            result = includeFile.getResource();
                        }
                    } else {
                        result = resource;
                    }
                } catch (final Exception e) {
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.