Fix errors after merge

This commit is contained in:
Tobe O 2018-08-20 15:34:00 -04:00
parent b729908447
commit 692ebf57bf
18 changed files with 28 additions and 66 deletions

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
<excludeFolder url="file://$MODULE_DIR$/.pub" />
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
<excludeFolder url="file://$MODULE_DIR$/build" />
<excludeFolder url="file://$MODULE_DIR$/temp" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Dart SDK" level="project" />
<orderEntry type="library" name="Dart Packages" level="project" />
</component>
</module>

View file

@ -1,8 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All Tests" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true">
<option name="filePath" value="$PROJECT_DIR$/test" />
<option name="scope" value="FOLDER" />
<option name="testRunnerOptions" value="-j4" />
<method />
</configuration>
</component>

View file

@ -1,8 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="parse in parse_test.dart" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$/test/parse_test.dart" />
<option name="scope" value="GROUP_OR_TEST_BY_NAME" />
<option name="testName" value="parse" />
<method />
</configuration>
</component>

View file

@ -2,7 +2,7 @@
<configuration default="false" name="tests in route" type="DartTestRunConfigurationType" factoryName="Dart Test" singleton="true" nameIsGenerated="true">
<option name="filePath" value="$PROJECT_DIR$" />
<option name="scope" value="FOLDER" />
<option name="testRunnerOptions" value="-j 4" />
<option name="testRunnerOptions" value="-j4" />
<method />
</configuration>
</component>

View file

@ -1,7 +1,3 @@
analyzer:
strong-mode:
<<<<<<< HEAD
implicit-casts: false
=======
implicit-casts: false
>>>>>>> 6bf72feffc1af269e2ebfa5d1fbcd4f08ba3ea90

View file

@ -18,6 +18,6 @@ class MiddlewarePipeline<T> {
return _handlers = handlers;
}
MiddlewarePipeline(Iterable<RoutingResult> routingResults)
MiddlewarePipeline(Iterable<RoutingResult<T>> routingResults)
: this.routingResults = routingResults.toList();
}

View file

@ -267,16 +267,16 @@ class Router<T> {
/// Finds the first [Route] that matches the given path,
/// with the given method.
bool resolve(String absolute, String relative, List<RoutingResult> out,
bool resolve(String absolute, String relative, List<RoutingResult<T>> out,
{String method: 'GET', bool strip: true}) {
final cleanRelative =
strip == false ? relative : stripStraySlashes(relative);
var scanner = new SpanScanner(cleanRelative);
bool crawl(Router r) {
bool crawl(Router<T> r) {
bool success = false;
for (Route route in r.routes) {
for (var route in r.routes) {
int pos = scanner.position;
if (route is SymlinkRoute<T>) {
@ -290,7 +290,7 @@ class Router<T> {
var parseResult = route.parser.parse(scanner);
if (parseResult.successful && scanner.isDone) {
var result = new RoutingResult(
var result = new RoutingResult<T>(
parseResult: parseResult,
params: parseResult.value,
shallowRoute: route,

View file

@ -1,12 +1,16 @@
/// Represents an error in route configuration or navigation.
abstract class RoutingException extends Exception {
factory RoutingException(String message) => new _RoutingExceptionImpl(message);
factory RoutingException(String message) =>
new _RoutingExceptionImpl(message);
/// Occurs when trying to resolve the parent of a [Route] without a parent.
factory RoutingException.orphan() => new _RoutingExceptionImpl("Tried to resolve path '..' on a route that has no parent.");
factory RoutingException.orphan() => new _RoutingExceptionImpl(
"Tried to resolve path '..' on a route that has no parent.");
/// Occurs when the user attempts to navigate to a non-existent route.
factory RoutingException.noSuchRoute(String path) => new _RoutingExceptionImpl("Tried to navigate to non-existent route: '$path'.");
factory RoutingException.noSuchRoute(String path) =>
new _RoutingExceptionImpl(
"Tried to navigate to non-existent route: '$path'.");
}
class _RoutingExceptionImpl implements RoutingException {

View file

@ -41,7 +41,9 @@ class RoutingResult<T> {
/// The handlers at this sub-path.
List<T> get handlers {
return <T>[]..addAll(shallowRouter.middleware)..addAll(shallowRoute.handlers);
return <T>[]
..addAll(shallowRouter.middleware)
..addAll(shallowRoute.handlers);
}
/// All handlers on this sub-path and its children.
@ -52,8 +54,7 @@ class RoutingResult<T> {
handlers.addAll(result.handlers);
if (result.nested?.isNotEmpty == true) {
for (var r in result.nested)
crawl(r);
for (var r in result.nested) crawl(r);
}
}
@ -70,8 +71,7 @@ class RoutingResult<T> {
params.addAll(result.params);
if (result.nested?.isNotEmpty == true) {
for (var r in result.nested)
crawl(r);
for (var r in result.nested) crawl(r);
}
}

View file

@ -4,5 +4,6 @@ part of angel_route.src.router;
/// to a mounted [Router].
class SymlinkRoute<T> extends Route<T> {
final Router<T> router;
SymlinkRoute(String path, this.router) : super(path, method: null, handlers: null);
SymlinkRoute(String path, this.router)
: super(path, method: null, handlers: null);
}

View file

@ -20,8 +20,7 @@ String stripStray(String haystack, String needle) {
if (haystack[i] != needle) {
var sub = haystack.substring(i);
if (!sub.endsWith(needle))
return sub;
if (!sub.endsWith(needle)) return sub;
var lastSlash = sub.lastIndexOf(needle);

View file

@ -2,9 +2,7 @@ import 'package:angel_route/angel_route.dart';
import 'package:test/test.dart';
main() {
final router = new Router()
..get('/hello', '')
..get('/user/:id', '');
final router = new Router()..get('/hello', '')..get('/user/:id', '');
router.group('/book/:id', (router) {
router.get('/reviews', '');

View file

@ -1,8 +1,6 @@
import 'dart:convert';
import 'dart:io';
import 'package:angel_route/angel_route.dart';
import 'package:dart2_constant/convert.dart';
import 'package:http/http.dart' as http;
import 'package:test/test.dart';

View file

@ -18,7 +18,8 @@ void main() {
});
test('match if segments before', () {
var result = router.resolveAbsolute('/isnt/she/fierce%20harmonica%solo').first;
var result =
router.resolveAbsolute('/isnt/she/fierce%20harmonica%solo').first;
expect(result.handlers, ['lovely']);
});
}

View file

@ -2,4 +2,3 @@ import 'package:angel_route/browser.dart';
import '../shared/basic.dart';
main() => basic(new BrowserRouter(hash: true));

View file

@ -2,4 +2,3 @@ import 'package:angel_route/browser.dart';
import '../shared/basic.dart';
main() => basic(new BrowserRouter());