diff options
author | amywu | 2007-09-26 19:05:32 +0000 |
---|---|---|
committer | amywu | 2007-09-26 19:05:32 +0000 |
commit | 679e0864226c0ab103df36aa812855b665efdbee (patch) | |
tree | eb31076db87338739dcbfe79df0e401ee0a6ada4 | |
parent | 6d4526dc736b522239e8e32c1a072606a2f0a775 (diff) | |
download | webtools.sourceediting-679e0864226c0ab103df36aa812855b665efdbee.tar.gz webtools.sourceediting-679e0864226c0ab103df36aa812855b665efdbee.tar.xz webtools.sourceediting-679e0864226c0ab103df36aa812855b665efdbee.zip |
[198711] CompoundContentAssistProcessor shows wrong error message when more than 1 CA processor installed
3 files changed, 54 insertions, 18 deletions
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java index 1a9df5c277..80d565aea0 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/StructuredTextViewer.java @@ -401,11 +401,11 @@ public class StructuredTextViewer extends ProjectionViewer implements IDocumentS case CONTENTASSIST_CONTEXT_INFORMATION : if (fContentAssistant != null) { String err = fContentAssistant.showContextInformation(); - PlatformStatusLineUtil.displayErrorMessage(err); + if (err != null) { + // don't wanna beep if there is no error + PlatformStatusLineUtil.displayErrorMessage(err); + } PlatformStatusLineUtil.addOneTimeClearListener(); - // setErrorMessage(err); - // new OneTimeListener(getTextWidget(), new - // ClearErrorMessage()); } break; case SHIFT_RIGHT : diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java index 6d6d4a5bc3..c71a239019 100644 --- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java +++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CompoundContentAssistProcessor.java @@ -230,6 +230,7 @@ class CompoundContentAssistProcessor implements IContentAssistProcessor, ISubjec } private final Set fProcessors = new LinkedHashSet(); + private String fErrorMessage; /** * Creates a new instance. @@ -284,12 +285,22 @@ class CompoundContentAssistProcessor implements IContentAssistProcessor, ISubjec * int) */ public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { + fErrorMessage = null; List ret = new LinkedList(); for (Iterator it = fProcessors.iterator(); it.hasNext();) { IContentAssistProcessor p = (IContentAssistProcessor) it.next(); ICompletionProposal[] proposals = p.computeCompletionProposals(viewer, documentOffset); - if (proposals != null) + if (proposals != null && proposals.length > 0) { ret.addAll(Arrays.asList(proposals)); + fErrorMessage = null; // Hide previous errors + } else { + if (fErrorMessage == null && ret.isEmpty()) { + String errorMessage = p.getErrorMessage(); + if (errorMessage != null) { + fErrorMessage = errorMessage; + } + } + } } return (ICompletionProposal[]) ret.toArray(new ICompletionProposal[ret.size()]); } @@ -305,13 +316,23 @@ class CompoundContentAssistProcessor implements IContentAssistProcessor, ISubjec * int) */ public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) { + fErrorMessage = null; List ret = new LinkedList(); for (Iterator it = fProcessors.iterator(); it.hasNext();) { IContentAssistProcessor p = (IContentAssistProcessor) it.next(); IContextInformation[] informations = p.computeContextInformation(viewer, documentOffset); - if (informations != null) + if (informations != null && informations.length > 0) { for (int i = 0; i < informations.length; i++) ret.add(new WrappedContextInformation(informations[i], p)); + fErrorMessage = null; // Hide previous errors + } else { + if (fErrorMessage == null && ret.isEmpty()) { + String errorMessage = p.getErrorMessage(); + if (errorMessage != null) { + fErrorMessage = errorMessage; + } + } + } } return (IContextInformation[]) ret.toArray(new IContextInformation[ret.size()]); } @@ -361,21 +382,15 @@ class CompoundContentAssistProcessor implements IContentAssistProcessor, ISubjec } /** - * Returns the first non- <code>null</code> error message of any - * contained processor, or <code>null</code> if no processor has an + * Returns the error message of one of + * contained processor if any, or <code>null</code> if no processor has an * error message. * * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() * @return {@inheritDoc} */ public String getErrorMessage() { - for (Iterator it = fProcessors.iterator(); it.hasNext();) { - IContentAssistProcessor p = (IContentAssistProcessor) it.next(); - String err = p.getErrorMessage(); - if (err != null) - return err; - } - return null; + return fErrorMessage; } /** @@ -433,14 +448,24 @@ class CompoundContentAssistProcessor implements IContentAssistProcessor, ISubjec * int) */ public ICompletionProposal[] computeCompletionProposals(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) { + fErrorMessage = null; List ret = new LinkedList(); for (Iterator it = fProcessors.iterator(); it.hasNext();) { Object o = it.next(); if (o instanceof ISubjectControlContentAssistProcessor) { ISubjectControlContentAssistProcessor p = (ISubjectControlContentAssistProcessor) o; ICompletionProposal[] proposals = p.computeCompletionProposals(contentAssistSubjectControl, documentOffset); - if (proposals != null) + if (proposals != null && proposals.length > 0) { ret.addAll(Arrays.asList(proposals)); + fErrorMessage = null; // Hide previous errors + } else { + if (fErrorMessage == null && ret.isEmpty()) { + String errorMessage = p.getErrorMessage(); + if (errorMessage != null) { + fErrorMessage = errorMessage; + } + } + } } } @@ -458,15 +483,25 @@ class CompoundContentAssistProcessor implements IContentAssistProcessor, ISubjec * int) */ public IContextInformation[] computeContextInformation(IContentAssistSubjectControl contentAssistSubjectControl, int documentOffset) { + fErrorMessage = null; List ret = new LinkedList(); for (Iterator it = fProcessors.iterator(); it.hasNext();) { Object o = it.next(); if (o instanceof ISubjectControlContentAssistProcessor) { ISubjectControlContentAssistProcessor p = (ISubjectControlContentAssistProcessor) o; IContextInformation[] informations = p.computeContextInformation(contentAssistSubjectControl, documentOffset); - if (informations != null) + if (informations != null && informations.length > 0) { for (int i = 0; i < informations.length; i++) ret.add(new WrappedContextInformation(informations[i], p)); + fErrorMessage = null; // Hide previous errors + } else { + if (fErrorMessage == null && ret.isEmpty()) { + String errorMessage = p.getErrorMessage(); + if (errorMessage != null) { + fErrorMessage = errorMessage; + } + } + } } } return (IContextInformation[]) ret.toArray(new IContextInformation[ret.size()]); diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java index 5f2b548e51..a48e75337b 100644 --- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java +++ b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java @@ -58,7 +58,8 @@ public class ContextInfoModelUtil { xmlNode = (IDOMNode) xmlModel.getIndexedRegion(offset); } finally { - xmlModel.releaseFromRead(); + if (xmlModel != null) + xmlModel.releaseFromRead(); } return xmlNode; } |