From 6bf8113b6e680cabef8bef8b432bc0787c666813 Mon Sep 17 00:00:00 2001 From: Nicolay Mitropolsky Date: Sun, 5 Aug 2018 20:52:21 +0300 Subject: [PATCH] `CommonInjectedFileChangesHandler` made more extendable * accepts `List` instead of Shreads * allows to override method to change host contents --- .../CommonInjectedFileChangesHandler.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/changesHandler/CommonInjectedFileChangesHandler.java b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/changesHandler/CommonInjectedFileChangesHandler.java index ee88e580bd4c..1b52b5b673c9 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/changesHandler/CommonInjectedFileChangesHandler.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/tree/injected/changesHandler/CommonInjectedFileChangesHandler.java @@ -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> myMarkers = ContainerUtil.newLinkedList(); - public CommonInjectedFileChangesHandler(Place shreds, Editor editor, Document newDocument, PsiFile injectedFile) { + public CommonInjectedFileChangesHandler(List 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()) {