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

Side by Side Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 2329463002: Remove JavaPatternMatcher from java_core. (Closed)
Patch Set: Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.test.generated.all_the_rest_test; 5 library analyzer.test.generated.all_the_rest_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
11 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/file_system/memory_file_system.dart'; 12 import 'package:analyzer/file_system/memory_file_system.dart';
13 import 'package:analyzer/file_system/physical_file_system.dart'; 13 import 'package:analyzer/file_system/physical_file_system.dart';
14 import 'package:analyzer/src/dart/ast/ast.dart'; 14 import 'package:analyzer/src/dart/ast/ast.dart';
15 import 'package:analyzer/src/dart/ast/utilities.dart' hide ConstantEvaluator; 15 import 'package:analyzer/src/dart/ast/utilities.dart' hide ConstantEvaluator;
16 import 'package:analyzer/src/dart/element/builder.dart'; 16 import 'package:analyzer/src/dart/element/builder.dart';
17 import 'package:analyzer/src/dart/element/element.dart'; 17 import 'package:analyzer/src/dart/element/element.dart';
18 import 'package:analyzer/src/dart/sdk/sdk.dart' hide SdkLibrariesReader; 18 import 'package:analyzer/src/dart/sdk/sdk.dart' hide SdkLibrariesReader;
19 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
20 import 'package:analyzer/src/generated/error.dart'; 20 import 'package:analyzer/src/generated/error.dart';
21 import 'package:analyzer/src/generated/java_core.dart';
22 import 'package:analyzer/src/generated/java_engine_io.dart'; 21 import 'package:analyzer/src/generated/java_engine_io.dart';
23 import 'package:analyzer/src/generated/java_io.dart'; 22 import 'package:analyzer/src/generated/java_io.dart';
24 import 'package:analyzer/src/generated/resolver.dart'; 23 import 'package:analyzer/src/generated/resolver.dart';
25 import 'package:analyzer/src/generated/sdk.dart'; 24 import 'package:analyzer/src/generated/sdk.dart';
26 import 'package:analyzer/src/generated/sdk_io.dart'; 25 import 'package:analyzer/src/generated/sdk_io.dart';
27 import 'package:analyzer/src/generated/source.dart'; 26 import 'package:analyzer/src/generated/source.dart';
28 import 'package:analyzer/src/generated/source_io.dart'; 27 import 'package:analyzer/src/generated/source_io.dart';
29 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 28 import 'package:analyzer/src/generated/testing/ast_factory.dart';
30 import 'package:analyzer/src/generated/testing/element_factory.dart'; 29 import 'package:analyzer/src/generated/testing/element_factory.dart';
31 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; 30 import 'package:analyzer/src/generated/testing/test_type_provider.dart';
(...skipping 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 CompilationUnit cu = _resolveContents(code); 3036 CompilationUnit cu = _resolveContents(code);
3038 int start = _getOffsetOfMatch(code, nodePattern, index); 3037 int start = _getOffsetOfMatch(code, nodePattern, index);
3039 int end = start + nodePattern.length; 3038 int end = start + nodePattern.length;
3040 return new NodeLocator(start, end).searchWithin(cu); 3039 return new NodeLocator(start, end).searchWithin(cu);
3041 } 3040 }
3042 3041
3043 int _getOffsetOfMatch(String contents, String pattern, int matchIndex) { 3042 int _getOffsetOfMatch(String contents, String pattern, int matchIndex) {
3044 if (matchIndex == 0) { 3043 if (matchIndex == 0) {
3045 return contents.indexOf(pattern); 3044 return contents.indexOf(pattern);
3046 } 3045 }
3047 JavaPatternMatcher matcher = 3046 Iterable<Match> matches = new RegExp(pattern).allMatches(contents);
3048 new JavaPatternMatcher(new RegExp(pattern), contents); 3047 Match match = matches.toList()[matchIndex];
3049 int count = 0; 3048 return match.start;
3050 while (matcher.find()) {
3051 if (count == matchIndex) {
3052 return matcher.start();
3053 }
3054 ++count;
3055 }
3056 return -1;
3057 } 3049 }
3058 3050
3059 /** 3051 /**
3060 * Parse, resolve and verify the given source lines to produce a fully 3052 * Parse, resolve and verify the given source lines to produce a fully
3061 * resolved AST. 3053 * resolved AST.
3062 * 3054 *
3063 * [code] the code to resolve. 3055 * [code] the code to resolve.
3064 * 3056 *
3065 * Returns the result of resolving the AST structure representing the content 3057 * Returns the result of resolving the AST structure representing the content
3066 * of the source. 3058 * of the source.
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
4556 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); 4548 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI));
4557 expect(UriKind.fromEncoding(0x58), same(null)); 4549 expect(UriKind.fromEncoding(0x58), same(null));
4558 } 4550 }
4559 4551
4560 void test_getEncoding() { 4552 void test_getEncoding() {
4561 expect(UriKind.DART_URI.encoding, 0x64); 4553 expect(UriKind.DART_URI.encoding, 0x64);
4562 expect(UriKind.FILE_URI.encoding, 0x66); 4554 expect(UriKind.FILE_URI.encoding, 0x66);
4563 expect(UriKind.PACKAGE_URI.encoding, 0x70); 4555 expect(UriKind.PACKAGE_URI.encoding, 0x70);
4564 } 4556 }
4565 } 4557 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698