From 88c2f4a06353645504472465a95140f98a0b2424 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Fri, 24 Apr 2009 10:49:54 +0000 Subject: [PATCH] Bug 239923 - No Template proposals within doxygen comments --- core/org.eclipse.cdt.ui/plugin.properties | 1 + core/org.eclipse.cdt.ui/plugin.xml | 15 +++++++++-- .../template/c/DocCommentContextType.java | 26 +++++++++++++++++++ .../TemplateCompletionProposalComputer.java | 12 ++++++++- .../src/org/eclipse/cdt/ui/CUIPlugin.java | 4 ++- 5 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 29491a0125c..17645fdfa15 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -396,6 +396,7 @@ asmCompareFontDefinition.description= The Assembly compare text font is used by #--- templates c.contextType.name = C/C++ comment.contextType.name = Comment +doccomment.contextType.name = Doc Comment # completion completionContributors=Content Assist Completion Contributor diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index f74147cdc55..cf2b98745a5 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -2416,15 +2416,24 @@ + + id="org.eclipse.cdt.ui.text.templates.c" + registryId="org.eclipse.cdt.ui.editor.CEditor"> + name="%comment.contextType.name" + registryId="org.eclipse.cdt.ui.editor.CEditor"> + + + + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java new file mode 100644 index 00000000000..e164bff4811 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/corext/template/c/DocCommentContextType.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2009 Wind River Systems, Inc. and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.corext.template.c; + +/** + * A context type for documentation comments. + * + * @since 5.1 + */ +public class DocCommentContextType extends CommentContextType { + + @SuppressWarnings("hiding") + public static final String ID= "org.eclipse.cdt.ui.text.templates.doccomment"; //$NON-NLS-1$ + + public DocCommentContextType() { + } + +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java index 8ee2f02c4c1..9638894b809 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -30,6 +30,7 @@ import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer; import org.eclipse.cdt.internal.corext.template.c.CContextType; import org.eclipse.cdt.internal.corext.template.c.CommentContextType; +import org.eclipse.cdt.internal.corext.template.c.DocCommentContextType; import org.eclipse.cdt.internal.ui.text.CHeuristicScanner; import org.eclipse.cdt.internal.ui.text.template.TemplateEngine; @@ -43,6 +44,7 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo private final TemplateEngine fCTemplateEngine; private final TemplateEngine fCommentTemplateEngine; + private final TemplateEngine fDocCommentTemplateEngine; /** * Default constructor is required (executable extension). @@ -60,6 +62,12 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType); } fCommentTemplateEngine= new TemplateEngine(contextType); + contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(DocCommentContextType.ID); + if (contextType == null) { + contextType= new DocCommentContextType(); + CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType); + } + fDocCommentTemplateEngine= new TemplateEngine(contextType); } /* @@ -73,6 +81,8 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo String partition= TextUtilities.getContentType(viewer.getDocument(), ICPartitions.C_PARTITIONING, offset, true); if (partition.equals(ICPartitions.C_MULTI_LINE_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_COMMENT)) { engine= fCommentTemplateEngine; + } else if (partition.equals(ICPartitions.C_MULTI_LINE_DOC_COMMENT) || partition.equals(ICPartitions.C_SINGLE_LINE_DOC_COMMENT)) { + engine= fDocCommentTemplateEngine; } else { if (isValidContext(context)) { engine= fCTemplateEngine; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index 70f42120665..d1d89f6f34c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -75,6 +75,7 @@ import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.cdt.internal.corext.template.c.CContextType; import org.eclipse.cdt.internal.corext.template.c.CodeTemplateContextType; import org.eclipse.cdt.internal.corext.template.c.CommentContextType; +import org.eclipse.cdt.internal.corext.template.c.DocCommentContextType; import org.eclipse.cdt.internal.corext.template.c.FileTemplateContextType; import org.eclipse.cdt.internal.ui.CElementAdapterFactory; @@ -872,9 +873,10 @@ public class CUIPlugin extends AbstractUIPlugin { */ public ContextTypeRegistry getTemplateContextRegistry() { if (fContextTypeRegistry == null) { - fContextTypeRegistry= new ContributionContextTypeRegistry(); + fContextTypeRegistry= new ContributionContextTypeRegistry(EDITOR_ID); fContextTypeRegistry.addContextType(CContextType.ID); fContextTypeRegistry.addContextType(CommentContextType.ID); + fContextTypeRegistry.addContextType(DocCommentContextType.ID); } return fContextTypeRegistry; }