use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class ExpressionPosRpcMessage method parseRefactoringMessage.
@Override
protected void parseRefactoringMessage(final OtpErlangTuple resultTuple) throws WranglerException {
try {
final OtpErlangObject wranglerResult = resultTuple.elementAt(1);
if ("ok".equals(resultTuple.elementAt(0).toString())) {
OtpErlangList posDefList;
if (wranglerResult instanceof OtpErlangTuple) {
syntaxTree = ((OtpErlangTuple) wranglerResult).elementAt(0);
posDefList = (OtpErlangList) ((OtpErlangTuple) wranglerResult).elementAt(1);
} else {
syntaxTree = null;
posDefList = (OtpErlangList) wranglerResult;
}
positionDefs = new HashMap<>();
final OtpErlangObject[] elements = posDefList.elements();
for (final OtpErlangObject o : elements) {
final OtpErlangTuple value = (OtpErlangTuple) o;
final OtpErlangTuple pos = (OtpErlangTuple) value.elementAt(0);
try {
positionDefs.put(new Range(pos), value);
} catch (final OtpErlangRangeException e) {
ErlLogger.error(e);
setUnsuccessful("Failed to parse the result!");
}
}
setSuccessful();
} else {
final OtpErlangString errorMsg = (OtpErlangString) wranglerResult;
setUnsuccessful(errorMsg.stringValue());
return;
}
} catch (final Exception e) {
throw new WranglerRpcParsingException(resultTuple.toString());
}
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class ProcessRpcMessage method parseRefactoringMessage.
@Override
protected void parseRefactoringMessage(final OtpErlangTuple resultTuple) throws WranglerException {
final OtpErlangObject wranglerResult = resultTuple.elementAt(1);
if ("ok".equals(resultTuple.elementAt(0).toString())) {
if (wranglerResult instanceof OtpErlangList) {
changedFiles = parseFileList((OtpErlangList) wranglerResult);
setSuccessful();
return;
}
} else if ("undecidables".equals(resultTuple.elementAt(0).toString())) {
hasUndecidables = true;
}
final OtpErlangString errorMsg = (OtpErlangString) wranglerResult;
setUnsuccessful(errorMsg.stringValue());
return;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class RefactoringRpcMessage method parseRefactoringMessage.
@Override
protected void parseRefactoringMessage(final OtpErlangTuple tuple) throws WranglerRpcParsingException {
resultTuple = tuple;
final OtpErlangObject wranglerResult = tuple.elementAt(1);
if ("ok".equals(tuple.elementAt(0).toString())) {
if (wranglerResult instanceof OtpErlangList) {
changedFiles = parseFileList((OtpErlangList) wranglerResult);
setSuccessful();
return;
}
} else {
final OtpErlangString msg = (OtpErlangString) wranglerResult;
if ("warning".equals(tuple.elementAt(0).toString())) {
setWarning(msg.stringValue());
} else if ("question".equals(tuple.elementAt(0).toString())) {
setQuestion(msg.stringValue());
} else {
setUnsuccessful(msg.stringValue());
}
return;
}
throw new WranglerRpcParsingException(tuple.toString());
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class OpenUtils method findLocalCall.
private IErlElement findLocalCall(final IErlModule module, final IErlProject erlProject, final OpenResult res, final IErlElement element, final IErlElementLocator.Scope scope) throws RpcException, CoreException {
if (isTypeDefOrRecordDef(element, res)) {
return modelFindService.findTypespec(module, res.getFun());
}
final IErlFunction foundElement = module.findFunction(res.getFunction());
if (foundElement != null) {
return foundElement;
}
// imported functions
OtpErlangObject res2 = null;
String moduleName = null;
final IErlImport ei = module.findImport(res.getFunction());
if (ei != null) {
final IErlModel model = ErlangEngine.getInstance().getModel();
moduleName = ei.getImportModule();
res2 = ErlangEngine.getInstance().getOpenService().getSourceFromModule(model.getPathVars(), moduleName, erlProject.getProperties().getExternalModules());
}
if (res2 instanceof OtpErlangString && moduleName != null) {
// imported from otp module
final OtpErlangString otpErlangString = (OtpErlangString) res2;
final String modulePath = otpErlangString.stringValue();
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
return modelFindService.findFunction(model, erlProject, module, moduleName, modulePath, res.getFunction(), scope);
}
// functions defined in include files
final Collection<IErlModule> allIncludedFiles = ErlangEngine.getInstance().getModelFindService().findAllIncludedFiles(module);
for (final IErlModule includedModule : allIncludedFiles) {
final IErlFunction function = includedModule.findFunction(res.getFunction());
if (function != null) {
return function;
}
}
return null;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class RuntimeHelper method formatError.
public String formatError(final OtpErlangObject object) {
final OtpErlangTuple err = (OtpErlangTuple) object;
final OtpErlangAtom mod = (OtpErlangAtom) err.elementAt(1);
final OtpErlangObject arg = err.elementAt(2);
String res;
try {
OtpErlangObject r = target.call(mod.atomValue(), "format_error", "x", arg);
r = target.call("lists", "flatten", "x", r);
res = ((OtpErlangString) r).stringValue();
} catch (final Exception e) {
ErlLogger.error(e);
res = err.toString();
}
return res;
}
Aggregations