Java Code Examples for org.eclipse.jface.text.templates.TemplateVariable#setValues()
The following examples show how to use
org.eclipse.jface.text.templates.TemplateVariable#setValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabStopVariableResolver.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void resolve(TemplateVariable variable, TemplateContext context) { if (!variable.getVariableType().getParams().isEmpty()) { String[] values = (String[]) variable.getVariableType().getParams().toArray(new String[0]); variable.setValues(values); variable.setUnambiguous(false); variable.setResolved(true); } else { super.resolve(variable, context); setEvaluationString(variable.getName()); } }
Example 2
Source File: AbstractTemplateVariableResolver.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext templateContext) { XtextTemplateContext castedContext = (XtextTemplateContext) templateContext; List<String> names = resolveValues(variable, castedContext); String[] bindings = names.toArray(new String[names.size()]); if (bindings.length != 0) variable.setValues(bindings); if (bindings.length > 1) variable.setUnambiguous(false); else variable.setUnambiguous(isUnambiguous(castedContext)); variable.setResolved(true); }
Example 3
Source File: ElementNameResolver.java From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 | 5 votes |
@Override public void resolve(TemplateVariable variable, TemplateContext context) { List params = variable.getVariableType().getParams(); String[] bindings = new String[params.size()]; for (int i = 0; i < params.size(); i++) { bindings[i] = params.get(i).toString(); } if (bindings.length != 0) variable.setValues(bindings); variable.setResolved(true); }
Example 4
Source File: EnvironmentVariableVariableResolver.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public void resolve(TemplateVariable variable, TemplateContext context) { if (context instanceof DocumentSnippetTemplateContext) { DocumentSnippetTemplateContext documentSnippetTemplateContext = (DocumentSnippetTemplateContext) context; Template template = documentSnippetTemplateContext.getTemplate(); if (template instanceof SnippetTemplate) { SnippetTemplate snippetTemplate = (SnippetTemplate) template; CommandElement snippet = snippetTemplate.getCommandElement(); Map<String, String> environment = snippet.getEnvironment(); String name = variable.getName(); String value = environment.get(name); if (value == null) { if (!variable.getVariableType().getParams().isEmpty()) { String[] values = (String[]) variable.getVariableType().getParams().toArray(new String[0]); variable.setValues(values); variable.setUnambiguous(false); } else { super.resolve(variable, context); } } else { variable.setValues(new String[] { value }); } variable.setResolved(true); } } }