use of org.eclipse.jface.text.templates.TemplateVariable in project eclipse.platform.text by eclipse.
the class TemplateTranslatorTest method testMultiParameterizedTypeTemplate2.
@Test
public void testMultiParameterizedTypeTemplate2() throws Exception {
TemplateBuffer buffer = fTranslator.translate("foo ${var:type(param)} bar ${var} end");
assertNull(fTranslator.getErrorMessage());
assertEquals("foo var bar var end", buffer.getString());
TemplateVariable[] vars = buffer.getVariables();
assertEquals(1, vars.length);
assertEquals("var", vars[0].getName());
assertEquals(2, vars[0].getOffsets().length);
assertEquals(4, vars[0].getOffsets()[0]);
assertEquals(12, vars[0].getOffsets()[1]);
assertEquals(3, vars[0].getLength());
assertEquals(false, vars[0].isUnambiguous());
assertEquals("var", vars[0].getDefaultValue());
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("type", vars[0].getType());
assertEquals(Collections.singletonList("param"), vars[0].getVariableType().getParams());
}
use of org.eclipse.jface.text.templates.TemplateVariable in project eclipse.platform.text by eclipse.
the class TemplateTranslatorTest method testParameterizedTypeTemplateWithWhitespace.
@Test
public void testParameterizedTypeTemplateWithWhitespace() throws Exception {
TemplateBuffer buffer = fTranslator.translate("foo ${ var : type ( param1 , param2 , param3 ) } bar");
assertNull(fTranslator.getErrorMessage());
assertEquals("foo var bar", buffer.getString());
TemplateVariable[] vars = buffer.getVariables();
assertEquals(1, vars.length);
assertEquals("var", vars[0].getName());
assertEquals(1, vars[0].getOffsets().length);
assertEquals(4, vars[0].getOffsets()[0]);
assertEquals(3, vars[0].getLength());
assertEquals(false, vars[0].isUnambiguous());
assertEquals("var", vars[0].getDefaultValue());
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("type", vars[0].getType());
List<String> params = new ArrayList<>(2);
params.add("param1");
params.add("param2");
params.add("param3");
assertEquals(params, vars[0].getVariableType().getParams());
}
use of org.eclipse.jface.text.templates.TemplateVariable in project eclipse.platform.text by eclipse.
the class TemplateTranslatorTest method testSimpleTemplate.
@Test
public void testSimpleTemplate() throws Exception {
TemplateBuffer buffer = fTranslator.translate("foo ${var} bar");
assertNull(fTranslator.getErrorMessage());
assertEquals("foo var bar", buffer.getString());
TemplateVariable[] vars = buffer.getVariables();
assertEquals(1, vars.length);
assertEquals("var", vars[0].getName());
assertEquals(1, vars[0].getOffsets().length);
assertEquals(4, vars[0].getOffsets()[0]);
assertEquals(3, vars[0].getLength());
assertEquals(false, vars[0].isUnambiguous());
assertEquals("var", vars[0].getDefaultValue());
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("var", vars[0].getType());
}
use of org.eclipse.jface.text.templates.TemplateVariable in project eclipse.platform.text by eclipse.
the class TemplateTranslatorTest method testQualifiedTypeTemplate.
@Test
public void testQualifiedTypeTemplate() throws Exception {
TemplateBuffer buffer = fTranslator.translate("foo ${ var : qual.type ( qual.param1, qual.param2 ) } bar");
assertNull(fTranslator.getErrorMessage());
assertEquals("foo var bar", buffer.getString());
TemplateVariable[] vars = buffer.getVariables();
assertEquals(1, vars.length);
assertEquals("var", vars[0].getName());
assertEquals(1, vars[0].getOffsets().length);
assertEquals(4, vars[0].getOffsets()[0]);
assertEquals(3, vars[0].getLength());
assertEquals(false, vars[0].isUnambiguous());
assertEquals("var", vars[0].getDefaultValue());
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("qual.type", vars[0].getType());
List<String> params = new ArrayList<>(2);
params.add("qual.param1");
params.add("qual.param2");
assertEquals(params, vars[0].getVariableType().getParams());
}
use of org.eclipse.jface.text.templates.TemplateVariable in project eclipse.platform.text by eclipse.
the class TemplateTranslatorTest method testTextParameterTemplate.
@Test
public void testTextParameterTemplate() throws Exception {
TemplateBuffer buffer = fTranslator.translate("foo ${ var : qual.type ( 'a parameter 1', qual.param2, 'a parameter ''3' ) } bar");
assertNull(fTranslator.getErrorMessage());
assertEquals("foo var bar", buffer.getString());
TemplateVariable[] vars = buffer.getVariables();
assertEquals(1, vars.length);
assertEquals("var", vars[0].getName());
assertEquals(1, vars[0].getOffsets().length);
assertEquals(4, vars[0].getOffsets()[0]);
assertEquals(3, vars[0].getLength());
assertEquals(false, vars[0].isUnambiguous());
assertEquals("var", vars[0].getDefaultValue());
assertEquals(1, vars[0].getValues().length);
assertEquals(vars[0].getDefaultValue(), vars[0].getValues()[0]);
assertEquals("qual.type", vars[0].getType());
List<String> params = new ArrayList<>(3);
params.add("a parameter 1");
params.add("qual.param2");
params.add("a parameter '3");
assertEquals(params, vars[0].getVariableType().getParams());
}
Aggregations