mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CommonInjectedFileChangesHandler made more extendable
* accepts `List<PsiLanguageInjectionHost.Shred>` instead of Shreads * allows to override method to change host contents
This commit is contained in:
+9
-3
@@ -9,7 +9,6 @@ import com.intellij.openapi.util.ProperTextRange;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.injected.Place;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -20,7 +19,10 @@ import java.util.Set;
|
||||
public class CommonInjectedFileChangesHandler extends BaseInjectedFileChangesHandler {
|
||||
private final List<Trinity<RangeMarker, RangeMarker, SmartPsiElementPointer>> myMarkers = ContainerUtil.newLinkedList();
|
||||
|
||||
public CommonInjectedFileChangesHandler(Place shreds, Editor editor, Document newDocument, PsiFile injectedFile) {
|
||||
public CommonInjectedFileChangesHandler(List<PsiLanguageInjectionHost.Shred> shreds,
|
||||
Editor editor,
|
||||
Document newDocument,
|
||||
PsiFile injectedFile) {
|
||||
super(editor, newDocument, injectedFile);
|
||||
|
||||
SmartPointerManager smartPointerManager = SmartPointerManager.getInstance(myProject);
|
||||
@@ -95,11 +97,15 @@ public class CommonInjectedFileChangesHandler extends BaseInjectedFileChangesHan
|
||||
insideHost = insideHost == null ? localInsideHost : insideHost.union(localInsideHost);
|
||||
}
|
||||
assert insideHost != null;
|
||||
ElementManipulators.getManipulator(host).handleContentChange(host, insideHost, sb.toString());
|
||||
updateInjectionHostElement(host, insideHost, sb.toString());
|
||||
documentManager.commitDocument(myOrigDocument);
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateInjectionHostElement(PsiLanguageInjectionHost host, ProperTextRange insideHost, String content) {
|
||||
ElementManipulators.getManipulator(host).handleContentChange(host, insideHost, content);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlesRange(@NotNull TextRange range) {
|
||||
if (!myMarkers.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user