import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
import net.sourceforge.phpdt.core.ISourceRange;
import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
import net.sourceforge.phpdt.internal.core.SourceMethod;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ltk.core.refactoring.RefactoringStatus;
-import org.eclipse.ltk.core.refactoring.TextFileChange;
import org.eclipse.ltk.core.refactoring.participants.CheckConditionsContext;
import org.eclipse.ltk.core.refactoring.participants.IConditionChecker;
import org.eclipse.ltk.core.refactoring.participants.ValidateEditChecker;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.text.edits.ReplaceEdit;
/**
* <p>
Scanner scanner = new Scanner(true, false);
scanner.setSource(methodString.toCharArray());
scanner.setPHPMode(true);
- char[] word = info.getOldName().toCharArray();
+ String wordStr = info.getOldName();
+ char[] word = wordStr.toCharArray();
int fToken = ITerminalSymbols.TokenNameEOF;
+ String dqStr;
+ int dqOffset;
+ int index;
try {
fToken = scanner.getNextToken();
while (fToken != ITerminalSymbols.TokenNameEOF) {
if (fToken == ITerminalSymbols.TokenNameVariable) {
if (scanner.equalsCurrentTokenSource(word)) {
+ // the current variable token is equal to the given word
matches.add(Integer.valueOf(scanner.getCurrentTokenStartPosition() + offset));
}
+ } else if (fToken == ITerminalSymbols.TokenNameStringDoubleQuote) {
+ // determine the word in double quoted strings:
+ dqStr = new String(scanner.getCurrentTokenSource());
+ dqOffset = scanner.getCurrentTokenStartPosition();
+ index = -1;
+ while ((index = dqStr.indexOf(wordStr, index + 1)) >= 0) {
+ matches.add(Integer.valueOf(offset + dqOffset + index));
+ }
}
fToken = scanner.getNextToken();
}