introduce variable: reassign value to the existing: correctly process occurrences

This commit is contained in:
anna
2012-01-13 19:20:21 +01:00
parent 3e3fc26dce
commit cbaefc9774

View File

@@ -551,8 +551,11 @@ public abstract class IntroduceVariableBase extends IntroduceHandlerBase {
final RangeMarker exprMarker = editor.getDocument().createRangeMarker(expr.getTextRange());
final SuggestedNameInfo suggestedName = getSuggestedName(settings.getSelectedType(), expr, chosenAnchor);
final List<RangeMarker> occurrenceMarkers = new ArrayList<RangeMarker>();
final boolean noWrite = choice == OccurrencesChooser.ReplaceChoice.NO_WRITE;
for (PsiExpression occurrence : occurrences) {
occurrenceMarkers.add(editor.getDocument().createRangeMarker(occurrence.getTextRange()));
if (allOccurences || (noWrite && !PsiUtil.isAccessedForWriting(occurrence))) {
occurrenceMarkers.add(editor.getDocument().createRangeMarker(occurrence.getTextRange()));
}
}
final String expressionText = expr.getText();
final Runnable runnable =