Commit Graph

482 Commits

Author SHA1 Message Date
Konstantin Shcheglov c90ca298ed Provide a message for InconsistentAnalysisException.
R=brianwilkerson@google.com

Change-Id: I1498c70c1c9d7cd43760ca2c620a3fb819a0c823
Reviewed-on: https://dart-review.googlesource.com/47903
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-03-22 17:54:59 +00:00
Brian Wilkerson 1d159e7c23 Rename annotation testing methods in Element
Change-Id: I0f60b9abd3de350e62d89eac0d690a1db40316b7
Reviewed-on: https://dart-review.googlesource.com/45080
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-05 17:23:48 +00:00
Brian Wilkerson 5fd560f96b Add getters to replace ParameterKind
Change-Id: I0886c8d032e963857b8054e894ed3343a235b5c2
Reviewed-on: https://dart-review.googlesource.com/44921
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-03-05 14:22:52 +00:00
Paul Berry 593273cf51 Finish implementing mixin type inference in the analyzer.
Fixes #32146.

Change-Id: Ia46b6a54757901681858e682bdd6f809c194999c
Reviewed-on: https://dart-review.googlesource.com/43944
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2018-02-27 17:49:59 +00:00
Brian Wilkerson 73eb8a37e0 Make ContextRoot part of the API to support the angular plugin, fix some bugs
Change-Id: I3f23d1712473c4e5522c441ac31e013516ae5f4d
Reviewed-on: https://dart-review.googlesource.com/43880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-02-27 15:37:19 +00:00
Brian Wilkerson ceaac966fc Proposed analyzer API
Change-Id: I075a92a5e7f8dbdc0bb4827091c48c83c6272e0b
Reviewed-on: https://dart-review.googlesource.com/42083
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-02-20 22:43:35 +00:00
Brian Wilkerson 49e04b7875 Add an isConst getter to TypedLiteral
Change-Id: Ia884fe5aa6ba9b40ba5ef8c342c2312b3dd2ea77
Reviewed-on: https://dart-review.googlesource.com/38140
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-02-01 19:23:38 +00:00
Jaime Wren 7af4db0ea0 Implicit new constructor work for the analyzer, behind the previewDart2 flag.
I could not add a test into element_resolver_test.dart as the scope lookup logic does not resolve the type "Object" to the ClassElement for the type Object, that is:

test_visitMethodInvocation_implicit() async {
    // Object()
    InterfaceType obType = _typeProvider.objectType;
    MethodInvocation invocation = AstTestFactory.methodInvocation2("Object");
    // The invocation element in visitMethodInvocation is not resolved to be a
    // ClassElement in this test harness.
  }


This prevents this source from being invoked.

I was however able to get this test, and an accompanying test for named constructors, to work in resolver_test.dart.  It felt like the wrong test file to include so I left the tests out- do advise.

test_visitMethodInvocations_implicitConstructor() async {
    String code = '''
class A {
  A() {}
}
main() {
  var v = A(); // marker
}
    ''';
    CompilationUnit unit = await resolveSource(code);
    AstNode constructorName = findMarkedIdentifier(code, unit, "(); // marker");
    InstanceCreationExpression instanceCreationExpression =
        constructorName.parent.parent.parent;
    expect(instanceCreationExpression, isNotNull);
    expect(instanceCreationExpression, isNotNull);
    expect(instanceCreationExpression.constructorName.type.type, isNotNull);
    expect(instanceCreationExpression.constructorName.staticElement, isNotNull);
    expect(instanceCreationExpression.staticElement, isNotNull);
    expect(instanceCreationExpression.staticType, isNotNull);
  }

Change-Id: I03214c194f1052d000d7f5e840df80d4f66e2a82
Reviewed-on: https://dart-review.googlesource.com/36365
Commit-Queue: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-01-29 19:25:33 +00:00
Brian Wilkerson c40d9821dc Prepare for optional new/const
Change-Id: I138fffc3f03f2925d5b33cd7f340543789d4b6e6
Reviewed-on: https://dart-review.googlesource.com/31960
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-01-02 16:33:24 +00:00
Sam Rawlins 14629098dd Enforce @visibleForTesting annotations.
In particular, enforce that a method annotated with @visibleForTesting can only
be referenced from within the declaring library, or within a file that has
"/test" in its path. This allows @visibleForTesting methods to be accessed from
test files, or files in "/testing" folders, etc.

Bug: https://github.com/dart-lang/sdk/issues/28273
Change-Id: I3c19f73be330c49face7e3203879742d514bca74
Reviewed-on: https://dart-review.googlesource.com/27201
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-12-14 00:17:24 +00:00
Sam Rawlins 0a6253312f Check for @alwaysThrows when evaluating for dead code.
The meta package version 1.1.0 includes a new `alwaysThrows`, which developers
can use to annotate methods that always throw. This helps to avoid erroneous
DEAD_CODE warnings from analyzer.

Bug: https://github.com/dart-lang/sdk/issues/31384
Change-Id: I70e2469b4f3a0d2c87064851160b268ea2259807
Reviewed-on: https://dart-review.googlesource.com/26563
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-12-07 19:29:18 +00:00
Konstantin Shcheglov e8fe137e94 Remove ExecutableElement.functions and don't resynthesize local functions.
As for all other local elements - variables and labels, we now
created them when we analyze the unit, but we don't export them
through the element model.

R=brianwilkerson@google.com, paulberry@google.com

Bug:
Change-Id: I71eb567f58d6d710fc8a58d1653a66d95ef1ddcd
Reviewed-on: https://dart-review.googlesource.com/9861
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2017-10-01 21:08:04 +00:00
Brian Wilkerson 7afa1e2986 Deprecate MethodElement.getReifiedType
R=jmesserly@google.com

Review-Url: https://codereview.chromium.org/2997333002 .
2017-08-21 16:21:43 -07:00
Brian Wilkerson de0b7a2f40 Add sourceFactory getter to AnalysisSession
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2989883002 .
2017-07-28 06:18:53 -07:00
Konstantin Shcheglov ce4d7b1891 Restore UriReferencedElement and its uri/uriOffset/uriEnd properties.
This is a partial rollback of bdd69ccd6c,
it restores APIs and implementations, but does not restore its usages
in analyzer or analysis_server. Should be enough to make clients
temporary OK, but also keeps resynthesizing from Kernel working.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2991453002 .
2017-07-21 16:59:52 -07:00
Konstantin Shcheglov bdd69ccd6c Remove UriReferencedElement with its uri/uriOffset/uriEnd properties.
The 'Move File' refactoring does not work, so I comment out most
of its code.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2982993003 .
2017-07-19 09:31:03 -07:00
Konstantin Shcheglov 51b50f7710 Restore visitLabelElement() and visitLocalVariableElement().
Revert "Remove visitLabelElement() and visitLocalVariableElement()."

This reverts commit 2c064df145.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2977623002 .
2017-07-10 11:00:27 -07:00
Konstantin Shcheglov 2c064df145 Remove visitLabelElement() and visitLocalVariableElement().
These elements are not parts of the bigger element model, so it
does not make sense to implement these visit methods.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2971253002 .
2017-07-07 08:04:59 -07:00
Konstantin Shcheglov 49da688b0b Remove ExecutableElement.labels altogether.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2972103002 .
2017-07-06 14:32:07 -07:00
Konstantin Shcheglov 7ed5e1c433 Remove ExecutableElement.localVariables altogether.
It is not used in analyzer or analysis_server, and in packages in
internal codebase.

R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2966313002 .
2017-07-05 16:59:41 -07:00
Konstantin Shcheglov 7ea7324747 Remove CompilationUnitElement.getElementAt().
It is not used by any package we use internally.
It was added for search, but is not used anymore.

R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2967203002 .
2017-07-05 10:52:02 -07:00
Brian Wilkerson 5946ce552f Add AnalysisSession to analyzer
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2954153002 .
2017-06-26 09:16:11 -07:00
Erik Corry 029b1cb948 Spelling fixes e to i.
R=kevmoo@google.com
BUG=

Review-Url: https://codereview.chromium.org/2957593002 .
2017-06-24 13:41:39 +02:00
Brian Wilkerson 4fab4a1f52 Clean up type parameters in comments
R=devoncarew@google.com

Review-Url: https://codereview.chromium.org/2948393002 .
2017-06-23 12:53:11 -07:00
Brian Wilkerson e8a5e404c3 Move LocalDeclarationVisitor for use by contributors that will be moved to analyzer_plugin
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2918343002 .
2017-06-05 10:24:54 -07:00
Brian Wilkerson 50d0857f82 Add result interfaces used by AnalysisSession
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2908543002 .
2017-05-25 12:50:08 -07:00
Janice Collins 37330be1b9 Expose function contained in GenericTypeAliasImpl.
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2787513003 .
2017-03-30 09:08:46 -07:00
Brian Wilkerson 4f28d97ac2 Add error checking for the immutable annotation (issue 27750)
R=pquitslund@google.com

Review-Url: https://codereview.chromium.org/2775863004 .
2017-03-24 11:56:24 -07:00
Jacob Richman 6d1e3b4a90 Fix analyzer formatter errors.
BUG=
R=jmesserly@google.com

Review-Url: https://codereview.chromium.org/2765153002 .
2017-03-21 21:42:40 -07:00
Brian Wilkerson c56210c294 Create a new element for generic function types
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2758123002 .
2017-03-19 10:45:50 -07:00
Konstantin Shcheglov fe4378d2c8 Fix for parsing generic function types with Fasta.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2732213003 .
2017-03-07 12:03:55 -08:00
Brian Wilkerson 0fa6715bd8 More support for generic function types
Review-Url: https://codereview.chromium.org/2736643006 .
2017-03-07 08:04:01 -08:00
Konstantin Shcheglov 99b1f617dc Mark not-optional-parameters methods of AstFactory as deprecated.
...and use non-deprecated versions in AstTestFactory.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2726943002 .
2017-03-01 11:43:55 -08:00
Paul Berry 79cce42e38 Add an AST factory method for fieldDeclaration with all optional named parameters.
Also add 'covariantKeyword' to the Impl constructors and named factories.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2722033002 .
2017-02-28 16:43:31 -08:00
Janice Collins 05b00a9884 Add toSource() to ElementAnnotation, ElementAnnotationImpl (issue 28631)
This is the dartdoc-required case only.

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2713243003 .
2017-02-27 09:22:27 -08:00
Konstantin Shcheglov 3d88437bda Add AST factories for formal parameters with all optional named parameters.
Also add 'covariantKeyword' to the Impl constructors and named factories.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2713173003 .
2017-02-24 12:09:43 -08:00
Konstantin Shcheglov ddddb2c50d Revert "Add NormalFormalParameter.covariantKeyword setter and factory parameter."
This reverts commit 57b78f422e.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2710393002 .
2017-02-23 21:22:00 -08:00
Konstantin Shcheglov 57b78f422e Add NormalFormalParameter.covariantKeyword setter and factory parameter.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2714843002 .
2017-02-23 14:48:57 -08:00
Konstantin Shcheglov f47ebbcea3 Add CompilationUnitElement.lineInfo and resynthesize it.
One bit that is not quite straight is that UnlinkedUnit.lineInfo is
empty. Normally we would have [0] for empty files, which we pretend
missing files are. Should we fix this instead of checking in the
resynthesizer?

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2694403003 .
2017-02-15 09:54:28 -08:00
Jennifer Messerly 0e00b3e5c8 fix #28008, fix #28009 implement FutureOr<T>
This implements FutureOr<T> in strong mode, otherwise it's ignored (treated as `dynamic`.

Also fixes strong mode's inference subtype function incorrectly treating `void` as a malformed type. This had the consequence of allowing `void` to be inferred as a type argument.

R=leafp@google.com, paulberry@google.com

Review-Url: https://codereview.chromium.org/2647833002 .
2017-01-25 15:32:57 -08:00
Bob Nystrom 590a188066 Use "Object" as the reified type of covariant override parameters.
This ensures the runtime type is of the tear-off expression's static
type, even when accessed through a superclass.

I also moved the two tests into a subdirectory so they are easier to
find. (It is inscrutable to me why we would have a single directory
with 1,868 test files in it.) That involved enabling recursive
directory listing in codegen_test, which exposed a couple of things.

Fix #27484.

R=leafp@google.com

Review-Url: https://codereview.chromium.org/2641543003 .
2017-01-18 14:48:42 -08:00
Brian Wilkerson dac33b0b3d Add missing AST support for covariant keyword and fix bug from previous CL
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2639323002 .
2017-01-18 09:41:21 -08:00
Brian Wilkerson 6a7139cf51 Make TypeName a subtype of NamedType
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2635113004 .
2017-01-17 12:18:42 -08:00
Brian Wilkerson 38264a1463 Ast changes to support the covariant keyword
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2637753003 .
2017-01-17 06:45:06 -08:00
Brian Wilkerson 4833040749 Introduce the interface NamedType as a replacement for TypeName
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2637543002 .
2017-01-16 11:03:23 -08:00
Konstantin Shcheglov 24f61aef20 Report HintCode.MISSING_RETURN for async functions with return type that matters.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2630023003 .
2017-01-15 09:51:26 -08:00
Brian Wilkerson 22f561e914 Reapply "Add support for generic function type syntax, part 1"
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2622303006 .
2017-01-11 14:10:05 -08:00
Brian Wilkerson 85b1e7abbe Revert "Add support for generic function type syntax, part 1"
Review-Url: https://codereview.chromium.org/2624283003 .
2017-01-11 13:30:52 -08:00
Brian Wilkerson 1cd918533d Add support for generic function type syntax, part 1
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2613383003 .
2017-01-11 13:12:10 -08:00
Brian Wilkerson d1fcb1e986 Add visitors that throw by default
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2623453003 .
2017-01-09 10:08:53 -08:00