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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java

Issue 11305007: Getter with parameters is error. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java b/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java
index 28f04da0de2d7359af9fe9fc4b03b9c7683dcb29..e1dec65fe956295c13115c7b7e7dbe9632b3427b 100644
--- a/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java
+++ b/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/search/SearchEngineTest.java
@@ -13,6 +13,20 @@
*/
package com.google.dart.tools.core.search;
+import static org.fest.assertions.Assertions.assertThat;
Brian Wilkerson 2012/10/26 17:11:53 nit: why did these imports move?
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
import com.google.dart.compiler.DartCompilationError;
@@ -36,20 +50,6 @@ import com.google.dart.tools.core.model.Type;
import com.google.dart.tools.core.test.util.TestProject;
import com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities;
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.NullProgressMonitor;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
public class SearchEngineTest extends TestCase {
/**
* Asserts that there are required number of {@link SearchMatch} with same offset and length.
@@ -93,6 +93,130 @@ public class SearchEngineTest extends TestCase {
private InMemoryIndex index;
+ private void assertHasReferenceWithPrefix(List<SearchMatch> references, String expectedPrefix) {
Brian Wilkerson 2012/10/26 17:11:53 nit: Why did all of these private methods move? Th
+ assertThat(references).isNotEmpty();
+ assertEquals(expectedPrefix, references.get(0).getImportPrefix());
+ }
+
+ private void assertTypeReferences(Type type, int length, String[] refMarkers) throws Exception {
+ String source = type.getCompilationUnit().getSource();
+ // find references
+ List<SearchMatch> references = getTypeReferences(type);
+ assertReferences(source, references, length, refMarkers);
+ }
+
+ private String buildSource(String... strings) {
+ return Joiner.on("\n").join(strings);
+ }
+
+ private SearchEngine createSearchEngine() {
+ return new SearchEngineImpl(index);
+ }
+
+ private List<SearchMatch> getFieldReferences(Field field) throws SearchException {
+ SearchEngine engine = createSearchEngine();
+ return engine.searchReferences(
+ field,
+ SearchScopeFactory.createWorkspaceScope(),
+ null,
+ new NullProgressMonitor());
+ }
+
+ private List<SearchMatch> getFileReferences(IFile targetFile) throws SearchException {
+ SearchEngine engine = createSearchEngine();
+ List<SearchMatch> references = engine.searchReferences(
+ targetFile,
+ SearchScopeFactory.createWorkspaceScope(),
+ null,
+ new NullProgressMonitor());
+ return references;
+ }
+
+ private List<SearchMatch> getFunctionReferences(DartFunction function) throws SearchException {
+ SearchEngine engine = createSearchEngine();
+ return engine.searchReferences(
+ function,
+ SearchScopeFactory.createWorkspaceScope(),
+ null,
+ new NullProgressMonitor());
+ }
+
+ private List<SearchMatch> getFunctionTypeReferences(DartFunctionTypeAlias alias)
+ throws SearchException {
+ SearchEngine engine = createSearchEngine();
+ return engine.searchReferences(
+ alias,
+ SearchScopeFactory.createWorkspaceScope(),
+ null,
+ new NullProgressMonitor());
+ }
+
+ private List<SearchMatch> getImportReferences(DartImport dartImport) throws SearchException {
+ SearchEngine engine = createSearchEngine();
+ return engine.searchReferences(
+ dartImport,
+ SearchScopeFactory.createWorkspaceScope(),
+ null,
+ new NullProgressMonitor());
+ }
+
+ private List<SearchMatch> getMethodReferences(Method method) throws SearchException {
+ SearchEngine engine = createSearchEngine();
+ List<SearchMatch> matches = engine.searchReferences(
+ method,
+ SearchScopeFactory.createWorkspaceScope(),
+ null,
+ new NullProgressMonitor());
+ return matches;
+ }
+
+ private List<SearchMatch> getTypeReferences(Type type) throws SearchException {
+ SearchEngine engine = createSearchEngine();
+ return engine.searchReferences(
+ type,
+ SearchScopeFactory.createWorkspaceScope(),
+ null,
+ new NullProgressMonitor());
+ }
+
+ private List<SearchMatch> getVariableReferences(DartVariableDeclaration variable)
+ throws SearchException {
+ SearchEngine engine = createSearchEngine();
+ return engine.searchReferences(
+ variable,
+ SearchScopeFactory.createWorkspaceScope(),
+ null,
+ new NullProgressMonitor());
+ }
+
+ private void indexUnits(CompilationUnit... units) throws DartModelException {
+ ArrayList<DartCompilationError> errors = new ArrayList<DartCompilationError>();
+ for (CompilationUnit unit : units) {
+ index.indexResource(
+ ResourceFactory.getResource(unit),
+ null,
+ unit,
+ DartCompilerUtilities.resolveUnit(unit, errors));
+ }
+ }
+
+ private void prepare_searchReferences_import(TestProject testProject) throws Exception {
+ testProject.setUnitContent(
+ "LibA.dart",
+ buildSource(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "#library('libA');",
+ "class A {}",
+ "")).getResource();
+ testProject.setUnitContent(
+ "LibB.dart",
+ buildSource(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "#library('libB');",
+ "class B {}",
+ "")).getResource();
+ }
+
@Override
public void setUp() {
try {
@@ -273,7 +397,7 @@ public class SearchEngineTest extends TestCase {
try {
String source = buildSource(
"// filler filler filler filler filler filler filler filler filler filler",
- "int get test() {",
+ "int get test {",
" return 42;",
"}",
"f() {",
@@ -758,7 +882,7 @@ public class SearchEngineTest extends TestCase {
String source = buildSource(
"// filler filler filler filler filler filler filler filler filler filler",
"class A {",
- " int get test() {",
+ " int get test {",
" return 42;",
" }",
"}",
@@ -1319,128 +1443,4 @@ public class SearchEngineTest extends TestCase {
testProject.dispose();
}
}
-
- private void assertHasReferenceWithPrefix(List<SearchMatch> references, String expectedPrefix) {
- assertThat(references).isNotEmpty();
- assertEquals(expectedPrefix, references.get(0).getImportPrefix());
- }
-
- private void assertTypeReferences(Type type, int length, String[] refMarkers) throws Exception {
- String source = type.getCompilationUnit().getSource();
- // find references
- List<SearchMatch> references = getTypeReferences(type);
- assertReferences(source, references, length, refMarkers);
- }
-
- private String buildSource(String... strings) {
- return Joiner.on("\n").join(strings);
- }
-
- private SearchEngine createSearchEngine() {
- return new SearchEngineImpl(index);
- }
-
- private List<SearchMatch> getFieldReferences(Field field) throws SearchException {
- SearchEngine engine = createSearchEngine();
- return engine.searchReferences(
- field,
- SearchScopeFactory.createWorkspaceScope(),
- null,
- new NullProgressMonitor());
- }
-
- private List<SearchMatch> getFileReferences(IFile targetFile) throws SearchException {
- SearchEngine engine = createSearchEngine();
- List<SearchMatch> references = engine.searchReferences(
- targetFile,
- SearchScopeFactory.createWorkspaceScope(),
- null,
- new NullProgressMonitor());
- return references;
- }
-
- private List<SearchMatch> getFunctionReferences(DartFunction function) throws SearchException {
- SearchEngine engine = createSearchEngine();
- return engine.searchReferences(
- function,
- SearchScopeFactory.createWorkspaceScope(),
- null,
- new NullProgressMonitor());
- }
-
- private List<SearchMatch> getFunctionTypeReferences(DartFunctionTypeAlias alias)
- throws SearchException {
- SearchEngine engine = createSearchEngine();
- return engine.searchReferences(
- alias,
- SearchScopeFactory.createWorkspaceScope(),
- null,
- new NullProgressMonitor());
- }
-
- private List<SearchMatch> getImportReferences(DartImport dartImport) throws SearchException {
- SearchEngine engine = createSearchEngine();
- return engine.searchReferences(
- dartImport,
- SearchScopeFactory.createWorkspaceScope(),
- null,
- new NullProgressMonitor());
- }
-
- private List<SearchMatch> getMethodReferences(Method method) throws SearchException {
- SearchEngine engine = createSearchEngine();
- List<SearchMatch> matches = engine.searchReferences(
- method,
- SearchScopeFactory.createWorkspaceScope(),
- null,
- new NullProgressMonitor());
- return matches;
- }
-
- private List<SearchMatch> getTypeReferences(Type type) throws SearchException {
- SearchEngine engine = createSearchEngine();
- return engine.searchReferences(
- type,
- SearchScopeFactory.createWorkspaceScope(),
- null,
- new NullProgressMonitor());
- }
-
- private List<SearchMatch> getVariableReferences(DartVariableDeclaration variable)
- throws SearchException {
- SearchEngine engine = createSearchEngine();
- return engine.searchReferences(
- variable,
- SearchScopeFactory.createWorkspaceScope(),
- null,
- new NullProgressMonitor());
- }
-
- private void indexUnits(CompilationUnit... units) throws DartModelException {
- ArrayList<DartCompilationError> errors = new ArrayList<DartCompilationError>();
- for (CompilationUnit unit : units) {
- index.indexResource(
- ResourceFactory.getResource(unit),
- null,
- unit,
- DartCompilerUtilities.resolveUnit(unit, errors));
- }
- }
-
- private void prepare_searchReferences_import(TestProject testProject) throws Exception {
- testProject.setUnitContent(
- "LibA.dart",
- buildSource(
- "// filler filler filler filler filler filler filler filler filler filler",
- "#library('libA');",
- "class A {}",
- "")).getResource();
- testProject.setUnitContent(
- "LibB.dart",
- buildSource(
- "// filler filler filler filler filler filler filler filler filler filler",
- "#library('libB');",
- "class B {}",
- "")).getResource();
- }
}

Powered by Google App Engine
This is Rietveld 408576698