use of com.intellij.structuralsearch.plugin.replace.impl.ReplacementInfoImpl in project intellij-community by JetBrains.
the class DocumentBasedReplaceHandler method replace.
public void replace(ReplacementInfo info, ReplaceOptions options) {
if (info.getMatchesCount() == 0)
return;
assert info instanceof ReplacementInfoImpl;
PsiElement element = info.getMatch(0);
if (element == null)
return;
PsiFile file = element instanceof PsiFile ? (PsiFile) element : element.getContainingFile();
assert file != null;
RangeMarker rangeMarker = myRangeMarkers.get(info);
Document document = rangeMarker.getDocument();
document.replaceString(rangeMarker.getStartOffset(), rangeMarker.getEndOffset(), info.getReplacement());
PsiDocumentManager.getInstance(element.getProject()).commitDocument(document);
}
use of com.intellij.structuralsearch.plugin.replace.impl.ReplacementInfoImpl in project intellij-community by JetBrains.
the class DocumentBasedReplaceHandler method prepare.
@Override
public void prepare(ReplacementInfo info) {
assert info instanceof ReplacementInfoImpl;
MatchResult result = ((ReplacementInfoImpl) info).getMatchResult();
PsiElement element = result.getMatch();
PsiFile file = element instanceof PsiFile ? (PsiFile) element : element.getContainingFile();
Document document = PsiDocumentManager.getInstance(myProject).getDocument(file);
TextRange textRange = result.getMatch().getTextRange();
assert textRange != null;
RangeMarker rangeMarker = document.createRangeMarker(textRange);
rangeMarker.setGreedyToLeft(true);
rangeMarker.setGreedyToRight(true);
myRangeMarkers.put(info, rangeMarker);
}
Aggregations