Examples of IErlProject


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

    // IErlModule findIncludeFromProject(IErlProject project, String
    // includeName, String includePath, Scope scope) throws ErlModelException;
    @Test
    public void findIncludeFromProject() throws Exception {
        File externalIncludeFile = null;
        final IErlProject aProject = project;
        final IProject workspaceProject = aProject.getWorkspaceProject();
        final IProject[] referencedProjects = workspaceProject.getReferencedProjects();
        final Collection<IPath> includeDirs = aProject.getProperties().getIncludeDirs();
        // given
        // a project with an external include and an internal include and a
        // referenced project with an include
        try {
            final String xxHrl = "xx.hrl";
            externalIncludeFile = createTmpFile(xxHrl,
                    "-record(rec2, {field, another=def}.");
            final String externalIncludePath = externalIncludeFile.getAbsolutePath();
            final IPath p = new Path(externalIncludePath).removeLastSegments(1);
            final List<IPath> newIncludeDirs = Lists.newArrayList(includeDirs);
            newIncludeDirs.add(p);
            ((ErlProject) aProject).setIncludeDirs(newIncludeDirs);
            final IErlModule include = createInclude(aProject, "yy5.hrl",
                    "-define(Y, include).\n");
            final IErlProject project1 = project2;
            final IErlModule referencedInclude = createInclude(project1, "zz5.hrl",
                    "-define(Z, referenced).\n");
            aProject.open(null);
            // when
            // looking for includes
            final String xx = "xx";
            final IErlModule x1 = model.findIncludeFromProject(aProject, xx, null,
                    IErlElementLocator.Scope.PROJECT_ONLY);
            final IErlModule x2 = model.findIncludeFromProject(aProject, xx, null,
                    IErlElementLocator.Scope.ALL_PROJECTS);
            final IErlModule x3 = model.findIncludeFromProject(aProject, xx, null,
                    IErlElementLocator.Scope.REFERENCED_PROJECTS);
            final String yy = "yy5";
            final IErlModule y1 = model.findIncludeFromProject(aProject, yy, null,
                    IErlElementLocator.Scope.PROJECT_ONLY);
            final IErlModule y2 = model.findIncludeFromProject(aProject, yy, null,
                    IErlElementLocator.Scope.ALL_PROJECTS);
            final IErlModule y3 = model.findIncludeFromProject(aProject, yy, null,
                    IErlElementLocator.Scope.REFERENCED_PROJECTS);
            final IErlModule y4 = model.findIncludeFromProject(project1, yy, null,
                    IErlElementLocator.Scope.PROJECT_ONLY);
            final IErlModule y5 = model.findIncludeFromProject(project1, yy, null,
                    IErlElementLocator.Scope.ALL_PROJECTS);
            final IErlModule y6 = model.findIncludeFromProject(project1, yy, null,
                    IErlElementLocator.Scope.REFERENCED_PROJECTS);
            final String zz = "zz5";
            final IErlModule z1 = model.findIncludeFromProject(aProject, zz, null,
                    IErlElementLocator.Scope.PROJECT_ONLY);
            final IErlModule z2 = model.findIncludeFromProject(aProject, zz, null,
                    IErlElementLocator.Scope.ALL_PROJECTS);
            final IErlModule z3 = model.findIncludeFromProject(aProject, zz, null,
                    IErlElementLocator.Scope.REFERENCED_PROJECTS);
            final IProjectDescription description = workspaceProject.getDescription();
            description.setReferencedProjects(new IProject[] { project1
                    .getWorkspaceProject() });
            workspaceProject.setDescription(description, null);
            aProject.open(null);
            final IErlModule z4 = model.findIncludeFromProject(aProject, zz, null,
                    IErlElementLocator.Scope.PROJECT_ONLY);
View Full Code Here

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

    }

    @Test
    public void findInclude_preferProjectFile() throws Exception {
        File externalIncludeFile = null;
        final IErlProject aProject = project;
        final IProject workspaceProject = aProject.getWorkspaceProject();
        final IProject[] referencedProjects = workspaceProject.getReferencedProjects();
        final Collection<IPath> includeDirs = aProject.getProperties().getIncludeDirs();
        // given
        // a project with an external include and a
        // referenced project with an include, both have same name
        try {
            final String xxHrl = "xx.hrl";
            externalIncludeFile = createTmpFile(xxHrl,
                    "-record(rec2, {field, another=def}.");
            final String externalIncludePath = externalIncludeFile.getAbsolutePath();
            final IPath p = new Path(externalIncludePath).removeLastSegments(1);
            final List<IPath> newIncludeDirs = Lists.newArrayList(includeDirs);
            newIncludeDirs.add(p);
            ((ErlProject) aProject).setIncludeDirs(newIncludeDirs);
            final IErlProject project1 = project2;
            final IErlModule referencedInclude = createInclude(project1, xxHrl,
                    "-define(Z, referenced).\n");
            aProject.open(null);
            // when
            // looking for includes
            final String xx = "xx";
            final IErlModule x1 = model.findIncludeFromProject(aProject, xx, null,
                    IErlElementLocator.Scope.PROJECT_ONLY);
            final IErlModule x2 = model.findIncludeFromProject(aProject, xx, null,
                    IErlElementLocator.Scope.ALL_PROJECTS);
            final IErlModule x3 = model.findIncludeFromProject(aProject, xx, null,
                    IErlElementLocator.Scope.REFERENCED_PROJECTS);
            final IProjectDescription description = workspaceProject.getDescription();
            description.setReferencedProjects(new IProject[] { project1
                    .getWorkspaceProject() });
            workspaceProject.setDescription(description, null);
            aProject.open(null);
            final IErlModule x4 = model.findIncludeFromProject(aProject, xx, null,
                    IErlElementLocator.Scope.PROJECT_ONLY);
View Full Code Here

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

        private void addPathFiltersToContentProvider(final IProject project) {
            // FIXME (JC) all this seems too much... is it really necessary?
            // couldn't we just assume all links in external files should be
            // matchable?
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();
            final IErlProject erlProject = model.findProject(project);
            if (erlProject != null) {
                final ErlangProjectProperties properties = erlProject.getProperties();
                final String extMods = properties.getExternalModules();
                final List<String> files = new ArrayList<String>();
                files.addAll(PreferencesUtils.unpackList(extMods));
                final String extIncs = properties.getExternalIncludes();
                files.addAll(PreferencesUtils.unpackList(extIncs));
View Full Code Here

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

                proxyContentProvider.add(path, moduleFilter);
            }
        }

        private void addPaths(final IProject project) {
            final IErlProject erlProject = ErlangEngine.getInstance().getModel()
                    .getErlangProject(project);
            if (erlProject != null) {
                validPaths.addAll(getFullPaths(project, erlProject.getProperties()
                        .getIncludeDirs()));
                validPaths.addAll(getFullPaths(project, erlProject.getProperties()
                        .getSourceDirs()));
                final Collection<IPath> extras = Lists.newArrayList();
                for (final IPath p : SourcePathUtils.getExtraSourcePathsForModel(project)) {
                    extras.add(p);
                }
View Full Code Here

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

                if (!dest.exists()) {
                    dest.create(true, true, null);
                }
                options.put("dir", new OtpErlangString(dest.getLocation().toString()));
                final List<String> files = new ArrayList<String>();
                final IErlProject erlProject = ErlangEngine.getInstance().getModel()
                        .findProject(project);
                for (final IPath dir : erlProject.getProperties().getSourceDirs()) {
                    final IFolder folder = project.getFolder(dir);
                    if (folder.isAccessible()) {
                        folder.accept(new IResourceVisitor() {
                            @Override
                            public boolean visit(final IResource resource)
View Full Code Here

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

    @Test
    public void moduleWithNonErlangExtension() throws Exception {
        // given an erlang project
        final String projectName = "testproject";
        final IErlProject erlProject = createTmpErlProject(projectName);
        assertNotNull(erlProject);
        // when creating a module with non-erlang extension, e.g. erlx
        final IErlModule a = createModule(erlProject, "a.erlx",
                        "-module(a).\n-export([t/0]).\nt() ->\n    p(a).\np(L) ->\n    lists:reverse(L).\n");
        // then it should be created
View Full Code Here

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

            if (!(element instanceof IResource)) {
                return;
            }
            final IErlElement erlElement = ErlangEngine.getInstance().getModel()
                    .findElement((IResource) element);
            final IErlProject project = ErlangEngine.getInstance().getModelUtilService()
                    .getProject(erlElement);
            if (project != null) {
                projects.add(project);
            }
        }
View Full Code Here

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

    @Override
    public void launch(final IEditorPart editor, final String mode) {
        ErlLogger.debug("** Launch :: " + editor.getTitle());
        if (editor instanceof AbstractErlangEditor) {
            final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) editor;
            final IErlProject project = erlangEditor.getProject();
            if (project != null) {
                try {
                    doLaunch(mode, Lists.newArrayList(project));
                } catch (final CoreException e) {
                    final IWorkbench workbench = PlatformUI.getWorkbench();
View Full Code Here

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

    }

    // IErlModule getModule(String name) throws ErlModelException;
    @Test
    public void getModule() throws Exception {
        final IErlProject aProject = project2;
        final Collection<IPath> sourceDirs = aProject.getProperties().getSourceDirs();
        try {
            // given
            // an Erlang project and a module
            final IErlModule aModule = createModule(aProject, "aa.erl", "-module(aa).\n");
            final IPath srcxPath = new Path("srcx");
            final List<IPath> srcxDirs = Lists.newArrayList(srcxPath);
            aProject.open(null);
            // when
            // setting source dirs so the module is on source path
            final IErlModule module2 = aProject.getModule("aa");
            assertEquals(aModule, module2);

            final IErlModule nullModule = aProject.getModule("aa.hrl");
            final IErlModule nullModule2 = aProject.getModule("AA");
            final IErlModule nullModule3 = aProject.getModule("aA");
            final IErlModule nullModule4 = aProject.getModule("AA.erl");
            assertNull(nullModule);
            assertNull(nullModule2);
            assertNull(nullModule3);
            assertNull(nullModule4);

            final IErlModule module4 = aProject.getModule("aa.erl");
            ((ErlProject) aProject).setSourceDirs(srcxDirs);
            aProject.open(null);
            assertEquals(aModule, module4);

            final IErlModule srcxModule = aProject.getModule("aa");
            ((ErlProject) aProject).setSourceDirs(sourceDirs);
            assertNull(srcxModule);

            aProject.open(null);
            final IErlModule module3 = aProject.getModule("aa");
            assertEquals(aModule, module3);
        } finally {
            ((ErlProject) aProject).setSourceDirs(sourceDirs);
        }
    }
View Full Code Here

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

    }

    // IProject getWorkspaceProject();
    @Test
    public void getWorkspaceProject() throws Exception {
        final IErlProject aProject = project2;
        final IProject workspaceProject = aProject.getWorkspaceProject();
        assertNotNull(workspaceProject);
        assertEquals(aProject.getName(), workspaceProject.getName());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.