diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java index 3f87f9c9823..de54a7bbb3e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java @@ -44,7 +44,6 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.text.ICCompletionProposal; -import org.eclipse.cdt.internal.corext.template.c.CContextType; import org.eclipse.cdt.internal.corext.template.c.TranslationUnitContext; import org.eclipse.cdt.internal.corext.template.c.TranslationUnitContextType; @@ -54,23 +53,20 @@ import org.eclipse.cdt.internal.ui.text.contentassist.RelevanceConstants; public class TemplateEngine { - private static final String $_LINE_SELECTION= "${" + GlobalTemplateVariables.LineSelection.NAME + "}"; //$NON-NLS-1$ //$NON-NLS-2$ - private static final String $_WORD_SELECTION= "${" + GlobalTemplateVariables.WordSelection.NAME + "}"; //$NON-NLS-1$ //$NON-NLS-2$ + private static final String $_LINE_SELECTION= "${" + GlobalTemplateVariables.LineSelection.NAME + '}'; //$NON-NLS-1$ + private static final String $_WORD_SELECTION= "${" + GlobalTemplateVariables.WordSelection.NAME + '}'; //$NON-NLS-1$ /** The context type. */ - private TemplateContextType fContextType; + private final TemplateContextType fContextType; /** The result proposals. */ - private ArrayList fProposals= new ArrayList(); + private final ArrayList fProposals= new ArrayList(); /** Positions created on the key documents to remove in reset. */ private final Map fPositions= new HashMap(); /** Pattern to match the start of a line content */ private final Pattern fStartOfLineContentPattern = Pattern.compile("[^ \t]"); //$NON-NLS-1$ - public class CTemplateProposal extends TemplateProposal implements ICCompletionProposal { + public static class CTemplateProposal extends TemplateProposal implements ICCompletionProposal { - /* - * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension3#getInformationControlCreator() - */ @Override public IInformationControlCreator getInformationControlCreator() { return new IInformationControlCreator() { @@ -80,12 +76,7 @@ public class TemplateEngine { } }; } - /** - * @param template - * @param context - * @param region - * @param image - */ + public CTemplateProposal(Template template, TemplateContext context, IRegion region, Image image) { super(template, context, region, image, RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.TEMPLATE_TYPE_RELEVANCE); } @@ -104,17 +95,6 @@ public class TemplateEngine { fContextType= contextType; } - /** - * This is the default constructor used by the new content assist extension point - */ - public TemplateEngine() { - fContextType = CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CContextType.ID); - if (fContextType == null) { - fContextType= new CContextType(); - CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(fContextType); - } - } - /** * Empties the collector. */ @@ -133,7 +113,6 @@ public class TemplateEngine { * Returns the array of matching templates. */ public List getResults() { - //return (TemplateProposal[]) fProposals.toArray(new TemplateProposal[fProposals.size()]); return fProposals; } @@ -144,8 +123,7 @@ public class TemplateEngine { * @param completionPosition the context position in the document of the text viewer * @param translationUnit the translation unit (may be null) */ - public void complete(ITextViewer viewer, int completionPosition, ITranslationUnit translationUnit) - { + public void complete(ITextViewer viewer, int completionPosition, ITranslationUnit translationUnit) { if (!(fContextType instanceof TranslationUnitContextType)) return;