Skip to content

Instantly share code, notes, and snippets.

@munificent
Created October 20, 2016 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save munificent/201d2bf9e6c7660d4658b963d37c43a7 to your computer and use it in GitHub Desktop.
Save munificent/201d2bf9e6c7660d4658b963d37c43a7 to your computer and use it in GitHub Desktop.
Using `return func(params)` syntax.
// Uses in typedefs.
typedef CompilerInputProvider = Future/*<String | List<int>>*/ func(Uri);
typedef ReadStringFromUri = Future<String> func(Uri);
typedef CompilerOutputProvider = EventSink<String> func(String name, String extension);
typedef DiagnosticHandler =
void func(Uri, int begin, int end, String message, Diagnostic kind);
typedef PackagesDiscoveryProvider = Future<Packages> func(Uri);
// Uses in parameters and fields.
class _DeferredAction {
final Element element;
final void func() action;
_DeferredAction(this.element, this.action);
}
/// If [DEBUG_PRINT_ENABLED] is `true` print [s] using the current identation.
void func(dynamic s) get debugPrint {
enableDebugMode();
// TODO(johnniwinther): Maybe disable debug mode after the call.
return _debugPrint;
}
/// Use this to get a tree-like debug printout for nested calls.
dynamic func(dynamic s, dynamic func() f) get debugWrapPrint {
enableDebugMode();
return _debugWrapPrint;
}
/// Print a message with a source location.
dynamic func(DiagnosticReporter, Spannable node, String debugMessage)
get reportHere {
enableDebugMode();
return _reportHere;
}
void func(String message, {bool func(String stackTrace) condition, int limit,
bool throwOnPrint})
get trace {
enableDebugMode();
return _trace;
}
void _trace(String message,
{bool func(String stackTrace) condition, int limit,
bool throwOnPrint: false}) {
...
}
/// Implementation of [traceAndReport].
void _traceAndReport(
DiagnosticReporter reporter, Spannable node, String message,
{bool func(String stackTrace) condition, int limit,
bool throwOnPrint: false}) {
trace(message, limit: limit, throwOnPrint: throwOnPrint,
condition: (String stackTrace) {
...
});
}
void emitNoSuchMethodHandlers(
jsAst.Property func(jsAst.Name, jsAst.Expression) addProperty) {
ClassStubGenerator generator =
new ClassStubGenerator(compiler, namer, backend);
...
}
void _generateIsTestsOn(
ClassElement cls,
void func(Element) generateIsTest,
void func(Element method, FunctionType methodType)
generateFunctionTypeSignature,
void func(Element, {bool emitNull}) generateSubstitution,
void func(TypeCheck check) emitTypeCheck) {
Setlet<Element> generated = new Setlet<Element>();
...
}
void _generateInterfacesIsTests(
ClassElement cls,
void func(ClassElement) generateIsTest,
void func(Element, {bool emitNull}) generateSubstitution,
Set<Element> alreadyGenerated) {
...
}
/// Similar to [resetAsync] but [reuseLibrary] maps all libraries to a list
/// of libraries that can be reused.
Future<Null> resetLibraries(
Future<Iterable<LibraryElement>> func(Iterable<LibraryElement>)
reuseLibraries);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment