Commit Graph

3034 Commits

Author SHA1 Message Date
Brian Wilkerson f8aebca4c9 Validate that the expressions in an assert in the initializer list of a const constructor are all potentially const expressions
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2483213010 .
2016-11-11 09:31:33 -08:00
Konstantin Shcheglov 1ac36f7c38 Rename setters synthetic/static to isSynthetic/isStatic.
Also rename ConstructorElementImpl.const2 to isConst.

These are breaking changes.

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

Review URL: https://codereview.chromium.org/2489363002 .
2016-11-10 12:22:58 -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
Brian Wilkerson 6ce2f220e3 Add an error when a type parameter from a generic function is used in an is test
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2479293004 .
2016-11-09 07:47:54 -08:00
Konstantin Shcheglov e7350d171e Don't serialize elements of top-level function/constructor/method bodies.
Instead in DeclarationResolver build these local elements in the bodies.

As you can see, the summary_common tests are quite ugly now, we decided
that we still have to serialize everything in variable initialiers,
including local functions. So, this requires repurposing the tests to
using initializers, and also keep buildLabelElements() in
DeclarationResolver.

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

Review URL: https://codereview.chromium.org/2485043004 .
2016-11-08 19:19:46 -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 562c2be184 Convert generic method errors to hints
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/2487583002 .
2016-11-08 11:06:42 -08:00
Konstantin Shcheglov ed172ddf70 When DefaultFormalParameter, don't use ParameterKind.REQUIRED.
It's a compilation error, but we still want to be consisten.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2477183002 .
2016-11-07 09:31:48 -08:00
Brian Wilkerson b57a73e279 Fix the parsing of generic function expressions
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2477793002 .
2016-11-03 09:34:22 -07:00
Brian Wilkerson 30ba51ff9a Fix lookup of members (issue 27723)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2469643003 .
2016-11-02 07:41:49 -07:00
Konstantin Shcheglov f797154673 Fix for LibraryDirective annotations while applying resynthesized element model.
This allows us to clean up the analysis driver.

I will NOT land this without your review.

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

Review URL: https://codereview.chromium.org/2445193003 .
2016-10-26 07:40:07 -07:00
Brian Wilkerson 785b949894 Improve error recovery (issue 27646)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2444453002 .
2016-10-21 12:36:01 -07:00
Paul Berry 396d7862b4 More improvements to DeclarationResolver.
This CL makes the following improvements:

- When visiting an executable element, local variables and labels are
  rebuilt rather than matching them up to the old element model.  This
  ensures that if the element model was resynthesized from an API
  summary (which doesn't contain local variables or labels), these
  elements are not lost.

- When matching up existing elements, if the elements did not
  previously contain offsets, offsets are recorded.  If they did
  previously contain offsets, the offsets are compared to verify that
  they match.  This ensures that if the element model was
  resynthesized from an API summary (which doesn't contain offsets),
  the offsets will be correct.

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

Review URL: https://codereview.chromium.org/2435313002 .
2016-10-21 11:13:55 -07:00
Vyacheslav Egorov 1f6e03883e Teach analyzer parser to handle native const factories/const constructors.
This is needed to parse VM patch files, which contain things like:

@patch const factory String.fromEnvironment(String name,
                                              {String defaultValue})
      native "String_fromEnvironment";

Currently analyzer would throw "Only redirecting factory constructors can be
declared to be 'const'." error when it sees this code.

BUG=
R=paulberry@google.com

Review URL: https://codereview.chromium.org/2435013003 .
2016-10-20 20:09:07 +02:00
Konstantin Shcheglov bf43e4b43e Validate local resolution scope, and compute initial name scope.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2439583003 .
2016-10-19 14:08:46 -07:00
Konstantin Shcheglov 38e2b55fff Implement 'local' mode in TypeResolverVisitor.
If we start resolution not from CompilationUnit, we need to put type
parameters into scopes. This is not implemented yet.

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

Review URL: https://codereview.chromium.org/2432273003 .
2016-10-19 09:47:40 -07:00
Konstantin Shcheglov b64e116422 Add TypeResolverMode and implement 'api' in TypeResolverVisitor.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2428233002 .
2016-10-18 19:31:14 -07:00
Konstantin Shcheglov 13d2420a3d Extract ElementBuilder tests into a separate file.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2430723002 .
2016-10-18 10:22:45 -07:00
Konstantin Shcheglov e1f8a0a103 Begin separating API and local element builders.
I will write separate tests for them and do some more clean up in
separate CLs.

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

Review URL: https://codereview.chromium.org/2425853003 .
2016-10-18 08:22:30 -07:00
Brian Wilkerson 724ac40b8d Improve error messages and add many corrections
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2426583003 .
2016-10-17 10:40:43 -07:00
Brian Wilkerson 3155b1e08c Remove unused method and field from DartSdkManager
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2415413003 .
2016-10-14 09:53:44 -07:00
Lasse R.H. Nielsen efb9a12811 Add = as default-value separator for named parameters.
Fixes issue #27559.

BUG= http://dartbug.com/27559
R=asiva@google.com, eernst@google.com, floitsch@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/2411633002 .
2016-10-14 11:25:25 +02:00
Brian Wilkerson 1a893edb82 Add prefix to path import to work around breaking change
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2411423003 .
2016-10-13 08:29:09 -07:00
Paul Berry cf5f9e0a38 Move class DeclarationResolver to its own file.
Auxiliary classes ElementGatherer, ElementMismatchException, and
ExistingElementResolver, which were only used by DeclarationResolver,
are also moved.

(No functional change; just code motion).

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/2406863003 .
2016-10-10 11:43:26 -07:00
Konstantin Shcheglov 4511504171 Implement BazelPackageUriResolver.restoreAbsolute().
It is mostly tested with the same tests as for resolveAbsolute().

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

Review URL: https://codereview.chromium.org/2403733002 .
2016-10-10 08:16:00 -07:00
Konstantin Shcheglov 78051dc47d Add more tests for BazelPackageUriResolver.resolveAbsolute().
Create separate set of resources in each test in order to simplify the
tests.

Fix the case when files are generated for third_party/dart/XXX.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/2403723002 .
2016-10-09 14:40:18 -07:00
Brian Wilkerson 789fd11ebf Get more tests passing on windows
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2397933006 .
2016-10-08 11:09:20 -07: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
Konstantin Shcheglov 51f617c0d3 Automatically identify the workspace suffix for READONLY.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2406603002 .
2016-10-07 14:24:10 -07:00
Konstantin Shcheglov 5e5f3cfa60 Automatically detect 'blaze' or 'bazel' symlink prefix.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2401993002 .
2016-10-07 13:08:13 -07:00
Konstantin Shcheglov 84b1a98173 Replace BazelWorkspace factory with the static 'find' method.
This is a breaking change:

1. The factory constructor was removed.
2. The method find() may return null.

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

Review URL: https://codereview.chromium.org/2402713002 .
2016-10-07 10:15:32 -07:00
Konstantin Shcheglov f63b3d3e7b Add BazelPackageUriResolver with resolveAbsolute().
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2393963004 .
2016-10-07 09:19:53 -07:00
Konstantin Shcheglov 59e8af7047 Report CompileTimeErrorCode.DUPLICATE_PART when not only URI, but even Source is the same.
There is one usecase when strongly speaking the error should not be
reported - when the part is empty. But that still does not seem practical.

R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/27509

Review URL: https://codereview.chromium.org/2401783002 .
2016-10-06 20:44:28 -07:00
Paul Berry f9c819057b Fix null reference issues in bazel.dart.
There were two issues:

- We were trying to use `parent` before null checking it.

- In the event that no workspace root could be found, we were returning
  `null` from the BazelWorkspace factory constructor.  This CL changes
  the behavior so that we return a BazelWorkspace that has no special
  bin or genfiles behaviors.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/2394213002 .
2016-10-06 14:21:17 -07:00
Brian Wilkerson 6de0803deb Clean up hints
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2394733004 .
2016-10-06 12:59:38 -07:00
Konstantin Shcheglov 26cc95d8b4 Issue 27515. Report DUPLICATE_PART when the same library contains two part directives with the same URI.
R=brianwilkerson@google.com, paulberry@google.com
BUG= https://github.com/dart-lang/sdk/issues/27515

Review URL: https://codereview.chromium.org/2401463004 .
2016-10-06 11:28:05 -07:00
Brian Wilkerson 2328bef00b Fix more tests on windows bots
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2398113002 .
2016-10-06 10:21:01 -07:00
Konstantin Shcheglov 5455fd0118 Remove 'initializeTestEnvironment' from 'analyzer'.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2399913002 .
2016-10-06 10:18:54 -07:00
Konstantin Shcheglov 175dad4f15 Switch 'analyzer' to 'package:test' and test_reflective_loader ^0.1.0.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2391423003 .
2016-10-06 08:46:35 -07:00
Konstantin Shcheglov 8a3d8eee67 Add BazelWorkspace and move BazelFileUriResolver to it.
R=brianwilkerson@google.com, jwren@google.com
BUG=

Review URL: https://codereview.chromium.org/2393813003 .
2016-10-05 18:08:07 -07:00
Brian Wilkerson a52e53a3b2 Fix BazelFileUriResolver tests
R=jwren@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/2392133002 .
2016-10-04 14:17:18 -07:00
Brian Wilkerson db73915c77 More fixes for testing under windows
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2393663002 .
2016-10-04 13:11:57 -07:00
Brian Wilkerson 154bd389db Fix some failures on the windows bots
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2392793003 .
2016-10-04 08:21:28 -07:00
Brian Wilkerson 29c5c9985e Remove JavaFile.pathContext
R=scheglov@google.com

Review URL: https://codereview.chromium.org/2386123004 .
2016-10-03 19:28:49 -07:00
John Messerly 5c9e12497e fix #27135 and fix #27449 strong mode does not use propagated types
R=leafp@google.com

Review URL: https://codereview.chromium.org/2380863003 .
2016-09-29 00:14:07 -07:00
Konstantin Shcheglov 3f6afd8cf5 Add tests for resolveRelativeUri() and a workaround.
The actual problem should be fixed in SDKs Uri implementation.
https://github.com/dart-lang/sdk/issues/27447

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/2376073003 .
2016-09-28 13:20:26 -07:00
Konstantin Shcheglov 85d3aff259 Issue 25706. Fix for resolving '@prefix.ClassName.staticVariable.'.
R=brianwilkerson@google.com, paulberry@google.com
BUG= https://github.com/dart-lang/sdk/issues/25706

Review URL: https://codereview.chromium.org/2376463002 .
2016-09-26 10:59:40 -07:00
Lasse R.H. Nielsen 574ae435f3 Allow surrogates in string literals.
Fixes issue #26620
BUG: http://dartbug.com/26620

R=asiva@google.com, brianwilkerson@google.com, floitsch@google.com, hausner@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/2304923002 .
2016-09-26 13:23:41 +02:00
Konstantin Shcheglov 0223b08a34 Issue 27300. Report HintCode.ABSTRACT_SUPER_MEMBER_REFERENCE. (Land again)
The pkg/analysis_server/test/integration/analysis/error_test was fixed.

R=brianwilkerson@google.com, paulberry@google.com
BUG= https://github.com/dart-lang/sdk/issues/27300

Review URL: https://codereview.chromium.org/2366963002 .
2016-09-23 10:21:21 -07:00
Paul Berry fe2c152ee2 Revert "Issue 27300. Report HintCode.ABSTRACT_SUPER_MEMBER_REFERENCE."
This broke the analyzer bots.  See for example https://build.chromium.org/p/client.dart/builders/analyzer-mac10.11-release-be/builds/337/steps/analysis%20server%20unit%20tests/logs/stdio

This reverts commit 77ba5fd087.

TBR=scheglov@google.com

Review URL: https://codereview.chromium.org/2361393002 .
2016-09-23 05:24:53 -07:00