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);
}
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;
}
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();
}
Aggregations