| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package com.google.dart.compiler.resolver; | 5 package com.google.dart.compiler.resolver; |
| 6 | 6 |
| 7 import com.google.common.annotations.VisibleForTesting; | 7 import com.google.common.annotations.VisibleForTesting; |
| 8 import com.google.common.base.Objects; | 8 import com.google.common.base.Objects; |
| 9 import com.google.dart.compiler.DartCompilerContext; | 9 import com.google.dart.compiler.DartCompilerContext; |
| 10 import com.google.dart.compiler.ErrorCode; | 10 import com.google.dart.compiler.ErrorCode; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 modifiers = modifiers.makeStatic(); | 348 modifiers = modifiers.makeStatic(); |
| 349 // Set the "const" modifier so that it is easy to compare a constant fie
ld to other | 349 // Set the "const" modifier so that it is easy to compare a constant fie
ld to other |
| 350 // types of constant expressions. | 350 // types of constant expressions. |
| 351 modifiers = modifiers.makeConstant(); | 351 modifiers = modifiers.makeConstant(); |
| 352 } | 352 } |
| 353 if (fieldNode.getValue() != null) { | 353 if (fieldNode.getValue() != null) { |
| 354 modifiers = modifiers.makeInitialized(); | 354 modifiers = modifiers.makeInitialized(); |
| 355 } | 355 } |
| 356 FieldNodeElement fieldElement = fieldNode.getElement(); | 356 FieldNodeElement fieldElement = fieldNode.getElement(); |
| 357 if (fieldElement == null) { | 357 if (fieldElement == null) { |
| 358 fieldElement = Elements.fieldFromNode(fieldNode, currentHolder, fieldNod
e.getMetadata(), | 358 fieldElement = Elements.fieldFromNode(fieldNode, currentHolder, fieldNod
e.getObsoleteMetadata(), |
| 359 modifiers); | 359 modifiers); |
| 360 addField(currentHolder, fieldElement); | 360 addField(currentHolder, fieldElement); |
| 361 } else { | 361 } else { |
| 362 // This is a top-level element, and an element was already created in | 362 // This is a top-level element, and an element was already created in |
| 363 // TopLevelElementBuilder. | 363 // TopLevelElementBuilder. |
| 364 Elements.addField(currentHolder, fieldElement); | 364 Elements.addField(currentHolder, fieldElement); |
| 365 assertTopLevel(fieldNode); | 365 assertTopLevel(fieldNode); |
| 366 } | 366 } |
| 367 fieldElement.setType(type); | 367 fieldElement.setType(type); |
| 368 recordElement(fieldNode.getName(), fieldElement); | 368 recordElement(fieldNode.getName(), fieldElement); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 element = topLevelContext.getScope().findElement(context.getScope().getL
ibrary(), name); | 432 element = topLevelContext.getScope().findElement(context.getScope().getL
ibrary(), name); |
| 433 } | 433 } |
| 434 | 434 |
| 435 FieldElementImplementation fieldElement = null; | 435 FieldElementImplementation fieldElement = null; |
| 436 if (element == null || element.getKind().equals(ElementKind.FIELD) | 436 if (element == null || element.getKind().equals(ElementKind.FIELD) |
| 437 && element.getModifiers().isAbstractField()) { | 437 && element.getModifiers().isAbstractField()) { |
| 438 fieldElement = (FieldElementImplementation) element; | 438 fieldElement = (FieldElementImplementation) element; |
| 439 } | 439 } |
| 440 | 440 |
| 441 if (fieldElement == null) { | 441 if (fieldElement == null) { |
| 442 fieldElement = Elements.fieldFromNode(fieldNode, currentHolder, fieldNod
e.getMetadata(), | 442 fieldElement = Elements.fieldFromNode(fieldNode, currentHolder, fieldNod
e.getObsoleteMetadata(), |
| 443 fieldNode.getModifiers()); | 443 fieldNode.getModifiers()); |
| 444 addField(currentHolder, fieldElement); | 444 addField(currentHolder, fieldElement); |
| 445 } | 445 } |
| 446 | 446 |
| 447 if (accessorNode.getModifiers().isGetter()) { | 447 if (accessorNode.getModifiers().isGetter()) { |
| 448 if (fieldElement.getGetter() != null) { | 448 if (fieldElement.getGetter() != null) { |
| 449 if (!topLevelDefinition) { | 449 if (!topLevelDefinition) { |
| 450 reportDuplicateDeclaration(ResolverErrorCode.DUPLICATE_MEMBER, field
Element.getGetter()); | 450 reportDuplicateDeclaration(ResolverErrorCode.DUPLICATE_MEMBER, field
Element.getGetter()); |
| 451 reportDuplicateDeclaration(ResolverErrorCode.DUPLICATE_MEMBER, acces
sorElement); | 451 reportDuplicateDeclaration(ResolverErrorCode.DUPLICATE_MEMBER, acces
sorElement); |
| 452 } | 452 } |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 */ | 667 */ |
| 668 private void reportDuplicateDeclaration(ErrorCode errorCode, Element element
) { | 668 private void reportDuplicateDeclaration(ErrorCode errorCode, Element element
) { |
| 669 String name = | 669 String name = |
| 670 element instanceof MethodElement | 670 element instanceof MethodElement |
| 671 ? Elements.getRawMethodName((MethodElement) element) | 671 ? Elements.getRawMethodName((MethodElement) element) |
| 672 : element.getName(); | 672 : element.getName(); |
| 673 resolutionError(element.getNameLocation(), errorCode, name); | 673 resolutionError(element.getNameLocation(), errorCode, name); |
| 674 } | 674 } |
| 675 } | 675 } |
| 676 } | 676 } |
| OLD | NEW |