| Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java
|
| diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java
|
| index 1120b21813c4f613cead59d56d14b144023790d3..b6ce57dd1930d095bf69a0007a7fa508cad167d8 100644
|
| --- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java
|
| +++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/hint/BestPracticesVerifier.java
|
| @@ -45,11 +45,13 @@ import com.google.dart.engine.ast.visitor.RecursiveAstVisitor;
|
| import com.google.dart.engine.element.ClassElement;
|
| import com.google.dart.engine.element.ConstructorElement;
|
| import com.google.dart.engine.element.Element;
|
| +import com.google.dart.engine.element.ImportElement;
|
| import com.google.dart.engine.element.LibraryElement;
|
| import com.google.dart.engine.element.MethodElement;
|
| import com.google.dart.engine.element.ParameterElement;
|
| import com.google.dart.engine.element.PropertyAccessorElement;
|
| import com.google.dart.engine.element.VariableElement;
|
| +import com.google.dart.engine.error.CompileTimeErrorCode;
|
| import com.google.dart.engine.error.ErrorCode;
|
| import com.google.dart.engine.error.HintCode;
|
| import com.google.dart.engine.internal.error.ErrorReporter;
|
| @@ -172,6 +174,12 @@ public class BestPracticesVerifier extends RecursiveAstVisitor<Void> {
|
| @Override
|
| public Void visitImportDirective(ImportDirective node) {
|
| checkForDeprecatedMemberUse(node.getUriElement(), node);
|
| + ImportElement importElement = node.getElement();
|
| + if (importElement != null) {
|
| + if (importElement.isDeferred()) {
|
| + checkForLoadLibraryFunction(node, importElement);
|
| + }
|
| + }
|
| return super.visitImportDirective(node);
|
| }
|
|
|
| @@ -549,6 +557,30 @@ public class BestPracticesVerifier extends RecursiveAstVisitor<Void> {
|
| }
|
|
|
| /**
|
| + * Check that the imported library does not define a loadLibrary function. The import has already
|
| + * been determined to be deferred when this is called.
|
| + *
|
| + * @param node the import directive to evaluate
|
| + * @param importElement the {@link ImportElement} retrieved from the node
|
| + * @return {@code true} if and only if an error code is generated on the passed node
|
| + * @see CompileTimeErrorCode#IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION
|
| + */
|
| + private boolean checkForLoadLibraryFunction(ImportDirective node, ImportElement importElement) {
|
| + LibraryElement importedLibrary = importElement.getImportedLibrary();
|
| + if (importedLibrary == null) {
|
| + return false;
|
| + }
|
| + if (importedLibrary.hasLoadLibraryFunction()) {
|
| + errorReporter.reportErrorForNode(
|
| + HintCode.IMPORT_DEFERRED_LIBRARY_WITH_LOAD_FUNCTION,
|
| + node,
|
| + importedLibrary.getName());
|
| + return true;
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + /**
|
| * Generate a hint for functions or methods that have a return type, but do not have a return
|
| * statement on all branches. At the end of blocks with no return, Dart implicitly returns
|
| * {@code null}, avoiding these implicit returns is considered a best practice.
|
|
|