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

Unified Diff: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/local/computer/OutlineImpl.java

Issue 311053005: Updates for the Outline API and use it in Editor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/local/computer/OutlineImpl.java
diff --git a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/local/computer/OutlineImpl.java b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/local/computer/OutlineImpl.java
index 528fef0fe847ec6dd5989276f217878cb78a4e03..ea6cbaa6bf3e03502bfe44bbabc7b2390d285a0c 100644
--- a/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/local/computer/OutlineImpl.java
+++ b/editor/tools/plugins/com.google.dart.server/src/com/google/dart/server/internal/local/computer/OutlineImpl.java
@@ -20,41 +20,47 @@ import com.google.dart.server.Outline;
import org.apache.commons.lang3.StringUtils;
-import java.util.Arrays;
-
/**
* A concrete implementation of {@link Outline}.
*
* @coverage dart.server.local
*/
-public class OutlineImpl extends SourceRegionImpl implements Outline {
+public class OutlineImpl implements Outline {
private final Outline parent;
private final ElementKind kind;
private final String name;
+ private final int nameOffset;
+ private final int nameLength;
+ private final int elementOffset;
+ private final int elementLength;
private final boolean isAbstract;
private final boolean isStatic;
- private final String arguments;
+ private final String parameters;
private final String returnType;
private Outline[] children = Outline.EMPTY_ARRAY;
- public OutlineImpl(Outline parent, ElementKind kind, String name, int offset, int length,
- boolean isAbstract, boolean isStatic) {
- this(parent, kind, name, offset, length, isAbstract, isStatic, null, null);
- }
-
- public OutlineImpl(Outline parent, ElementKind kind, String name, int offset, int length,
- boolean isAbstract, boolean isStatic, String arguments, String returnType) {
- super(offset, length);
+ public OutlineImpl(Outline parent, ElementKind kind, String name, int nameOffset, int nameLength,
+ int elementOffset, int elementLength, boolean isAbstract, boolean isStatic,
+ String parameters, String returnType) {
this.parent = parent;
this.kind = kind;
this.name = name;
+ this.nameOffset = nameOffset;
+ this.nameLength = nameLength;
+ this.elementOffset = elementOffset;
+ this.elementLength = elementLength;
this.isAbstract = isAbstract;
this.isStatic = isStatic;
- this.arguments = arguments;
+ this.parameters = parameters;
this.returnType = returnType;
}
@Override
+ public boolean containsInclusive(int offset) {
+ return elementOffset <= offset && offset <= elementOffset + elementLength;
+ }
+
+ @Override
public boolean equals(Object object) {
if (object == this) {
return true;
@@ -63,29 +69,26 @@ public class OutlineImpl extends SourceRegionImpl implements Outline {
return false;
}
OutlineImpl other = (OutlineImpl) object;
- if (ObjectUtilities.equals(other.parent, parent) && other.getOffset() == getOffset()
- && other.getLength() == getLength() && other.kind == kind && other.name.equals(name)
- && ObjectUtilities.equals(other.arguments, arguments)
- && ObjectUtilities.equals(other.returnType, returnType)
- && (other.children.length == children.length)) {
- for (int i = 0; i < other.children.length; i++) {
- if (!other.children[i].equals(children[i])) {
- return false;
- }
- }
+ if (other.kind == kind && other.name.equals(name) && other.getNameOffset() == getNameOffset()
+ && other.getNameLength() == getNameLength()) {
return true;
}
return false;
}
@Override
- public String getArguments() {
- return arguments;
+ public Outline[] getChildren() {
+ return children;
}
@Override
- public Outline[] getChildren() {
- return children;
+ public int getElementLength() {
+ return elementLength;
+ }
+
+ @Override
+ public int getElementOffset() {
+ return elementOffset;
}
@Override
@@ -99,6 +102,21 @@ public class OutlineImpl extends SourceRegionImpl implements Outline {
}
@Override
+ public int getNameLength() {
+ return nameLength;
+ }
+
+ @Override
+ public int getNameOffset() {
+ return nameOffset;
+ }
+
+ @Override
+ public String getParameters() {
+ return parameters;
+ }
+
+ @Override
public Outline getParent() {
return parent;
}
@@ -110,12 +128,7 @@ public class OutlineImpl extends SourceRegionImpl implements Outline {
@Override
public int hashCode() {
- return ObjectUtilities.combineHashCodes(
- Arrays.hashCode(new int[] {
- parent == null ? 0 : parent.hashCode(), kind.hashCode(), name.hashCode(),
- arguments == null ? 0 : arguments.hashCode(),
- returnType == null ? 0 : returnType.hashCode()}),
- Arrays.hashCode(children));
+ return ObjectUtilities.combineHashCodes(kind.hashCode(), name.hashCode());
}
@Override
@@ -128,6 +141,9 @@ public class OutlineImpl extends SourceRegionImpl implements Outline {
if (kind == ElementKind.COMPILATION_UNIT) {
return false;
}
+ if (kind == ElementKind.CONSTRUCTOR) {
+ return name.contains("._");
+ }
return StringUtilities.startsWithChar(name, '_');
}
@@ -143,16 +159,20 @@ public class OutlineImpl extends SourceRegionImpl implements Outline {
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("[offset=");
- builder.append(getOffset());
- builder.append(", length=");
- builder.append(getLength());
- builder.append(", kind=");
+ builder.append("[kind=");
builder.append(kind.name());
builder.append(", name=");
builder.append(name);
+ builder.append(", nameOffset=");
+ builder.append(nameOffset);
+ builder.append(", nameLength=");
+ builder.append(nameLength);
+ builder.append(", elementOffset=");
+ builder.append(elementOffset);
+ builder.append(", elementLength=");
+ builder.append(elementLength);
builder.append(", arguments=");
- builder.append(arguments == null ? "null" : arguments);
+ builder.append(parameters == null ? "null" : parameters);
builder.append(", returnType=");
builder.append(returnType == null ? "null" : returnType);
builder.append(", children=[");

Powered by Google App Engine
This is Rietveld 408576698