Search in sources :

Example 21 with IErlElementLocator

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);
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlFunction(org.erlide.engine.model.erlang.IErlFunction) IErlModule(org.erlide.engine.model.root.IErlModule) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) Test(org.junit.Test)

Example 22 with IErlElementLocator

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());
}
Also used : IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) URI(java.net.URI)

Example 23 with IErlElementLocator

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;
}
Also used : CompletionData(org.erlide.engine.services.codeassist.CompletionData) FunctionCompletionData(org.erlide.engine.services.codeassist.FunctionCompletionData) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) IErlModule(org.erlide.engine.model.root.IErlModule) ModelFindService(org.erlide.engine.services.search.ModelFindService) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 24 with IErlElementLocator

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;
}
Also used : IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) LocalFileStorage(org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage) IErlModule(org.erlide.engine.model.root.IErlModule) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator)

Example 25 with IErlElementLocator

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);
}
Also used : IErlFunction(org.erlide.engine.model.erlang.IErlFunction) ErlangFunction(org.erlide.engine.model.erlang.ErlangFunction) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator)

Aggregations

IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)33 IErlModule (org.erlide.engine.model.root.IErlModule)26 Test (org.junit.Test)17 IErlProject (org.erlide.engine.model.root.IErlProject)13 ErlProject (org.erlide.engine.internal.model.root.ErlProject)8 File (java.io.File)7 IFile (org.eclipse.core.resources.IFile)7 IErlElement (org.erlide.engine.model.IErlElement)6 IProject (org.eclipse.core.resources.IProject)5 IPath (org.eclipse.core.runtime.IPath)5 Path (org.eclipse.core.runtime.Path)5 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)3 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)3 IFolder (org.eclipse.core.resources.IFolder)3 CoreException (org.eclipse.core.runtime.CoreException)3 IErlFunction (org.erlide.engine.model.erlang.IErlFunction)3 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)2 ArrayList (java.util.ArrayList)2 IMarker (org.eclipse.core.resources.IMarker)2 IResource (org.eclipse.core.resources.IResource)2