use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class BuilderHelper method createMarkersForCodeClashes.
private void createMarkersForCodeClashes(final IOtpRpc backend, final IProject project) {
try {
final OtpErlangList res = BuilderHelper.getCodeClashes(backend);
for (final OtpErlangObject elem : res) {
final OtpErlangTuple t = (OtpErlangTuple) elem;
final String f1 = ((OtpErlangString) t.elementAt(0)).stringValue();
final String f2 = ((OtpErlangString) t.elementAt(1)).stringValue();
// add marker only for modules belonging to this project!
final IResource r1 = project.findMember(f1);
final IResource r2 = project.findMember(f2);
if (r1 != null || r2 != null) {
MarkerUtils.createProblemMarker(project, null, "code clash between " + f1 + " and " + f2, 0, IMarker.SEVERITY_WARNING);
}
}
} catch (final Exception e) {
}
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class EdocExportWizard method performFinish.
@Override
public boolean performFinish() {
if (!validateFinish()) {
return false;
}
final Collection<IProject> projects = page.getSelectedResources();
final Map<String, OtpErlangObject> options = page.getOptions();
for (final IProject project : projects) {
if (!project.isAccessible()) {
ErlLogger.debug("EDOC: " + project.getName() + " is not accessible, skipping.");
continue;
}
ErlLogger.debug("EDOC: " + project.getName());
try {
final IFolder dest = project.getFolder(page.getDestination());
if (!dest.exists()) {
dest.create(true, true, null);
}
options.put("dir", new OtpErlangString(dest.getLocation().toString()));
final List<String> files = new ArrayList<>();
final IErlProject erlProject = ErlangEngine.getInstance().getModel().findProject(project);
for (final IPath dir : erlProject.getProperties().getSourceDirs()) {
final IFolder folder = project.getFolder(dir);
if (folder.isAccessible()) {
folder.accept(new IResourceVisitor() {
@Override
public boolean visit(final IResource resource) throws CoreException {
if ("erl".equals(resource.getFileExtension())) {
if (resource.isAccessible()) {
files.add(resource.getLocation().toString());
}
}
return true;
}
});
}
}
try {
ErlangEngine.getInstance().getEdocExportService().files(files, options);
} catch (final Exception e) {
ErlLogger.warn(e);
}
} catch (final CoreException e) {
ErlLogger.warn(e);
}
}
return true;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class EdocExportWizardPage method getOptions.
public Map<String, OtpErlangObject> getOptions() {
final Map<String, OtpErlangObject> result = new HashMap<>();
result.put("dir", new OtpErlangString(destination.getText()));
// result.put("preprocess", new OtpErlangBoolean(false));
return result;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class OtpParser method parse.
private static OtpErlangObject parse(final List<Token> tokens) throws OtpParserException {
if (tokens.isEmpty()) {
return null;
}
OtpErlangObject result = null;
final Token t = tokens.remove(0);
final String text = t.text;
if (text == null) {
throw new OtpParserException("null token" + t.toString());
}
switch(t.kind) {
case ATOM:
result = new OtpErlangAtom(text);
break;
case VARIABLE:
result = new OtpPatternVariable(text);
break;
case STRING:
result = new OtpErlangString(text);
break;
case INTEGER:
result = new OtpErlangLong(Long.parseLong(text));
break;
case PLACEHOLDER:
result = new OtpFormatPlaceholder(text);
break;
case TUPLESTART:
result = OtpParser.parseTuple(tokens, new Stack<>());
break;
case TUPLEEND:
throw new OtpParserException("unexpected " + t.toString());
case LISTSTART:
result = OtpParser.parseList(tokens, new Stack<>(), null);
break;
case LISTEND:
throw new OtpParserException("unexpected " + t.toString());
case MAP:
result = OtpParser.parseMap(tokens, new Stack<>());
break;
case COMMA:
throw new OtpParserException("unexpected " + t.toString());
default:
throw new OtpParserException("unknown token" + t.toString());
}
return result;
}
use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.
the class TypeConverter method cvtString.
private static String cvtString(final OtpErlangObject obj) throws SignatureException {
if (obj instanceof OtpErlangString) {
return ((OtpErlangString) obj).stringValue();
}
if (obj instanceof OtpErlangAtom) {
return ((OtpErlangAtom) obj).atomValue();
}
if (obj instanceof OtpErlangBinary) {
return new String(((OtpErlangBinary) obj).binaryValue());
}
if (obj instanceof OtpErlangList) {
final StringBuilder res = new StringBuilder();
for (final OtpErlangObject el : (OtpErlangList) obj) {
if (el instanceof OtpErlangLong) {
final long l = ((OtpErlangLong) el).longValue();
res.append((char) (l & 0xFFFF));
} else {
res.append(TypeConverter.erlang2java(el, String.class));
}
}
return res.toString();
}
throw new SignatureException(TypeConverter.WRONG_ARG_TYPE + obj.getClass().getName() + TypeConverter.CANT_CONVERT_TO + "String");
}
Aggregations