Commit Graph

144 Commits

Author SHA1 Message Date
Brian Wilkerson 1f03109200 Proposed replacement for SourceFactory
Change-Id: Iadcb71a4f9682d4cb9636aea6bb0b91f3bf040f9
Reviewed-on: https://dart-review.googlesource.com/58160
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-06-05 16:09:49 +00:00
Konstantin Shcheglov f32509b849 Export 'resourceProvider' from AnalysisSession.
R=brianwilkerson@google.com

Change-Id: I0544be022a078f96be23c4e75923c32f70385589
Reviewed-on: https://dart-review.googlesource.com/55443
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-05-16 17:28:16 +00:00
Konstantin Shcheglov 8515d74332 Add ImportElement.namespace and use it in completion.
R=brianwilkerson@google.com

Change-Id: I58cadf0e3239ad4ae8584d79485f4d9ebda10eba
Reviewed-on: https://dart-review.googlesource.com/54064
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-05-07 21:23:48 +00:00
Konstantin Shcheglov b7a63c8d52 Use @isTest and @isTestGroup to understand executable element as a test/group.
R=brianwilkerson@google.com, devoncarew@google.com

Bug: https://github.com/flutter/flutter-intellij/issues/2055
Change-Id: I7c8e7639d111eca63df0780ebdec182573493047
Reviewed-on: https://dart-review.googlesource.com/53690
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2018-05-04 17:09:06 +00:00
Brian Wilkerson cb15b43c32 Add support for getting parse results synchronously
Change-Id: I2a6c4507fcc6debf3d4ffc3458621100d184619b
Reviewed-on: https://dart-review.googlesource.com/52820
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-04-26 20:24:46 +00:00
Brian Wilkerson a865531f57 Remove two unused classes from the public API
Change-Id: I4d27bc95d3a3e0ffc3ad379ffd823abf4fff0db1
Reviewed-on: https://dart-review.googlesource.com/51244
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-04-16 19:15:29 +00:00
Brian Wilkerson dd897d35a2 Move the task API out of the public API
Change-Id: I0fbafb4965ced89fb9a063edb773c3f1cb3a39fa
Reviewed-on: https://dart-review.googlesource.com/51242
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-04-16 18:18:08 +00:00
Brian Wilkerson 98671b2659 Make DeclaredVariables immutable
Change-Id: I3d0233cfb4002140af7cf0166cd98466d73d630c
Reviewed-on: https://dart-review.googlesource.com/50580
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-04-11 01:58:51 +00:00
Brian Wilkerson 8054721512 Move DeclaredVariables to a better location
Change-Id: I17190a8e888cc37cded141cbaf028691db061e49
Reviewed-on: https://dart-review.googlesource.com/50540
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2018-04-10 19:25:11 +00:00
Brian Wilkerson 7764e6962e Initial API to build analysis contexts (replaces ContextLocator.locateContexts)
Change-Id: If00ce6321efb6ff4da96e654cfe2a0a8501bed95
Reviewed-on: https://dart-review.googlesource.com/50323
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-04-10 15:48:10 +00:00
Brian Wilkerson 8d78982c3f Move file system access support from AnalysisContext to ContextRoot
Change-Id: Ic9097b8852e578001cc6555bcd4d8a94a1fde08d
Reviewed-on: https://dart-review.googlesource.com/49041
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2018-04-02 22:16:25 +00:00
danrubel b82e5b4704 Replace code completion usage of token.previous with findPrevious
This CL is the first in a multi-part effort to remove the `previous`
field from the Token class. This first step introduces a new findPrevious
utility method that finds the the token before a given token in a token stream,
and then replaces usages of token.previous with calls to this
new findPrevious utility.

Change-Id: I57de4e542adb5950f1bddd951ff555dd98b19b3b
Reviewed-on: https://dart-review.googlesource.com/48461
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2018-03-28 02:27:54 +00:00
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