Search in sources :

Example 1 with OtpErlangString

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) {
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) IResource(org.eclipse.core.resources.IResource) CoreException(org.eclipse.core.runtime.CoreException) ErlModelException(org.erlide.engine.model.ErlModelException) RpcException(org.erlide.runtime.rpc.RpcException) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 2 with OtpErlangString

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;
}
Also used : IErlProject(org.erlide.engine.model.root.IErlProject) IResourceVisitor(org.eclipse.core.resources.IResourceVisitor) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) CoreException(org.eclipse.core.runtime.CoreException) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 3 with OtpErlangString

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;
}
Also used : OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Example 4 with OtpErlangString

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;
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) Stack(java.util.Stack)

Example 5 with OtpErlangString

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");
}
Also used : OtpErlangLong(com.ericsson.otp.erlang.OtpErlangLong) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangAtom(com.ericsson.otp.erlang.OtpErlangAtom) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) OtpErlangBinary(com.ericsson.otp.erlang.OtpErlangBinary) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString)

Aggregations

OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)56 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)36 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)31 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)22 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)15 ArrayList (java.util.ArrayList)9 RpcResult (org.erlide.runtime.rpc.RpcResult)8 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)7 RpcException (org.erlide.runtime.rpc.RpcException)7 Test (org.junit.Test)7 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)6 OtpErlangBinary (com.ericsson.otp.erlang.OtpErlangBinary)5 IPath (org.eclipse.core.runtime.IPath)5 ErlModelException (org.erlide.engine.model.ErlModelException)5 IErlElement (org.erlide.engine.model.IErlElement)5 WranglerRpcParsingException (org.erlide.wrangler.refactoring.exception.WranglerRpcParsingException)5 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)5 CoreException (org.eclipse.core.runtime.CoreException)4 WranglerException (org.erlide.wrangler.refactoring.exception.WranglerException)4 Map (java.util.Map)3