use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlModelUtils method openExternalFunction.
public static boolean openExternalFunction(final String moduleName, final ErlangFunction function, final String modulePath, final IErlModule module, final IErlProject project, final IErlElementLocator.Scope scope) throws CoreException {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule module2 = ErlangEngine.getInstance().getModelFindService().findModule(model, project, moduleName, modulePath, scope);
if (module2 != null) {
final IEditorPart editor = EditorUtility.openInEditor(module2);
return ErlModelUtils.openFunctionInEditor(function, editor);
}
return false;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlModelUtils method openModule.
public static void openModule(final String moduleName) throws CoreException {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule module = ErlangEngine.getInstance().getModelFindService().findModule(model, null, moduleName, null, IErlElementLocator.Scope.ALL_PROJECTS);
if (module != null) {
EditorUtility.openInEditor(module);
}
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlModelUtils method openFunctionInEditor.
/**
* Activate editor and select erlang function
*/
public static boolean openFunctionInEditor(final ErlangFunction erlangFunction, final IEditorPart editor) throws CoreException {
final AbstractErlangEditor erlangEditor = (AbstractErlangEditor) editor;
final IErlModule module = erlangEditor.getModule();
if (module == null) {
return false;
}
module.open(null);
final IErlFunction function = module.findFunction(erlangFunction);
if (function == null) {
return false;
}
EditorUtility.revealInEditor(editor, function);
return true;
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class ErlModelUtils method getModule.
public static IErlModule getModule(final IEditorInput editorInput) throws CoreException {
if (editorInput instanceof IFileEditorInput) {
final IFileEditorInput input = (IFileEditorInput) editorInput;
final IFile file = input.getFile();
final IErlModel model = ErlangEngine.getInstance().getModel();
IErlModule module = model.findModule(file);
if (module != null) {
return module;
}
final IPath path = file.getLocation();
Charset encoding;
try {
encoding = Charset.forName(file.getCharset());
} catch (Exception e) {
encoding = Charsets.UTF_8;
}
module = model.getModuleFromFile(model, file.getName(), path, encoding);
module.setResource(file);
return module;
}
if (editorInput instanceof ErlangExternalEditorInput) {
final ErlangExternalEditorInput erlangExternalEditorInput = (ErlangExternalEditorInput) editorInput;
return erlangExternalEditorInput.getModule();
}
final String path = ErlModelUtils.getPathForInput(editorInput);
if (path == null) {
return null;
}
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule module = ErlangEngine.getInstance().getModelFindService().findModule(model, null, null, path, IErlElementLocator.Scope.ALL_PROJECTS);
if (module != null) {
return module;
}
final Charset encoding = ErlModelUtils.getEncodingForInput(editorInput);
final IPath p = new Path(path);
return ErlangEngine.getInstance().getModel().getModuleFromFile(null, p.lastSegment(), p, encoding);
}
use of org.erlide.engine.model.root.IErlModule in project erlide_eclipse by erlang.
the class IErlImportTest method getImportModule.
// public String getImportModule();
@Test
public void getImportModule() throws Exception {
final IErlModule module2 = ErlideTestUtils.createModule(project, "zz.erl", "-module(zz).\n" + "-import(lists, [foldl/3, reverse/1, reverse/2]).\n");
module2.open(null);
final List<IErlElement> imports = module2.getChildrenOfKind(ErlElementKind.IMPORT);
final IErlImport import1 = (IErlImport) imports.get(0);
final String importModule = import1.getImportModule();
assertEquals("lists", importModule);
}
Aggregations