use of org.erlide.engine.model.root.IErlElementLocator in project erlide_eclipse by erlang.
the class ModelUtilsTest method findExternalFunctionModuleTest.
@Test
public void findExternalFunctionModuleTest() throws Exception {
// given
// a module with functions and functions
final IErlModule moduleD = ErlideTestUtils.createModule(ModelUtilsTest.projects[0], "d.erl", "-module(d).\n-export([f/0]).\nf() ->\n ok.\ng() ->\n ?MODULE:f().\n");
moduleD.open(null);
// when
// looking for it with ?MODULE
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlElement element1 = modelFindService.findFunction(model, ModelUtilsTest.projects[0], moduleD, "?MODULE", null, new ErlangFunction("f", 0), IErlElementLocator.Scope.PROJECT_ONLY);
// then
// it should be found
assertTrue(element1 instanceof IErlFunction);
}
use of org.erlide.engine.model.root.IErlElementLocator in project erlide_eclipse by erlang.
the class ErlangExternalEditorInputFactory method saveState.
public static void saveState(final IMemento memento, final ErlangExternalEditorInput input) {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final String externalModulePath = ErlangEngine.getInstance().getModelUtilService().getExternalModulePath(model, input.getModule());
memento.putString(ErlangExternalEditorInputFactory.TAG_EXTERNAL_MODULE_PATH, externalModulePath);
final URI uri = input.getURI();
memento.putString(ErlangExternalEditorInputFactory.TAG_URI, uri.toString());
}
use of org.erlide.engine.model.root.IErlElementLocator in project erlide_eclipse by erlang.
the class ErlangCompletionService method getExternalCallCompletions.
List<CompletionData> getExternalCallCompletions(final IOtpRpc b, final String moduleName0, final int offset, final String prefix, final boolean arityOnly) throws CoreException {
final ModelFindService modelFindService = ErlangEngine.getInstance().getModelFindService();
final String moduleName = modelFindService.resolveMacroValue(moduleName0, module);
// we have an external call
final List<CompletionData> result = new ArrayList<>();
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule theModule = modelFindService.findModule(model, project, moduleName, null, IErlElementLocator.Scope.ALL_PROJECTS);
// FIXME or IErlElementLocator.Scope.REFERENCED_PROJECTS
if (theModule != null) {
if (ErlangEngine.getInstance().getModelUtilService().isOtpModule(theModule)) {
final OtpErlangObject res = ErlangEngine.getInstance().getOtpDocService().getProposalsWithDoc(b, moduleName, prefix);
addFunctionProposalsWithDoc(offset, prefix, result, res, null, arityOnly);
} else {
addFunctionsFromModule(offset, prefix, arityOnly, result, theModule);
}
}
return result;
}
use of org.erlide.engine.model.root.IErlElementLocator in project erlide_eclipse by erlang.
the class ErlDebugModelPresentation method getEditorInput.
@Override
public IEditorInput getEditorInput(final Object element) {
if (element instanceof IFile) {
return new FileEditorInput((IFile) element);
}
if (element instanceof ILineBreakpoint) {
return new FileEditorInput((IFile) ((ILineBreakpoint) element).getMarker().getResource());
}
if (element instanceof LocalFileStorage) {
final LocalFileStorage lfs = (LocalFileStorage) element;
try {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
final IErlModule module = ErlangEngine.getInstance().getModelFindService().findModule(model, null, null, lfs.getFullPath().toString(), IErlElementLocator.Scope.ALL_PROJECTS);
return EditorUtility.getEditorInput(module);
} catch (final CoreException e) {
ErlLogger.error(e);
}
}
return null;
}
use of org.erlide.engine.model.root.IErlElementLocator in project erlide_eclipse by erlang.
the class OpenUtils method findExternalCallOrType.
private IErlElement findExternalCallOrType(final IErlModule module, final OpenResult res, final IErlProject project, final IErlElement element, final IErlElementLocator.Scope scope) throws CoreException {
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
if (isTypeDefOrRecordDef(element, res)) {
return modelFindService.findTypeDef(model, project, module, res.getName(), res.getFun(), res.getPath(), scope);
}
final IErlFunction result = modelFindService.findFunction(model, project, module, res.getName(), res.getPath(), res.getFunction(), scope);
if (result != null) {
return result;
}
return modelFindService.findFunction(model, project, module, res.getName(), res.getPath(), new ErlangFunction(res.getFun(), ErlangFunction.ANY_ARITY), scope);
}
Aggregations