use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class ErlParser method addRecordDef.
private IErlRecordDef addRecordDef(final IErlModule module, final OtpErlangObject pos, final OtpErlangObject val, final OtpErlangObject extra) {
if (val instanceof OtpErlangTuple) {
final OtpErlangTuple recordTuple = (OtpErlangTuple) val;
if (recordTuple.elementAt(0) instanceof OtpErlangAtom) {
final String s = extra instanceof OtpErlangString ? ((OtpErlangString) extra).stringValue() : null;
final OtpErlangList fields = (OtpErlangList) recordTuple.elementAt(1);
final ErlRecordDef r = new ErlRecordDef(module, null, s);
setPos(r, pos);
if (fields != null) {
final List<ErlRecordField> children = Lists.newArrayListWithCapacity(fields.arity());
for (final OtpErlangObject o : fields) {
if (o instanceof OtpErlangTuple) {
final OtpErlangTuple fieldTuple = (OtpErlangTuple) o;
final OtpErlangAtom fieldNameAtom = (OtpErlangAtom) fieldTuple.elementAt(0);
final String fieldName = fieldNameAtom.atomValue();
final ErlRecordField field = new ErlRecordField(r, fieldName);
final OtpErlangTuple posTuple = (OtpErlangTuple) fieldTuple.elementAt(1);
if (fieldTuple.arity() > 2) {
final OtpErlangObject fieldExtra = fieldTuple.elementAt(2);
field.setExtra(Util.stringValue(fieldExtra));
}
setPos(field, posTuple);
children.add(field);
} else {
ErlLogger.error("bad record def: %s", o);
}
}
r.setChildren(children);
} else {
r.setChildren(new ArrayList<>());
}
return r;
}
}
if (val instanceof OtpErlangAtom) {
final String s = extra instanceof OtpErlangString ? ((OtpErlangString) extra).stringValue() : null;
final ErlRecordDef r = new ErlRecordDef(module, null, s);
setPos(r, pos);
return r;
}
return null;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class ErlideDoc method getOtpDoc.
@Override
public OtpErlangObject getOtpDoc(final IOtpRpc b, final ErlangFunctionCall functionCall) {
OtpErlangObject res = null;
final OtpErlangTuple input = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangAtom("external"), new OtpErlangAtom(functionCall.getModule()), new OtpErlangAtom(functionCall.getName()), new OtpErlangInt(functionCall.getArity()), new OtpErlangString("") });
try {
res = b.call(ErlideDoc.ERLIDE_OTP_DOC, "get_doc", "sxs", functionCall.getModule(), input, stateDir);
} catch (final RpcException e) {
ErlLogger.warn(e);
}
return res;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class ErlModel method getPathVars.
@Override
public OtpErlangList getPathVars() {
// if (fCachedPathVars == null) {
final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
final String[] names = pvm.getPathVariableNames();
final OtpErlangObject[] objects = new OtpErlangObject[names.length];
for (int i = 0; i < names.length; i++) {
final String name = names[i];
final String value = URIUtil.toPath(pvm.getURIValue(name)).toPortableString();
objects[i] = new OtpErlangTuple(new OtpErlangObject[] { new OtpErlangString(name), new OtpErlangString(value) });
}
fCachedPathVars = new OtpErlangList(objects);
// }
return fCachedPathVars;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method processFunctionResult.
private ArrayList<IErlElement> processFunctionResult(final Shell shell, final RpcResult result) throws OtpErlangRangeException {
final ArrayList<IErlElement> elements = new ArrayList<>();
final OtpErlangObject obj = result.getValue();
final OtpErlangTuple restuple = (OtpErlangTuple) obj;
final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
if ("ok".equals(resindicator.atomValue())) {
final OtpErlangList erlangFunctionList = (OtpErlangList) restuple.elementAt(1);
for (int i = 0; i < erlangFunctionList.arity(); ++i) {
final OtpErlangTuple fTuple = (OtpErlangTuple) erlangFunctionList.elementAt(i);
IErlFunctionClause f;
try {
f = extractFunction(fTuple);
elements.add(f);
} catch (final ErlModelException e) {
}
}
} else {
final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
MessageDialog.openError(shell, "Error", s.stringValue());
return null;
}
return elements;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class SimpleCodeInspectionHandler method handleDepenenciesCall.
private void handleDepenenciesCall(final IErlSelection wranglerSelection, final Shell shell) {
// hiding the views
CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.CODE_INSPECTION_VIEW, SimpleCodeInspectionHandler.DEPENECIES_1_VIEW_ID);
CodeInspectionViewsManager.hideView(CodeInspectionViewsManager.CODE_INSPECTION_VIEW, SimpleCodeInspectionHandler.DEPENECIES_2_VIEW_ID);
// run the rpc
try {
final RpcResult res = WranglerBackendManager.getRefactoringBackend().callInspection("dependencies_of_a_module_eclipse", "sx", wranglerSelection.getFilePath(), wranglerSelection.getSearchPath());
ArrayList<IErlElement> modules1 = new ArrayList<>();
ArrayList<IErlElement> modules2 = new ArrayList<>();
final OtpErlangObject obj = res.getValue();
final OtpErlangTuple restuple = (OtpErlangTuple) obj;
final OtpErlangAtom resindicator = (OtpErlangAtom) restuple.elementAt(0);
if ("ok".equals(resindicator.atomValue())) {
final OtpErlangTuple listtuple = (OtpErlangTuple) restuple.elementAt(1);
final OtpErlangList modList1 = (OtpErlangList) listtuple.elementAt(0);
final OtpErlangList modList2 = (OtpErlangList) listtuple.elementAt(1);
modules1 = createErlModuleList(modList1);
modules2 = createErlModuleList(modList2);
} else {
final OtpErlangString s = (OtpErlangString) restuple.elementAt(1);
MessageDialog.openError(shell, "Error", s.stringValue());
return;
}
if (!modules1.isEmpty()) {
CodeInspectionViewsManager.showErlElements("Modules which depends on " + wranglerSelection.getErlElement().getAncestorOfKind(ErlElementKind.MODULE).getName(), modules1, SimpleCodeInspectionHandler.DEPENECIES_1_VIEW_ID);
}
if (!modules2.isEmpty()) {
CodeInspectionViewsManager.showErlElements("Modules, on which " + wranglerSelection.getErlElement().getAncestorOfKind(ErlElementKind.MODULE).getName() + " depends", modules2, SimpleCodeInspectionHandler.DEPENECIES_2_VIEW_ID);
} else {
MessageDialog.openInformation(shell, "No result", "There is no large module with the specified parameter!");
}
} catch (final Exception e) {
ErlLogger.error(e);
}
}
Aggregations