Gets rid of some warnings in the analyzer for unused code and unused imports

Ironically, the code to detect dead code in switch statements was itself
dead (holdover from a change I did yesterday)

Review URL: https://chromiumcodereview.appspot.com//10575019

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@8853 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
zundel@google.com
2012-06-19 15:45:19 +00:00
parent c3aafe3196
commit 26f4d623e4
4 changed files with 15 additions and 49 deletions
@@ -5,7 +5,6 @@
package com.google.dart.compiler.ast;
import com.google.common.base.Objects;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.dart.compiler.DartCompiler;
@@ -138,7 +137,7 @@ public class LibraryUnit {
public Iterable<LibraryImport> getImports() {
return imports;
}
public Iterable<LibraryUnit> getImportedLibraries() {
Set<LibraryUnit> libraries = Sets.newHashSet();
for (LibraryImport libraryImport : imports) {
@@ -4079,39 +4079,7 @@ public class DartParser extends CompletionHooksParserBase {
return done(new DartSwitchStatement(expr, members));
}
private void parseDeadSwitchCode() {
boolean done = false;
boolean warned = false;
boolean oldInCaseStatement = inCaseStatement;
inCaseStatement = true;
try {
while (!done) {
if (peek(0) == Token.IDENTIFIER && peek(1) == Token.COLON) {
beginLabel();
DartIdentifier identifier = parseIdentifier();
expect(Token.COLON);
done(new DartLabel(identifier, null));
}
Token nextToken = peek(0);
switch(nextToken) {
case CASE:
case DEFAULT:
case EOS:
case RBRACE:
return;
default:
warned = true;
parseStatement();
}
}
} finally {
inCaseStatement = oldInCaseStatement;
}
}
/**
/**
* <pre>
* catchParameter
* : FINAL type? identifier
@@ -174,7 +174,7 @@ public class CompileTimeConstantAnalyzer {
*/
private Type getMostSpecificType(DartNode node) {
if (node != null) {
Element element = (Element) node.getElement();
Element element = node.getElement();
Type type = inferredTypes.get(node);
if (type != null) {
return type;
@@ -289,7 +289,7 @@ public class CompileTimeConstantAnalyzer {
rememberInferredType(x, intType);
} else if (lhsType.equals(doubleType) && rhsType.equals(doubleType)) {
rememberInferredType(x, doubleType);
} else if (lhsType.equals(doubleType) && rhsType.equals(intType)
} else if (lhsType.equals(doubleType) && rhsType.equals(intType)
|| lhsType.equals(intType) && rhsType.equals(doubleType)) {
rememberInferredType(x, doubleType);
} else {
@@ -372,7 +372,7 @@ public class CompileTimeConstantAnalyzer {
if (!element.getModifiers().isConstant() && !element.getModifiers().isFinal()) {
expectedConstant(x);
}
// Infer type by visiting node or cached from Element.
final Type inferredType;
if (element instanceof FieldNodeElement) {
@@ -381,19 +381,19 @@ public class CompileTimeConstantAnalyzer {
fieldNode.accept(this);
inferredType = getMostSpecificType(fieldNode);
fieldNodeElement.setConstantType(inferredType);
} else if (fieldElement.getType() != null
} else if (fieldElement.getType() != null
&& !fieldElement.getType().equals(dynamicType)) {
inferredType = fieldElement.getType();
} else {
inferredType = fieldElement.getConstantType();
}
// Done with this element.
visitedElements.remove(element);
rememberInferredType(x, inferredType);
break;
case METHOD:
if (!element.getModifiers().isStatic() && !Elements.isTopLevel(element)) {
expectedConstant(x);
@@ -612,7 +612,7 @@ public class CompileTimeConstantAnalyzer {
}
return null;
}
@Override
public Void visitClass(DartClass node) {
ClassElement oldClassElement = currentClass;
@@ -623,7 +623,7 @@ public class CompileTimeConstantAnalyzer {
currentClass = oldClassElement;
}
}
@Override
public Void visitMethodDefinition(DartMethodDefinition node) {
inConstConstructor = node.getModifiers().isConstant();
@@ -12,7 +12,6 @@ import com.google.dart.compiler.ast.DartFunctionTypeAlias;
import com.google.dart.compiler.ast.DartIdentifier;
import com.google.dart.compiler.ast.DartNode;
import com.google.dart.compiler.ast.DartParameter;
import com.google.dart.compiler.ast.DartThisExpression;
import com.google.dart.compiler.ast.DartTypeNode;
import com.google.dart.compiler.ast.DartTypeParameter;
import com.google.dart.compiler.type.DynamicType;
@@ -52,13 +51,13 @@ abstract class ResolveVisitor extends ASTVisitor<Element> {
element.getParameters(), returnType);
Elements.setType(element, type);
for (DartParameter parameter : node.getParameters()) {
if (//!(parameter.getQualifier() instanceof DartThisExpression) &&
parameter.getModifiers().isNamed() &&
if (//!(parameter.getQualifier() instanceof DartThisExpression) &&
parameter.getModifiers().isNamed() &&
DartIdentifier.isPrivateName(parameter.getElement().getName())) {
getContext().onError(parameter.getName(),
getContext().onError(parameter.getName(),
ResolverErrorCode.NAMED_PARAMETERS_CANNOT_START_WITH_UNDER);
}
}
}
return element;
}
@@ -115,7 +114,7 @@ abstract class ResolveVisitor extends ASTVisitor<Element> {
recordElement(node.getName(), element);
return recordElement(node, element);
}
protected EnclosingElement getEnclosingElement() {
return null;
}