This does not remove the computation of available declarations. This CL
seemed big enough without that, so I (or someone else) can get that in
the next CL.
Change-Id: I67ab49b75c8a415ccfaef16c4e49a00026a6091f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Sorry for the long CL; once again I couldn't find a reasonable way to
split it up into smaller pieces.
This CL causes all of the elements from imports to be generated by the
new approach.
It does contain a new flag that is used to preserve the current
semantics when computing completions for Cider. I hope to be able to
make the new approach efficient enough that we can remove this flag,
but I can't realistically do that until more of the approach is
implemented.
I'm also not fond of the way it fails to handle conflicts in the import
scope. There's a TODO marking the places that would need to be changed,
but the current behavior is that if the same name N is imported from
two or more imports and they refer to different elements, the first one
found will be suggested and others won't. I don't think we want to
suggest any of them unless we also fix the imports so that the name
won't be conflicting. I'm not sure how we want to do that, but it needs
to work with whatever optimization approach we choose.
I think the changes to the tests are all positive, but please double
check that I haven't missed a good reason for the previous behavior.
Change-Id: I70d4514a67988f654984ac20f33b2d7a3cfc78e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/340282
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Sorry for the length of the CL. I couldn't really think of a good way
to split it up further.
The first pass was previously suggesting everything declared in scopes
below the class level. This CL expands that to include everything
declared in the current library. It does not include imported
declarations. It also doesn't yet handle members suggested after a
period. Those are both being handled by constributors.
Please look over the tests carefully. There are more changes than I
would have liked, although I think they're mostly for the better (as
in, the suggestions are more accurate), but I could easily have
missed an invalid change.
Change-Id: I98b3cfc8440ee5da09a8e6828c946d65d8d77759
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/338482
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
I'm fairly sure the failing tests are recent breakages. I was only able
to break it without noticing because we didn't have adequate testing.
The next CL should fix the tests.
Change-Id: I69f5fde6e7cd2e872b2ffab38905467d366caa9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336625
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
+ remove legacy functions
Some of these tests still use `indexOf` to find positions (like `rangeAtSearch`) that could perhaps be changed to use ranges marked in the code too, however I'm not sure if that'll make them more readable and this CL ended up already being a little larger than originally planned.
Change-Id: If23b712134171c9d716aa0585045489d109fb39a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333923
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
No functional changes, just moves the snippets tests and a few others off the old marker functions to the new TestCode class for consistency.
With this change, there are approximately 15 remaining instances of "withoutMarkers" to remove (inc. the declaration).
Change-Id: I7f11992bb9ce47740adf6972ed097cabbd011607
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333520
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Sharing the visibility tracker this way prevents shadowed elements from
being suggested and improves performance.
Most of these changes can be reverted once the local reference
contributor has been removed.
Change-Id: Ib156ae56455e8d85a31163f9e59ce4dd93f5920b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333124
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
I found the old style of tests difficult to read and even harder to
debug, so I decided to convert them. Fortunately, a small conversion
program did most of the work.
I didn't change the actual test code except in a couple of places where
the tests were failing because the test code produced diagnostics beyond
those expected for incomplete code (such as unreferenced variables).
As much as possible I kept the original pass/fail sense of the test.
There were a few tests that were failing because the expectations were
just wrong, so in those cases I allowed the test to pass with the right
expectations. I tried to verify the expectations of the tests, but I'm
sure I missed some.
Change-Id: I80b7f914e75012562d3423cc6eb242bb8be11cc1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331215
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
We already supported moving a single folder, which we expanded to each file inside it. This adds support for moving multiple distinct items at the same time (eg. dragging multiple files).
To support this, we need to track a full mapping of source/destination paths (because files might be moved from different levels into the same level - we can't compute destination paths from a single `newFile` variable), and also build a unique set of references that need updating (rather than building edits as we go - where we might try to edit the same reference from both ends).
Fixes https://github.com/Dart-Code/Dart-Code/issues/4533
This is currently only supported for LSP.
Change-Id: I3a8ab8b2dcb13451111d38d2ec0e2f69d6084e28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329320
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Makes behaviour of changing leading indent or trailing newlines opt-in.
There are only slightly more uses of this method that don't want this (now opt-in) behaviour, although I think this is slightly less surprising (for example the trailing newline behaviour was to "add a trailing newline only if it didn't already exist" which I don't think was obvious).
Mostly this was just changing the defaults and all of the call sites. However, some call sites were getting the old behaviour (inc leading/trailing whitespace), but then calling `.trim()`, so I didn't add the opt-in there because it would then be removed (they won't show up in the diff because they didn't actually get any changes).
Change-Id: I2f05b3a6266aaad5ee510ce2a8bf269b26d42d5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Fixes some cases where the same keyword was being suggested twice
because we were completing at the beginning of a statement which can
also be the beginning of an expression.
Change-Id: I7c12da8caed14438f9f1a16fa7121d1cbd96b891
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328769
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
The original goal of this change was to add the `switchExpression` test in `flutter_wrap_center_test.dart`, but it failed on Windows and exposed a bug that affected a number of assists/fixes.
The issue was that indentation was being rewritten using a regex:
src.replaceAll(RegExp('^$indentOld', multiLine: true), indentNew)
On Windows, when `indentOld` is an empty string, both `\r` and `\n` are matched individually, resulting in indentation being inserted between them:
foo\r \n bar
To fix this, I changed all places using a regex for replacement like this to call the existing `CorrectionUtils.replaceSourceIndent` method which did not have this problem. However, it made two different assumptions:
1. Indentation should always be updated on the first line (which if `indentOld` is an empty string, results in extra unwanted indentation being prepended to the string)
2. A new EOL should always be added at the end of the new code
To handle this, I added two new parameters and kept the original behaviour the same (although, I'm not sure if defaulting to adding a newline makes a lot of sense).
Change-Id: Ifa714da62c2541ba54a5376aa67149c90396dec2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328220
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Sorry about the size of the change.
This started as a CL to move the computation of keywords with a record
pattern from the contributor to the pass. In the process of doing so I
realized that the previous computation of the completion node (the node
that's visited) was too aggressive about moving upward in the AST. I
believe the issue happens when we reach a node in a list of similar
nodes (such as a statement in a block).
I changed the computation of the completion node, which necessitated a
lot of changes to existing code. It also resulted in changing several
tests, most for the better I think, but please look carefully for
places where you think the changes aren't reasonable. I'm also
interested in feedback about the change to the computation of the
completion node.
Change-Id: I2c6ac76fe88f672a206c3692d9ff51d2e487ec0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324620
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>