X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameIdentifierDelegate.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameIdentifierDelegate.java index 2e14cd8..4313127 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameIdentifierDelegate.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ltk/core/RenameIdentifierDelegate.java @@ -41,7 +41,7 @@ import org.eclipse.text.edits.ReplaceEdit; *
* delegate object that contains the logic used by the processor. *
- * + * */ public class RenameIdentifierDelegate { @@ -71,14 +71,14 @@ public class RenameIdentifierDelegate { return result; } - RefactoringStatus checkFinalConditions(final IProgressMonitor pm, final CheckConditionsContext ctxt) { + RefactoringStatus checkFinalConditions(final IProgressMonitor pm, + final CheckConditionsContext ctxt) { RefactoringStatus result = new RefactoringStatus(); pm.beginTask(CoreTexts.renamePropertyDelegate_checking, 100); // do something long-running here: traverse the entire project (or even // workspace) to look for all *.properties files with the same bundle // base name IContainer rootContainer; - ArrayList phpProjects = new ArrayList(); IProject project; if (info.isAllProjects()) { rootContainer = ResourcesPlugin.getWorkspace().getRoot(); @@ -89,20 +89,27 @@ public class RenameIdentifierDelegate { if (members[i] instanceof IProject) { project = (IProject) members[i]; try { - if (project.isNatureEnabled(PHPeclipsePlugin.PHP_NATURE_ID)) { + if (project + .isNatureEnabled(PHPeclipsePlugin.PHP_NATURE_ID)) { search(project, result); } } catch (CoreException e) { - String msg = "Project: " + project.getLocation().toOSString() + " CoreException " + e.getMessage(); + String msg = "Project: " + + project.getLocation().toOSString() + + " CoreException " + e.getMessage(); result.addError(msg); } catch (Exception e) { - String msg = "Project: " + project.getLocation().toOSString() + " Exception " + e.getMessage(); + String msg = "Project: " + + project.getLocation().toOSString() + + " Exception " + e.getMessage(); result.addError(msg); } } } } catch (CoreException e) { - String msg = "Workspace: " + rootContainer.getLocation().toOSString() + " CoreException " + e.getMessage(); + String msg = "Workspace: " + + rootContainer.getLocation().toOSString() + + " CoreException " + e.getMessage(); result.addError(msg); } } else { @@ -112,10 +119,12 @@ public class RenameIdentifierDelegate { search(project, result); } } catch (CoreException e) { - String msg = "Project: " + project.getLocation().toOSString() + " CoreException " + e.getMessage(); + String msg = "Project: " + project.getLocation().toOSString() + + " CoreException " + e.getMessage(); result.addError(msg); } catch (Exception e) { - String msg = "Project: " + project.getLocation().toOSString() + " Exception " + e.getMessage(); + String msg = "Project: " + project.getLocation().toOSString() + + " Exception " + e.getMessage(); result.addError(msg); } } @@ -125,7 +134,8 @@ public class RenameIdentifierDelegate { if (ctxt != null) { IFile[] files = new IFile[phpFiles.size()]; phpFiles.keySet().toArray(files); - IConditionChecker checker = ctxt.getChecker(ValidateEditChecker.class); + IConditionChecker checker = ctxt + .getChecker(ValidateEditChecker.class); ValidateEditChecker editChecker = (ValidateEditChecker) checker; editChecker.addFiles(files); } @@ -133,9 +143,11 @@ public class RenameIdentifierDelegate { return result; } - protected void createChange(final IProgressMonitor pm, final CompositeChange rootChange) { + protected void createChange(final IProgressMonitor pm, + final CompositeChange rootChange) { try { - pm.beginTask(CoreTexts.renamePropertyDelegate_collectingChanges, 100); + pm.beginTask(CoreTexts.renamePropertyDelegate_collectingChanges, + 100); // all files in the same bundle if (info.isUpdateProject()) { rootChange.addAll(createChangesForContainer(pm)); @@ -157,7 +169,8 @@ public class RenameIdentifierDelegate { // MultiTextEdit fileChangeRootEdit = new MultiTextEdit(); // result.setEdit(fileChangeRootEdit); // - // // edit object for the text replacement in the file, this is the only child + // // edit object for the text replacement in the file, this is the only + // child // ReplaceEdit edit = new ReplaceEdit(info.getOffset(), // info.getOldName().length(), info.getNewName()); // fileChangeRootEdit.addChild(edit); @@ -179,16 +192,18 @@ public class RenameIdentifierDelegate { MultiTextEdit fileChangeRootEdit = new MultiTextEdit(); tfc.setEdit(fileChangeRootEdit); - // edit object for the text replacement in the file, there could be + // edit object for the text replacement in the file, there could + // be // multiple childs ReplaceEdit edit; for (int i = 0; i < list.size(); i++) { - edit = new ReplaceEdit(((Integer) list.get(i)).intValue(), info.getOldName().length(), info.getNewName()); + edit = new ReplaceEdit(((Integer) list.get(i)).intValue(), + info.getOldName().length(), info.getNewName()); fileChangeRootEdit.addChild(edit); } result.add(tfc); } - work = Double.valueOf(++indx * percent).intValue(); + work = new Double((++indx) * percent).intValue(); pm.worked(work); } return (Change[]) result.toArray(new Change[result.size()]); @@ -198,7 +213,8 @@ public class RenameIdentifierDelegate { return candidate == null || candidate.trim().length() == 0; } - // private boolean isPropertyKey( final IFile file, final String candidate ) { + // private boolean isPropertyKey( final IFile file, final String candidate ) + // { // boolean result = false; // try { // Properties props = new Properties(); @@ -231,7 +247,8 @@ public class RenameIdentifierDelegate { // return result; // } - private void search(final IContainer rootContainer, final RefactoringStatus status) { + private void search(final IContainer rootContainer, + final RefactoringStatus status) { try { IResource[] members = rootContainer.members(); for (int i = 0; i < members.length; i++) { @@ -264,7 +281,8 @@ public class RenameIdentifierDelegate { // finds the offsets of the identifier to rename // usually, this would be the job of a proper parser; // using a primitive brute-force approach here - private void determineKeyOffsets(final IFile file, final RefactoringStatus status) { + private void determineKeyOffsets(final IFile file, + final RefactoringStatus status) { ArrayList matches = new ArrayList(); try { String content = readFileContent(file, status); @@ -277,24 +295,29 @@ public class RenameIdentifierDelegate { try { fToken = scanner.getNextToken(); while (fToken != ITerminalSymbols.TokenNameEOF) { - if (fToken == ITerminalSymbols.TokenNameVariable || fToken == ITerminalSymbols.TokenNameIdentifier) { + if (fToken == ITerminalSymbols.TokenNameVariable + || fToken == ITerminalSymbols.TokenNameIdentifier) { if (scanner.equalsCurrentTokenSource(word)) { - matches.add(Integer.valueOf(scanner.getCurrentTokenStartPosition())); + matches.add(new Integer(scanner + .getCurrentTokenStartPosition())); } } fToken = scanner.getNextToken(); } } catch (InvalidInputException e) { - String msg = "File: " + file.getLocation().toOSString() + " InvalidInputException " + e.getMessage(); + String msg = "File: " + file.getLocation().toOSString() + + " InvalidInputException " + e.getMessage(); status.addError(msg); } catch (SyntaxError e) { - String msg = "File: " + file.getLocation().toOSString() + " SyntaxError " + e.getMessage(); + String msg = "File: " + file.getLocation().toOSString() + + " SyntaxError " + e.getMessage(); status.addError(msg); } } catch (Exception e) { - String msg = "File: " + file.getLocation().toOSString() + " Exception " + e.getMessage(); + String msg = "File: " + file.getLocation().toOSString() + + " Exception " + e.getMessage(); status.addError(msg); } if (matches.size() > 0) { @@ -312,7 +335,8 @@ public class RenameIdentifierDelegate { // if( result == -1 ) { // // still nothing found, we add a warning to the status // // (we have checked the file contains the property, so that we can't - // // determine it's offset is probably because of the rough way employed + // // determine it's offset is probably because of the rough way + // employed // // here to find it) // String msg = CoreTexts.renamePropertyDelegate_propNotFound // + file.getLocation().toOSString(); @@ -321,7 +345,8 @@ public class RenameIdentifierDelegate { // return result; } - private String readFileContent(final IFile file, final RefactoringStatus refStatus) { + private String readFileContent(final IFile file, + final RefactoringStatus refStatus) { String result = null; try { InputStream is = file.getContents(); @@ -350,7 +375,8 @@ public class RenameIdentifierDelegate { // final int candidateIndex ) { // int index = candidateIndex + info.getOldName().length(); // // skip whitespace - // while( content.charAt( index ) == ' ' || content.charAt( index ) == '\t' ) + // while( content.charAt( index ) == ' ' || content.charAt( index ) == '\t' + // ) // { // index++; // }