Package org.erlide.engine.model.root

Examples of org.erlide.engine.model.root.IErlProject


    }

    @Test
    public void findExternalIncludeFileOnIncludePath() throws Exception {
        File externalInclude = null;
        IErlProject project = null;
        // given
        // a project with an include dir outside the model
        try {
            final String projectName = "testprojectx";
            project = createProject(projectName, getTmpPath(projectName));
            final String includeName = "x01.hrl";
            externalInclude = createTmpFile(includeName,
                    "-record(rec2, {field, another=def}.");
            final String includePath = externalInclude.getAbsolutePath();
            final IPath p = new Path(includePath).removeLastSegments(1);
            ((ErlProject) project).setIncludeDirs(Lists.newArrayList(p));
            // when
            // looking for the include file
            // String includeFile =
            // ErlangEngine.getInstance().getModelUtilService().findIncludeFile(erlProject,
            // "x.hrl", "");
            project.open(null);
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();
            final IErlModule module = model.findIncludeFromProject(project, null,
                    includePath, IErlElementLocator.Scope.REFERENCED_PROJECTS);
            final IErlModule module2 = model.findModuleFromProject(project, includeName,
                    null, IErlElementLocator.Scope.REFERENCED_PROJECTS);
View Full Code Here


    @Test
    public void findIncludeFileOnIncludePathInOtherProject() throws Exception {
        // http://www.assembla.com/spaces/erlide/tickets/756-navigation--external-include-files-are-not-found
        IErlModule externalInclude = null;
        IErlProject project = null;
        IErlProject project2 = null;
        // given
        // a project with an include dir outside the model
        try {
            final String projectName = "testprojectx";
            project = createProject(projectName, getTmpPath(projectName));
View Full Code Here

    @Test
    public void findFunctionInExternalFilesTest() throws Exception {
        // given
        // a module with calls to the lists module
        final IErlProject project = projects[0];
        final IErlModule moduleE = createModule(
                project,
                "e.erl",
                "-module(e).\n-export([f/0]).\nf() ->\n    lists:reverse([1, 0]),\n    lists:reverse([1, 0], [2]).\n");
        final ScannerService scanner = moduleE.getScanner();
        try {
            moduleE.open(null);
            // when
            // looking for lists:reverse/2 and lists:reverse/1
            final IErlModel model = ErlangEngine.getInstance().getModel();
            final OpenResult res = ErlangEngine
                    .getInstance()
                    .getService(OpenService.class)
                    .open(moduleE.getScannerName(),
                            49,
                            ErlangEngine.getInstance().getModelUtilService()
                                    .getImportsAsList(moduleE),
                            project.getProperties().getExternalModules(),
                            model.getPathVars(project.getWorkspaceProject()));
            assertTrue(res instanceof ExternalCallOpenResult);
            final ExternalCallOpenResult eres = (ExternalCallOpenResult) res;
            final IErlFunction function = ErlangEngine
                    .getInstance()
                    .getModelFindService()
View Full Code Here

    }

    @Test
    public void findExternalModule() throws Exception {
        File externalFile = null;
        IErlProject project = null;
        try {
            // given
            // an erlang project with an external file
            final String projectName = "testproject";
            project = createTmpErlProject(projectName);
            final String externalFileName = "external.erl";
            externalFile = createTmpFile(externalFileName,
                    "-module(external).\nf([_ | _]=L ->\n    atom_to_list(L).\n");
            final String absolutePath = externalFile.getAbsolutePath();
            final String externalsFileName = "x.erlidex";
            final File externalsFile = createTmpFile(externalsFileName, absolutePath);
            ((ErlProject) project)
                    .setExternalModulesFile(externalsFile.getAbsolutePath());
            project.open(null);
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();
            // when
            // looking for it
            final IErlModule externalModule = model.findModuleFromProject(project,
                    externalFileName, null, IErlElementLocator.Scope.PROJECT_ONLY);
View Full Code Here

public class ErlModelCacheTest extends WorkspaceTest {

    @Test
    public void checkThatCachesAreEmptyWhenProjectIsRemoved() throws CoreException {
        IErlProject project = null;
        try {
            // given
            // a project with a module, and some searches that fills the model
            // cache
            final String projectName = "testprojectx";
            project = createProject(
                    projectName, getTmpPath(projectName));
            final String moduleName = "f.erl";
            final IErlModule module = createModule(
                            project,
                            moduleName,
                            "-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);
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();
            final IErlModule module2 = model.findModuleFromProject(project, moduleName,
                    null, IErlElementLocator.Scope.PROJECT_ONLY);
            // final ErlModelCache cache = ErlModelCache.getDefault();
            // final Set<IErlModule> modulesByName2 = cache
            // .getModulesByName(ListsUtils.withoutExtension(moduleName));
            // when
            // deleting the project
            deleteProject(project);
            // then
            // the model cache shouldn't know about the module anymore
            assertEquals(module2, module);
            // final Set<IErlModule> modulesByName = cache
            // .getModulesByName(ListsUtils.withoutExtension(moduleName));
            // assertTrue(!modulesByName2.isEmpty());
            // assertTrue(modulesByName.isEmpty());
        } finally {
            if (project != null && project.exists()) {
                deleteProject(project);
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void checkThatNewModulesInNewProjectsAreCorrect() throws Exception {
        IErlProject project = null;
        IErlProject project2 = null;
        try {
            // given
            // a project with an external module and searching for it so the
            // cache
            // is updated
            final String projectName = "testprojecta";
            project = createProject(
                    projectName, getTmpPath(projectName));
            final String externalName = "xyz.erl";
            final File externalFile = createTmpFile(externalName,
                    "-module(xyz).\nf([_ | _]=L ->\n    atom_to_list(L).\n");
            final String absolutePath = externalFile.getAbsolutePath();
            final File externalsFile = createTmpFile("x.erlidex",
                    absolutePath);
            ((ErlProject) project)
                    .setExternalModulesFile(externalsFile.getAbsolutePath());
            project.open(null);
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();
            final IErlModule findModule = model.findModuleFromProject(project,
                    externalName, null, IErlElementLocator.Scope.PROJECT_ONLY);
            // final ErlModelCache cache = ErlModelCache.getDefault();
            // final Set<IErlModule> modulesByName = cache
            // .getModulesByName(ListsUtils
            // .withoutExtension(externalName));
            // when
            // creating a new project with a module with the same name and
            // searching
            // for it
            final String projectName2 = "testprojectb";
            project2 = createProject(
                    projectName2, getTmpPath(projectName2));
            final IErlModule module = createModule(project2,
                    externalName, "-module(xyz).\n");
            final IErlModule findModule2 = model.findModuleFromProject(project,
                    externalName, null, IErlElementLocator.Scope.ALL_PROJECTS);
            // final Set<IErlModule> modulesByName2 = cache
            // .getModulesByName(ListsUtils
            // .withoutExtension(externalName));
            // then
            // the new module should be found
            assertNotNull(findModule);
            assertEquals(module, findModule2);
            // assertTrue(modulesByName2.contains(module));
            // final SetView<IErlModule> difference = Sets.difference(
            // modulesByName2, modulesByName);
            // assertEquals(1, difference.size());
            // assertEquals(module, difference.toArray()[0]);
        } finally {
            if (project != null && project.exists()) {
                deleteProject(project);
            }
            if (project2 != null && project2.exists()) {
                deleteProject(project2);
            }
        }
    }
View Full Code Here

                    container = (IContainer) resource;
                } else {
                    container = resource.getParent();
                }
                final IProject project = resource.getProject();
                final IErlProject erlProject = ErlangEngine.getInstance().getModel()
                        .getErlangProject(project);
                String txt = container.getFullPath().toString();
                final Collection<IPath> sourceDirs = erlProject.getProperties()
                        .getSourceDirs();
                if (!sourceDirs.isEmpty()) {
                    final IPath sourceDirWithinContainer = sourceDirWithinContainer(
                            sourceDirs, container);
                    if (sourceDirWithinContainer != null) {
View Full Code Here

        final int interrogationMarkPos = text.lastIndexOf('?');
        final int arrowPos = text.lastIndexOf("->");

        RecordCompletion rc = null;
        if (hashMarkPos >= 0) {
            final IErlProject aproject = project;
            if (aproject != null) {
                rc = ErlangEngine
                        .getInstance()
                        .getContextAssistService()
                        .checkRecordCompletion(BackendCore.getBuildBackend(aproject),
View Full Code Here

    }

    private List<ICompletionProposal> addCompletions(final CompletionOptions options)
            throws CoreException, BadLocationException {
        final List<ICompletionProposal> result = new ArrayList<ICompletionProposal>();
        final IErlProject aProject = project;
        if (aProject == null) {
            return result;
        }
        final IOtpRpc backend = BackendCore.getBuildBackend(aProject);
        if (options.flags.contains(Kinds.DECLARED_FUNCTIONS)) {
View Full Code Here

        final IErlangEngine engine = ErlangEngine.getInstance();
        if (engine == null) {
            ErlLogger.warn("Erlang engine was not created!");
            return null;
        }
        final IErlProject erlProject = engine.getModel().getErlangProject(project);
        if (erlProject == null) {
            ErlLogger.warn("Project " + project + " is not in erlang model...");
            return null;
        }
        final IFolder r = project.getFolder(erlProject.getProperties().getOutputDir());
        try {
            r.refreshLocal(IResource.DEPTH_ONE, null);
        } catch (final CoreException e) {
            // ignore
        }
View Full Code Here

TOP

Related Classes of org.erlide.engine.model.root.IErlProject

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.