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

Unified Diff: compiler/java/com/google/dart/compiler/parser/DartParser.java

Issue 10887011: Fix for issue 4776 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/parser/DartParser.java
===================================================================
--- compiler/java/com/google/dart/compiler/parser/DartParser.java (revision 11455)
+++ compiler/java/com/google/dart/compiler/parser/DartParser.java (working copy)
@@ -722,7 +722,7 @@
beginMetadata();
next();
beginQualifiedIdentifier();
- DartExpression name = parseQualified();
+ DartExpression name = parseQualified(true);
if (optional(Token.PERIOD)) {
name = new DartPropertyAccess(name, parseIdentifier());
}
@@ -879,7 +879,7 @@
DartParameterizedTypeNode defaultClass = null;
if (isParsingInterface &&
(optionalDeprecatedFactory() || optional(Token.DEFAULT))) {
- DartExpression qualified = parseQualified();
+ DartExpression qualified = parseQualified(false);
List<DartTypeParameter> defaultTypeParameters = parseTypeParametersOpt();
defaultClass = doneWithoutConsuming(new DartParameterizedTypeNode(qualified,
defaultTypeParameters));
@@ -1451,7 +1451,7 @@
*/
private DartMethodDefinition parseFactory(Modifiers modifiers) {
beginMethodName();
- DartExpression name = parseQualified();
+ DartExpression name = parseQualified(true);
if (optional(Token.PERIOD)) {
name = doneWithoutConsuming(new DartPropertyAccess(name, parseIdentifier()));
}
@@ -4772,7 +4772,7 @@
beginCatchClause();
next();
beginTypeAnnotation();
- DartTypeNode exceptionType = done(new DartTypeNode(parseQualified()));
+ DartTypeNode exceptionType = done(new DartTypeNode(parseQualified(false)));
DartParameter exception = null;
DartParameter stackTrace = null;
if (optional(Token.CATCH)) {
@@ -4906,7 +4906,7 @@
*/
private DartTypeNode parseTypeAnnotation() {
beginTypeAnnotation();
- return done(new DartTypeNode(parseQualified(), parseTypeArgumentsOpt()));
+ return done(new DartTypeNode(parseQualified(false), parseTypeArgumentsOpt()));
}
/**
@@ -4951,9 +4951,15 @@
* ;
* </pre>
*/
- private DartExpression parseQualified() {
+ private DartExpression parseQualified(boolean canBeFollowedByPeriod) {
beginQualifiedIdentifier();
- DartExpression qualified = parseIdentifier();
+ DartIdentifier identifier = parseIdentifier();
+ if (!prefixes.contains(identifier.getName())) {
+ if (canBeFollowedByPeriod && !(peek(0) == Token.PERIOD && peek(1) == Token.IDENTIFIER && peek(2) == Token.PERIOD)) {
+ return done(identifier);
+ }
+ }
+ DartExpression qualified = identifier;
if (optional(Token.PERIOD)) {
// The previous identifier was a prefix.
qualified = new DartPropertyAccess(qualified, parseIdentifier());
@@ -4981,7 +4987,7 @@
List<DartTypeNode> typeArguments = new ArrayList<DartTypeNode>();
beginTypeAnnotation(); // to allow roll-back in case we're not at a type
- DartNode qualified = parseQualified();
+ DartNode qualified = parseQualified(false);
if (optional(Token.LT)) {
if (peek(0) != Token.IDENTIFIER) {
@@ -4989,7 +4995,7 @@
return null;
}
beginTypeArguments();
- DartNode qualified2 = parseQualified();
+ DartNode qualified2 = parseQualified(false);
DartTypeNode argument;
switch (peek(0)) {
case LT:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698