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/b71a9ecb75e8e9ad25803019703bbf09 to your computer and use it in GitHub Desktop.
Save munificent/b71a9ecb75e8e9ad25803019703bbf09 to your computer and use it in GitHub Desktop.
Using `return (params)` syntax
// Uses in typedefs.
typedef CompilerInputProvider = Future/*<String | List<int>>*/ (Uri);
typedef ReadStringFromUri = Future<String> (Uri);
typedef CompilerOutputProvider = EventSink<String> (String name, String extension);
typedef DiagnosticHandler =
void (Uri, int begin, int end, String message, Diagnostic kind);
typedef PackagesDiscoveryProvider = Future<Packages> (Uri);
// Uses in parameters and fields.
class _DeferredAction {
final Element element;
final void () action;
_DeferredAction(this.element, this.action);
}
/// If [DEBUG_PRINT_ENABLED] is `true` print [s] using the current identation.
void (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 (dynamic s, dynamic () f) get debugWrapPrint {
enableDebugMode();
return _debugWrapPrint;
}
/// Print a message with a source location.
dynamic (DiagnosticReporter, Spannable node, String debugMessage)
get reportHere {
enableDebugMode();
return _reportHere;
}
void (String message, {bool (String stackTrace) condition, int limit,
bool throwOnPrint})
get trace {
enableDebugMode();
return _trace;
}
void _trace(String message,
{bool (String stackTrace) condition, int limit,
bool throwOnPrint: false}) {
...
}
/// Implementation of [traceAndReport].
void _traceAndReport(
DiagnosticReporter reporter, Spannable node, String message,
{bool (String stackTrace) condition, int limit,
bool throwOnPrint: false}) {
trace(message, limit: limit, throwOnPrint: throwOnPrint,
condition: (String stackTrace) {
...
});
}
void emitNoSuchMethodHandlers(
jsAst.Property (jsAst.Name, jsAst.Expression) addProperty) {
ClassStubGenerator generator =
new ClassStubGenerator(compiler, namer, backend);
...
}
void _generateIsTestsOn(
ClassElement cls,
void (Element) generateIsTest,
void (Element method, FunctionType methodType)
generateFunctionTypeSignature,
void (Element, {bool emitNull}) generateSubstitution,
void (TypeCheck check) emitTypeCheck) {
Setlet<Element> generated = new Setlet<Element>();
...
}
void _generateInterfacesIsTests(
ClassElement cls,
void (ClassElement) generateIsTest,
void (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>> (Iterable<LibraryElement>)
reuseLibraries);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment