Search in sources :

Example 16 with TemplateVariableResolver

use of org.eclipse.jface.text.templates.TemplateVariableResolver in project che by eclipse.

the class JavaPlugin method registerJavaContext.

/**
     * Registers the given Java template context.
     *
     * @param registry the template context type registry
     * @param id the context type id
     * @param parent the parent context type
     * @since 3.4
     */
private static void registerJavaContext(ContributionContextTypeRegistry registry, String id, TemplateContextType parent) {
    TemplateContextType contextType = registry.getContextType(id);
    Iterator<TemplateVariableResolver> iter = parent.resolvers();
    while (iter.hasNext()) contextType.addResolver(iter.next());
}
Also used : TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType) CodeTemplateContextType(org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

Example 17 with TemplateVariableResolver

use of org.eclipse.jface.text.templates.TemplateVariableResolver in project webtools.sourceediting by eclipse.

the class TestTemplateContextTypeXSL method testDateVariableAvailable.

@Test
public void testDateVariableAvailable() throws Exception {
    TemplateContextTypeXSL contextType = new TemplateContextTypeXSL();
    Iterator<TemplateVariableResolver> variables = contextType.resolvers();
    while (variables.hasNext()) {
        TemplateVariableResolver resolver = variables.next();
        if (resolver.getType().equals("date")) {
            return;
        }
    }
    fail("Date variable resolver was not found.");
}
Also used : TemplateContextTypeXSL(org.eclipse.wst.xsl.ui.internal.templates.TemplateContextTypeXSL) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

Example 18 with TemplateVariableResolver

use of org.eclipse.jface.text.templates.TemplateVariableResolver in project webtools.sourceediting by eclipse.

the class TestTemplateContextTypeXSL method testWordSelectionVariableAvailable.

@Test
public void testWordSelectionVariableAvailable() throws Exception {
    TemplateContextTypeXSL contextType = new TemplateContextTypeXSL();
    Iterator<TemplateVariableResolver> variables = contextType.resolvers();
    while (variables.hasNext()) {
        TemplateVariableResolver resolver = variables.next();
        if (resolver.getType().equals("word_selection")) {
            return;
        }
    }
    fail("Word Selection variable resolver was not found.");
}
Also used : TemplateContextTypeXSL(org.eclipse.wst.xsl.ui.internal.templates.TemplateContextTypeXSL) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

Example 19 with TemplateVariableResolver

use of org.eclipse.jface.text.templates.TemplateVariableResolver in project webtools.sourceediting by eclipse.

the class TestTemplateContextTypeXSL method testLineSelectionVariableAvailable.

@Test
public void testLineSelectionVariableAvailable() throws Exception {
    TemplateContextTypeXSL contextType = new TemplateContextTypeXSL();
    Iterator<TemplateVariableResolver> variables = contextType.resolvers();
    while (variables.hasNext()) {
        TemplateVariableResolver resolver = variables.next();
        if (resolver.getType().equals("line_selection")) {
            return;
        }
    }
    fail("Line Selection variable resolver was not found.");
}
Also used : TemplateContextTypeXSL(org.eclipse.wst.xsl.ui.internal.templates.TemplateContextTypeXSL) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

Example 20 with TemplateVariableResolver

use of org.eclipse.jface.text.templates.TemplateVariableResolver in project webtools.sourceediting by eclipse.

the class TestTemplateContextTypeXSL method testCursorVariableAvailable.

@Test
public void testCursorVariableAvailable() throws Exception {
    TemplateContextTypeXSL contextType = new TemplateContextTypeXSL();
    Iterator<TemplateVariableResolver> variables = contextType.resolvers();
    while (variables.hasNext()) {
        TemplateVariableResolver resolver = variables.next();
        if (resolver.getType().equals("cursor")) {
            return;
        }
    }
    fail("Cursor variable resolver was not found.");
}
Also used : TemplateContextTypeXSL(org.eclipse.wst.xsl.ui.internal.templates.TemplateContextTypeXSL) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

Aggregations

TemplateVariableResolver (org.eclipse.jface.text.templates.TemplateVariableResolver)28 TemplateContextTypeXSL (org.eclipse.wst.xsl.ui.internal.templates.TemplateContextTypeXSL)10 TemplateContextType (org.eclipse.jface.text.templates.TemplateContextType)9 CoreException (org.eclipse.core.runtime.CoreException)5 ContextTypeRegistry (org.eclipse.jface.text.templates.ContextTypeRegistry)5 ContextTypeIdHelper (org.eclipse.xtext.ui.editor.templates.ContextTypeIdHelper)5 TemplateBuffer (org.eclipse.jface.text.templates.TemplateBuffer)4 IInspectableTemplateVariableResolver (org.eclipse.xtext.ui.codetemplates.ui.resolvers.IInspectableTemplateVariableResolver)4 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)3 TemplateTranslator (org.eclipse.jface.text.templates.TemplateTranslator)3 StyledString (org.eclipse.jface.viewers.StyledString)3 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)2 Grammar (org.eclipse.xtext.Grammar)2 Codetemplate (org.eclipse.xtext.ui.codetemplates.templates.Codetemplate)2 Codetemplates (org.eclipse.xtext.ui.codetemplates.templates.Codetemplates)2 Variable (org.eclipse.xtext.ui.codetemplates.templates.Variable)2 ConfigurableCompletionProposal (org.eclipse.xtext.ui.editor.contentassist.ConfigurableCompletionProposal)2 ArrayList (java.util.ArrayList)1