Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Unified Diff: third_party/pkg/route_hierarchical/lib/pattern.dart

Issue 1086713003: Remove everything but markdown from third_party (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/pkg/route_hierarchical/lib/pattern.dart
diff --git a/third_party/pkg/route_hierarchical/lib/pattern.dart b/third_party/pkg/route_hierarchical/lib/pattern.dart
deleted file mode 100644
index 17f010ff32db7e472ac5abd2d949084e44035b77..0000000000000000000000000000000000000000
--- a/third_party/pkg/route_hierarchical/lib/pattern.dart
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-/**
- * Pattern utilities for use with server.Router.
- *
- * Example:
- *
- * var router = new Router(server);
- * router.filter(matchesAny(new UrlPattern(r'/(\w+)'),
- * exclude: [new UrlPattern('/login')]), authFilter);
- */
-library pattern;
-
-class _MultiPattern extends Pattern {
- final Iterable<Pattern> include;
- final Iterable<Pattern> exclude;
-
- _MultiPattern(Iterable<Pattern> this.include,
- {Iterable<Pattern> this.exclude});
-
- Iterable<Match> allMatches(String str) {
- var _allMatches = [];
- for (var pattern in include) {
- var matches = pattern.allMatches(str);
- if (_hasMatch(matches)) {
- if (exclude != null) {
- for (var excludePattern in exclude) {
- if (_hasMatch(excludePattern.allMatches(str))) {
- return [];
- }
- }
- }
- _allMatches.add(matches);
- }
- }
- return _allMatches.expand((x) => x);
- }
-
- Match matchAsPrefix(String string, [int start = 0]) {
- throw new UnimplementedError('matchAsPrefix is not implemented');
- }
-}
-
-/**
- * Returns a [Pattern] that matches against every pattern in [include] and
- * returns all the matches. If the input string matches against any pattern in
- * [exclude] no matches are returned.
- */
-Pattern matchAny(Iterable<Pattern> include, {Iterable<Pattern> exclude}) =>
- new _MultiPattern(include, exclude: exclude);
-
-/**
- * Returns true if [pattern] has a single match in [str] that matches the whole
- * string, not a substring.
- */
-bool matchesFull(Pattern pattern, String str) {
- var iter = pattern.allMatches(str).iterator;
- if (iter.moveNext()) {
- var match = iter.current;
- return match.start == 0 && match.end == str.length && !iter.moveNext();
- }
- return false;
-}
-
-bool matchesPrefix(Pattern pattern, String str) {
- Iterable<Match> matches = pattern.allMatches(str);
- return !matches.isEmpty && matches.first.start == 0;
-}
-
-/// return the tail
-Match prefixMatch(Pattern pattern, String str) {
- Iterable<Match> matches = pattern.allMatches(str);
- if (!matches.isEmpty && matches.first.start == 0) {
- return matches.first;
- }
- return null;
-}
-
-bool _hasMatch(Iterable<Match> matches) => matches.iterator.moveNext();
« no previous file with comments | « third_party/pkg/route_hierarchical/lib/client.dart ('k') | third_party/pkg/route_hierarchical/lib/route_handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698