Package org.erlide.engine.model.erlang

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


    public IErlModule findModuleFromProject(final IErlProject project,
            final String moduleName, final String modulePath,
            final boolean checkExternals, final IErlElementLocator.Scope scope)
            throws ErlModelException {
        if (project != null) {
            final IErlModule module = getModuleFromCacheByNameOrPath(
                    (ErlProject) project, moduleName, modulePath, scope);
            if (module != null && module.isOnSourcePath()) {
                return module;
            }
        }
        final List<IErlModule> allModules = Lists.newArrayList();
        final Set<String> paths = Sets.newHashSet();
        try {
            for (int i = 0; i < 2; ++i) {
                final boolean externalModules = i > 0;
                if (externalModules && !checkExternals) {
                    break;
                }
                if (project != null) {
                    final IErlModule module = tryFindModule(Sets.newHashSet(project),
                            moduleName, modulePath, allModules, paths, externalModules);
                    if (module != null) {
                        return module;
                    }
                }
                if ((scope == Scope.REFERENCED_PROJECTS || scope == Scope.ALL_PROJECTS)
                        && project != null) {
                    final Collection<IErlProject> projects = project
                            .getReferencedProjects();
                    final IErlModule module = tryFindModule(projects, moduleName,
                            modulePath, allModules, paths, externalModules);
                    if (module != null) {
                        return module;
                    }
                }

                if (scope == Scope.ALL_PROJECTS) {
                    final Collection<IErlProject> projects = getErlangProjects();
                    final IErlModule module = tryFindModule(projects, moduleName,
                            modulePath, allModules, paths, externalModules);
                    if (module != null) {
                        return module;
                    }
                }
View Full Code Here


    private IErlModule tryFindModule(final Collection<IErlProject> projects,
            final String moduleName, final String modulePath,
            final List<IErlModule> allModules, final Set<String> paths,
            final boolean externalModules) throws ErlModelException {
        IErlModule module;
        for (final IErlProject project : projects) {
            final Collection<IErlModule> modules = Lists.newArrayList();
            final Collection<IErlModule> modulesOrExternals = externalModules ? project
                    .getExternalModules() : project.getModules();
            getAllModulesAux(modulesOrExternals, modules, paths);
View Full Code Here

            final IErlElementLocator.Scope scope) throws ErlModelException {
        final IErlElement parent = module.getParent();
        if (parent instanceof IErlFolder) {
            final IErlFolder folder = (IErlFolder) parent;
            folder.open(null);
            final IErlModule include = folder.findInclude(includeName, includePath);
            if (include != null) {
                return include;
            }
        }
        return findIncludeFromProject(ErlangEngine.getInstance().getModelUtilService()
View Full Code Here

    }

    @Override
    public void elementChanged(final IErlElement element) {
        if (element instanceof IErlModule) {
            final IErlModule m = (IErlModule) element;
            final IResource r = m.getResource();
            if (r instanceof IFile) {
                doRefresh((IFile) r);
            }
        }
    }
View Full Code Here

        // Get the file name.
        final String externalModulePath = memento.getString(TAG_EXTERNAL_MODULE_PATH);
        if (externalModulePath == null) {
            return null;
        }
        IErlModule module;
        try {
            final IErlModel model = ErlangEngine.getInstance().getModel();
            module = ErlangEngine.getInstance().getModelUtilService()
                    .getModuleFromExternalModulePath(model, externalModulePath);
        } catch (final ErlModelException e1) {
View Full Code Here

        final Collection<IEditorPart> allErlangEditors = EditorUtility
                .getAllErlangEditors();
        for (final IEditorPart editorPart : allErlangEditors) {
            if (inputElement instanceof IErlElement) {
                final IErlElement element = (IErlElement) inputElement;
                final IErlModule module = ErlangEngine.getInstance()
                        .getModelUtilService().getModule(element);
                final AbstractErlangEditor editor = (AbstractErlangEditor) editorPart;
                if (module.equals(editor.getModule())) {
                    return editorPart;
                }
            }
        }
        final IEditorInput input = getEditorInput(inputElement);
View Full Code Here

    private void findExternalCallsTestAux(final LimitTo limitTo, final int nFoundExpected)
            throws CoreException, ErlModelException, OperationCanceledException {
        // given
        // a module a with an exported function f
        // and a module b which calls a:f()
        final IErlModule moduleA = createModule(project, "a.erl",
                "-module(a). -export([f/0]). f() -> ok.");
        final IErlModule moduleB = createModule(project, "b.erl",
                "-module(b). -export([f/0]). f() -> a:f().");
        moduleA.open(null);
        moduleB.open(null);
        // when
        // searching for the call to a:f
        final ErlangSearchPattern ref = new SearchPatternFactory(ErlangEngine
                .getInstance().getModelUtilService()).getSearchPattern(
                SearchFor.FUNCTION, "a", "f", 0, limitTo, moduleA);
View Full Code Here

    @Test
    public void findCallAfterRecordRef() throws Exception {
        // given
        // a module a with an exported function f
        // and a module b which calls a:f()
        final IErlModule moduleA = createModule(project, "a.erl",
                "-module(a).\n-export([f/0]).\nf() ->\n    ok.\n");
        final IErlModule moduleB = createModule(project, "b.erl",
                "-module(b).\n-export([f/0]).\nf() ->\n    #a.b,\n    a:f().\n");
        moduleA.open(null);
        moduleB.open(null);
        // when
        // searching for the call to a:f
        final ErlangSearchPattern ref = new SearchPatternFactory(ErlangEngine
                .getInstance().getModelUtilService()).getSearchPattern(
                SearchFor.FUNCTION, "a", "f", 0, LimitTo.REFERENCES, moduleA);
View Full Code Here

    @Test
    public void findVariableRef() throws Exception {
        // given
        // a module a with an exported function f
        // and a module b which calls a:f()
        final IErlModule moduleA = createModule(project, "az.erl",
                "-module(az).\n-export([f/1]).\nf(A) ->\n    {A}.\n");
        final IErlModule moduleB = createModule(project, "bz.erl",
                "-module(bz).\n-export([f/0]).\nf(A) ->\n    [A].\n");
        moduleA.open(null);
        moduleB.open(null);
        // when
        // searching for the variable A from module a
        final ErlangSearchPattern pattern = new SearchPatternFactory(ErlangEngine
                .getInstance().getModelUtilService()).getSearchPattern(
                SearchFor.VARIABLE, null, "A", 0, LimitTo.ALL_OCCURRENCES, moduleA);
View Full Code Here

            final String filePath = elt.getFilePath();
            if (parent == ErlangEngine.getInstance().getModel() && filePath != null) {
                parent = elt.getParent();
            }
            if (parent instanceof IErlModule) {
                final IErlModule mod = (IErlModule) parent;
                final IResource resource = mod.getCorrespondingResource();
                if (resource != null) {
                    return resource;
                }
            } else {
                return parent;
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.