Skip to content

Webstorm indexing and invalidation of generated implementations. #495

Closed
@rayk

Description

@rayk

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions