import java.util.Map;
import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
+import net.sourceforge.phpdt.core.compiler.ITerminalSymbols.TokenName;
import net.sourceforge.phpdt.core.compiler.InvalidInputException;
import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
import net.sourceforge.phpdt.internal.compiler.parser.SyntaxError;
-import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
+import net.sourceforge.phpdt.internal.core.util.PHPFileUtil;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.core.resources.IContainer;
* <p>
* delegate object that contains the logic used by the processor.
* </p>
- *
+ *
*/
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();
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.getFullPath().toOSString()
+ + " CoreException " + e.getMessage();
result.addError(msg);
} catch (Exception e) {
- String msg = "Project: " + project.getLocation().toOSString() + " Exception " + e.getMessage();
+ String msg = "Project: "
+ + project.getFullPath().toOSString()
+ + " Exception " + e.getMessage();
result.addError(msg);
}
}
}
} catch (CoreException e) {
- String msg = "Workspace: " + rootContainer.getLocation().toOSString() + " CoreException " + e.getMessage();
+ String msg = "Workspace: "
+ + rootContainer.getFullPath().toOSString()
+ + " CoreException " + e.getMessage();
result.addError(msg);
}
} else {
search(project, result);
}
} catch (CoreException e) {
- String msg = "Project: " + project.getLocation().toOSString() + " CoreException " + e.getMessage();
+ String msg = "Project: " + project.getFullPath().toOSString()
+ + " CoreException " + e.getMessage();
result.addError(msg);
} catch (Exception e) {
- String msg = "Project: " + project.getLocation().toOSString() + " Exception " + e.getMessage();
+ String msg = "Project: " + project.getFullPath().toOSString()
+ + " Exception " + e.getMessage();
result.addError(msg);
}
}
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);
}
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));
// 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);
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 = new Double((++indx)* percent).intValue();
+ work = new Double((++indx) * percent).intValue();
pm.worked(work);
}
return (Change[]) result.toArray(new Change[result.size()]);
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();
// 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++) {
// 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);
scanner.setPHPMode(false);
char[] word = info.getOldName().toCharArray();
- int fToken = ITerminalSymbols.TokenNameEOF;
+ TokenName fToken = ITerminalSymbols.TokenName.EOF;
try {
fToken = scanner.getNextToken();
- while (fToken != ITerminalSymbols.TokenNameEOF) {
- if (fToken == ITerminalSymbols.TokenNameVariable || fToken == ITerminalSymbols.TokenNameIdentifier) {
+ while (fToken != ITerminalSymbols.TokenName.EOF) {
+ if (fToken == ITerminalSymbols.TokenName.VARIABLE
+ || fToken == ITerminalSymbols.TokenName.IDENTIFIER) {
if (scanner.equalsCurrentTokenSource(word)) {
- matches.add(new Integer(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.getFullPath().toOSString()
+ + " InvalidInputException " + e.getMessage();
status.addError(msg);
} catch (SyntaxError e) {
- String msg = "File: " + file.getLocation().toOSString() + " SyntaxError " + e.getMessage();
+ String msg = "File: " + file.getFullPath().toOSString()
+ + " SyntaxError " + e.getMessage();
status.addError(msg);
}
} catch (Exception e) {
- String msg = "File: " + file.getLocation().toOSString() + " Exception " + e.getMessage();
+ String msg = "File: " + file.getFullPath().toOSString()
+ + " Exception " + e.getMessage();
status.addError(msg);
}
if (matches.size() > 0) {
// 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();
// 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();
// 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++;
// }