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

Side by Side Diff: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/utilities/ast/DartElementLocatorTest.java

Issue 10582003: Issue 1355. Support for call(). Tweaks for element locator and rename refactoring (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Check target range Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2012, the Dart project authors. 2 * Copyright 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
(...skipping 28 matching lines...) Expand all
39 import java.util.List; 39 import java.util.List;
40 40
41 /** 41 /**
42 * Test for {@link DartElementLocator}. 42 * Test for {@link DartElementLocator}.
43 */ 43 */
44 public class DartElementLocatorTest extends TestCase { 44 public class DartElementLocatorTest extends TestCase {
45 45
46 @SuppressWarnings("unchecked") 46 @SuppressWarnings("unchecked")
47 private static <T extends DartElement> T assertLocation(CompilationUnit unit, String posMarker, 47 private static <T extends DartElement> T assertLocation(CompilationUnit unit, String posMarker,
48 Class<?> expectedElementType, String expectedMarker, int expectedLen) thro ws Exception { 48 Class<?> expectedElementType, String expectedMarker, int expectedLen) thro ws Exception {
49 TestProject.waitForAutoBuild();
49 String source = unit.getSource(); 50 String source = unit.getSource();
50 // prepare DartUnit 51 // prepare DartUnit
51 DartUnit dartUnit; 52 DartUnit dartUnit;
52 { 53 {
53 List<DartCompilationError> errors = Lists.newArrayList(); 54 List<DartCompilationError> errors = Lists.newArrayList();
54 dartUnit = DartCompilerUtilities.resolveUnit(unit, errors); 55 dartUnit = DartCompilerUtilities.resolveUnit(unit, errors);
55 // we don't want errors 56 // we don't want errors
56 if (!errors.isEmpty()) { 57 if (!errors.isEmpty()) {
57 fail("Parse/resolve errors: " + errors); 58 fail("Parse/resolve errors: " + errors);
58 } 59 }
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 IResource resourceTest = testProject.setUnitContent( 182 IResource resourceTest = testProject.setUnitContent(
182 "TestC.dart", 183 "TestC.dart",
183 Joiner.on("\n").join( 184 Joiner.on("\n").join(
184 "// filler filler filler filler filler filler filler filler filler filler", 185 "// filler filler filler filler filler filler filler filler filler filler",
185 "#library('Test');", 186 "#library('Test');",
186 "#import('LibA.dart', prefix: 'aaa');", 187 "#import('LibA.dart', prefix: 'aaa');",
187 "f() {", 188 "f() {",
188 " aaa.A a;", 189 " aaa.A a;",
189 "}", 190 "}",
190 "")).getResource(); 191 "")).getResource();
192 TestProject.waitForAutoBuild();
191 DartLibrary libraryA = testProject.getDartProject().getDartLibrary(libReso urceA); 193 DartLibrary libraryA = testProject.getDartProject().getDartLibrary(libReso urceA);
192 DartLibrary libraryTest = testProject.getDartProject().getDartLibrary(reso urceTest); 194 DartLibrary libraryTest = testProject.getDartProject().getDartLibrary(reso urceTest);
193 // usage of "aaa" = "libraryA" 195 // usage of "aaa" = "libraryA"
194 { 196 {
195 DartImport imprt = assertLocation( 197 DartImport imprt = assertLocation(
196 libraryTest.getDefiningCompilationUnit(), 198 libraryTest.getDefiningCompilationUnit(),
197 "aaa.A", 199 "aaa.A",
198 DartImport.class, 200 DartImport.class,
199 "'aaa');", 201 "'aaa');",
200 5); 202 5);
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 "f() {", 313 "f() {",
312 " test();", 314 " test();",
313 "}", 315 "}",
314 ""), 316 ""),
315 "test();", 317 "test();",
316 DartFunction.class, 318 DartFunction.class,
317 "test() {", 319 "test() {",
318 4); 320 4);
319 } 321 }
320 322
323 public void test_Method_call() throws Exception {
324 testElementLocator(
325 formatLines(
326 "// filler filler filler filler filler filler filler filler filler f iller filler",
327 "class A {",
328 " call() {",
329 " }",
330 "}",
331 "f() {",
332 " A a = new A();",
333 " a(); // marker",
334 "}",
335 ""),
336 "; // marker",
337 Method.class,
338 "call() {",
339 4);
340 }
341
321 public void test_Method_getter_onDeclaration() throws Exception { 342 public void test_Method_getter_onDeclaration() throws Exception {
322 testElementLocator( 343 testElementLocator(
323 formatLines( 344 formatLines(
324 "// filler filler filler filler filler filler filler filler filler f iller filler", 345 "// filler filler filler filler filler filler filler filler filler f iller filler",
325 "process(x) {}", 346 "process(x) {}",
326 "class A {", 347 "class A {",
327 " int get test() {", 348 " int get test() {",
328 " }", 349 " }",
329 "}", 350 "}",
330 ""), 351 ""),
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 "foo() {", 544 "foo() {",
524 " process(aaa);", 545 " process(aaa);",
525 "}"), 546 "}"),
526 "aaa);", 547 "aaa);",
527 DartVariableDeclaration.class, 548 DartVariableDeclaration.class,
528 "aaa = 1", 549 "aaa = 1",
529 3); 550 3);
530 } 551 }
531 552
532 } 553 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698