-
Notifications
You must be signed in to change notification settings - Fork 3
Annotations
apleshkov edited this page Aug 3, 2018
·
8 revisions
Saber uses annotations to get an info for building containers.
Simple rules to follow:
// @saber.scope(App)
struct A {}
// WRONG:
/* @saber.scope(App) */
struct A {}
// @saber.scope(App)
class A {
// @saber.inject
var foo: Foo!
}
// WRONG:
class A { // @saber.scope(App)
var foo: Foo! // @saber.inject
}
// @saber.scope(App)
// @saber.cached
class A {}
// WRONG:
// @saber.scope(App) @saber.cached
class A {}
// @saber.scope(App) Any text on the same line breaks parsing
class A {}
// WRONG: all annotations will be ignored
// @saber.scope(App)
// @saber.cached
class A {}
// WRONG: scope will be ignored
// @saber.scope(App)
// @saber.cached
class A {}
// WRONG: scope will be ignored
// @saber.scope(App)
/*
Multiline comment with newlines
*/
class A {}
Multiline comments stop Saber parser, so place them above if needed. Any /*
isn't recognizable, so it doesn't matter if there're newlines or not.
You can still use single-line comments everywhere.
/* User text
*/
// @saber.scope(App)
// Also here
// @saber.cached
/// Or even here
class A {}
// WRONG:
// @saber.scope(App)
/* This line will stop the parser */
class A {}
- User's Guide
- Advanced