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

Unified Diff: editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/status/RefactoringStatusContext.java

Issue 250823006: Translate parts of engine.services project. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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.engine.services/src/com/google/dart/engine/services/status/RefactoringStatusContext.java
diff --git a/editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/status/RefactoringStatusContext.java b/editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/status/RefactoringStatusContext.java
index 6808e1b8b3e42a73b62e5bd5873f17f262191dca..96e523f1d7dbbe1e56d85412346636499f94261b 100644
--- a/editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/status/RefactoringStatusContext.java
+++ b/editor/tools/plugins/com.google.dart.engine.services/src/com/google/dart/engine/services/status/RefactoringStatusContext.java
@@ -13,8 +13,6 @@
*/
package com.google.dart.engine.services.status;
-import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
import com.google.dart.engine.ast.AstNode;
import com.google.dart.engine.ast.CompilationUnit;
import com.google.dart.engine.context.AnalysisContext;
@@ -23,6 +21,7 @@ import com.google.dart.engine.element.Element;
import com.google.dart.engine.search.SearchMatch;
import com.google.dart.engine.source.Source;
import com.google.dart.engine.utilities.source.SourceRange;
+import com.google.dart.engine.utilities.translation.DartName;
import static com.google.dart.engine.utilities.source.SourceRangeFactory.rangeElementName;
import static com.google.dart.engine.utilities.source.SourceRangeFactory.rangeNode;
@@ -33,43 +32,6 @@ import static com.google.dart.engine.utilities.source.SourceRangeFactory.rangeNo
*/
public class RefactoringStatusContext {
/**
- * @return the {@link RefactoringStatusContext} which corresponds to the given {@link AstNode}.
- */
- public static RefactoringStatusContext create(AstNode node) {
- Preconditions.checkNotNull(node);
- SourceRange range = rangeNode(node);
- CompilationUnit unit = node.getAncestor(CompilationUnit.class);
- return create(unit, range);
- }
-
- /**
- * @return the {@link RefactoringStatusContext} which corresponds to given location in the
- * {@link Source} of the given {@link CompilationUnit}.
- */
- public static RefactoringStatusContext create(CompilationUnit unit, SourceRange range) {
- CompilationUnitElement unitElement = unit.getElement();
- return new RefactoringStatusContext(unitElement.getContext(), unitElement.getSource(), range);
- }
-
- /**
- * @return the {@link RefactoringStatusContext} which corresponds to the declaration of the given
- * {@link Element}.
- */
- public static RefactoringStatusContext create(Element element) {
- Preconditions.checkNotNull(element);
- SourceRange range = rangeElementName(element);
- return new RefactoringStatusContext(element.getContext(), element.getSource(), range);
- }
-
- /**
- * @return the {@link RefactoringStatusContext} which corresponds to given location in the
- * {@link Source} of given {@link Element}.
- */
- public static RefactoringStatusContext create(Element element, SourceRange range) {
- return new RefactoringStatusContext(element.getContext(), element.getSource(), range);
- }
-
- /**
* @return the {@link RefactoringStatusContext} that corresponds to the given {@link SearchMatch}.
*/
public static RefactoringStatusContext create(SearchMatch match) {
@@ -81,7 +43,9 @@ public class RefactoringStatusContext {
}
private final AnalysisContext context;
+
private final Source source;
+
private final SourceRange range;
public RefactoringStatusContext(AnalysisContext context, Source source, SourceRange range) {
@@ -91,6 +55,41 @@ public class RefactoringStatusContext {
}
/**
+ * Creates a new {@link RefactoringStatusContext} which corresponds to the given {@link AstNode}.
+ */
+ @DartName("forNode")
+ public RefactoringStatusContext(AstNode node) {
+ CompilationUnit unit = node.getAncestor(CompilationUnit.class);
+ CompilationUnitElement unitElement = unit.getElement();
+ this.context = unitElement.getContext();
+ this.source = unitElement.getSource();
+ this.range = rangeNode(node);
+ }
+
+ /**
+ * Creates a new {@link RefactoringStatusContext} which corresponds to given location in the
+ * {@link Source} of the given {@link CompilationUnit}.
+ */
+ @DartName("forUnit")
+ public RefactoringStatusContext(CompilationUnit unit, SourceRange range) {
+ CompilationUnitElement unitElement = unit.getElement();
+ this.context = unitElement.getContext();
+ this.source = unitElement.getSource();
+ this.range = range;
+ }
+
+ /**
+ * @return the {@link RefactoringStatusContext} which corresponds to the declaration of the given
+ * {@link Element}.
+ */
+ @DartName("forElement")
+ public RefactoringStatusContext(Element element) {
+ this.context = element.getContext();
+ this.source = element.getSource();
+ this.range = rangeElementName(element);
+ }
+
+ /**
* @return the {@link AnalysisContext} in which this status occurs.
*/
public AnalysisContext getContext() {
@@ -113,6 +112,12 @@ public class RefactoringStatusContext {
@Override
public String toString() {
- return Objects.toStringHelper(this).add("source", source).add("range", range).toString();
+ StringBuilder builder = new StringBuilder();
+ builder.append("[source=");
+ builder.append(source);
+ builder.append(", range=");
+ builder.append(range);
+ builder.append("]");
+ return builder.toString();
}
}

Powered by Google App Engine
This is Rietveld 408576698