INRIA/spoon

add support for inline templates

Aperta

#3118 aperta il 22 set 2019

 (9 commenti) (0 reazioni) (0 assegnatari)Java (383 fork)github user discovery
good first issueroadmap

Metriche repository

Star
 (1933 stelle)
Metriche merge PR
 (Merge medio 19g 11h) (49 PR mergiate in 30 g)

Descrizione

inline templates:

  • with anonymous classes
  • with lambda

Inline templates

Templates can be made inline, if the source code of the transformation is passed appropriately, as an anonymous class, as follows:

// example of inline template definition + instantiation
Template t = new StatementTemplate() {
	TemplateParameter<Collection<?>> _col_ = createVariableAccess(method.getParameters().get(0));
	@Override
	public void statement() {
		if (_col_.S().size() > 10)
			throw new OutOfBoundException();
	}
}; // end of inline template
CtStatement injectedCode = t.apply();

Guida contributor