use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class GenFunRefactoringMessage method parseRefactoringMessage.
@Override
protected void parseRefactoringMessage(final OtpErlangTuple resultTuple) throws WranglerException {
final OtpErlangObject wranglerResult = resultTuple.elementAt(1);
final String state = resultTuple.elementAt(0).toString();
if ("ok".equals(state)) {
if (wranglerResult instanceof OtpErlangList) {
changedFiles = parseFileList((OtpErlangList) wranglerResult);
setSuccessful();
return;
}
} else if ("error".equals(state)) {
final OtpErlangString msg = (OtpErlangString) wranglerResult;
setUnsuccessful(msg.stringValue());
return;
} else if ("multiple_instances".equals(state)) {
parameters = new HashMap<>();
final OtpErlangTuple pars = (OtpErlangTuple) wranglerResult;
setState("", RefactoringState.MULTI_INSTANCES);
parameters.put(GenFunReturnParameterName.parName, pars.elementAt(0));
parameters.put(GenFunReturnParameterName.funName, pars.elementAt(1));
parameters.put(GenFunReturnParameterName.arity, pars.elementAt(2));
parameters.put(GenFunReturnParameterName.funDefPos, pars.elementAt(3));
parameters.put(GenFunReturnParameterName.exp, pars.elementAt(4));
parameters.put(GenFunReturnParameterName.sideEffect, pars.elementAt(5));
parameters.put(GenFunReturnParameterName.dupsInFun, pars.elementAt(6));
parameters.put(GenFunReturnParameterName.logCmd, pars.elementAt(7));
} else if ("unknown_side_effect".equals(state)) {
parameters = new HashMap<>();
final OtpErlangTuple pars = (OtpErlangTuple) wranglerResult;
setState("", RefactoringState.UNKNOWN_SIDE_EFFECT);
parameters.put(GenFunReturnParameterName.parName, pars.elementAt(0));
parameters.put(GenFunReturnParameterName.funName, pars.elementAt(1));
parameters.put(GenFunReturnParameterName.arity, pars.elementAt(2));
parameters.put(GenFunReturnParameterName.funDefPos, pars.elementAt(3));
parameters.put(GenFunReturnParameterName.exp, pars.elementAt(4));
parameters.put(GenFunReturnParameterName.noOfClauses, pars.elementAt(5));
parameters.put(GenFunReturnParameterName.dupsInFun, pars.elementAt(6));
parameters.put(GenFunReturnParameterName.dupsInClause, pars.elementAt(7));
parameters.put(GenFunReturnParameterName.logCmd, pars.elementAt(8));
} else if ("more_than_one_clause".equals(state)) {
parameters = new HashMap<>();
final OtpErlangTuple pars = (OtpErlangTuple) wranglerResult;
setState("", RefactoringState.MORE_THAN_ONE_CLAUSE);
parameters.put(GenFunReturnParameterName.parName, pars.elementAt(0));
parameters.put(GenFunReturnParameterName.funName, pars.elementAt(1));
parameters.put(GenFunReturnParameterName.arity, pars.elementAt(2));
parameters.put(GenFunReturnParameterName.funDefPos, pars.elementAt(3));
parameters.put(GenFunReturnParameterName.exp, pars.elementAt(4));
parameters.put(GenFunReturnParameterName.sideEffect, pars.elementAt(5));
parameters.put(GenFunReturnParameterName.dupsInFun, pars.elementAt(6));
parameters.put(GenFunReturnParameterName.dupsInClause, pars.elementAt(7));
parameters.put(GenFunReturnParameterName.logCmd, pars.elementAt(8));
} else {
throw new WranglerRpcParsingException(resultTuple.toString());
}
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class StateDataToRecordRpcMessage method parseRefactoringMessage.
@Override
protected void parseRefactoringMessage(final OtpErlangTuple resultTuple) throws WranglerException {
final OtpErlangObject wranglerResult = resultTuple.elementAt(1);
if (!"ok".equals(resultTuple.elementAt(0).toString())) {
final OtpErlangString msg = (OtpErlangString) wranglerResult;
setUnsuccessful(msg.stringValue());
} else {
if ("non_tuple".equals(wranglerResult.toString())) {
fieldCount = 1;
} else {
try {
fieldCount = ((OtpErlangLong) ((OtpErlangTuple) wranglerResult).elementAt(1)).intValue();
} catch (final OtpErlangRangeException e) {
throw new WranglerException(e.getMessage());
}
}
stateFuns = resultTuple.elementAt(2);
setSuccessful();
}
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class ErlModule method getIncludeFiles.
@Override
public Collection<ErlangIncludeFile> getIncludeFiles() throws ErlModelException {
if (!isStructureKnown()) {
open(null);
}
final List<ErlangIncludeFile> r = Lists.newArrayList();
synchronized (getModelLock()) {
for (final IErlElement m : internalGetChildren()) {
if (m instanceof IErlAttribute) {
final IErlAttribute a = (IErlAttribute) m;
final OtpErlangObject v = a.getValue();
if (v instanceof OtpErlangString) {
final String s = ((OtpErlangString) v).stringValue();
if ("include".equals(a.getName())) {
r.add(new ErlangIncludeFile(false, s));
} else if ("include_lib".equals(a.getName())) {
r.add(new ErlangIncludeFile(true, s));
}
}
}
}
}
return r;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class ErlOtpExternalReferenceEntryList method mkOtpStructureMap.
private void mkOtpStructureMap(final OtpErlangList input) {
if (input == null) {
return;
}
for (final OtpErlangObject o : input) {
final OtpErlangTuple t = (OtpErlangTuple) o;
final String lib = ((OtpErlangString) t.elementAt(0)).stringValue();
final OtpErlangList dirs = (OtpErlangList) t.elementAt(1);
final String group = OtpErlang.asString(t.elementAt(2));
final ErlExternalReferenceEntry extLib = new ErlExternalReferenceEntry(this, getLibName(lib), new Path(lib), true, false);
extLib.setGroup(group);
addChild(extLib);
for (final OtpErlangObject dir : dirs.elements()) {
final OtpErlangTuple tdir = (OtpErlangTuple) dir;
final String dname = ((OtpErlangString) tdir.elementAt(0)).stringValue();
final OtpErlangList files = (OtpErlangList) tdir.elementAt(1);
final ErlExternalReferenceEntry subdir = new ErlExternalReferenceEntry(extLib, getLibName(dname), new Path(dname), true, includePath(dname));
extLib.addChild(subdir);
for (final OtpErlangObject fn : files.elements()) {
final String sfn = ((OtpErlangString) fn).stringValue();
final IErlModule ext = new ErlModule(subdir, getModuleName(sfn), sfn, Charsets.ISO_8859_1, null);
subdir.addChild(ext);
}
}
}
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class ErlangCompletionService method getModules0.
List<String> getModules0(final IOtpRpc backend, final int offset, final String prefix, final CompletionFlag kind) throws ErlModelException {
final List<String> result = Lists.newArrayList();
final boolean includes = kind == CompletionFlag.INCLUDES || kind == CompletionFlag.INCLUDE_LIBS;
final List<String> names = ErlangEngine.getInstance().getModelUtilService().findUnitsWithPrefix(prefix, project, kind != CompletionFlag.INCLUDES, includes);
final OtpErlangObject res = ErlangEngine.getInstance().getOtpDocService().getModules(backend, prefix, names, includes);
if (res instanceof OtpErlangList) {
final OtpErlangList resList = (OtpErlangList) res;
for (final OtpErlangObject o : resList) {
if (o instanceof OtpErlangString) {
final OtpErlangString s = (OtpErlangString) o;
result.add(s.stringValue());
}
}
}
return result;
}
Aggregations