use of org.erlide.engine.model.root.IErlModel in project erlide_eclipse by erlang.
the class ErlFolder method buildStructure.
@Override
public boolean buildStructure(final IProgressMonitor pm) throws ErlModelException {
final IErlModel model = ErlangEngine.getInstance().getModel();
final IContainer c = (IContainer) getResource();
try {
// FIXME this is general stuff -> model or model manager?
final IResource[] members = c.members();
for (final IResource resource : members) {
model.create(resource);
}
} catch (final CoreException e) {
throw new ErlModelException(new ErlModelStatus(ErlModelStatusConstants.CORE_EXCEPTION, e));
}
return true;
}
use of org.erlide.engine.model.root.IErlModel in project erlide_eclipse by erlang.
the class ErlideTestUtils method deleteProject.
public static void deleteProject(final IErlProject erlProject) throws CoreException {
final IProject project = erlProject.getWorkspaceProject();
final IPath location = project.getLocation();
project.delete(true, null);
if (location != null) {
new File(location.toPortableString()).delete();
}
if (ErlideTestUtils.modulesAndIncludes != null) {
final List<IErlModule> list = Lists.newArrayList(ErlideTestUtils.modulesAndIncludes);
for (final IErlModule module : list) {
if (ErlangEngine.getInstance().getModelUtilService().getProject(module) == erlProject) {
ErlideTestUtils.deleteModule(module);
}
}
}
erlProject.dispose();
if (ErlideTestUtils.projects != null) {
ErlideTestUtils.projects.remove(ErlangEngine.getInstance().getModel().findProject(project));
}
final IErlModel model = ErlangEngine.getInstance().getModel();
model.resourceChanged(null);
model.open(null);
}
use of org.erlide.engine.model.root.IErlModel 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.IErlModel in project erlide_eclipse by erlang.
the class RunDialyzerHandler method collectModulesFromSelection.
private Set<IErlModule> collectModulesFromSelection(final ISelection selection) {
final Set<IErlModule> modules = Sets.newHashSet();
if (selection instanceof IStructuredSelection) {
final IStructuredSelection structuredSelection = (IStructuredSelection) selection;
final IErlModel model = ErlangEngine.getInstance().getModel();
try {
model.open(null);
for (final Object i : structuredSelection.toList()) {
if (i instanceof IResource) {
final IResource r = (IResource) i;
modules.addAll(DialyzerUtils.collectModulesFromResource(model, r));
}
}
} catch (final ErlModelException e) {
ErlLogger.debug(e);
}
}
return modules;
}
use of org.erlide.engine.model.root.IErlModel in project erlide_eclipse by erlang.
the class OpenAction method run.
@Override
public void run(final ITextSelection selection) {
try {
final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
final int offset = selection.getOffset();
ITextEditor textEditor = null;
OpenResult openResult = null;
IErlElement element = null;
IErlProject project = null;
IErlModule module = null;
final IErlModel model = ErlangEngine.getInstance().getModel();
if (activeEditor instanceof AbstractErlangEditor) {
final AbstractErlangEditor editor = (AbstractErlangEditor) activeEditor;
textEditor = editor;
editor.reconcileNow();
final String scannerName = editor.getScannerName();
module = editor.getModule();
project = editor.getProject();
openResult = ErlangEngine.getInstance().getOpenService().open(scannerName, offset, ErlangEngine.getInstance().getModelUtilService().getImportsAsList(module), project.getProperties().getExternalModules(), model.getPathVars());
ErlLogger.debug("open " + openResult);
element = editor.getElementAt(offset, true);
} else if (activeEditor instanceof ITextEditor) {
textEditor = (ITextEditor) activeEditor;
final String text = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()).get();
openResult = ErlangEngine.getInstance().getOpenService().openText(text, offset);
final IFile file = textEditor.getEditorInput().getAdapter(IFile.class);
if (file != null) {
final IProject p = file.getProject();
if (p != null) {
project = model.findProject(p);
}
}
}
if (openResult != null) {
helper.openOpenResult(textEditor, module, offset, project, openResult, element);
}
} catch (final Exception e) {
ErlLogger.error(e);
}
}
Aggregations