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

Unified Diff: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/base/DartStatusContext.java

Issue 10162026: Report warnings and non-fatal errors for shadowing declaration and usage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks for review comments Created 8 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: editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/base/DartStatusContext.java
diff --git a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/base/DartStatusContext.java b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/base/DartStatusContext.java
index e9be842fcb095d7b704bc4c92507d89b596f5d8f..37426d0e6e39fdb1dc5a72552c72b36154142f8b 100644
--- a/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/base/DartStatusContext.java
+++ b/editor/tools/plugins/com.google.dart.tools.ui/src/com/google/dart/tools/internal/corext/refactoring/base/DartStatusContext.java
@@ -20,6 +20,7 @@ import com.google.dart.tools.core.model.DartElement;
import com.google.dart.tools.core.model.DartModelException;
import com.google.dart.tools.core.model.SourceRange;
import com.google.dart.tools.core.model.SourceReference;
+import com.google.dart.tools.core.search.SearchMatch;
import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;
import org.eclipse.ltk.core.refactoring.RefactoringStatusEntry;
@@ -92,10 +93,10 @@ public abstract class DartStatusContext extends RefactoringStatusContext {
// }
// }
- private static class DartElementSourceContext extends DartStatusContext {
+ private static class DartElementContext extends DartStatusContext {
private final CompilationUnitElement element;
- private DartElementSourceContext(CompilationUnitElement element) {
+ private DartElementContext(CompilationUnitElement element) {
this.element = element;
}
@@ -115,6 +116,26 @@ public abstract class DartStatusContext extends RefactoringStatusContext {
return new SourceRangeImpl(0, 0);
}
}
+
+ private static class DartSourceRangeContext extends DartStatusContext {
+ private final CompilationUnit unit;
+ private final SourceRange sourceRange;
+
+ private DartSourceRangeContext(CompilationUnit unit, SourceRange sourceRange) {
+ this.unit = unit;
+ this.sourceRange = sourceRange;
+ }
+
+ @Override
+ public CompilationUnit getCompilationUnit() {
+ return unit;
+ }
+
+ @Override
+ public SourceRange getSourceRange() {
+ return sourceRange;
+ }
+ }
// /**
// * Creates an status entry context for the given import declaration
@@ -137,7 +158,19 @@ public abstract class DartStatusContext extends RefactoringStatusContext {
if (element == null || !element.exists()) {
return null;
}
- return new DartElementSourceContext(element);
+ return new DartElementContext(element);
+ }
+
+ /**
+ * @return the {@link RefactoringStatusContext} for given {@link SearchMatch}, may be
+ * <code>null</code> if the context cannot be created.
+ */
+ public static RefactoringStatusContext create(SearchMatch match) {
+ if (match == null || match.getElement() == null) {
+ return null;
+ }
+ CompilationUnit unit = match.getElement().getAncestor(CompilationUnit.class);
+ return new DartSourceRangeContext(unit, match.getSourceRange());
}
// /**

Powered by Google App Engine
This is Rietveld 408576698