Search in sources :

Example 86 with IErlProject

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

the class ModelInternalUtils method getModuleInfo.

@Override
public String getModuleInfo(final IErlModule module) {
    final String errorValue = "There is no module information about this file.";
    if (module == null) {
        return errorValue;
    }
    final IErlProject project = getProject(module);
    final IPath beamPath = project.getProperties().getOutputDir().append(module.getModuleName()).addFileExtension("beam");
    final IFile beam = project.getWorkspaceProject().getFile(beamPath);
    try {
        final OtpErlangObject info = backend.call("erlide_backend", "get_module_info", "s", beam.getLocation().toPortableString());
        return (String) TypeConverter.erlang2java(info, String.class);
    } catch (final Exception e) {
        ErlLogger.warn(e);
    }
    return errorValue;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ErlModelException(org.erlide.engine.model.ErlModelException)

Example 87 with IErlProject

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

the class ErlideTestUtils method createErlProject.

public static IErlProject createErlProject(final String name) throws CoreException {
    final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    final IProject project2 = root.getProject(name);
    try {
        project2.delete(true, null);
    } catch (final CoreException x) {
    // ignore
    }
    final IErlProject erlProject = ErlangEngine.getInstance().getModel().newProject(name);
    erlProject.getBuilderProperties().setBuilderTool(BuilderTool.INTERNAL);
    final IProject project = erlProject.getWorkspaceProject();
    final ErlangProjectProperties prefs = erlProject.getProperties();
    final List<IPath> srcDirs = new ArrayList<>();
    ErlideTestUtils.createFolder(project2, "src");
    srcDirs.add(new Path("src"));
    prefs.setSourceDirs(srcDirs);
    ErlideTestUtils.buildPaths(root, project, srcDirs);
    final List<IPath> includeDirs = new ArrayList<>();
    ErlideTestUtils.createFolder(project2, "include");
    includeDirs.add(new Path("include"));
    ErlideTestUtils.buildPaths(root, project, includeDirs);
    prefs.setIncludeDirs(includeDirs);
    ErlideTestUtils.createFolder(project2, "ebin");
    final IPath ebinDir = new Path("ebin");
    ErlideTestUtils.buildPaths(root, project, Lists.newArrayList(ebinDir));
    prefs.setOutputDir(ebinDir);
    ErlideTestUtils.projects.add(erlProject);
    return erlProject;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) ErlangProjectProperties(org.erlide.engine.model.root.ErlangProjectProperties) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject)

Example 88 with IErlProject

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

the class InterpretedModuleListContentProvider method addModules.

/**
 * Find modules from string list add to IFile-list
 *
 * @param interpret
 *            the list of strings from prefs (projectName:fileName;... or
 *            moduleName;...)
 */
public void addModules(final Collection<String> interpret) {
    final IErlModel model = ErlangEngine.getInstance().getModel();
    for (final String projectColonModule : interpret) {
        // project:module | module
        final String[] projectModule = projectColonModule.split(":");
        IErlModule module = null;
        if (projectModule.length > 1) {
            final IErlProject project = (IErlProject) model.getChildNamed(projectModule[0]);
            if (project != null) {
                final String mName = projectModule[1];
                try {
                    final boolean isErlangFile = CommonUtils.isErlangFileContentFileName(mName);
                    final String s = isErlangFile ? mName : mName + ".erl";
                    module = project.getModule(s);
                } catch (final ErlModelException e) {
                    ErlLogger.warn(e);
                }
            }
        } else {
            try {
                module = model.findModule(projectColonModule);
            } catch (final ErlModelException e) {
            }
        }
        addModule(module);
    }
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModel(org.erlide.engine.model.root.IErlModel) ErlModelException(org.erlide.engine.model.ErlModelException) IErlModule(org.erlide.engine.model.root.IErlModule)

Example 89 with IErlProject

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

the class RunDialyzerHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final ISelection selection = HandlerUtil.getCurrentSelection(event);
    final Set<IErlModule> modules = collectModulesFromSelection(selection);
    final Set<IErlProject> projects = collectProjectsFromModules(modules);
    // build
    final WorkspaceJob buildJob = new BuildOperation("Building projects", projects);
    buildJob.setUser(true);
    buildJob.setRule(ResourcesPlugin.getWorkspace().getRuleFactory().buildRule());
    buildJob.schedule();
    // run dialyzer
    final Job job = new DialyzeOperation("Running Dialyzer", modules, projects);
    final ISchedulingRule rule = createRuleForModules(modules);
    job.setRule(rule);
    job.setUser(true);
    job.schedule();
    return null;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) ISelection(org.eclipse.jface.viewers.ISelection) IErlModule(org.erlide.engine.model.root.IErlModule) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) Job(org.eclipse.core.runtime.jobs.Job) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule)

Example 90 with IErlProject

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

the class RunDialyzerHandler method collectProjectsFromModules.

private Set<IErlProject> collectProjectsFromModules(final Set<IErlModule> modules) {
    final Set<IErlProject> projects = Sets.newHashSet();
    for (final IErlModule module : modules) {
        final IErlProject project = ErlangEngine.getInstance().getModelUtilService().getProject(module);
        projects.add(project);
    }
    return projects;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IErlModule(org.erlide.engine.model.root.IErlModule)

Aggregations

IErlProject (org.erlide.engine.model.root.IErlProject)123 IErlModule (org.erlide.engine.model.root.IErlModule)57 Test (org.junit.Test)47 IPath (org.eclipse.core.runtime.IPath)30 IProject (org.eclipse.core.resources.IProject)29 ErlProject (org.erlide.engine.internal.model.root.ErlProject)25 File (java.io.File)19 Path (org.eclipse.core.runtime.Path)16 CoreException (org.eclipse.core.runtime.CoreException)13 ErlModelException (org.erlide.engine.model.ErlModelException)13 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)13 IErlModel (org.erlide.engine.model.root.IErlModel)13 ArrayList (java.util.ArrayList)11 IErlElement (org.erlide.engine.model.IErlElement)10 IFile (org.eclipse.core.resources.IFile)9 IResource (org.eclipse.core.resources.IResource)9 HashSet (java.util.HashSet)7 IProjectDescription (org.eclipse.core.resources.IProjectDescription)7 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)6 IErlPreprocessorDef (org.erlide.engine.model.erlang.IErlPreprocessorDef)6