Search in sources :

Example 16 with IErlFunction

use of org.erlide.engine.model.erlang.IErlFunction in project erlide_eclipse by erlang.

the class ErlangCompletionService method addFunctionsFromModule.

boolean addFunctionsFromModule(final int offset, final String prefix, final boolean arityOnly, final List<CompletionData> proposals, final IErlModule m) {
    boolean result = false;
    try {
        m.open(null);
        for (final IErlElement e : m.getChildren()) {
            if (e instanceof IErlFunction) {
                final IErlFunction f = (IErlFunction) e;
                if (f.isExported()) {
                    addFunctionCompletion(offset, prefix, proposals, f, arityOnly);
                    result = true;
                }
            }
        }
    } catch (final ErlModelException e) {
        ErlLogger.error(e);
    }
    return result;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) ErlModelException(org.erlide.engine.model.ErlModelException) IErlFunction(org.erlide.engine.model.erlang.IErlFunction)

Example 17 with IErlFunction

use of org.erlide.engine.model.erlang.IErlFunction in project erlide_eclipse by erlang.

the class ErlParser method checkForComment.

private void checkForComment(final List<IErlMember> all, final int i) {
    final IErlMember m = all.get(i);
    if (m instanceof IErlFunction) {
        final IErlFunction function = (IErlFunction) m;
        final LinkedList<IErlComment> comments = Lists.newLinkedList();
        int j = considerPrevious(i, all, comments, function);
        j = considerPrevious(j, all, comments, function);
        j = considerPrevious(j, all, comments, function);
        if (!comments.isEmpty()) {
            function.setComments(comments);
        }
    }
}
Also used : IErlComment(org.erlide.engine.model.erlang.IErlComment) IErlMember(org.erlide.engine.model.erlang.IErlMember) IErlFunction(org.erlide.engine.model.erlang.IErlFunction)

Example 18 with IErlFunction

use of org.erlide.engine.model.erlang.IErlFunction in project erlide_eclipse by erlang.

the class CreateTracePatternHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
    if (selection instanceof ITreeSelection) {
        final Object firstElement = ((ITreeSelection) selection).getFirstElement();
        if (firstElement instanceof IErlFunction) {
            final IErlFunction function = (IErlFunction) firstElement;
            final TracePattern tracePattern = new TracePattern(true);
            tracePattern.setFunctionName(function.getFunctionName());
            tracePattern.setModuleName(ErlangEngine.getInstance().getModelUtilService().getModule(function).getModuleName());
            tracePattern.setArity(function.getArity());
            tracePattern.setLocal(true);
            tracePattern.setEnabled(true);
            TraceBackend.getInstance().addTracePattern(tracePattern);
        }
    }
    return null;
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IErlFunction(org.erlide.engine.model.erlang.IErlFunction) ISelection(org.eclipse.jface.viewers.ISelection) TracePattern(org.erlide.tracing.core.mvc.model.TracePattern)

Example 19 with IErlFunction

use of org.erlide.engine.model.erlang.IErlFunction in project erlide_eclipse by erlang.

the class RemoveTracePatternHandler method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
    if (selection instanceof ITreeSelection) {
        final Object firstElement = ((ITreeSelection) selection).getFirstElement();
        if (firstElement instanceof IErlFunction) {
            final IErlFunction function = (IErlFunction) firstElement;
            final TracePattern tracePattern = new TracePattern(true);
            tracePattern.setFunctionName(function.getFunctionName());
            tracePattern.setModuleName(ErlangEngine.getInstance().getModelUtilService().getModule(function).getModuleName());
            tracePattern.setArity(function.getArity());
            TraceBackend.getInstance().removeTracePattern(tracePattern);
        }
    }
    return null;
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) IErlFunction(org.erlide.engine.model.erlang.IErlFunction) ISelection(org.eclipse.jface.viewers.ISelection) TracePattern(org.erlide.tracing.core.mvc.model.TracePattern)

Example 20 with IErlFunction

use of org.erlide.engine.model.erlang.IErlFunction 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

IErlFunction (org.erlide.engine.model.erlang.IErlFunction)22 IErlModule (org.erlide.engine.model.root.IErlModule)7 IErlElement (org.erlide.engine.model.IErlElement)6 ISelection (org.eclipse.jface.viewers.ISelection)5 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)5 ErlModelException (org.erlide.engine.model.ErlModelException)5 ErlangFunction (org.erlide.engine.model.erlang.ErlangFunction)4 IErlFunctionClause (org.erlide.engine.model.erlang.IErlFunctionClause)4 TracePattern (org.erlide.tracing.core.mvc.model.TracePattern)4 IErlAttribute (org.erlide.engine.model.erlang.IErlAttribute)3 IErlPreprocessorDef (org.erlide.engine.model.erlang.IErlPreprocessorDef)3 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)3 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 Composite (org.eclipse.swt.widgets.Composite)2 Label (org.eclipse.swt.widgets.Label)2 PartInitException (org.eclipse.ui.PartInitException)2 IErlModel (org.erlide.engine.model.root.IErlModel)2 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)1