INRIA/spoon

add support for inline templates

Open

#3,118 opened on Sep 22, 2019

 (9 comments) (0 reactions) (0 assignees)Java (383 forks)github user discovery
good first issueroadmap

Repository metrics

Stars
 (1,933 stars)
PR merge metrics
 (Avg merge 19d 11h) (49 merged PRs in 30d)

Description

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();

Contributor guide