Search in sources :

Example 56 with OtpErlangString

use of com.ericsson.otp.erlang.OtpErlangString in project erlide_eclipse by erlang.

the class BuilderHelper method refreshDirs.

private void refreshDirs(final IProject project, final OtpErlangObject element) {
    final OtpErlangList list = (OtpErlangList) element;
    final Map<IPath, String> paths = Maps.newHashMap();
    for (final OtpErlangObject ebeam : list) {
        final OtpErlangString beam = (OtpErlangString) ebeam;
        final String sbeam = beam.stringValue();
        IPath p = new Path(sbeam);
        p = p.removeLastSegments(1);
        p = p.removeFirstSegments(project.getLocation().segmentCount());
        p = p.setDevice(null);
        paths.put(p, sbeam);
    }
    for (final Entry<IPath, String> p : paths.entrySet()) {
        final IPath pp = p.getKey();
        IResource dir = project.findMember(pp);
        if (dir == null) {
            try {
                final IResource[] top = project.members();
                if (top.length == 1 && top[0] instanceof IContainer) {
                    final IResource[] ds = ((IContainer) top[0]).members();
                    for (final IResource r : ds) {
                        if (r.getLocation().toPortableString().equals(p.getValue())) {
                            dir = r;
                            break;
                        }
                    }
                }
            } catch (final CoreException e) {
                e.printStackTrace();
            }
        }
        if (dir != null) {
            try {
                dir.refreshLocal(IResource.DEPTH_ONE, null);
            } catch (final CoreException e) {
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangString(com.ericsson.otp.erlang.OtpErlangString) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource) 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