Example #1
0
 @Override
 public List<String> resolveValues(TemplateVariable variable, XtextTemplateContext castedContext) {
   String enumerationName = (String) variable.getVariableType().getParams().iterator().next();
   EEnum enumeration =
       (EEnum) getEClassifierForGrammar(enumerationName, getGrammar(castedContext));
   if (enumeration == null) {
     return Collections.emptyList();
   }
   return Lists.transform(
       enumeration.getELiterals(),
       new Function<EEnumLiteral, String>() {
         public String apply(EEnumLiteral enumLiteral) {
           return enumLiteral.getLiteral();
         }
       });
 }
Example #2
0
  /* (non-Javadoc)
   * @see org.eclipse.jface.text.templates.TemplateVariableResolver#resolve(org.eclipse.jface.text.templates.TemplateVariable, org.eclipse.jface.text.templates.TemplateContext)
   */
  @Override
  public void resolve(TemplateVariable variable, TemplateContext context) {
    variable.setUnambiguous(true);
    variable.setValue(""); // $NON-NLS-1$

    if (context instanceof JavaContext) {
      JavaContext jc = (JavaContext) context;
      List<String> params = variable.getVariableType().getParams();
      if (params.size() > 0) {
        for (Iterator<String> iterator = params.iterator(); iterator.hasNext(); ) {
          String typeName = iterator.next();
          jc.addImport(typeName);
        }
      }
    } else {
      super.resolve(variable, context);
    }
  }