private RenameIdentifierInfo info = new RenameIdentifierInfo();
- public void setActiveEditor(final IAction action, final IEditorPart targetEditor) {
+ public void setActiveEditor(final IAction action,
+ final IEditorPart targetEditor) {
this.targetEditor = targetEditor;
onPHPFile = false;
IFile file = getFile();
if (targetEditor != null && (targetEditor instanceof PHPEditor)) {
PHPEditor editor = (PHPEditor) targetEditor;
if (editor != null) {
- ITextSelection textSelection = (ITextSelection) editor.getSelectionProvider().getSelection();
- IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput());
+ ITextSelection textSelection = (ITextSelection) editor
+ .getSelectionProvider().getSelection();
+ IDocument doc = editor.getDocumentProvider()
+ .getDocument(editor.getEditorInput());
int pos = textSelection.getOffset();
point = PHPWordExtractor.findWord(doc, pos);
if (point != null) {
try {
word = doc.get(point.x, point.y);
- IWorkingCopyManager manager = PHPeclipsePlugin.getDefault().getWorkingCopyManager();
- ICompilationUnit unit = manager.getWorkingCopy(editor.getEditorInput());
- SourceMethod method = (SourceMethod) findEnclosingElement(point.x, unit, IJavaElement.METHOD);
- if (word == null || word.charAt(0) != '$' || method == null || !(method instanceof SourceMethod)) {
+ IWorkingCopyManager manager = PHPeclipsePlugin
+ .getDefault().getWorkingCopyManager();
+ ICompilationUnit unit = manager
+ .getWorkingCopy(editor.getEditorInput());
+ SourceMethod method = (SourceMethod) findEnclosingElement(
+ point.x, unit, IJavaElement.METHOD);
+ if (word == null || word.charAt(0) != '$'
+ || method == null
+ || !(method instanceof SourceMethod)) {
refuseLocalVariable();
} else {
- applySelection((ITextSelection) selection, word, point, method);
+ applySelection((ITextSelection) selection,
+ word, point, method);
if (saveAll()) {
openWizard();
}
* Returns the enclosing element of a particular element type,
* <code>null</code> if no enclosing element of that type exists.
*/
- public IJavaElement findEnclosingElement(int start, ICompilationUnit cu, int elementType) {
+ public IJavaElement findEnclosingElement(int start, ICompilationUnit cu,
+ int elementType) {
if (cu == null)
return null;
}
}
- public void selectionChanged(final IAction action, final ISelection selection) {
+ public void selectionChanged(final IAction action,
+ final ISelection selection) {
this.selection = selection;
}
// helping methods
// ////////////////
- private void applySelection(final ITextSelection textSelection, String word, Point point, SourceMethod method) {
+ private void applySelection(final ITextSelection textSelection,
+ String word, Point point, SourceMethod method) {
if (word != null) {
info.setOldName(word);
info.setNewName(word);
}
private void openWizard() {
- RenameLocalVariableDelegate delegate = new RenameLocalVariableDelegate(info);
+ RenameLocalVariableDelegate delegate = new RenameLocalVariableDelegate(
+ info);
RefactoringProcessor processor = new RenamePHPProcessor(info, delegate);
- RenameIdentifierRefactoring ref = new RenameIdentifierRefactoring(processor);
- RenameLocalVariableWizard wizard = new RenameLocalVariableWizard(ref, info);
- RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
+ RenameIdentifierRefactoring ref = new RenameIdentifierRefactoring(
+ processor);
+ RenameLocalVariableWizard wizard = new RenameLocalVariableWizard(ref,
+ info);
+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(
+ wizard);
try {
String titleForFailedChecks = ""; //$NON-NLS-1$
op.run(getShell(), titleForFailedChecks);
if (targetEditor != null) {
result = targetEditor.getSite().getShell();
} else {
- result = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ result = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell();
}
return result;
}