OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
11 * or implied. See the License for the specific language governing permissions a
nd limitations under | 11 * or implied. See the License for the specific language governing permissions a
nd limitations under |
12 * the License. | 12 * the License. |
13 */ | 13 */ |
14 package com.google.dart.tools.core.internal.completion; | 14 package com.google.dart.tools.core.internal.completion; |
15 | 15 |
16 import com.google.common.base.Joiner; | 16 import com.google.common.base.Joiner; |
17 import com.google.dart.tools.core.analysis.AnalysisTestUtilities; | 17 import com.google.dart.tools.core.analysis.AnalysisTestUtilities; |
18 import com.google.dart.tools.core.internal.index.impl.InMemoryIndex; | 18 import com.google.dart.tools.core.internal.index.impl.InMemoryIndex; |
(...skipping 21 matching lines...) Expand all Loading... |
40 test( | 40 test( |
41 "class X {static final num MAX = 0;num yc,xc;mth() {xc = yc = MA!1X;x!2c
.abs();num f = M!3AX;}}", | 41 "class X {static final num MAX = 0;num yc,xc;mth() {xc = yc = MA!1X;x!2c
.abs();num f = M!3AX;}}", |
42 "1+MAX", | 42 "1+MAX", |
43 "2+xc", | 43 "2+xc", |
44 "3+MAX", | 44 "3+MAX", |
45 "3+Map"); | 45 "3+Map"); |
46 } | 46 } |
47 | 47 |
48 public void testCommentSnippets002() throws Exception { | 48 public void testCommentSnippets002() throws Exception { |
49 test( | 49 test( |
50 "class Y {String x='hi';mth() {x.l!1ength;int n = 0;x!2.charCodeAt(n!3);
}}", | 50 "class Y {String x='hi';mth() {x.l!1ength;int n = 0;x!2.codeUnitAt(n!3);
}}", |
51 "1+length", | 51 "1+length", |
52 "2+x", | 52 "2+x", |
53 "3+n"); | 53 "3+n"); |
54 } | 54 } |
55 | 55 |
56 public void testCommentSnippets003() throws Exception { | 56 public void testCommentSnippets003() throws Exception { |
57 test( | 57 test( |
58 "class Z {!1Ex!2ception m = new !3Exception!4();mth() {var x = new Li!5s
t.!6fr!7om(['a']);}}", | 58 "class Z {!1Ex!2ception m = new !3Exception!4();mth() {var x = new Li!5s
t.!6fr!7om(['a']);}}", |
59 "1+void", | 59 "1+void", |
60 "2+Exception", | 60 "2+Exception", |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 } | 866 } |
867 | 867 |
868 /** | 868 /** |
869 * Run a set of completion tests on the given <code>originalSource</code>. The
source string has | 869 * Run a set of completion tests on the given <code>originalSource</code>. The
source string has |
870 * completion points embedded in it, which are identified by '!X' where X is a
single character. | 870 * completion points embedded in it, which are identified by '!X' where X is a
single character. |
871 * Each X is matched to positive or negative results in the array of | 871 * Each X is matched to positive or negative results in the array of |
872 * <code>validationStrings</code>. Validation strings contain the name of a pr
ediction with a two | 872 * <code>validationStrings</code>. Validation strings contain the name of a pr
ediction with a two |
873 * character prefix. The first character of the prefix corresponds to an X in
the | 873 * character prefix. The first character of the prefix corresponds to an X in
the |
874 * <code>originalSource</code>. The second character is either a '+' or a '-'
indicating whether | 874 * <code>originalSource</code>. The second character is either a '+' or a '-'
indicating whether |
875 * the string is a positive or negative result. | 875 * the string is a positive or negative result. |
876 * | 876 * |
877 * @param originalSource The source for a completion test that contains comple
tion points | 877 * @param originalSource The source for a completion test that contains comple
tion points |
878 * @param validationStrings The positive and negative predictions | 878 * @param validationStrings The positive and negative predictions |
879 */ | 879 */ |
880 private void test(String originalSource, String... results) throws URISyntaxEx
ception, | 880 private void test(String originalSource, String... results) throws URISyntaxEx
ception, |
881 DartModelException { | 881 DartModelException { |
882 Collection<CompletionSpec> completionTests = CompletionSpec.from(originalSou
rce, results); | 882 Collection<CompletionSpec> completionTests = CompletionSpec.from(originalSou
rce, results); |
883 assertTrue( | 883 assertTrue( |
884 "Expected exclamation point ('!') within the source" | 884 "Expected exclamation point ('!') within the source" |
885 + " denoting the position at which code completion should occur", | 885 + " denoting the position at which code completion should occur", |
886 !completionTests.isEmpty()); | 886 !completionTests.isEmpty()); |
(...skipping 15 matching lines...) Expand all Loading... |
902 } | 902 } |
903 for (String result : test.positiveResults) { | 903 for (String result : test.positiveResults) { |
904 requestor.assertSuggested(result); | 904 requestor.assertSuggested(result); |
905 } | 905 } |
906 for (String result : test.negativeResults) { | 906 for (String result : test.negativeResults) { |
907 requestor.assertNotSuggested(result); | 907 requestor.assertNotSuggested(result); |
908 } | 908 } |
909 } | 909 } |
910 } | 910 } |
911 } | 911 } |
OLD | NEW |