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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations