Comments (6)
from sdk.
Some quick debugging shows that there are no drivers in driversMap when empty data[] is returned, but there is driver when it starts to show up:
from sdk.
Creating the analysis roots is async, so at the time the request is being handled they probably haven't been set up yet.
Probably the fix will be something like changing this direct call to server.getResolvedUnit()
:
To instead use requireResolvedUnit
which wraps it, but in the case where context roots are being set up, will wait for them to complete:
sdk/pkg/analysis_server/lib/src/lsp/handlers/handlers.dart
Lines 207 to 215 in 43fa0e0
That method treats errors slightly differently though so it might need a little tweaking to ensure requests for semantic tokens for non-Dart files or files that legitimately aren't analyzed are handled correctly.
from sdk.
Indeed this dirty fix helped. Thanks! (not sure how to make it better so that it can be merged, so just leaving here for now).
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_semantic_tokens.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_semantic_tokens.dart
index 1a0e4da212d..740df9aaea5 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_semantic_tokens.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_semantic_tokens.dart
@@ -32,8 +32,11 @@ abstract class AbstractSemanticTokensHandler<T>
Future<List<SemanticTokenInfo>> getServerResult(
String path, SourceRange? range) async {
- var result = await server.getResolvedUnit(path);
- var unit = result?.unit;
+ var result = await requireResolvedUnit(path);
+ if (result.isError) {
+ return [];
+ }
+ var unit = result.resultOrNull?.unit;
if (unit != null) {
var computer = DartUnitHighlightsComputer(unit, range: range);
return computer.computeSemanticTokens();
from sdk.
Thanks for confirming - I'll open a change for this (w/ some tests) soon.
from sdk.
Got a fix open at https://dart-review.googlesource.com/c/sdk/+/369464
from sdk.
Related Issues (20)
- Improve `dart:developer` Timeline API HOT 1
- Even though the types match, the analyzer still reports a type mismatch, but there are no errors at runtime HOT 3
- [vm/core] Inlining `_GrowableList.add` bloats program too much HOT 4
- vm/dart/isolates/shared_primitives_test changing from flaky to RTE on vm-reload-linux-debug-x64 HOT 2
- [diagnostic] don't report `DUPLICATE_FIELD_NAME` if the name is invalid
- Refactoring to convert params/args between positional and named HOT 2
- Analyzer exception doesn't specify affected file HOT 3
- VM always prints "<isolate> has no debugger is attached and is paused"
- [dart2wasm] UnimplementedError when calling Flutter's Matrix4.translate with an integer argument HOT 2
- `where` can't accept an async predicate HOT 6
- [Augmentations] Wrong error in the analyzer when augmenting enum member
- [Augmentations] No error in the analyzer when augmenting a function type with no augmented type
- [Augmentations] No error in analyzer for mixin and extension when augmentation is before original declaration HOT 1
- [Augmentations] Analyzer crash on co19/LanguageFeatures/Augmentation-libraries/augmenting_types_A01_t01
- [Augmentations] Analyzer error when augmenting representation variable
- [Augmentations] Omitted type bound is not inherited
- [Augmentations] No error in the analyzer if augmentation declares a different return type HOT 2
- The integer negative zero formats as "-0.0" HOT 7
- [dart2js] bug in global inference with `call` getter HOT 1
- DevTools URI opens to a white screen
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.