Search in sources :

Example 1 with IErlRecordField

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

the class IndexedErlangValue method getVariable.

@Override
public IVariable getVariable(final int offset) throws DebugException {
    String name;
    if (record != null) {
        try {
            final IErlRecordField recordField = (IErlRecordField) record.getChildren().get(offset);
            name = recordField.getFieldName();
        } catch (final ErlModelException e) {
            name = varName + ":" + offset;
        }
    } else {
        name = varName + ":" + offset;
    }
    return new ErlangVariable(getDebugTarget(), name, true, getElementAt(offset), process, moduleName, -1);
}
Also used : ErlModelException(org.erlide.engine.model.ErlModelException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) IErlRecordField(org.erlide.engine.model.erlang.IErlRecordField)

Example 2 with IErlRecordField

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

the class ErlangCompletionService method getRecordFieldCompletions.

List<CompletionData> getRecordFieldCompletions(final String recordName, final int offset, final String prefix, final int hashMarkPos, final List<String> fieldsSoFar) {
    if (module == null) {
        return ErlangCompletionService.EMPTY_COMPLETIONS;
    }
    IErlPreprocessorDef pd;
    try {
        pd = ErlangEngine.getInstance().getModelFindService().findPreprocessorDef(module, recordName, ErlElementKind.RECORD_DEF);
    } catch (final CoreException e) {
        return ErlangCompletionService.EMPTY_COMPLETIONS;
    }
    if (pd instanceof IErlRecordDef) {
        final List<CompletionData> result = new ArrayList<>();
        try {
            for (final IErlElement i : pd.getChildren()) {
                final IErlRecordField field = (IErlRecordField) i;
                final String fieldName = field.getFieldName();
                if (!fieldsSoFar.contains(fieldName)) {
                    addIfMatches(fieldName, prefix, offset, result);
                }
            }
        } catch (final ErlModelException e) {
        }
        return result;
    }
    return ErlangCompletionService.EMPTY_COMPLETIONS;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) CompletionData(org.erlide.engine.services.codeassist.CompletionData) FunctionCompletionData(org.erlide.engine.services.codeassist.FunctionCompletionData) CoreException(org.eclipse.core.runtime.CoreException) IErlRecordDef(org.erlide.engine.model.erlang.IErlRecordDef) ErlModelException(org.erlide.engine.model.ErlModelException) ArrayList(java.util.ArrayList) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) IErlPreprocessorDef(org.erlide.engine.model.erlang.IErlPreprocessorDef) IErlRecordField(org.erlide.engine.model.erlang.IErlRecordField)

Example 3 with IErlRecordField

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

the class IndexedErlangValue method getRecordValueString.

private String getRecordValueString(final IErlRecordDef r, final OtpErlangObject o) {
    final StringBuilder b = new StringBuilder();
    List<IErlElement> children;
    try {
        children = r.getChildren();
    } catch (final ErlModelException e) {
        children = IndexedErlangValue.EMPTY_LIST;
    }
    final OtpErlangTuple t = (OtpErlangTuple) o;
    b.append(t.elementAt(0)).append("#{");
    final int n = children.size();
    if (n > 0) {
        for (int i = 0; i < n; i++) {
            final IErlRecordField field = (IErlRecordField) children.get(i);
            b.append(field.getFieldName()).append('=').append(t.elementAt(i + 1).toString()).append(", ");
        }
        b.setLength(b.length() - 2);
    }
    b.append('}');
    return b.toString();
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) ErlModelException(org.erlide.engine.model.ErlModelException) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) IErlRecordField(org.erlide.engine.model.erlang.IErlRecordField)

Aggregations

ErlModelException (org.erlide.engine.model.ErlModelException)3 IErlRecordField (org.erlide.engine.model.erlang.IErlRecordField)3 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)2 IErlElement (org.erlide.engine.model.IErlElement)2 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 ArrayList (java.util.ArrayList)1 CoreException (org.eclipse.core.runtime.CoreException)1 IErlPreprocessorDef (org.erlide.engine.model.erlang.IErlPreprocessorDef)1 IErlRecordDef (org.erlide.engine.model.erlang.IErlRecordDef)1 CompletionData (org.erlide.engine.services.codeassist.CompletionData)1 FunctionCompletionData (org.erlide.engine.services.codeassist.FunctionCompletionData)1