Support URIs in part-of directives. (#626)

* Support URIs in part-of directives.

Fix #615.

* Add tests for and tweak how function types are formatted.

* Remove duplicate test.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9e97e3a..248d1f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.0.6
+
+* Support URIs in part-of directives (#615).
+
 # 1.0.5
 
 * Support the latest version of `pkg/analyzer`.
diff --git a/bin/format.dart b/bin/format.dart
index 3899305..7af4d16 100644
--- a/bin/format.dart
+++ b/bin/format.dart
@@ -14,7 +14,7 @@
 import 'package:dart_style/src/source_code.dart';
 
 // Note: The following line of code is modified by tool/grind.dart.
-const version = "1.0.5";
+const version = "1.0.6";
 
 void main(List<String> args) {
   var parser = new ArgParser(allowTrailingOptions: true);
diff --git a/lib/src/source_visitor.dart b/lib/src/source_visitor.dart
index 5023663..1104119 100644
--- a/lib/src/source_visitor.dart
+++ b/lib/src/source_visitor.dart
@@ -1190,8 +1190,15 @@
   }
 
   visitGenericFunctionType(GenericFunctionType node) {
-    visit(node.returnType, after: space);
+    builder.startLazyRule();
+    builder.nestExpression();
+
+    visit(node.returnType, after: split);
     token(node.functionKeyword);
+
+    builder.unnest();
+    builder.endRule();
+
     _visitParameterSignature(node.typeParameters, node.parameters);
   }
 
@@ -1516,7 +1523,11 @@
       space();
       token(node.ofKeyword);
       space();
+
+      // Part-of may have either a name or a URI. Only one of these will be
+      // non-null. We visit both since visit() ignores null.
       visit(node.libraryName);
+      visit(node.uri);
     });
   }
 
diff --git a/pubspec.yaml b/pubspec.yaml
index 4f212f0..93ccf0c 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
 name: dart_style
 # Note: See tool/grind.dart for how to bump the version.
-version: 1.0.5
+version: 1.0.6
 author: Dart Team <misc@dartlang.org>
 description: Opinionated, automatic Dart source code formatter.
 homepage: https://github.com/dart-lang/dart_style
diff --git a/test/splitting/function_types.unit b/test/splitting/function_types.unit
new file mode 100644
index 0000000..efd2294
--- /dev/null
+++ b/test/splitting/function_types.unit
@@ -0,0 +1,98 @@
+40 columns                              |
+>>> many parameters
+Function(first, second, third, fourth, fifth, sixth, seventh, eighth, ninth,
+    tenth, eleventh, twelfth) f;
+<<<
+Function(
+    first,
+    second,
+    third,
+    fourth,
+    fifth,
+    sixth,
+    seventh,
+    eighth,
+    ninth,
+    tenth,
+    eleventh,
+    twelfth) f;
+>>> parameters fit but ) does not
+Function(int firstArgume, int argumentTo) f;
+<<<
+Function(
+    int firstArgume, int argumentTo) f;
+>>> keep mandatory and positional on same line
+Function(param, [foo, bar]) f;
+<<<
+Function(param, [foo, bar]) f;
+>>> keep mandatory and named on same line
+Function(param, {T foo, T bar}) f;
+<<<
+Function(param, {T foo, T bar}) f;
+>>> move just optional positional to second line even though all fit on second
+Function(parameter, [int foo, String bar]) f;
+<<<
+Function(parameter,
+    [int foo, String bar]) f;
+>>> move just named to second line even though all fit on second
+Function(parameter, {int foo, String bar}) f;
+<<<
+Function(parameter,
+    {int foo, String bar}) f;
+>>> avoid splitting in function type parameters
+Function(parameter1, void printFn(param1, param2)) f;
+<<<
+Function(parameter1,
+    void printFn(param1, param2)) f;
+>>> allow splitting in function type parameters
+Function(v callback(parameter1, parameter2, parameter3, parameter4)) f;
+<<<
+Function(
+    v callback(parameter1, parameter2,
+        parameter3, parameter4)) f;
+>>> split optional onto one per line if they don't fit on one line
+Function([parameter1, parameter2, parameter3]) f;
+<<<
+Function(
+    [parameter1,
+    parameter2,
+    parameter3]) f;
+>>> split between type and name
+Function(VerylongParameterType parameterName) f;
+<<<
+Function(
+    VerylongParameterType
+        parameterName) f;
+>>> split in function type and on variable name
+Function(VeryVeryVeryVeryLongParameterType) veryLongVariableName;
+<<<
+Function(
+        VeryVeryVeryVeryLongParameterType)
+    veryLongVariableName;
+>>> split in nested function type forces outer split
+Function(int, String, Function(parameter1, parameter2, parameter3)) f;
+<<<
+Function(
+    int,
+    String,
+    Function(parameter1, parameter2,
+        parameter3)) f;
+>>> split in type arguments and variable
+Function<Parameter1, Parameter2, Parameter3>() veryVeryLongVariableName;
+<<<
+Function<Parameter1, Parameter2,
+        Parameter3>()
+    veryVeryLongVariableName;
+>>> split after return type
+GenericClass<Parameter1, Parameter2> Function() f;
+<<<
+GenericClass<Parameter1, Parameter2>
+    Function() f;
+>>> chained return types
+Function<Argument>(String) Function<Argument>(num) Function<Argument>(int) Function<Argument>(bool) longVariable;
+<<<
+Function<Argument>(String)
+                Function<Argument>(num)
+            Function<Argument>(int)
+        Function<Argument>(bool)
+    longVariable;
\ No newline at end of file
diff --git a/test/splitting/part.unit b/test/splitting/part.unit
new file mode 100644
index 0000000..d7e136c
--- /dev/null
+++ b/test/splitting/part.unit
@@ -0,0 +1,9 @@
+40 columns                              |
+>>> part of with uri that fits
+part of "uri.dart";
+<<<
+part of "uri.dart";
+>>> part of with uri does not split on long line
+part of "very_very_very_very_long_uri.dart";
+<<<
+part of "very_very_very_very_long_uri.dart";
\ No newline at end of file
diff --git a/test/whitespace/directives.unit b/test/whitespace/directives.unit
index 5d7ff38..d174133 100644
--- a/test/whitespace/directives.unit
+++ b/test/whitespace/directives.unit
@@ -57,4 +57,8 @@
 >>> configuration
 export'a'if(b  . c=='d'   )'e';
 <<<
-export 'a' if (b.c == 'd') 'e';
\ No newline at end of file
+export 'a' if (b.c == 'd') 'e';
+>>> part-of with uri
+part   of'uri.dart'     ;
+<<<
+part of 'uri.dart';
\ No newline at end of file
diff --git a/test/whitespace/function_types.unit b/test/whitespace/function_types.unit
new file mode 100644
index 0000000..b8dfe9b
--- /dev/null
+++ b/test/whitespace/function_types.unit
@@ -0,0 +1,21 @@
+40 columns                              |
+>>>
+Function ( )  f;
+<<<
+Function() f;
+>>>
+void  Function(  int  i,  String   s)   f;
+<<<
+void Function(int i, String s) f;
+>>>
+Function(  int i,  [  String   s,  bool   b   ]  )   f;
+<<<
+Function(int i, [String s, bool b]) f;
+>>>
+Function(  int i,  {   String  s,  bool   b   }  )   f;
+<<<
+Function(int i, {String s, bool b}) f;
+>>>
+Function  <  T  extends S   >   () f;
+<<<
+Function<T extends S>() f;
\ No newline at end of file