use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection 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());
}
use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.
the class RenameFunctionRefactoring method getDefaultValue.
@Override
public String getDefaultValue() {
final IErlMemberSelection sel = (IErlMemberSelection) GlobalParameters.getWranglerSelection();
if (sel == null) {
return "";
}
final RpcResult res = WranglerBackendManager.getRefactoringBackend().callWithoutParser("get_fun_name_eclipse", "siixi", sel.getFilePath(), sel.getSelectionRange().getStartLine(), sel.getSelectionRange().getStartCol(), sel.getSearchPath(), GlobalParameters.getTabWidth());
if (res.getValue().getClass().equals(OtpErlangString.class)) {
return ((OtpErlangString) res.getValue()).stringValue();
}
return "";
}
use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.
the class TupleFunctionParametersRefactoring method checkInitialConditions.
@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
final IErlSelection sel = GlobalParameters.getWranglerSelection();
if (sel instanceof IErlMemberSelection) {
final SelectionKind kind = sel.getKind();
if (kind == SelectionKind.FUNCTION_CLAUSE || kind == SelectionKind.FUNCTION) {
final IErlMemberSelection s = (IErlMemberSelection) sel;
numberOfTuplingParameters = calculateParametersNumber(WranglerUtils.getTextFromEditor(s.getSelectionRange(), s.getDocument()));
if (numberOfTuplingParameters > 0) {
return new RefactoringStatus();
}
}
}
return RefactoringStatus.createFatalErrorStatus("Please select function parameters!");
}
use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection in project erlide_eclipse by erlang.
the class FoldLocalExpressionRefactoring method checkInitialConditions.
/**
* Preprocessing the file(s), and finding the candidates to fold.
*/
@Override
public RefactoringStatus checkInitialConditions(final IProgressMonitor pm) throws CoreException, OperationCanceledException {
final IErlSelection selection = GlobalParameters.getWranglerSelection();
if (!(selection instanceof IErlMemberSelection && (selection.getKind() == SelectionKind.FUNCTION || selection.getKind() == SelectionKind.FUNCTION_CLAUSE))) {
return RefactoringStatus.createFatalErrorStatus("Please select an expression!");
}
final IErlMemberSelection sel = (IErlMemberSelection) selection;
ExpressionPosRpcMessage m = new ExpressionPosRpcMessage();
m = (ExpressionPosRpcMessage) WranglerBackendManager.getRefactoringBackend().callWithParser(m, "fold_expr_by_loc_eclipse", "siixi", sel.getFilePath(), sel.getMemberRange().getStartLine(), sel.getMemberRange().getStartCol(), sel.getSearchPath(), GlobalParameters.getTabWidth());
if (m.isSuccessful()) {
syntaxTree = m.getSyntaxTree();
positions = m.getPositionDefinitions(sel.getDocument());
selectedPositions = new ArrayList<>();
} else {
return RefactoringStatus.createFatalErrorStatus(m.getMessageString());
}
return new RefactoringStatus();
}
use of org.erlide.wrangler.refactoring.selection.IErlMemberSelection 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);
}
Aggregations