Commit Graph

65 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
Paul Berry ae6fd961a1 Prepare for decoupling analyzer ASTs from element model.
This CL creates top level accessor functions which may be used to map from AST data structures to their corresponding elements and types, and begins using those accessor functions throughout the SDK.  It also adds empty interfaces ResolutionTarget and ResolutionType, which are implemented by Element and DartType respectively.

In a future CL, I will change the types stored in the AST to ResolutionTarget and ResolutionType, rather than specific element types; this will decouple the ASTs from the element model.  The presence of the accessor functions will allow clients to continue accessing elements and types in a type-safe way.

R=asgerf@google.com, brianwilkerson@google.com, scheglov@google.com, vsm@google.com

Review URL: https://codereview.chromium.org/2551023005 .
2016-12-07 11:08:14 -08:00
Paul Berry c4f50f53cb Remove old AST factory constructors from analyzer.
This reapplies the remainder of
1d028eed8d (which was reverted due to
conflicts with dev_compiler), since dev_compiler has now been fixed to
use analyzer's new astFactory.

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

Review URL: https://codereview.chromium.org/2549613002 .
2016-12-01 11:17:10 -08:00
Vijay Menon b8d3758dcd Revert "Transition analyzer and analysis_server to new astFactory; remove old AST factory methods."
This reverts commit 1d028eed8d.

This was breaking DDC.

TBR=paulberry@google.com

Review URL: https://codereview.chromium.org/2542753002 .
2016-11-30 14:57:49 -08:00
Paul Berry 1d028eed8d Transition analyzer and analysis_server to new astFactory; remove old AST factory methods.
R=brianwilkerson@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/2539243002 .
2016-11-30 12:28:51 -08:00
Paul Berry be11197a6c Consolidate AST element/type interfaces.
The AST getters/setters for `bestElement`, `propagatedElement`, and
`staticElement` having type `MethodElement` are moved to a common
interface class, `MethodReferenceExpression`.

The AST getters/setters for `staticElement` having type
`ConstructorElement` are moved to a common interface class,
`ConstructorReferenceNode`.

The overrides for `propagatedInvokeType` and `staticInvokeType` are
removed from `FunctionExpressionInvocation` and `MethodInvocation`,
since these overrides are identical to the corresponding declarations
in the base class, `InvocationExpression`.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2536253002 .
2016-11-29 10:11:35 -08:00
Paul Berry f4baeb20d7 Create a new AstFactory class to be used by analyzer and its clients.
Unlike the previous AstFactory (now called AstTestFactory), this class
is not just for testing; it is intended to be able to create all
analyzer AST objects used in production.  Also, its methods are
non-static.

For now, all users of the new AstFactory access it using the final
variable `astFactory` in standard_ast_factory.dart.  In future CLs I
intend to plumb a reference to the AstFactory through various analyzer
classes so that it can be used in a dependency injection style.

Also, the classes CommentType and UriValidationCodeImpl have been
moved out of the AST implementation file
(pkg/analyzer/lib/src/dart/ast/ast.dart) and to their own files so
that the AST interface will be able to continue to use them without
depending on the AST implementation.

In follow-up CLs I will change the analyzer and its clients to use the
AstFactory rather than the redirecting constructors in the AST
interface file, and then remove those redirecting constructors.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2522143003 .
2016-11-28 10:50:20 -08:00
Brian Wilkerson b923dafd25 Add parser support for using a URI in a part-of directive
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2526063002 .
2016-11-25 08:16:45 -08:00
Paul Berry 4cd9b28eb6 Create pkg/front_end/src/base and begin populating with general use classes.
In the long run, pkg/front_end/src/base is intended to contain code
that is useful to many components of the front end.

In this initial implementation, it contains:
- Source and the classes it references
- ErrorCode, ErrorSeverity, and ErrorType
- SyntacticEntity

Note that AnalysisTarget is included (even though strictly speaking it
is part of the analyzer task model) because it was too hard to
disentangle from Source.

Note that Token classes remain in pkg/front_end/src/scanner for now; I
plan to reorganize them at the time the parser is moved into the front
end.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2486923007 .
2016-11-14 09:20:18 -08:00
Brian Wilkerson c7eab6ba06 Enhance generalizing visitor to allow visiting an invocation expression
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2490703004 .
2016-11-10 09:50:46 -08:00
Brian Wilkerson 3c437f5d9e Create AST structure for asserts in constructor initializers
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2492633002 .
2016-11-10 09:00:18 -08:00
Paul Berry 0a1fb8d248 Move scanner into pkg/front_end/lib/src/scanner.
Several support classes also had to move to front_end along with the
scanner.  Some of these support classes arguably don't belong to the
scanner itself, since they have other uses (e.g. SyntacticEntity,
ErrorCode, ErrorSeverity, ErrorType, and StringUtilities).  They will
be reorganized into a more appropriate location in future CLs, at the
time that they become needed by other components of the front end.

In order to avoid dragging in a lot of dependencies, the following
changes were made:

1. Scanner no longer reports errors through Source and
AnalysisErrorListener objects passed to the constructor.  Instead, it
provides an abstract reportError() method which clients may override
to perform error reporting in any way they wish.  Analyzer contains an
override of Scanner that mimics the old behavior in order to maintain
compatibility.

2. Static members of ErrorCode (`values` and `byUniqueName`) have been
moved to top level, and remain in analyzer.  To maintain
compatibility, these static members remain in ErrorCode (as deprecated
members that simply wrap the implementations in analyzer).  This means
we have a reverse dependency (front_end depends on analyzer), but this
dependency will go away as soon as we publish the next breaking change
release of analyzer.

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

Review URL: https://codereview.chromium.org/2486873003 .
2016-11-08 13:47:17 -08:00
Brian Wilkerson 6446cab391 Guard against exceptions thrown by linters (issue 27545)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2407553002 .
2016-10-07 14:37:39 -07:00
Paul Berry dac96d0584 Add SyntacticEntity, an interface shared by AstNode and Token.
This allows types to be tightened up for AstNode.childEntities.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2357803002 .
2016-09-21 11:23:46 -07:00
Konstantin Shcheglov 54ee2b88c8 ImportElement/ExportElement 'uri' should be the selected URI.
So, that the URI is consistent with the imported/exportedLibrary.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2343103003 .
2016-09-17 17:26:13 -07:00
Brian Wilkerson 772c93ccf2 Rename libraryUri
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2347213002 .
2016-09-16 10:54:25 -07:00
Brian Wilkerson 7eb7573dc4 Initial support for the NNBD proposal
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2342383002 .
2016-09-16 10:51:19 -07:00
Brian Wilkerson 22040876bf Use declared variables to select the correct configuration for resolution
R=paulberry@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/2345773003 .
2016-09-16 07:32:40 -07:00
Brian Wilkerson 4dcb9b6196 Initial implementation for lazy compound assignment operators
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2199323002 .
2016-08-02 09:16:17 -07:00
pq c07b21d03b Dangling comment reference cleanup in analyzer.
First pass with the new `comment_reference` lint.

BUG=
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1994243002 .
2016-05-19 10:24:53 -07:00
Brian Wilkerson 3024554b3c Improve type information and minor clean up
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1977413002 .
2016-05-16 08:43:58 -07:00
Brian Wilkerson 61818c95a1 Convert some for-in loops for performance
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1955373003 .
2016-05-09 11:01:16 -07:00
Brian Wilkerson 91e2852659 Remove cast from AstNodeImpl._becomeParentOf
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1939853002 .
2016-05-02 10:21:33 -07:00
Brian Wilkerson 24d23680d1 Use null-aware operators to clean up the code
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1933763002 .
2016-04-29 08:48:12 -07:00
Brian Wilkerson ee8bb2cea9 Add a (public) utility method to clean-up code
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1925173002 .
2016-04-28 10:07:32 -07:00
Konstantin Shcheglov 305f1f538c Pull the 'keyword' property into Token.
So, we can use it without casting to KeywordToken.
This gives small, but noticable performanace boost, about 4% on hot VM.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1909843002 .
2016-04-21 08:23:49 -07:00
Brian Wilkerson 513433d514 Sort analyzer sources
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1843473002 .
2016-03-28 17:41:52 -07:00
Bob Nystrom 31aa8e26df Distinguish SimpleIdentifier uses and declarations at parse time.
Instead of a very slow .inDeclarationContext() method which determines
whether a given identifier is in a use position or not, we just create
a different subclass at parse time that encodes that fact directly.

Also, remove an unnecessary _validateElement() method.

On my Mac laptop, this takes benchmark/errors_in_all_libraries.dart

From: 0:00:05.673849
To:   0:00:05.193563 (91.53%)

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1833573006 .
2016-03-25 10:38:22 -07:00
Brian Wilkerson 5309d86424 First batch of changes to make analyzer package strong mode error free
Review URL: https://codereview.chromium.org/1808123005 .
2016-03-18 07:47:58 -07:00