Search in sources :

Example 1 with IErlRange

use of org.erlide.wrangler.refactoring.util.IErlRange in project erlide_eclipse by erlang.

the class RenameFunctionRefactoring method runAlternative.

@Override
public IRefactoringRpcMessage runAlternative(final IErlSelection selection) {
    final IErlMemberSelection sel = (IErlMemberSelection) selection;
    final IErlRange memberRange = sel.getMemberRange();
    return WranglerBackendManager.getRefactoringBackend().call("rename_fun_1_eclipse", "siisxi", sel.getFilePath(), memberRange.getStartLine(), memberRange.getStartCol(), userInput, sel.getSearchPath(), GlobalParameters.getTabWidth());
}
Also used : IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection)

Example 2 with IErlRange

use of org.erlide.wrangler.refactoring.util.IErlRange in project erlide_eclipse by erlang.

the class ErlMemberSelection method getSelectionRange.

@Override
public IErlRange getSelectionRange() {
    IErlRange range;
    range = new ErlRange(getStartLine(), getStartCol(), getEndLine(), getEndCol(), member.getSourceRange().getOffset(), member.getSourceRange().getLength());
    return range;
}
Also used : IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) ErlRange(org.erlide.wrangler.refactoring.util.ErlRange) IErlRange(org.erlide.wrangler.refactoring.util.IErlRange)

Example 3 with IErlRange

use of org.erlide.wrangler.refactoring.util.IErlRange in project erlide_eclipse by erlang.

the class SelectionInputPage method createControl.

@Override
public void createControl(final Composite parent) {
    composite = new Composite(parent, SWT.NONE);
    inputLabel = new Label(composite, SWT.LEFT);
    inputLabel.setText(labelText);
    final GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.horizontalSpan = 2;
    inputLabel.setLayoutData(gridData);
    checkButtons = new HashMap<>();
    Button b;
    GridData gd;
    final IDocument doc = ((IErlMemberSelection) GlobalParameters.getWranglerSelection()).getDocument();
    for (final IErlRange r : refactoring.getPositions()) {
        b = new Button(composite, SWT.CHECK);
        b.setText(WranglerUtils.getTextFromEditor(r, doc) + " at " + r.toString());
        gd = new GridData();
        gd.horizontalAlignment = GridData.FILL;
        gd.horizontalSpan = 2;
        gd.grabExcessHorizontalSpace = true;
        b.setLayoutData(gd);
        checkButtons.put(b, r);
        final ExpressionCheckButtonListener l = new ExpressionCheckButtonListener(checkButtons);
        b.addMouseTrackListener(l);
    }
    final GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    composite.setLayout(layout);
    setControl(composite);
}
Also used : IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) ExpressionCheckButtonListener(org.erlide.wrangler.refactoring.ui.ExpressionCheckButtonListener) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) IDocument(org.eclipse.jface.text.IDocument)

Example 4 with IErlRange

use of org.erlide.wrangler.refactoring.util.IErlRange in project erlide_eclipse by erlang.

the class ErlTextMemberSelection method getMemberRange.

@Override
public IErlRange getMemberRange() {
    if (getErlElement() instanceof IErlMember) {
        IErlRange range = null;
        final IErlMember member = (IErlMember) getErlElement();
        int sL;
        int sC;
        int eL;
        int eC;
        sL = member.getLineStart() + 1;
        eL = member.getLineEnd() + 1;
        sC = WranglerUtils.calculateColumnFromOffset(member.getSourceRange().getOffset(), sL - 1, document);
        eC = WranglerUtils.calculateColumnFromOffset(member.getSourceRange().getOffset() + member.getSourceRange().getLength(), eL - 1, document);
        range = new ErlRange(sL, sC, eL, eC, member.getSourceRange().getOffset(), member.getSourceRange().getLength());
        return range;
    }
    return getSelectionRange();
}
Also used : IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) IErlMember(org.erlide.engine.model.erlang.IErlMember) ErlRange(org.erlide.wrangler.refactoring.util.ErlRange) IErlRange(org.erlide.wrangler.refactoring.util.IErlRange)

Example 5 with IErlRange

use of org.erlide.wrangler.refactoring.util.IErlRange in project erlide_eclipse by erlang.

the class GeneraliseFunctionRefactoring method createPositionList.

/**
 * Returns IErlRange, OtpErlangTuple pairs, which are represents the same
 * position in a module
 *
 * @param thePositions
 * @return
 */
protected HashMap<IErlRange, OtpErlangTuple> createPositionList(final OtpErlangList thePositions) {
    try {
        final HashMap<IErlRange, OtpErlangTuple> ret = new HashMap<>();
        final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
        for (final OtpErlangObject o : thePositions) {
            // {{sl, sc}, {el,ec}}
            final OtpErlangTuple pos = (OtpErlangTuple) o;
            ret.put(new ErlRange(new Range(pos), sel.getDocument()), pos);
        }
        return ret;
    } catch (final OtpErlangException e) {
        ErlLogger.error(e);
        return null;
    }
}
Also used : IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) HashMap(java.util.HashMap) IErlMemberSelection(org.erlide.wrangler.refactoring.selection.IErlMemberSelection) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangException(com.ericsson.otp.erlang.OtpErlangException) ErlRange(org.erlide.wrangler.refactoring.util.ErlRange) IErlRange(org.erlide.wrangler.refactoring.util.IErlRange) OtpErlangTuple(com.ericsson.otp.erlang.OtpErlangTuple) Range(org.erlide.wrangler.refactoring.util.Range) ErlRange(org.erlide.wrangler.refactoring.util.ErlRange) IErlRange(org.erlide.wrangler.refactoring.util.IErlRange)

Aggregations

IErlRange (org.erlide.wrangler.refactoring.util.IErlRange)6 IErlMemberSelection (org.erlide.wrangler.refactoring.selection.IErlMemberSelection)4 ErlRange (org.erlide.wrangler.refactoring.util.ErlRange)3 OtpErlangException (com.ericsson.otp.erlang.OtpErlangException)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 OtpErlangTuple (com.ericsson.otp.erlang.OtpErlangTuple)1 HashMap (java.util.HashMap)1 IDocument (org.eclipse.jface.text.IDocument)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 IErlMember (org.erlide.engine.model.erlang.IErlMember)1 ExpressionCheckButtonListener (org.erlide.wrangler.refactoring.ui.ExpressionCheckButtonListener)1 Range (org.erlide.wrangler.refactoring.util.Range)1