Comments (15)
@bwilkerson @pq I dug into this a little but I don't understand enough to know what the problem/fix is.
What seems to happen is that when we're building the context roots, we get into ContextBuilderImpl.createContext
and try to build analysisOptionsMap
here:
In the implementation of _createOptionsMap
it finds the package include, and tries to resolve it using sourceFactory.resolveUri()
to get the target file. However, sourceFactory.resolveUri
returns null
because the package map is empty.
That source factory was created here from the workspace:
But I feel like there is a mismatch here. The "workspace" here seems to correspond to the root folder opened in my IDE (the analysis root sent by the client), which is C:\dev\root
here. But the context being built is for C:\dev\root\package_a
so the package:
URI should be resolved based on that packages package_config, and not the root folder (which doesn't have a package config in this case).
So I feel like the fix is to change ContextBuilderImpl.createContext
in some way so that it's using the package map for the context it's building (and not the root) when building the options file. Probably you two are more familiar with this code than I am though. I'll open a CL with my failing test for now in case it's easier for someone else to debug/fix.
It's possible this is also the cause of #55732.
from sdk.
Labels: area-analyzer
, type-bug
Summary: The include:
directive in analysis_options.yaml
is not working as expected in VS Code. While the dart analyze
command correctly identifies linting issues based on the included configuration, VS Code does not show these findings. This issue has been encountered in multiple repositories, leading to the workaround of copying the entire configuration instead of using include:
.
from sdk.
@davidmorgan can you confirm what commit I can use to repro this? I checked out your add-schema-and-codegen
branch (346ae07) but I see different errors to what you mentioned above (and the same in VS Code + terminal):
from sdk.
Oh, I see you pushed a fix for it. I reverted that fix, but I do see the avoid_dynamic_calls
showing up in VS Code:
Can you confirm which folder you have opened in VS Code, and whether the package is correctly in tool/dart_mdeol_generator/.dart_tool/package_config.json
? Mine looks like:
{
"name": "dart_flutter_team_lints",
"rootUri": "file:///C:/Users/danny/AppData/Local/Pub/Cache/hosted/pub.dev/dart_flutter_team_lints-3.1.0",
"packageUri": "lib/",
"languageVersion": "3.4"
},
from sdk.
I tried opening a simpler workspace that just has the macros folder
code --remote [email protected] /usr/local/google/home/davidmorgan/git/macros
but no difference, the lint config still seems to be missing. Here's ~/git/macros/tool/dart_model_generator/.dart_tool/package_config.json
:
{
"name": "dart_flutter_team_lints",
"rootUri": "file:///usr/local/google/home/davidmorgan/.pub-cache/hosted/pub.dev/dart_flutter_team_lints-3.1.0",
"packageUri": "lib/",
"languageVersion": "3.4"
},
It's possible I have a bad dart version, I'm using the SDK from main from the last time I happened to build it, I can try with a known-good SDK version if that helps. Thanks :)
from sdk.
I was using a new bleeding-edge build I just grabbed from https://gsdview.appspot.com/dart-archive/channels/be/raw/latest/sdk/
Can you reproduce it without the SSH? I doubt it's related, but since we're seeing different behaviour it'd be good to eliminate some variables.
from sdk.
Oh, interesting, local version works straight away
code /usr/local/google/home/davidmorgan/git/macros
both local and remote are on the same VSCode version
1.87.1
1e790d77f81672c49be070e04474901747115651
x64
and I don't see anything suspicious in the remote settings.
Ooookay it gets even more interesting! I downloaded an SDK from the link you gave, and with that both work. But that's quite an old SDK? It's from Nov 2023.
If I instead use a more recent one from https://gsdview.appspot.com/dart-archive/channels/main/raw/latest/sdk/ then again I see local VSCode works but remote doesn't.
So it looks like it is related to some change in the SDK.
from sdk.
I downloaded an SDK from the link you gave, and with that both work. But that's quite an old SDK? It's from Nov 2023.
Oh, I messed up here.. Firstly, I downloaded a new SDK but was actually still set to use the stable SDK. Secondly, I pasted a bad link here - I got the SDK from https://gsdview.appspot.com/dart-archive/channels/main/raw/latest/sdk/ (be
changed to main
in the URL some time ago) but I replied to you from another machine that had a stable bookmark.
So, I properly updated to the bleeding edge SDK I said I was using, and I do not see the lint. But I don't see it either in VS Code or dart analyze
:
I don't know why your results are less consistent, but I can at least try looking into the cause of this.
from sdk.
It seems to be triggered by having another project in the workspace.
I've reduced it to this... two projects in the workspace. One has a violation for that lint and the other has no code. Both of them import the lints.
Analyzing the offending project on its own (both by opening it in VS Code itself, or dart analyze
on it) results in the lint diagnostic. Analyzing the parent folder that also includes the other (empty) project results in no lint warning (again, from VS Code or dart analyze
).
This is running on current bleeding-edge code.
from sdk.
Ah, I should have said, I was running "dart analyze" from inside tool/dart_model_generator
, not from the top level.
I'm not actually sure what "dart analyze" is supposed to do if run from a folder enclosing multiple packages? From the "macros" folder:
dart --version
Dart SDK version: 3.5.0-edge (main) (Unknown timestamp) on "linux_x64"
dart analyze
--> no issues found
dart analyze tool/dart_model_generator
--> does find issues!
which matches: with bleeding edge Dart, if I open VSCode remote to "macros" which has two packages, no lint is reported; if I open it to "macros/tool/dart_model_generator" which is just one package, the lint is reported.
from sdk.
I'm not actually sure what "dart analyze" is supposed to do if run from a folder enclosing multiple packages?
I would expect it to analyze everything, though I'm not certain (@bwilkerson?). Though the behaviour is the same in VS Code and still broken - if I open the one project I see the lint failure, and if I open the parent I do not. It should definitely work in that case.
I think I've managed to reproduce this in a test, will continue debugging.
from sdk.
@davidmorgan I updated the issue title to match what I believe to be the issue here.
which matches: with bleeding edge Dart, if I open VSCode remote to "macros" which has two packages, no lint is reported; if I open it to "macros/tool/dart_model_generator" which is just one package, the lint is reported.
It turns out that you don't even need a second project to repro this (besides the one being imported). I reduced my repo to just this:
If you open the package itself, everything works - I believe .dart_tool/package_config.json
is used to resolve package:dart_flutter_team_lints
in the analysis_options. However, if you open the parent folder (even if that folder contains nothing else except this project), then package:dart_flutter_team_lints
in the analysis_options does not resolve (because it's not using the package map from the nested project folder), and therefore the lint doesn't get included in the set for that projects context.
Let me know if you're seeing any behaviour that doesn't seem to match this, in case I discovered a slightly different bug to the one you're seeing 😄 (I did re-test with macros and that does seem to match for me though).
from sdk.
Yes, that looks like a minimal repro of what I'm seeing. Thanks :)
from sdk.
I bisected across old SDK versions, looks like the issue is with "multi-option contexts" turned on here
if I set the constant back to true
it works as expected, both the CLI and in VSCode. @pq
from sdk.
I'm not actually sure what "dart analyze" is supposed to do if run from a folder enclosing multiple packages?
I would expect it to analyze everything ...
So would I. Running dart analyze
(without a file path) on the command line ought to be equivalent, in terms of analyzed files, to opening the working directory in an IDE.
from sdk.
Related Issues (20)
- [dartdev] `Could not find dart. Have you built the full Dart SDK?` on `dart build` HOT 10
- [infra] More frequent dev releases HOT 1
- Consider dropping instructions after return, throw, unreachable, br in wasm_builder
- Consider optimizing `x < 0 || x > positiveInt` to single unsigned comparison
- Support `Add null check` fix for entire file HOT 4
- Failures on [dart2wasm] Use unsafeCast in a few places...Reland "[vm] Move `ResolveUri` to bin" HOT 3
- Analyzer data-based fix request HOT 2
- `dart compile js` fails with the newest SDK HOT 17
- Cannot resolve top-level methods with docimports HOT 4
- [Wildcard Variables] Update `DUPLICATE_DEFINTION` reporting
- CFE fails to report error when `super` is used in a redirecting constructor. HOT 2
- DevTools not serving properly on app refresh HOT 1
- [Wildcard Variables] Update `DUPLICATE_FIELD_FORMAL_PARAMETER` reporting
- `@internal` annotation does not supress `public_member_api_docs` lint on functions HOT 1
- Dart analyzer does not infer the correct type for generic record HOT 2
- Having true cancelable future HOT 2
- Simplify branch conditions based on ranges & simplify control flow afterwards if condition turns out to be constant
- Issue in number multiplication with 10, 20, etc HOT 4
- Feature Request: Add `--insert-ignore-comments` flag to `dart fix` command for existing code HOT 3
- [vm/core] `_GrowableList.add` has unnecessary bounds check HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk.