Bug 553622 - Highlighting in context information no longer works This change restores the previous behavior in case of a single IContextInformationValidator, so it removes the regression. The case of multiple validators will be treated in a separate change, as it's not a regression but more a missing feature for mulitple completion processors. Change-Id: I9a826bc5ec43ea59c48d304b330d4a3ed2d7739b Signed-off-by: Mickael Istria <mistria@redhat.com>
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompositeContextInformationValidator.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompositeContextInformationValidator.java index 1f2bd35..31ac39e 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompositeContextInformationValidator.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompositeContextInformationValidator.java
@@ -13,8 +13,9 @@ import java.util.Arrays; import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.TextPresentation; -class CompositeContextInformationValidator implements IContextInformationValidator { +class CompositeContextInformationValidator implements IContextInformationValidator, IContextInformationPresenter { private final IContextInformationValidator[] children; @@ -32,4 +33,12 @@ return Arrays.stream(children).anyMatch(child -> child.isContextInformationValid(offset)); } + @Override + public boolean updatePresentation(int offset, TextPresentation presentation) { + if (children.length == 1 && children[0] instanceof IContextInformationPresenter) { + return ((IContextInformationPresenter) children[0]).updatePresentation(offset, presentation); + } + return false; + } + }
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java index 04c7e63..4da58e2 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java
@@ -2120,6 +2120,8 @@ .toArray(IContextInformationValidator[]::new); if (validators.length == 0) { return null; + } else if (validators.length == 1) { + return validators[0]; } return new CompositeContextInformationValidator(validators); } @@ -2146,6 +2148,8 @@ .toArray(IContextInformationValidator[]::new); if (validators.length == 0) { return null; + } else if (validators.length == 1) { + return validators[0]; } return new CompositeContextInformationValidator(validators); }