Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webstorm indexing and invalidation of generated implementations. #495

Closed
rayk opened this issue Aug 31, 2018 · 5 comments
Closed

Webstorm indexing and invalidation of generated implementations. #495

rayk opened this issue Aug 31, 2018 · 5 comments
Assignees
Labels

Comments

@rayk
Copy link

rayk commented Aug 31, 2018

High Probability this issue does not belong here, but it may be falling through the crack across a number different projects.

Setup:
pubspec.yaml

environment:
  sdk: '>=2.0.0 <3.0.0'

dependencies:
  angular: ^5.0.0
  angular_components: ^0.9.0
  angular_forms: ^2.0.0
  angular_router: ^2.0.0-alpha+19
  built_redux: 7.4.5
  chartjs: ^0.5.0
  firebase: ^5.0.1
  googleapis_auth: ^0.2.5+2
  intl: 0.15.7
  json_annotation: ^1.0.0
  logging: ^0.11.3+2
  meta: ^1.1.6
  optional: ^3.0.0+2
  pub_semver: ^1.4.2
  service_worker: ^0.2.3
  time_machine: ^0.9.4
  uuid: ^1.0.3


dev_dependencies:
  angular_test: ^2.0.0
  build_runner: ^0.10.1
  build_test: ^0.10.2
  build_web_compilers: ^0.4.0
  built_collection: '>=2.0.0 <4.0.0'
  built_value: '>=5.5.5 <7.0.0'
  built_value_generator: ^6.0.0
  json_serializable: ^1.0.0
  quiver: '>=0.21.0 <3.0.0'
  sass_builder: ^2.0.0
  test: ^1.3.0

IDE
Webstorm-2018.2.2 & EAP 2018.2.3

Situation

During a development workflow, it's not uncommon to create a new value object or modify an existing one, for example, the abstract below:

library app_instance;

import 'package:built_value/built_value.dart';
import 'package:time_machine/time_machine.dart';
import 'package:pub_semver/pub_semver.dart';
import '../services/environment/service.dart';


part 'app_instance.g.dart';

abstract class  AppInstance  implements Built<AppInstance, AppInstanceBuilder> {

  AppInstance._();

  /// Constructor Factory, for building the class.
  factory AppInstance([dynamic updates(AppInstanceBuilder b)]) = _$AppInstance;

  factory AppInstance.fromEnvironment() {
    return AppInstance((b) => b
      ..codeVersion = EnvironmentService.appVersion
      ..runningAs = EnvironmentService.runningIn
      ..instanceId = "alskdj"
      ..appLabel = EnvironmentService.appLabel
    );

  }

  /// The highest version number supported by the code.
  @memoized
  Version get codeVersion;

  /// Which mode the application is running in.
  @memoized
  RuntimeMode get runningAs;

  /// Unique instance finger print.
  @memoized
  String get instanceId;

  /// Application Name.
  @memoized
  String get appLabel;

}

One can then run pub run builder_runner build, which works perfectly fine and produce that beautiful implementation of the abstract. 🥇

Here is the rub, webstorm/dart analyzer does not appear to immediately recognize the generated file, in the case of the above app_instance.g.dart, it is visible in the directory tree, with red squiggly line.

The underlying generated implementation class is fine; it is just not indexed.

The Workaround
One merely has to restart the IDE & invalidate the webstrom cache, using the menu option provided in webstrom.

Shortcomings
The above is very heavy handled given the regularity that one creates and changes value objects.

Is it your Environment
Have eliminated this by reproducing the issue in different containers and clean Mac OSX 10.13.6 environment.

Other Sightings
There appears to other issues with similar favours, hence the broad filling of this issue.

flutter/flutter#17353
dart-lang/sdk#34139

Also does not appear to any related issue on the webstorm forums.

@davidmorgan
Copy link
Collaborator

Thanks for reporting.

One question, does it work to synchronize the project? (On my setup, Ctrl+Q).

@rayk
Copy link
Author

rayk commented Aug 31, 2018

Should have mentioned that synchronize, does cause the generated.g.dart file to appear in the project panel, but not with indexing. That is to say that I see the file in the tree, but when I attempt to MyGeneratedObject((b) => b ..someProp) webStorm/Analyzer puts the red squiggly line under the someProp with the message the setter is not defined for MyGeneratedObject. ("It actually is generated, I can open the .g.dart file and see it).

Hope this helps....

@rayk
Copy link
Author

rayk commented Aug 31, 2018

More Info

I can also confirm that restarting the Dart Analysis Server, solves the issue... As a workaround that's much better (quicker) then invaliding the caches.

@davidmorgan
Copy link
Collaborator

Interesting. If it's visible in intellij but not picked up by the analyzer, then that sounds like an analyzer issue.

If I understand correctly the analyzer is supposed to watch for file changes. What operating system are you on? I think that code is OS-dependent.

I suggest filing over at https://github.com/dart-lang/sdk/tree/master/pkg/analyzer

@rayk
Copy link
Author

rayk commented Sep 3, 2018

The plot thickens. I shall file in the analyzer project... Thanks for the input...

Happy for this one to be closed...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants