Search in sources :

Example 26 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class ErlProject method getExternalModules.

@Override
public Collection<IErlModule> getExternalModules() throws ErlModelException {
    final List<IErlModule> result = Lists.newArrayList();
    accept(new IErlElementVisitor() {

        @Override
        public boolean visit(final IErlElement element) throws ErlModelException {
            final boolean isExternalOrProject = element.getKind() == ErlElementKind.EXTERNAL_ROOT || element.getKind() == ErlElementKind.EXTERNAL_APP || element.getKind() == ErlElementKind.EXTERNAL_FOLDER || element.getKind() == ErlElementKind.PROJECT;
            if (element instanceof IErlModule) {
                final IErlModule module = (IErlModule) element;
                if (module.getAncestorOfKind(ErlElementKind.PROJECT) == ErlProject.this) {
                    result.add(module);
                }
                return false;
            } else if (isExternalOrProject && element instanceof IOpenable) {
                final IOpenable openable = (IOpenable) element;
                openable.open(null);
            }
            return isExternalOrProject;
        }
    }, EnumSet.noneOf(AcceptFlags.class), ErlElementKind.MODULE);
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IOpenable(org.erlide.engine.model.root.IOpenable) ErlModelException(org.erlide.engine.model.ErlModelException) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementVisitor(org.erlide.engine.model.IErlElementVisitor)

Example 27 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class ErlideTestUtils method createModuleFromText.

public static IErlModule createModuleFromText(final String initialText) {
    final IErlModel model = ErlangEngine.getInstance().getModel();
    final IErlModule module = model.getModuleFromText(model, "test1", initialText, null);
    ErlideTestUtils.modulesAndIncludes.add(module);
    return module;
}
Also used : IErlModel(org.erlide.engine.model.root.IErlModel) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 28 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class ErlideTestUtils method createModule.

public static IErlModule createModule(final String moduleName, final String moduleContents, final IFolder folder) throws CoreException {
    final IFile file = ErlideTestUtils.createFile(folder.getProject(), folder.getName() + "/" + moduleName, moduleContents);
    final IErlModel model = ErlangEngine.getInstance().getModel();
    IErlModule module = model.findModule(file);
    if (module == null) {
        final IPath path = file.getLocation();
        module = model.getModuleFromFile(model, file.getName(), path, Charset.defaultCharset());
    }
    return module;
}
Also used : IFile(org.eclipse.core.resources.IFile) IErlModel(org.erlide.engine.model.root.IErlModel) IPath(org.eclipse.core.runtime.IPath) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 29 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class ErlideTestUtils method createModule.

public static IErlModule createModule(final IErlProject project, final String moduleName, final String moduleContents) throws CoreException {
    final IFolder folder = project.getWorkspaceProject().getFolder("src");
    final IErlModule module = ErlideTestUtils.createModule(moduleName, moduleContents, folder);
    ErlideTestUtils.modulesAndIncludes.add(module);
    return module;
}
Also used : IErlModule(org.erlide.engine.model.root.IErlModule) IFolder(org.eclipse.core.resources.IFolder)

Example 30 with IErlModule

use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.

the class ErlideSearchServer method getModulesFromScope.

private OtpErlangList getModulesFromScope(final ErlSearchScope scope) {
    final OtpErlangObject[] result = new OtpErlangObject[scope.size()];
    int i = 0;
    for (final IErlModule module : scope.getModules()) {
        result[i] = make2Tuple(module.getScannerName(), module.getFilePath());
        i++;
    }
    return new OtpErlangList(result);
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) IErlModule(org.erlide.engine.model.root.IErlModule)

Aggregations

IErlModule (org.erlide.engine.model.root.IErlModule)191 Test (org.junit.Test)66 IErlProject (org.erlide.engine.model.root.IErlProject)57 IErlElement (org.erlide.engine.model.IErlElement)35 IFile (org.eclipse.core.resources.IFile)26 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)26 ErlModelException (org.erlide.engine.model.ErlModelException)22 IPath (org.eclipse.core.runtime.IPath)21 ErlProject (org.erlide.engine.internal.model.root.ErlProject)21 File (java.io.File)20 IErlModel (org.erlide.engine.model.root.IErlModel)18 Path (org.eclipse.core.runtime.Path)17 IProject (org.eclipse.core.resources.IProject)16 IResource (org.eclipse.core.resources.IResource)14 ArrayList (java.util.ArrayList)13 CoreException (org.eclipse.core.runtime.CoreException)10 IEditorPart (org.eclipse.ui.IEditorPart)10 IParent (org.erlide.engine.model.IParent)10 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)9 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)9