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

Side by Side Diff: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java

Issue 66253002: Version 0.8.10.9 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, the Dart project authors. 2 * Copyright (c) 2013, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 for (FieldElement fieldElement : fieldElements) { 469 for (FieldElement fieldElement : fieldElements) {
470 if (!fieldElement.isSynthetic()) { 470 if (!fieldElement.isSynthetic()) {
471 initialFieldElementsMap.put(fieldElement, fieldElement.getInitialize r() == null 471 initialFieldElementsMap.put(fieldElement, fieldElement.getInitialize r() == null
472 ? INIT_STATE.NOT_INIT : INIT_STATE.INIT_IN_DECLARATION); 472 ? INIT_STATE.NOT_INIT : INIT_STATE.INIT_IN_DECLARATION);
473 } 473 }
474 } 474 }
475 } 475 }
476 checkForFinalNotInitialized(node); 476 checkForFinalNotInitialized(node);
477 checkForDuplicateDefinitionInheritance(); 477 checkForDuplicateDefinitionInheritance();
478 checkForConflictingGetterAndMethod(); 478 checkForConflictingGetterAndMethod();
479 checkForConflictingInstanceGetterAndSuperclassMember();
479 checkImplementsSuperClass(node); 480 checkImplementsSuperClass(node);
480 checkImplementsFunctionWithoutCall(node); 481 checkImplementsFunctionWithoutCall(node);
481 return super.visitClassDeclaration(node); 482 return super.visitClassDeclaration(node);
482 } finally { 483 } finally {
483 isInNativeClass = false; 484 isInNativeClass = false;
484 initialFieldElementsMap = null; 485 initialFieldElementsMap = null;
485 enclosingClass = outerClass; 486 enclosingClass = outerClass;
486 } 487 }
487 } 488 }
488 489
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 try { 782 try {
782 isInStaticMethod = node.isStatic(); 783 isInStaticMethod = node.isStatic();
783 enclosingFunction = node.getElement(); 784 enclosingFunction = node.getElement();
784 SimpleIdentifier identifier = node.getName(); 785 SimpleIdentifier identifier = node.getName();
785 String methodName = ""; 786 String methodName = "";
786 if (identifier != null) { 787 if (identifier != null) {
787 methodName = identifier.getName(); 788 methodName = identifier.getName();
788 } 789 }
789 if (node.isSetter() || node.isGetter()) { 790 if (node.isSetter() || node.isGetter()) {
790 checkForMismatchedAccessorTypes(node, methodName); 791 checkForMismatchedAccessorTypes(node, methodName);
791 checkForConflictingInstanceGetterAndSuperclassMember(node);
792 } 792 }
793 if (node.isGetter()) { 793 if (node.isGetter()) {
794 checkForConflictingStaticGetterAndInstanceSetter(node); 794 checkForConflictingStaticGetterAndInstanceSetter(node);
795 } else if (node.isSetter()) { 795 } else if (node.isSetter()) {
796 checkForWrongNumberOfParametersForSetter(node.getName(), node.getParamet ers()); 796 checkForWrongNumberOfParametersForSetter(node.getName(), node.getParamet ers());
797 checkForNonVoidReturnTypeForSetter(node.getReturnType()); 797 checkForNonVoidReturnTypeForSetter(node.getReturnType());
798 checkForConflictingStaticSetterAndInstanceMember(node); 798 checkForConflictingStaticSetterAndInstanceMember(node);
799 } else if (node.isOperator()) { 799 } else if (node.isOperator()) {
800 checkForOptionalParameterInOperator(node); 800 checkForOptionalParameterInOperator(node);
801 checkForWrongNumberOfParametersForOperator(node); 801 checkForWrongNumberOfParametersForOperator(node);
(...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after
2189 name.length(), 2189 name.length(),
2190 enclosingClass.getDisplayName(), 2190 enclosingClass.getDisplayName(),
2191 inherited.getEnclosingElement().getDisplayName(), 2191 inherited.getEnclosingElement().getDisplayName(),
2192 name); 2192 name);
2193 } 2193 }
2194 // done 2194 // done
2195 return hasProblem; 2195 return hasProblem;
2196 } 2196 }
2197 2197
2198 /** 2198 /**
2199 * This verifies that the superclass of the enclosing class does not declare a ccessible static 2199 * This verifies that the superclass of the {@link #enclosingClass} does not d eclare accessible
2200 * member with the same name as the passed instance getter/setter method decla ration. 2200 * static members with the same name as the instance getters/setters declared in
2201 * {@link #enclosingClass}.
2201 * 2202 *
2202 * @param node the method declaration to evaluate 2203 * @param node the method declaration to evaluate
2203 * @return {@code true} if and only if an error code is generated on the passe d node 2204 * @return {@code true} if and only if an error code is generated on the passe d node
2204 * @see StaticWarningCode#CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER 2205 * @see StaticWarningCode#CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER
2205 * @see StaticWarningCode#CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER 2206 * @see StaticWarningCode#CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER
2206 */ 2207 */
2207 private boolean checkForConflictingInstanceGetterAndSuperclassMember(MethodDec laration node) { 2208 private boolean checkForConflictingInstanceGetterAndSuperclassMember() {
2208 if (node.isStatic()) {
2209 return false;
2210 }
2211 // prepare name
2212 SimpleIdentifier nameNode = node.getName();
2213 if (nameNode == null) {
2214 return false;
2215 }
2216 String name = nameNode.getName();
2217 // prepare enclosing type
2218 if (enclosingClass == null) { 2209 if (enclosingClass == null) {
2219 return false; 2210 return false;
2220 } 2211 }
2221 InterfaceType enclosingType = enclosingClass.getType(); 2212 InterfaceType enclosingType = enclosingClass.getType();
2222 // try to find super element 2213 // check every accessor
2223 ExecutableElement superElement; 2214 boolean hasProblem = false;
2224 superElement = enclosingType.lookUpGetterInSuperclass(name, currentLibrary); 2215 for (PropertyAccessorElement accessor : enclosingClass.getAccessors()) {
2225 if (superElement == null) { 2216 // we analyze instance accessors here
2226 superElement = enclosingType.lookUpSetterInSuperclass(name, currentLibrary ); 2217 if (accessor.isStatic()) {
2218 continue;
2219 }
2220 // prepare accessor properties
2221 String name = accessor.getDisplayName();
2222 boolean getter = accessor.isGetter();
2223 // if non-final variable, ignore setter - we alreay reported problem for g etter
2224 if (accessor.isSetter() && accessor.isSynthetic()) {
2225 continue;
2226 }
2227 // try to find super element
2228 ExecutableElement superElement;
2229 superElement = enclosingType.lookUpGetterInSuperclass(name, currentLibrary );
2230 if (superElement == null) {
2231 superElement = enclosingType.lookUpSetterInSuperclass(name, currentLibra ry);
2232 }
2233 if (superElement == null) {
2234 superElement = enclosingType.lookUpMethodInSuperclass(name, currentLibra ry);
2235 }
2236 if (superElement == null) {
2237 continue;
2238 }
2239 // OK, not static
2240 if (!superElement.isStatic()) {
2241 continue;
2242 }
2243 // prepare "super" type to report its name
2244 ClassElement superElementClass = (ClassElement) superElement.getEnclosingE lement();
2245 InterfaceType superElementType = superElementClass.getType();
2246 // report problem
2247 hasProblem = true;
2248 if (getter) {
2249 errorReporter.reportError(
2250 StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER,
2251 accessor,
2252 superElementType.getDisplayName());
2253 } else {
2254 errorReporter.reportError(
2255 StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER,
2256 accessor,
2257 superElementType.getDisplayName());
2258 }
2227 } 2259 }
2228 if (superElement == null) { 2260 // done
2229 superElement = enclosingType.lookUpMethodInSuperclass(name, currentLibrary ); 2261 return hasProblem;
2230 }
2231 if (superElement == null) {
2232 return false;
2233 }
2234 // OK, not static
2235 if (!superElement.isStatic()) {
2236 return false;
2237 }
2238 // prepare "super" type to report its name
2239 ClassElement superElementClass = (ClassElement) superElement.getEnclosingEle ment();
2240 InterfaceType superElementType = superElementClass.getType();
2241 // report problem
2242 if (node.isGetter()) {
2243 errorReporter.reportError(
2244 StaticWarningCode.CONFLICTING_INSTANCE_GETTER_AND_SUPERCLASS_MEMBER,
2245 nameNode,
2246 superElementType.getDisplayName());
2247 } else {
2248 errorReporter.reportError(
2249 StaticWarningCode.CONFLICTING_INSTANCE_SETTER_AND_SUPERCLASS_MEMBER,
2250 nameNode,
2251 superElementType.getDisplayName());
2252 }
2253 return true;
2254 } 2262 }
2255 2263
2256 /** 2264 /**
2257 * This verifies that the enclosing class does not have an instance member wit h the same name as 2265 * This verifies that the enclosing class does not have an instance member wit h the same name as
2258 * the passed static getter method declaration. 2266 * the passed static getter method declaration.
2259 * 2267 *
2260 * @param node the method declaration to evaluate 2268 * @param node the method declaration to evaluate
2261 * @return {@code true} if and only if an error code is generated on the passe d node 2269 * @return {@code true} if and only if an error code is generated on the passe d node
2262 * @see StaticWarningCode#CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER 2270 * @see StaticWarningCode#CONFLICTING_STATIC_GETTER_AND_INSTANCE_SETTER
2263 */ 2271 */
(...skipping 3137 matching lines...) Expand 10 before | Expand all | Expand 10 after
5401 if (superClassElt != null) { 5409 if (superClassElt != null) {
5402 return memberHasConcreteMethodImplementationInSuperclassChain( 5410 return memberHasConcreteMethodImplementationInSuperclassChain(
5403 superClassElt, 5411 superClassElt,
5404 methodName, 5412 methodName,
5405 superclassChain); 5413 superclassChain);
5406 } 5414 }
5407 } 5415 }
5408 return false; 5416 return false;
5409 } 5417 }
5410 } 5418 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698