Search in sources :

Example 6 with DuplicatedCodeElement

use of org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.DuplicatedCodeElement in project erlide_eclipse by erlang.

the class SimilarExpressionSearchParser method parse.

/*
	 * Parse Wrangler messages which are in the following format: {ok, {[{{filename,
	 * startLine, startCol},{filePath, endLine, endCol}}], generalisation}
	 *
	 * @see org.erlide.wrangler.refactoring.duplicatedcode.core.IResultParser#parse
	 * (com.ericsson.otp.erlang.OtpErlangObject)
	 */
@Override
public void parse(final OtpErlangObject object) {
    try {
        final OtpErlangTuple res = (OtpErlangTuple) object;
        if (!"ok".equals(res.elementAt(0).toString())) {
            setUnSuccessful(((OtpErlangString) res.elementAt(1)).stringValue());
            return;
        }
        final OtpErlangTuple result = (OtpErlangTuple) res.elementAt(1);
        if (result.elementAt(0).equals(new OtpErlangList())) {
            setUnSuccessful("No more instances found!");
            return;
        }
        final DuplicatedCodeElement dup = parseDuplicates(result);
        duplicates = new ArrayList<>();
        duplicates.add(dup);
        isSuccessful = true;
        errorMessage = null;
    } catch (final Exception e) {
        setUnSuccessful(e.getMessage());
    }
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) DuplicatedCodeElement(org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.DuplicatedCodeElement) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) OtpErlangRangeException(com.ericsson.otp.erlang.OtpErlangRangeException)

Aggregations

DuplicatedCodeElement (org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.DuplicatedCodeElement)6 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)4 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)4 DuplicatedCodeInstanceElement (org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.DuplicatedCodeInstanceElement)4 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)3 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)3 ArrayList (java.util.ArrayList)3 IFile (org.eclipse.core.resources.IFile)3 DuplicatedFileElement (org.erlide.wrangler.refactoring.duplicatedcode.ui.elements.DuplicatedFileElement)3 OtpErlangString (com.ericsson.otp.erlang.OtpErlangString)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 OtpErlangRangeException (com.ericsson.otp.erlang.OtpErlangRangeException)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IErlSelection (org.erlide.wrangler.refactoring.selection.IErlSelection)1