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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/completion/CompletionEngine.java

Issue 10977081: Fix the build (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 3 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/src/com/google/dart/tools/core/internal/completion/CompletionEngine.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/completion/CompletionEngine.java (revision 13022)
+++ editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/internal/completion/CompletionEngine.java (working copy)
@@ -191,8 +191,8 @@
}
@Override
- public void visitorNotImplementedYet(DartNode node, DartNode sourceNode,
- Class<? extends ASTVisitor<Void>> astClass) {
+ public void visitorNotImplementedYet(
+ DartNode node, DartNode sourceNode, Class<? extends ASTVisitor<Void>> astClass) {
if (DEBUG) {
System.out.print("Need visitor for node: " + node.getClass().getSimpleName());
if (sourceNode != node) {
@@ -355,8 +355,8 @@
if (ElementKind.of(element) == ElementKind.LIBRARY_PREFIX) {
// { html.E! }
String prefixToMatch = qualNode.getName();
- Collection<LibraryUnit> libs = parsedUnit.getLibrary().getLibrariesWithPrefix(
- prefixToMatch);
+ Collection<LibraryUnit> libs = parsedUnit.getLibrary()
+ .getLibrariesWithPrefix(prefixToMatch);
for (LibraryUnit lib : libs) {
createCompletionsForLibraryPrefix(identifier, lib.getElement());
}
@@ -471,15 +471,15 @@
}
break;
case ForInitialization:
- // {for (in!t x = 0; i < 5; i++); }
+ // {for (in!t x = 0; i < 5; i++); }
case TypeFunctionOrVariable:
// { x; v! x; } or { v! x; }
proposeGenericTypeCompletions(typeCompleter, true);
proposeIdentifierPrefixCompletions(typeCompleter);
break;
case FunctionLiteral:
- // at top level
- // final num PI2 = Mat!
+ // at top level
+ // final num PI2 = Mat!
case TypeParameter:
// class X<K extends Ha!shable> {}
proposeTypesForPrefix(identifier);
@@ -846,7 +846,10 @@
if (node.getSourceInfo().getOffset() - 1 == actualCompletionPosition) {
if (node.getParent() instanceof DartMethodInvocation) {
// { x.j..b()..c..!a(); }
- ((DartMethodInvocation) node.getParent()).getTarget().accept(this);
+ DartExpression target = ((DartMethodInvocation) node.getParent()).getRealTarget();
+ if (target != null) {
+ target.accept(this);
+ }
} else if (node.getParent() instanceof DartPropertyAccess) {
// { x.j..b()..c..!c; }
((DartPropertyAccess) node.getParent()).getQualifier().accept(this);
@@ -880,15 +883,16 @@
functionName = null;
}
// { foo.! doFoo(); }
- DartExpression expr = completionNode.getTarget();
- if (expr.getElement() != null && expr.getElement().getKind() == ElementKind.LIBRARY_PREFIX
+ DartExpression expr = completionNode.getRealTarget();
+ if (expr != null && expr.getElement() != null
+ && expr.getElement().getKind() == ElementKind.LIBRARY_PREFIX
&& expr instanceof DartIdentifier) {
DartIdentifier ident = (DartIdentifier) expr;
for (LibraryElement lib : ((LibraryPrefixElement) expr.getElement()).getLibraries()) {
createCompletionsForLibraryPrefix(ident, lib);
}
} else {
- Type type = analyzeType(completionNode.getTarget());
+ Type type = analyzeType(completionNode.getRealTarget());
if (type != null) {
createCompletionsForQualifiedMemberAccess(functionName, type, false, false);
}
@@ -964,8 +968,9 @@
ParameterCompleter param = (ParameterCompleter) node;
// when completion is requested on the first word of a param decl we assume it is a type
DartExpression typeName = param.getName();
- if (typeName.getSourceInfo().getOffset() <= actualCompletionPosition
- && typeName.getSourceInfo().getOffset() + typeName.getSourceInfo().getLength() >= actualCompletionPosition) {
+ if (typeName.getSourceInfo().getOffset() <= actualCompletionPosition &&
+ typeName.getSourceInfo().getOffset() + typeName.getSourceInfo().getLength()
+ >= actualCompletionPosition) {
if (typeName instanceof DartIdentifier) {
DartIdentifier typeId = (DartIdentifier) typeName;
List<SearchMatch> matches = findTypesWithPrefix(typeId);
@@ -1045,7 +1050,8 @@
// so we will check that we could have a variable interpolation but will not
// try to be too strict, since we cannot
if (iStrings.size() >= 1) {
- for (int idxStrings = 1, idxExprs = 0; idxStrings < iStrings.size(); idxStrings++, idxExprs++) {
+ for (int idxStrings = 1, idxExprs = 0; idxStrings < iStrings.size(); idxStrings++,
+ idxExprs++) {
DartStringLiteral lit = iStrings.get(idxStrings);
DartExpression exp = iExprs.get(idxExprs);
if (lit.getValue().isEmpty() && exp instanceof DartSyntheticErrorExpression) {
@@ -1169,7 +1175,8 @@
List<DartVariable> vars = completionNode.getVariables();
if (vars.size() > 0) {
DartVariable var = vars.get(vars.size() - 1);
- if (var.getSourceInfo().getOffset() + var.getSourceInfo().getLength() <= actualCompletionPosition) {
+ if (var.getSourceInfo().getOffset() + var.getSourceInfo().getLength()
+ <= actualCompletionPosition) {
// { num theta = i * ! }
proposeVariables(completionNode, null, resolvedMember);
proposeTypesForNewParam();
@@ -1245,8 +1252,8 @@
return posParamCount;
}
- static private Set<Element> findAllElements(LibraryUnit library, String prefix,
- Set<LibraryUnit> libs) {
+ static private Set<Element> findAllElements(
+ LibraryUnit library, String prefix, Set<LibraryUnit> libs) {
if (libs.contains(library)) {
return new HashSet<Element>();
}
@@ -1418,7 +1425,8 @@
private static final String C_EXTENDS = "extends";
private static final String C_IMPLEMENTS = "implements";
private static final char[] DYNAMIC_CA = "Dynamic".toCharArray();
- private static final boolean DEBUG = "true".equalsIgnoreCase(Platform.getDebugOption("com.google.dart.tools.ui/debug/CompletionEngine"));
+ private static final boolean DEBUG = "true".equalsIgnoreCase(
+ Platform.getDebugOption("com.google.dart.tools.ui/debug/CompletionEngine"));
private static final String C_VOID = "void";
private static final String CORELIB_NAME = "dart:core";
private static final String MAP_TYPE_NAME = "Map";
@@ -1551,7 +1559,8 @@
NodeFinder finder = NodeFinder.find(parsedUnit, completionPosition, 0);
DartNode resolvedNode = finder.selectNode();
// NodeFinder returns the inner most node, in case of DartParameter - name of its type, or name.
- if (resolvedNode instanceof DartIdentifier && resolvedNode.getParent() instanceof DartParameter) {
+ if (resolvedNode instanceof DartIdentifier
+ && resolvedNode.getParent() instanceof DartParameter) {
resolvedNode = resolvedNode.getParent();
}
resolvedMember = finder.getEnclosingMethod();
@@ -1625,6 +1634,9 @@
}
private Type analyzeType(DartNode target) {
+ if (target == null) {
+ return Types.newDynamicType();
+ }
Type type = target.getType();
if (type != null) {
return type;
@@ -1638,8 +1650,8 @@
}
}
- private void createCompletionForIndexer(FieldElement field, boolean includeDeclaration,
- DartIdentifier node, String prefix) {
+ private void createCompletionForIndexer(
+ FieldElement field, boolean includeDeclaration, DartIdentifier node, String prefix) {
if (!isIndexableType(field.getType())) {
return;
}
@@ -1684,7 +1696,8 @@
char[][] parameterTypeNames = getParameterTypeNames(function);
char[] returnTypeName = null;
returnTypeName = function.getFunctionType().getReturnType().getElement().getName().toCharArray();
- proposal.setDeclarationSignature(function.getLibrary().getLibraryUnit().getName().toCharArray());
+ proposal.setDeclarationSignature(
+ function.getLibrary().getLibraryUnit().getName().toCharArray());
proposal.setSignature(typeName.toCharArray());
proposal.setCompletion(name.toCharArray());
proposal.setName(name.toCharArray());
@@ -1697,8 +1710,8 @@
requestor.accept(proposal);
}
- private void createCompletionsForFactoryInvocation(DartIdentifier memberName,
- DartNode completionNode, InterfaceType itype) {
+ private void createCompletionsForFactoryInvocation(
+ DartIdentifier memberName, DartNode completionNode, InterfaceType itype) {
String prefix = extractFilterPrefix(memberName);
List<Element> members = getConstructors(itype);
if (!isCompletionAfterDot && memberName == null) {
@@ -1760,7 +1773,8 @@
char[][] parameterTypeNames = getParameterTypeNames(func);
char[] returnTypeName = null;
returnTypeName = func.getReturnType().getElement().getName().toCharArray();
- proposal.setDeclarationSignature(func.getElement().getLibrary().getLibraryUnit().getName().toCharArray());
+ proposal.setDeclarationSignature(
+ func.getElement().getLibrary().getLibraryUnit().getName().toCharArray());
proposal.setSignature(typeName.toCharArray());
proposal.setCompletion(name.toCharArray());
proposal.setName(name.toCharArray());
@@ -1794,8 +1808,8 @@
}
}
- private void createCompletionsForLibraryPrefix(DartIdentifier identifier,
- LibraryElement libraryElement) {
+ private void createCompletionsForLibraryPrefix(
+ DartIdentifier identifier, LibraryElement libraryElement) {
String prefix = extractFilterPrefix(identifier);
Scope scope = libraryElement.getScope();
Map<String, Element> elements = scope.getElements();
@@ -1832,7 +1846,8 @@
FunctionAliasElement function = (FunctionAliasElement) element;
parameterNames = getParameterNames(function);
parameterTypeNames = getParameterTypeNames(function);
- returnTypeName = function.getFunctionType().getReturnType().getElement().getName().toCharArray();
+ returnTypeName = function.getFunctionType()
+ .getReturnType().getElement().getName().toCharArray();
break;
case METHOD:
kind = CompletionProposal.METHOD_NAME_REFERENCE;
@@ -1980,8 +1995,8 @@
}
boolean isSetter = method.getModifiers().isSetter();
boolean isGetter = method.getModifiers().isGetter();
- int kind = isGetter || isSetter ? CompletionProposal.FIELD_REF
- : CompletionProposal.METHOD_REF;
+ int kind = isGetter || isSetter
+ ? CompletionProposal.FIELD_REF : CompletionProposal.METHOD_REF;
InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(
kind,
actualCompletionPosition - offset);
@@ -2081,8 +2096,8 @@
}
}
- private void createCompletionsForQualifiedMemberAccess(DartIdentifier memberName, Type type,
- boolean allowDynamic, boolean isInstance) {
+ private void createCompletionsForQualifiedMemberAccess(
+ DartIdentifier memberName, Type type, boolean allowDynamic, boolean isInstance) {
// At the completion point, the language allows both field and method access.
// The parser needs more look-ahead to disambiguate. Those tokens may not have
// been typed yet.
@@ -2111,8 +2126,8 @@
}
}
- private void createTypeCompletionsForConstructor(DartNode node, DartNewExpression newExpr,
- SearchMatch match, String prefix) {
+ private void createTypeCompletionsForConstructor(
+ DartNode node, DartNewExpression newExpr, SearchMatch match, String prefix) {
DartElement element = match.getElement();
if (!(element instanceof com.google.dart.tools.core.model.Type)) {
return;
@@ -2146,9 +2161,8 @@
continue;
}
name = method.getElementName(); // insert named constructors, too
- InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal.create(
- CompletionProposal.METHOD_REF,
- actualCompletionPosition - offset);
+ InternalCompletionProposal proposal = (InternalCompletionProposal) CompletionProposal
+ .create(CompletionProposal.METHOD_REF, actualCompletionPosition - offset);
char[] declaringTypeName = method.getDeclaringType().getElementName().toCharArray();
char[] methodName = name.toCharArray();
proposal.setDeclarationSignature(declaringTypeName);
@@ -2214,7 +2228,8 @@
requestor.accept(proposal);
}
- private void createTypeCompletionsForParameterDecl(DartNode node, SearchMatch match, String prefix) {
+ private void createTypeCompletionsForParameterDecl(
+ DartNode node, SearchMatch match, String prefix) {
DartElement element = match.getElement();
String name;
boolean isInterface;
@@ -2446,7 +2461,8 @@
if (libs == null) { // no prefix specified (vs undefined prefix)
try {
int idx = 0;
- for (com.google.dart.tools.core.model.Type localType : getCurrentCompilationUnit().getTypes()) {
+ for (com.google.dart.tools.core.model.Type localType :
+ getCurrentCompilationUnit().getTypes()) {
String typeName = localType.getElementName();
if (typeName.startsWith(prefix)) { // this test is case sensitive
SearchMatch match = new SearchMatch(
@@ -2466,7 +2482,8 @@
}
}
}
- for (com.google.dart.tools.core.model.DartFunctionTypeAlias localType : getCurrentCompilationUnit().getFunctionTypeAliases()) {
+ for (com.google.dart.tools.core.model.DartFunctionTypeAlias localType :
+ getCurrentCompilationUnit().getFunctionTypeAliases()) {
String typeName = localType.getElementName();
if (typeName.startsWith(prefix)) { // this test is case sensitive
SearchMatch match = new SearchMatch(
@@ -2750,8 +2767,8 @@
}
}
- private void visitorNotImplementedYet(DartNode node, DartNode sourceNode,
- Class<? extends ASTVisitor<Void>> astClass) {
+ private void visitorNotImplementedYet(
+ DartNode node, DartNode sourceNode, Class<? extends ASTVisitor<Void>> astClass) {
if (metrics != null) {
metrics.visitorNotImplementedYet(node, sourceNode, astClass);
}

Powered by Google App Engine
This is Rietveld 408576698