diff --git a/.github/workflows/health.yaml b/.github/workflows/health.yaml new file mode 100644 index 00000000..b684ae67 --- /dev/null +++ b/.github/workflows/health.yaml @@ -0,0 +1,15 @@ +name: Health +on: + pull_request: + branches: [ main ] + paths: + - .github/workflows/record_use.yaml + - pkgs/record_use/** + types: [opened, synchronize, reopened, labeled, unlabeled] +jobs: + health: + uses: dart-lang/ecosystem/.github/workflows/health.yaml@main + with: + coverage_web: false + permissions: + pull-requests: write diff --git a/.github/workflows/post_summaries.yaml b/.github/workflows/post_summaries.yaml new file mode 100644 index 00000000..8697d74a --- /dev/null +++ b/.github/workflows/post_summaries.yaml @@ -0,0 +1,17 @@ +name: Comment on the pull request + +on: + # Trigger this workflow after the Health workflow completes. This workflow will have permissions to + # do things like create comments on the PR, even if the original workflow couldn't. + workflow_run: + workflows: + - Health + - Publish + types: + - completed + +jobs: + upload: + uses: dart-lang/ecosystem/.github/workflows/post_summaries.yaml@main + permissions: + pull-requests: write diff --git a/.github/workflows/record_use.yaml b/.github/workflows/record_use.yaml new file mode 100644 index 00000000..05a2cc8f --- /dev/null +++ b/.github/workflows/record_use.yaml @@ -0,0 +1,39 @@ +name: 'package:record_use' +permissions: read-all + +on: + pull_request: + branches: [ main ] + paths: + - .github/workflows/record_use.yaml + - pkgs/record_use/** + push: + branches: [ main ] + paths: + - .github/workflows/record_use.yaml + - pkgs/record_use/** + schedule: + - cron: '0 0 * * 0' # weekly + +jobs: + build: + runs-on: ubuntu-latest + defaults: + run: + working-directory: pkgs/record_use/ + strategy: + matrix: + sdk: [stable, dev] + steps: + - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 + - uses: dart-lang/setup-dart@2986c8e337a31eb7b455ce93dc984e9bf5797756 + with: + sdk: ${{matrix.sdk}} + + - run: dart pub get + + - run: dart analyze --fatal-infos + + - run: dart format --output=none --set-exit-if-changed . + + - run: dart test diff --git a/README.md b/README.md index 2fbc6037..411a98e0 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This repository is home to various Dart packages under the [dart.dev](https://pu ## Packages | Package | Description | Version | -|---|---|---| +|[`record_use`](pkgs/record_use/)| The serialization logic and API for the usage recording SDK feature.|[![pub package](https://img.shields.io/pub/v/record_use.svg)](https://pub.dev/packages/record_use)| ## Publishing automation diff --git a/pkgs/placeholder b/pkgs/placeholder deleted file mode 100644 index e69de29b..00000000 diff --git a/pkgs/record_use/.gitignore b/pkgs/record_use/.gitignore new file mode 100644 index 00000000..3cceda55 --- /dev/null +++ b/pkgs/record_use/.gitignore @@ -0,0 +1,7 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock diff --git a/pkgs/record_use/CHANGELOG.md b/pkgs/record_use/CHANGELOG.md new file mode 100644 index 00000000..a0712a79 --- /dev/null +++ b/pkgs/record_use/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.1.0 + +- Initial version. diff --git a/pkgs/record_use/LICENSE b/pkgs/record_use/LICENSE new file mode 100644 index 00000000..b03a7886 --- /dev/null +++ b/pkgs/record_use/LICENSE @@ -0,0 +1,27 @@ +Copyright 2024, the Dart project authors. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google LLC nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/pkgs/record_use/README.md b/pkgs/record_use/README.md new file mode 100644 index 00000000..ea1872ac --- /dev/null +++ b/pkgs/record_use/README.md @@ -0,0 +1,116 @@ +# `package:record_use` + + +> [!CAUTION] +> This is an experimental package, and it's API can break at any time. Use at +> your own discretion. + +This package provides the data classes for the usage recording feature in the +Dart SDK. + +Dart objects with the `@RecordUse` annotation are being recorded at compile +time, providing the user with information. The information depends on the object +being recorded. + +- If placed on a static method, the annotation means that arguments passed to +the method will be recorded, as far as they can be inferred at compile time. +- If placed on a class with a constant constructor, the annotation means that +any constant instance of the class will be recorded. This is particularly useful +when using the class as an annotation. + +## Example + +```dart +import 'package:meta/meta.dart' show RecordUse; + +void main() { + print(SomeClass.stringMetadata(42)); + print(SomeClass.doubleMetadata(42)); + print(SomeClass.intMetadata(42)); + print(SomeClass.boolMetadata(42)); +} + +class SomeClass { + @RecordMetadata('leroyjenkins') + @RecordUse() + static stringMetadata(int i) { + return i + 1; + } + + @RecordMetadata(3.14) + @RecordUse() + static doubleMetadata(int i) { + return i + 1; + } + + @RecordMetadata(42) + @RecordUse() + static intMetadata(int i) { + return i + 1; + } + + @RecordMetadata(true) + @RecordUse() + static boolMetadata(int i) { + return i + 1; + } +} + +@RecordUse() +class RecordMetadata { + final Object metadata; + + const RecordMetadata(this.metadata); +} + +``` +This code will generate a data file that contains both the `metadata` values of +the `RecordMetadata` instances, as well as the arguments for the different +methods annotated with `@RecordUse()`. + +This information can then be accessed in a link hook as follows: +```dart +import 'package:native_assets_cli/native_assets_cli.dart'; + +void main(List arguments){ + link(arguments, (config, output) async { + final uses = config.recordedUses; + + final args = uses.constArgumentsTo(boolMetadataId)); + //[args] is an iterable of arguments, in this case containing "42" + + final fields = uses.instanceReferencesTo(recordMetadataId); + //[fields] is an iterable of the fields of the class, in this case + //containing + // {"arguments": "leroyjenkins"} + // {"arguments": 3.14} + // {"arguments": 42} + // {"arguments": true} + + ... // Do something with the information, such as tree-shaking native assets + }); +} +``` + +## Installation +To install the record_use package, run the following command: + +```bash +dart pub add record_use +``` + +## Internals + +The data is stored in protobuf format. Two schemas are provided: + +### [usages_read](lib/src/proto/usages_read.proto) +This is the schema for the internal API for the storage format, which is used +in the SDK for writing the data, and in the [record_use](lib/src/record_use.dart) format for retrieving the +data for the queries from the user. + +### [usages_storage](lib/src/proto/usages_storage.proto) +This schema is for the storage of the data, and contains some optimizations such +as collecting all URIs in a table, to avoid repetitions. + +## Contributing +Contributions are welcome! Please open an issue or submit a pull request. \ No newline at end of file diff --git a/pkgs/record_use/analysis_options.yaml b/pkgs/record_use/analysis_options.yaml new file mode 100644 index 00000000..8b87070d --- /dev/null +++ b/pkgs/record_use/analysis_options.yaml @@ -0,0 +1,13 @@ +analyzer: + exclude: + - lib/src/proto/** + +include: package:dart_flutter_team_lints/analysis_options.yaml + +linter: + rules: + - conditional_uri_does_not_exist + - prefer_const_constructors + - prefer_final_locals + - prefer_relative_imports + - unnecessary_parenthesis diff --git a/pkgs/record_use/example/record_use_example.dart b/pkgs/record_use/example/record_use_example.dart new file mode 100644 index 00000000..c5fb7c26 --- /dev/null +++ b/pkgs/record_use/example/record_use_example.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:record_use/record_use.dart'; + +void doStuff(RecordedUsages usage, Identifier callId, Identifier referenceId) { + print(usage.version); + print(usage.constArgumentsTo(callId)); + print(usage.instanceReferencesTo(referenceId)); + print(usage.hasNonConstArguments(callId)); +} diff --git a/pkgs/record_use/lib/record_use.dart b/pkgs/record_use/lib/record_use.dart new file mode 100644 index 00000000..7b40776a --- /dev/null +++ b/pkgs/record_use/lib/record_use.dart @@ -0,0 +1,5 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +export 'src/record_use.dart' show Identifier, RecordedUsages; diff --git a/pkgs/record_use/lib/record_use_internal.dart b/pkgs/record_use/lib/record_use_internal.dart new file mode 100644 index 00000000..c5127a1f --- /dev/null +++ b/pkgs/record_use/lib/record_use_internal.dart @@ -0,0 +1,7 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +export 'src/data_classes/extensions.dart'; +export 'src/proto/usages_read.pb.dart'; +export 'src/proto/usages_shared.pb.dart'; diff --git a/pkgs/record_use/lib/src/data_classes/extensions.dart b/pkgs/record_use/lib/src/data_classes/extensions.dart new file mode 100644 index 00000000..1264a8c3 --- /dev/null +++ b/pkgs/record_use/lib/src/data_classes/extensions.dart @@ -0,0 +1,147 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:convert'; +import 'dart:typed_data'; + +import '../proto/usages_read.pb.dart' as pb; +import '../proto/usages_shared.pb.dart' as pb_shared; +import '../proto/usages_storage.pb.dart' as pb_storage; + +extension UsagesExt on pb.Usages { + Uint8List toBuffer() => _toStorage().writeToBuffer(); + String toDebugJson() => + const JsonEncoder.withIndent(' ').convert(_toStorage().writeToJsonMap()); + + pb_storage.Usages _toStorage() { + final usageList = [...calls, ...instances]; + final uris = usageList + .expand((usage) => [ + usage.definition.identifier.uri, + ...usage.references.map((reference) => reference.location.uri) + ]) + .toSet() + .toList(); + final definitions = usageList + .map((usage) => usage.definition.toStorage(uris)) + .toSet() + .toList(); + return pb_storage.Usages( + metadata: metadata, + definitions: definitions, + uris: uris, + instances: + instances.map((instance) => instance.toStorage(definitions, uris)), + calls: calls.map((call) => call.toStorage(definitions, uris)), + ); + } +} + +extension UsageExt on pb.Usage { + pb_storage.Usage toStorage( + List definitions, List uris) => + pb_storage.Usage( + definition: definitions.indexOf(definition.toStorage(uris)), + references: references.map((e) => e.toStorage(uris)), + ); +} + +extension ReferenceExt on pb.Reference { + pb_storage.Reference toStorage(List uris) => pb_storage.Reference( + arguments: hasArguments() ? arguments : null, + fields: hasFields() ? fields : null, + loadingUnit: loadingUnit, + location: location.toStorage(uris), + ); +} + +extension LocationExt on pb.Location { + pb_storage.Location toStorage(List uris) => pb_storage.Location( + column: column, + line: line, + uri: uris.indexOf(uri), + ); +} + +extension DefinitionExt on pb.Definition { + pb_storage.Definition toStorage(List uris) => pb_storage.Definition( + identifier: identifier.toStorage(uris), + column: column, + line: line, + loadingUnit: hasLoadingUnit() ? loadingUnit : null, + ); +} + +extension IdentifierExt on pb.Identifier { + pb_storage.Identifier toStorage(List uris) => pb_storage.Identifier( + name: name, + parent: hasParent() ? parent : null, + uri: uris.indexOf(uri), + ); +} + +extension UsagesStorageExt on pb_storage.Usages { + pb.Usages toApi() => pb.Usages( + metadata: metadata, + calls: calls.map((e) => e.toApi(definitions, uris)), + instances: instances.map((e) => e.toApi(definitions, uris)), + ); +} + +extension UsageStorageExt on pb_storage.Usage { + pb.Usage toApi(List definitions, List uris) => + pb.Usage( + definition: definitions[definition].toApi(uris), + references: references.map((e) => e.toApi(uris)), + ); +} + +extension ReferenceStorageExt on pb_storage.Reference { + pb.Reference toApi(List uris) => pb.Reference( + arguments: hasArguments() ? arguments : null, + fields: hasFields() ? fields : null, + loadingUnit: loadingUnit, + location: location.toApi(uris), + ); +} + +extension LocationStorageExt on pb_storage.Location { + pb.Location toApi(List uris) => pb.Location( + column: column, + line: line, + uri: uris[uri], + ); +} + +extension DefinitionStorageExt on pb_storage.Definition { + pb.Definition toApi(List uris) => pb.Definition( + identifier: identifier.toApi(uris), + column: column, + line: line, + loadingUnit: hasLoadingUnit() ? loadingUnit : null, + ); +} + +extension IdentifierStorageExt on pb_storage.Identifier { + pb.Identifier toApi(List uris) => pb.Identifier( + name: name, + parent: hasParent() ? parent : null, + uri: uris[uri], + ); +} + +extension FieldValueExt on pb_shared.FieldValue { + Object toObject() => switch (whichValue()) { + pb_shared.FieldValue_Value.mapValue => + mapValue.value.map((key, value) => MapEntry(key, value.toObject())), + pb_shared.FieldValue_Value.listValue => + listValue.value.map((e) => e.toObject()), + pb_shared.FieldValue_Value.intValue => intValue, + pb_shared.FieldValue_Value.doubleValue => doubleValue, + pb_shared.FieldValue_Value.boolValue => boolValue, + pb_shared.FieldValue_Value.stringValue => stringValue, + pb_shared.FieldValue_Value.nullValue => nullValue, + pb_shared.FieldValue_Value.notSet => throw UnimplementedError(), + }; +} diff --git a/pkgs/record_use/lib/src/proto/usages_read.pb.dart b/pkgs/record_use/lib/src/proto/usages_read.pb.dart new file mode 100644 index 00000000..5d897d07 --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_read.pb.dart @@ -0,0 +1,602 @@ +// +// Generated code. Do not modify. +// source: usages_read.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +import 'usages_shared.pb.dart' as $0; + +class Usages extends $pb.GeneratedMessage { + factory Usages({ + $0.Metadata? metadata, + $core.Iterable? calls, + $core.Iterable? instances, + }) { + final $result = create(); + if (metadata != null) { + $result.metadata = metadata; + } + if (calls != null) { + $result.calls.addAll(calls); + } + if (instances != null) { + $result.instances.addAll(instances); + } + return $result; + } + Usages._() : super(); + factory Usages.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Usages.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Usages', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..aOM<$0.Metadata>(1, _omitFieldNames ? '' : 'metadata', + subBuilder: $0.Metadata.create) + ..pc(4, _omitFieldNames ? '' : 'calls', $pb.PbFieldType.PM, + subBuilder: Usage.create) + ..pc(5, _omitFieldNames ? '' : 'instances', $pb.PbFieldType.PM, + subBuilder: Usage.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Usages clone() => Usages()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Usages copyWith(void Function(Usages) updates) => + super.copyWith((message) => updates(message as Usages)) as Usages; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Usages create() => Usages._(); + Usages createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Usages getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Usages? _defaultInstance; + + @$pb.TagNumber(1) + $0.Metadata get metadata => $_getN(0); + @$pb.TagNumber(1) + set metadata($0.Metadata v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasMetadata() => $_has(0); + @$pb.TagNumber(1) + void clearMetadata() => clearField(1); + @$pb.TagNumber(1) + $0.Metadata ensureMetadata() => $_ensure(0); + + @$pb.TagNumber(4) + $core.List get calls => $_getList(1); + + @$pb.TagNumber(5) + $core.List get instances => $_getList(2); +} + +class Usage extends $pb.GeneratedMessage { + factory Usage({ + Definition? definition, + $core.Iterable? references, + }) { + final $result = create(); + if (definition != null) { + $result.definition = definition; + } + if (references != null) { + $result.references.addAll(references); + } + return $result; + } + Usage._() : super(); + factory Usage.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Usage.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Usage', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'definition', + subBuilder: Definition.create) + ..pc(2, _omitFieldNames ? '' : 'references', $pb.PbFieldType.PM, + subBuilder: Reference.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Usage clone() => Usage()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Usage copyWith(void Function(Usage) updates) => + super.copyWith((message) => updates(message as Usage)) as Usage; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Usage create() => Usage._(); + Usage createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Usage getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Usage? _defaultInstance; + + @$pb.TagNumber(1) + Definition get definition => $_getN(0); + @$pb.TagNumber(1) + set definition(Definition v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasDefinition() => $_has(0); + @$pb.TagNumber(1) + void clearDefinition() => clearField(1); + @$pb.TagNumber(1) + Definition ensureDefinition() => $_ensure(0); + + @$pb.TagNumber(2) + $core.List get references => $_getList(1); +} + +class Location extends $pb.GeneratedMessage { + factory Location({ + $core.String? uri, + $core.int? line, + $core.int? column, + }) { + final $result = create(); + if (uri != null) { + $result.uri = uri; + } + if (line != null) { + $result.line = line; + } + if (column != null) { + $result.column = column; + } + return $result; + } + Location._() : super(); + factory Location.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Location.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Location', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'uri') + ..a<$core.int>(2, _omitFieldNames ? '' : 'line', $pb.PbFieldType.OU3) + ..a<$core.int>(3, _omitFieldNames ? '' : 'column', $pb.PbFieldType.OU3) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Location clone() => Location()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Location copyWith(void Function(Location) updates) => + super.copyWith((message) => updates(message as Location)) as Location; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Location create() => Location._(); + Location createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Location getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Location? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get uri => $_getSZ(0); + @$pb.TagNumber(1) + set uri($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasUri() => $_has(0); + @$pb.TagNumber(1) + void clearUri() => clearField(1); + + @$pb.TagNumber(2) + $core.int get line => $_getIZ(1); + @$pb.TagNumber(2) + set line($core.int v) { + $_setUnsignedInt32(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasLine() => $_has(1); + @$pb.TagNumber(2) + void clearLine() => clearField(2); + + @$pb.TagNumber(3) + $core.int get column => $_getIZ(2); + @$pb.TagNumber(3) + set column($core.int v) { + $_setUnsignedInt32(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasColumn() => $_has(2); + @$pb.TagNumber(3) + void clearColumn() => clearField(3); +} + +enum Reference_Reference { arguments, fields, notSet } + +class Reference extends $pb.GeneratedMessage { + factory Reference({ + Location? location, + $core.String? loadingUnit, + $0.Arguments? arguments, + $0.Fields? fields, + }) { + final $result = create(); + if (location != null) { + $result.location = location; + } + if (loadingUnit != null) { + $result.loadingUnit = loadingUnit; + } + if (arguments != null) { + $result.arguments = arguments; + } + if (fields != null) { + $result.fields = fields; + } + return $result; + } + Reference._() : super(); + factory Reference.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Reference.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static const $core.Map<$core.int, Reference_Reference> + _Reference_ReferenceByTag = { + 3: Reference_Reference.arguments, + 4: Reference_Reference.fields, + 0: Reference_Reference.notSet + }; + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Reference', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..oo(0, [3, 4]) + ..aOM(1, _omitFieldNames ? '' : 'location', + subBuilder: Location.create) + ..aOS(2, _omitFieldNames ? '' : 'loadingUnit') + ..aOM<$0.Arguments>(3, _omitFieldNames ? '' : 'arguments', + subBuilder: $0.Arguments.create) + ..aOM<$0.Fields>(4, _omitFieldNames ? '' : 'fields', + subBuilder: $0.Fields.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Reference clone() => Reference()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Reference copyWith(void Function(Reference) updates) => + super.copyWith((message) => updates(message as Reference)) as Reference; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Reference create() => Reference._(); + Reference createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Reference getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Reference? _defaultInstance; + + Reference_Reference whichReference() => + _Reference_ReferenceByTag[$_whichOneof(0)]!; + void clearReference() => clearField($_whichOneof(0)); + + @$pb.TagNumber(1) + Location get location => $_getN(0); + @$pb.TagNumber(1) + set location(Location v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasLocation() => $_has(0); + @$pb.TagNumber(1) + void clearLocation() => clearField(1); + @$pb.TagNumber(1) + Location ensureLocation() => $_ensure(0); + + @$pb.TagNumber(2) + $core.String get loadingUnit => $_getSZ(1); + @$pb.TagNumber(2) + set loadingUnit($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasLoadingUnit() => $_has(1); + @$pb.TagNumber(2) + void clearLoadingUnit() => clearField(2); + + @$pb.TagNumber(3) + $0.Arguments get arguments => $_getN(2); + @$pb.TagNumber(3) + set arguments($0.Arguments v) { + setField(3, v); + } + + @$pb.TagNumber(3) + $core.bool hasArguments() => $_has(2); + @$pb.TagNumber(3) + void clearArguments() => clearField(3); + @$pb.TagNumber(3) + $0.Arguments ensureArguments() => $_ensure(2); + + @$pb.TagNumber(4) + $0.Fields get fields => $_getN(3); + @$pb.TagNumber(4) + set fields($0.Fields v) { + setField(4, v); + } + + @$pb.TagNumber(4) + $core.bool hasFields() => $_has(3); + @$pb.TagNumber(4) + void clearFields() => clearField(4); + @$pb.TagNumber(4) + $0.Fields ensureFields() => $_ensure(3); +} + +class Definition extends $pb.GeneratedMessage { + factory Definition({ + Identifier? identifier, + $core.int? line, + $core.int? column, + $core.String? loadingUnit, + }) { + final $result = create(); + if (identifier != null) { + $result.identifier = identifier; + } + if (line != null) { + $result.line = line; + } + if (column != null) { + $result.column = column; + } + if (loadingUnit != null) { + $result.loadingUnit = loadingUnit; + } + return $result; + } + Definition._() : super(); + factory Definition.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Definition.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Definition', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'identifier', + subBuilder: Identifier.create) + ..a<$core.int>(2, _omitFieldNames ? '' : 'line', $pb.PbFieldType.OU3) + ..a<$core.int>(3, _omitFieldNames ? '' : 'column', $pb.PbFieldType.OU3) + ..aOS(4, _omitFieldNames ? '' : 'loadingUnit') + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Definition clone() => Definition()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Definition copyWith(void Function(Definition) updates) => + super.copyWith((message) => updates(message as Definition)) as Definition; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Definition create() => Definition._(); + Definition createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Definition getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static Definition? _defaultInstance; + + @$pb.TagNumber(1) + Identifier get identifier => $_getN(0); + @$pb.TagNumber(1) + set identifier(Identifier v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasIdentifier() => $_has(0); + @$pb.TagNumber(1) + void clearIdentifier() => clearField(1); + @$pb.TagNumber(1) + Identifier ensureIdentifier() => $_ensure(0); + + @$pb.TagNumber(2) + $core.int get line => $_getIZ(1); + @$pb.TagNumber(2) + set line($core.int v) { + $_setUnsignedInt32(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasLine() => $_has(1); + @$pb.TagNumber(2) + void clearLine() => clearField(2); + + @$pb.TagNumber(3) + $core.int get column => $_getIZ(2); + @$pb.TagNumber(3) + set column($core.int v) { + $_setUnsignedInt32(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasColumn() => $_has(2); + @$pb.TagNumber(3) + void clearColumn() => clearField(3); + + @$pb.TagNumber(4) + $core.String get loadingUnit => $_getSZ(3); + @$pb.TagNumber(4) + set loadingUnit($core.String v) { + $_setString(3, v); + } + + @$pb.TagNumber(4) + $core.bool hasLoadingUnit() => $_has(3); + @$pb.TagNumber(4) + void clearLoadingUnit() => clearField(4); +} + +class Identifier extends $pb.GeneratedMessage { + factory Identifier({ + $core.String? uri, + $core.String? parent, + $core.String? name, + }) { + final $result = create(); + if (uri != null) { + $result.uri = uri; + } + if (parent != null) { + $result.parent = parent; + } + if (name != null) { + $result.name = name; + } + return $result; + } + Identifier._() : super(); + factory Identifier.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Identifier.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Identifier', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'uri') + ..aOS(2, _omitFieldNames ? '' : 'parent') + ..aOS(3, _omitFieldNames ? '' : 'name') + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Identifier clone() => Identifier()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Identifier copyWith(void Function(Identifier) updates) => + super.copyWith((message) => updates(message as Identifier)) as Identifier; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Identifier create() => Identifier._(); + Identifier createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Identifier getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static Identifier? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get uri => $_getSZ(0); + @$pb.TagNumber(1) + set uri($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasUri() => $_has(0); + @$pb.TagNumber(1) + void clearUri() => clearField(1); + + @$pb.TagNumber(2) + $core.String get parent => $_getSZ(1); + @$pb.TagNumber(2) + set parent($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasParent() => $_has(1); + @$pb.TagNumber(2) + void clearParent() => clearField(2); + + @$pb.TagNumber(3) + $core.String get name => $_getSZ(2); + @$pb.TagNumber(3) + set name($core.String v) { + $_setString(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasName() => $_has(2); + @$pb.TagNumber(3) + void clearName() => clearField(3); +} + +const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); +const _omitMessageNames = + $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/pkgs/record_use/lib/src/proto/usages_read.pbenum.dart b/pkgs/record_use/lib/src/proto/usages_read.pbenum.dart new file mode 100644 index 00000000..2abf009c --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_read.pbenum.dart @@ -0,0 +1,10 @@ +// +// Generated code. Do not modify. +// source: usages_read.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import diff --git a/pkgs/record_use/lib/src/proto/usages_read.pbjson.dart b/pkgs/record_use/lib/src/proto/usages_read.pbjson.dart new file mode 100644 index 00000000..d6de7a6c --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_read.pbjson.dart @@ -0,0 +1,191 @@ +// +// Generated code. Do not modify. +// source: usages_read.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:convert' as $convert; +import 'dart:core' as $core; +import 'dart:typed_data' as $typed_data; + +@$core.Deprecated('Use usagesDescriptor instead') +const Usages$json = { + '1': 'Usages', + '2': [ + { + '1': 'metadata', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages_shared.Metadata', + '10': 'metadata' + }, + { + '1': 'calls', + '3': 4, + '4': 3, + '5': 11, + '6': '.usages.Usage', + '10': 'calls' + }, + { + '1': 'instances', + '3': 5, + '4': 3, + '5': 11, + '6': '.usages.Usage', + '10': 'instances' + }, + ], +}; + +/// Descriptor for `Usages`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List usagesDescriptor = $convert.base64Decode( + 'CgZVc2FnZXMSMwoIbWV0YWRhdGEYASABKAsyFy51c2FnZXNfc2hhcmVkLk1ldGFkYXRhUghtZX' + 'RhZGF0YRIjCgVjYWxscxgEIAMoCzINLnVzYWdlcy5Vc2FnZVIFY2FsbHMSKwoJaW5zdGFuY2Vz' + 'GAUgAygLMg0udXNhZ2VzLlVzYWdlUglpbnN0YW5jZXM='); + +@$core.Deprecated('Use usageDescriptor instead') +const Usage$json = { + '1': 'Usage', + '2': [ + { + '1': 'definition', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages.Definition', + '10': 'definition' + }, + { + '1': 'references', + '3': 2, + '4': 3, + '5': 11, + '6': '.usages.Reference', + '10': 'references' + }, + ], +}; + +/// Descriptor for `Usage`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List usageDescriptor = $convert.base64Decode( + 'CgVVc2FnZRIyCgpkZWZpbml0aW9uGAEgASgLMhIudXNhZ2VzLkRlZmluaXRpb25SCmRlZmluaX' + 'Rpb24SMQoKcmVmZXJlbmNlcxgCIAMoCzIRLnVzYWdlcy5SZWZlcmVuY2VSCnJlZmVyZW5jZXM='); + +@$core.Deprecated('Use locationDescriptor instead') +const Location$json = { + '1': 'Location', + '2': [ + {'1': 'uri', '3': 1, '4': 1, '5': 9, '10': 'uri'}, + {'1': 'line', '3': 2, '4': 1, '5': 13, '10': 'line'}, + {'1': 'column', '3': 3, '4': 1, '5': 13, '10': 'column'}, + ], +}; + +/// Descriptor for `Location`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List locationDescriptor = $convert.base64Decode( + 'CghMb2NhdGlvbhIQCgN1cmkYASABKAlSA3VyaRISCgRsaW5lGAIgASgNUgRsaW5lEhYKBmNvbH' + 'VtbhgDIAEoDVIGY29sdW1u'); + +@$core.Deprecated('Use referenceDescriptor instead') +const Reference$json = { + '1': 'Reference', + '2': [ + { + '1': 'location', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages.Location', + '10': 'location' + }, + {'1': 'loading_unit', '3': 2, '4': 1, '5': 9, '10': 'loadingUnit'}, + { + '1': 'arguments', + '3': 3, + '4': 1, + '5': 11, + '6': '.usages_shared.Arguments', + '9': 0, + '10': 'arguments' + }, + { + '1': 'fields', + '3': 4, + '4': 1, + '5': 11, + '6': '.usages_shared.Fields', + '9': 0, + '10': 'fields' + }, + ], + '8': [ + {'1': 'reference'}, + ], +}; + +/// Descriptor for `Reference`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List referenceDescriptor = $convert.base64Decode( + 'CglSZWZlcmVuY2USLAoIbG9jYXRpb24YASABKAsyEC51c2FnZXMuTG9jYXRpb25SCGxvY2F0aW' + '9uEiEKDGxvYWRpbmdfdW5pdBgCIAEoCVILbG9hZGluZ1VuaXQSOAoJYXJndW1lbnRzGAMgASgL' + 'MhgudXNhZ2VzX3NoYXJlZC5Bcmd1bWVudHNIAFIJYXJndW1lbnRzEi8KBmZpZWxkcxgEIAEoCz' + 'IVLnVzYWdlc19zaGFyZWQuRmllbGRzSABSBmZpZWxkc0ILCglyZWZlcmVuY2U='); + +@$core.Deprecated('Use definitionDescriptor instead') +const Definition$json = { + '1': 'Definition', + '2': [ + { + '1': 'identifier', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages.Identifier', + '10': 'identifier' + }, + {'1': 'line', '3': 2, '4': 1, '5': 13, '10': 'line'}, + {'1': 'column', '3': 3, '4': 1, '5': 13, '10': 'column'}, + { + '1': 'loading_unit', + '3': 4, + '4': 1, + '5': 9, + '9': 0, + '10': 'loadingUnit', + '17': true + }, + ], + '8': [ + {'1': '_loading_unit'}, + ], +}; + +/// Descriptor for `Definition`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List definitionDescriptor = $convert.base64Decode( + 'CgpEZWZpbml0aW9uEjIKCmlkZW50aWZpZXIYASABKAsyEi51c2FnZXMuSWRlbnRpZmllclIKaW' + 'RlbnRpZmllchISCgRsaW5lGAIgASgNUgRsaW5lEhYKBmNvbHVtbhgDIAEoDVIGY29sdW1uEiYK' + 'DGxvYWRpbmdfdW5pdBgEIAEoCUgAUgtsb2FkaW5nVW5pdIgBAUIPCg1fbG9hZGluZ191bml0'); + +@$core.Deprecated('Use identifierDescriptor instead') +const Identifier$json = { + '1': 'Identifier', + '2': [ + {'1': 'uri', '3': 1, '4': 1, '5': 9, '10': 'uri'}, + {'1': 'parent', '3': 2, '4': 1, '5': 9, '9': 0, '10': 'parent', '17': true}, + {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, + ], + '8': [ + {'1': '_parent'}, + ], +}; + +/// Descriptor for `Identifier`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List identifierDescriptor = $convert.base64Decode( + 'CgpJZGVudGlmaWVyEhAKA3VyaRgBIAEoCVIDdXJpEhsKBnBhcmVudBgCIAEoCUgAUgZwYXJlbn' + 'SIAQESEgoEbmFtZRgDIAEoCVIEbmFtZUIJCgdfcGFyZW50'); diff --git a/pkgs/record_use/lib/src/proto/usages_read.pbserver.dart b/pkgs/record_use/lib/src/proto/usages_read.pbserver.dart new file mode 100644 index 00000000..3231126d --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_read.pbserver.dart @@ -0,0 +1,13 @@ +// +// Generated code. Do not modify. +// source: usages_read.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names +// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +export 'usages_read.pb.dart'; diff --git a/pkgs/record_use/lib/src/proto/usages_read.proto b/pkgs/record_use/lib/src/proto/usages_read.proto new file mode 100644 index 00000000..f1c44f88 --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_read.proto @@ -0,0 +1,48 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +syntax = "proto3"; +package usages; + +import "usages_shared.proto"; + +message Usages { + usages_shared.Metadata metadata = 1; + repeated Usage calls = 4; + repeated Usage instances = 5; +} + +message Usage { + Definition definition = 1; + repeated Reference references = 2; +} + + +message Location { + string uri = 1; + uint32 line = 2; + uint32 column = 3; +} + +message Reference { + Location location = 1; + string loading_unit = 2; + oneof reference { + usages_shared.Arguments arguments = 3; + usages_shared.Fields fields = 4; + } +} + +message Definition { + Identifier identifier = 1; + uint32 line = 2; + uint32 column = 3; + optional string loading_unit = 4; // Optional, as some loading units are null +} + +message Identifier { + string uri = 1; + optional string parent = 2; + string name = 3; +} diff --git a/pkgs/record_use/lib/src/proto/usages_shared.pb.dart b/pkgs/record_use/lib/src/proto/usages_shared.pb.dart new file mode 100644 index 00000000..5961c534 --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_shared.pb.dart @@ -0,0 +1,757 @@ +// +// Generated code. Do not modify. +// source: usages_shared.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +class Metadata extends $pb.GeneratedMessage { + factory Metadata({ + $core.String? comment, + $core.String? version, + }) { + final $result = create(); + if (comment != null) { + $result.comment = comment; + } + if (version != null) { + $result.version = version; + } + return $result; + } + Metadata._() : super(); + factory Metadata.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Metadata.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Metadata', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'comment') + ..aOS(2, _omitFieldNames ? '' : 'version') + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Metadata clone() => Metadata()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Metadata copyWith(void Function(Metadata) updates) => + super.copyWith((message) => updates(message as Metadata)) as Metadata; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Metadata create() => Metadata._(); + Metadata createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Metadata getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Metadata? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get comment => $_getSZ(0); + @$pb.TagNumber(1) + set comment($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasComment() => $_has(0); + @$pb.TagNumber(1) + void clearComment() => clearField(1); + + @$pb.TagNumber(2) + $core.String get version => $_getSZ(1); + @$pb.TagNumber(2) + set version($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasVersion() => $_has(1); + @$pb.TagNumber(2) + void clearVersion() => clearField(2); +} + +class Fields extends $pb.GeneratedMessage { + factory Fields({ + $core.Iterable? fields, + }) { + final $result = create(); + if (fields != null) { + $result.fields.addAll(fields); + } + return $result; + } + Fields._() : super(); + factory Fields.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Fields.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Fields', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..pc(1, _omitFieldNames ? '' : 'fields', $pb.PbFieldType.PM, + subBuilder: Field.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Fields clone() => Fields()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Fields copyWith(void Function(Fields) updates) => + super.copyWith((message) => updates(message as Fields)) as Fields; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Fields create() => Fields._(); + Fields createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Fields getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Fields? _defaultInstance; + + @$pb.TagNumber(1) + $core.List get fields => $_getList(0); +} + +class Arguments extends $pb.GeneratedMessage { + factory Arguments({ + ConstArguments? constArguments, + NonConstArguments? nonConstArguments, + }) { + final $result = create(); + if (constArguments != null) { + $result.constArguments = constArguments; + } + if (nonConstArguments != null) { + $result.nonConstArguments = nonConstArguments; + } + return $result; + } + Arguments._() : super(); + factory Arguments.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Arguments.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Arguments', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'constArguments', + subBuilder: ConstArguments.create) + ..aOM(2, _omitFieldNames ? '' : 'nonConstArguments', + subBuilder: NonConstArguments.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Arguments clone() => Arguments()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Arguments copyWith(void Function(Arguments) updates) => + super.copyWith((message) => updates(message as Arguments)) as Arguments; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Arguments create() => Arguments._(); + Arguments createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Arguments getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Arguments? _defaultInstance; + + @$pb.TagNumber(1) + ConstArguments get constArguments => $_getN(0); + @$pb.TagNumber(1) + set constArguments(ConstArguments v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasConstArguments() => $_has(0); + @$pb.TagNumber(1) + void clearConstArguments() => clearField(1); + @$pb.TagNumber(1) + ConstArguments ensureConstArguments() => $_ensure(0); + + @$pb.TagNumber(2) + NonConstArguments get nonConstArguments => $_getN(1); + @$pb.TagNumber(2) + set nonConstArguments(NonConstArguments v) { + setField(2, v); + } + + @$pb.TagNumber(2) + $core.bool hasNonConstArguments() => $_has(1); + @$pb.TagNumber(2) + void clearNonConstArguments() => clearField(2); + @$pb.TagNumber(2) + NonConstArguments ensureNonConstArguments() => $_ensure(1); +} + +class ConstArguments extends $pb.GeneratedMessage { + factory ConstArguments({ + $core.Map<$core.int, FieldValue>? positional, + $core.Map<$core.String, FieldValue>? named, + }) { + final $result = create(); + if (positional != null) { + $result.positional.addAll(positional); + } + if (named != null) { + $result.named.addAll(named); + } + return $result; + } + ConstArguments._() : super(); + factory ConstArguments.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory ConstArguments.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'ConstArguments', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..m<$core.int, FieldValue>(1, _omitFieldNames ? '' : 'positional', + entryClassName: 'ConstArguments.PositionalEntry', + keyFieldType: $pb.PbFieldType.OU3, + valueFieldType: $pb.PbFieldType.OM, + valueCreator: FieldValue.create, + valueDefaultOrMaker: FieldValue.getDefault, + packageName: const $pb.PackageName('usages_shared')) + ..m<$core.String, FieldValue>(2, _omitFieldNames ? '' : 'named', + entryClassName: 'ConstArguments.NamedEntry', + keyFieldType: $pb.PbFieldType.OS, + valueFieldType: $pb.PbFieldType.OM, + valueCreator: FieldValue.create, + valueDefaultOrMaker: FieldValue.getDefault, + packageName: const $pb.PackageName('usages_shared')) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + ConstArguments clone() => ConstArguments()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + ConstArguments copyWith(void Function(ConstArguments) updates) => + super.copyWith((message) => updates(message as ConstArguments)) + as ConstArguments; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static ConstArguments create() => ConstArguments._(); + ConstArguments createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static ConstArguments getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static ConstArguments? _defaultInstance; + + @$pb.TagNumber(1) + $core.Map<$core.int, FieldValue> get positional => $_getMap(0); + + @$pb.TagNumber(2) + $core.Map<$core.String, FieldValue> get named => $_getMap(1); +} + +class NonConstArguments extends $pb.GeneratedMessage { + factory NonConstArguments({ + $core.Iterable<$core.int>? positional, + $core.Iterable<$core.String>? named, + }) { + final $result = create(); + if (positional != null) { + $result.positional.addAll(positional); + } + if (named != null) { + $result.named.addAll(named); + } + return $result; + } + NonConstArguments._() : super(); + factory NonConstArguments.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory NonConstArguments.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'NonConstArguments', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..p<$core.int>(1, _omitFieldNames ? '' : 'positional', $pb.PbFieldType.KU3) + ..pPS(2, _omitFieldNames ? '' : 'named') + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + NonConstArguments clone() => NonConstArguments()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + NonConstArguments copyWith(void Function(NonConstArguments) updates) => + super.copyWith((message) => updates(message as NonConstArguments)) + as NonConstArguments; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static NonConstArguments create() => NonConstArguments._(); + NonConstArguments createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static NonConstArguments getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static NonConstArguments? _defaultInstance; + + @$pb.TagNumber(1) + $core.List<$core.int> get positional => $_getList(0); + + @$pb.TagNumber(2) + $core.List<$core.String> get named => $_getList(1); +} + +class Field extends $pb.GeneratedMessage { + factory Field({ + $core.String? className, + $core.String? name, + FieldValue? value, + }) { + final $result = create(); + if (className != null) { + $result.className = className; + } + if (name != null) { + $result.name = name; + } + if (value != null) { + $result.value = value; + } + return $result; + } + Field._() : super(); + factory Field.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Field.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Field', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..aOS(1, _omitFieldNames ? '' : 'className') + ..aOS(2, _omitFieldNames ? '' : 'name') + ..aOM(3, _omitFieldNames ? '' : 'value', + subBuilder: FieldValue.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Field clone() => Field()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Field copyWith(void Function(Field) updates) => + super.copyWith((message) => updates(message as Field)) as Field; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Field create() => Field._(); + Field createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Field getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Field? _defaultInstance; + + @$pb.TagNumber(1) + $core.String get className => $_getSZ(0); + @$pb.TagNumber(1) + set className($core.String v) { + $_setString(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasClassName() => $_has(0); + @$pb.TagNumber(1) + void clearClassName() => clearField(1); + + @$pb.TagNumber(2) + $core.String get name => $_getSZ(1); + @$pb.TagNumber(2) + set name($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasName() => $_has(1); + @$pb.TagNumber(2) + void clearName() => clearField(2); + + @$pb.TagNumber(3) + FieldValue get value => $_getN(2); + @$pb.TagNumber(3) + set value(FieldValue v) { + setField(3, v); + } + + @$pb.TagNumber(3) + $core.bool hasValue() => $_has(2); + @$pb.TagNumber(3) + void clearValue() => clearField(3); + @$pb.TagNumber(3) + FieldValue ensureValue() => $_ensure(2); +} + +enum FieldValue_Value { + mapValue, + listValue, + intValue, + doubleValue, + boolValue, + stringValue, + nullValue, + notSet +} + +class FieldValue extends $pb.GeneratedMessage { + factory FieldValue({ + StringMapValue? mapValue, + ListValue? listValue, + $core.int? intValue, + $core.double? doubleValue, + $core.bool? boolValue, + $core.String? stringValue, + $core.bool? nullValue, + }) { + final $result = create(); + if (mapValue != null) { + $result.mapValue = mapValue; + } + if (listValue != null) { + $result.listValue = listValue; + } + if (intValue != null) { + $result.intValue = intValue; + } + if (doubleValue != null) { + $result.doubleValue = doubleValue; + } + if (boolValue != null) { + $result.boolValue = boolValue; + } + if (stringValue != null) { + $result.stringValue = stringValue; + } + if (nullValue != null) { + $result.nullValue = nullValue; + } + return $result; + } + FieldValue._() : super(); + factory FieldValue.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory FieldValue.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static const $core.Map<$core.int, FieldValue_Value> _FieldValue_ValueByTag = { + 1: FieldValue_Value.mapValue, + 2: FieldValue_Value.listValue, + 3: FieldValue_Value.intValue, + 4: FieldValue_Value.doubleValue, + 5: FieldValue_Value.boolValue, + 6: FieldValue_Value.stringValue, + 7: FieldValue_Value.nullValue, + 0: FieldValue_Value.notSet + }; + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'FieldValue', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..oo(0, [1, 2, 3, 4, 5, 6, 7]) + ..aOM(1, _omitFieldNames ? '' : 'mapValue', + subBuilder: StringMapValue.create) + ..aOM(2, _omitFieldNames ? '' : 'listValue', + subBuilder: ListValue.create) + ..a<$core.int>(3, _omitFieldNames ? '' : 'intValue', $pb.PbFieldType.O3) + ..a<$core.double>( + 4, _omitFieldNames ? '' : 'doubleValue', $pb.PbFieldType.OD) + ..aOB(5, _omitFieldNames ? '' : 'boolValue') + ..aOS(6, _omitFieldNames ? '' : 'stringValue') + ..aOB(7, _omitFieldNames ? '' : 'nullValue') + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + FieldValue clone() => FieldValue()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + FieldValue copyWith(void Function(FieldValue) updates) => + super.copyWith((message) => updates(message as FieldValue)) as FieldValue; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static FieldValue create() => FieldValue._(); + FieldValue createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static FieldValue getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static FieldValue? _defaultInstance; + + FieldValue_Value whichValue() => _FieldValue_ValueByTag[$_whichOneof(0)]!; + void clearValue() => clearField($_whichOneof(0)); + + @$pb.TagNumber(1) + StringMapValue get mapValue => $_getN(0); + @$pb.TagNumber(1) + set mapValue(StringMapValue v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasMapValue() => $_has(0); + @$pb.TagNumber(1) + void clearMapValue() => clearField(1); + @$pb.TagNumber(1) + StringMapValue ensureMapValue() => $_ensure(0); + + @$pb.TagNumber(2) + ListValue get listValue => $_getN(1); + @$pb.TagNumber(2) + set listValue(ListValue v) { + setField(2, v); + } + + @$pb.TagNumber(2) + $core.bool hasListValue() => $_has(1); + @$pb.TagNumber(2) + void clearListValue() => clearField(2); + @$pb.TagNumber(2) + ListValue ensureListValue() => $_ensure(1); + + @$pb.TagNumber(3) + $core.int get intValue => $_getIZ(2); + @$pb.TagNumber(3) + set intValue($core.int v) { + $_setSignedInt32(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasIntValue() => $_has(2); + @$pb.TagNumber(3) + void clearIntValue() => clearField(3); + + @$pb.TagNumber(4) + $core.double get doubleValue => $_getN(3); + @$pb.TagNumber(4) + set doubleValue($core.double v) { + $_setDouble(3, v); + } + + @$pb.TagNumber(4) + $core.bool hasDoubleValue() => $_has(3); + @$pb.TagNumber(4) + void clearDoubleValue() => clearField(4); + + @$pb.TagNumber(5) + $core.bool get boolValue => $_getBF(4); + @$pb.TagNumber(5) + set boolValue($core.bool v) { + $_setBool(4, v); + } + + @$pb.TagNumber(5) + $core.bool hasBoolValue() => $_has(4); + @$pb.TagNumber(5) + void clearBoolValue() => clearField(5); + + @$pb.TagNumber(6) + $core.String get stringValue => $_getSZ(5); + @$pb.TagNumber(6) + set stringValue($core.String v) { + $_setString(5, v); + } + + @$pb.TagNumber(6) + $core.bool hasStringValue() => $_has(5); + @$pb.TagNumber(6) + void clearStringValue() => clearField(6); + + @$pb.TagNumber(7) + $core.bool get nullValue => $_getBF(6); + @$pb.TagNumber(7) + set nullValue($core.bool v) { + $_setBool(6, v); + } + + @$pb.TagNumber(7) + $core.bool hasNullValue() => $_has(6); + @$pb.TagNumber(7) + void clearNullValue() => clearField(7); +} + +class ListValue extends $pb.GeneratedMessage { + factory ListValue({ + $core.Iterable? value, + }) { + final $result = create(); + if (value != null) { + $result.value.addAll(value); + } + return $result; + } + ListValue._() : super(); + factory ListValue.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory ListValue.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'ListValue', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..pc(1, _omitFieldNames ? '' : 'value', $pb.PbFieldType.PM, + subBuilder: FieldValue.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + ListValue clone() => ListValue()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + ListValue copyWith(void Function(ListValue) updates) => + super.copyWith((message) => updates(message as ListValue)) as ListValue; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static ListValue create() => ListValue._(); + ListValue createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static ListValue getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static ListValue? _defaultInstance; + + @$pb.TagNumber(1) + $core.List get value => $_getList(0); +} + +class StringMapValue extends $pb.GeneratedMessage { + factory StringMapValue({ + $core.Map<$core.String, FieldValue>? value, + }) { + final $result = create(); + if (value != null) { + $result.value.addAll(value); + } + return $result; + } + StringMapValue._() : super(); + factory StringMapValue.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory StringMapValue.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'StringMapValue', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages_shared'), + createEmptyInstance: create) + ..m<$core.String, FieldValue>(1, _omitFieldNames ? '' : 'value', + entryClassName: 'StringMapValue.ValueEntry', + keyFieldType: $pb.PbFieldType.OS, + valueFieldType: $pb.PbFieldType.OM, + valueCreator: FieldValue.create, + valueDefaultOrMaker: FieldValue.getDefault, + packageName: const $pb.PackageName('usages_shared')) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + StringMapValue clone() => StringMapValue()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + StringMapValue copyWith(void Function(StringMapValue) updates) => + super.copyWith((message) => updates(message as StringMapValue)) + as StringMapValue; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static StringMapValue create() => StringMapValue._(); + StringMapValue createEmptyInstance() => create(); + static $pb.PbList createRepeated() => + $pb.PbList(); + @$core.pragma('dart2js:noInline') + static StringMapValue getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static StringMapValue? _defaultInstance; + + @$pb.TagNumber(1) + $core.Map<$core.String, FieldValue> get value => $_getMap(0); +} + +const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); +const _omitMessageNames = + $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/pkgs/record_use/lib/src/proto/usages_shared.pbenum.dart b/pkgs/record_use/lib/src/proto/usages_shared.pbenum.dart new file mode 100644 index 00000000..5b22f28b --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_shared.pbenum.dart @@ -0,0 +1,10 @@ +// +// Generated code. Do not modify. +// source: usages_shared.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import diff --git a/pkgs/record_use/lib/src/proto/usages_shared.pbjson.dart b/pkgs/record_use/lib/src/proto/usages_shared.pbjson.dart new file mode 100644 index 00000000..83601c8e --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_shared.pbjson.dart @@ -0,0 +1,292 @@ +// +// Generated code. Do not modify. +// source: usages_shared.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:convert' as $convert; +import 'dart:core' as $core; +import 'dart:typed_data' as $typed_data; + +@$core.Deprecated('Use metadataDescriptor instead') +const Metadata$json = { + '1': 'Metadata', + '2': [ + { + '1': 'comment', + '3': 1, + '4': 1, + '5': 9, + '9': 0, + '10': 'comment', + '17': true + }, + {'1': 'version', '3': 2, '4': 1, '5': 9, '10': 'version'}, + ], + '8': [ + {'1': '_comment'}, + ], +}; + +/// Descriptor for `Metadata`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List metadataDescriptor = $convert.base64Decode( + 'CghNZXRhZGF0YRIdCgdjb21tZW50GAEgASgJSABSB2NvbW1lbnSIAQESGAoHdmVyc2lvbhgCIA' + 'EoCVIHdmVyc2lvbkIKCghfY29tbWVudA=='); + +@$core.Deprecated('Use fieldsDescriptor instead') +const Fields$json = { + '1': 'Fields', + '2': [ + { + '1': 'fields', + '3': 1, + '4': 3, + '5': 11, + '6': '.usages_shared.Field', + '10': 'fields' + }, + ], +}; + +/// Descriptor for `Fields`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List fieldsDescriptor = $convert.base64Decode( + 'CgZGaWVsZHMSLAoGZmllbGRzGAEgAygLMhQudXNhZ2VzX3NoYXJlZC5GaWVsZFIGZmllbGRz'); + +@$core.Deprecated('Use argumentsDescriptor instead') +const Arguments$json = { + '1': 'Arguments', + '2': [ + { + '1': 'const_arguments', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages_shared.ConstArguments', + '10': 'constArguments' + }, + { + '1': 'non_const_arguments', + '3': 2, + '4': 1, + '5': 11, + '6': '.usages_shared.NonConstArguments', + '10': 'nonConstArguments' + }, + ], +}; + +/// Descriptor for `Arguments`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List argumentsDescriptor = $convert.base64Decode( + 'CglBcmd1bWVudHMSRgoPY29uc3RfYXJndW1lbnRzGAEgASgLMh0udXNhZ2VzX3NoYXJlZC5Db2' + '5zdEFyZ3VtZW50c1IOY29uc3RBcmd1bWVudHMSUAoTbm9uX2NvbnN0X2FyZ3VtZW50cxgCIAEo' + 'CzIgLnVzYWdlc19zaGFyZWQuTm9uQ29uc3RBcmd1bWVudHNSEW5vbkNvbnN0QXJndW1lbnRz'); + +@$core.Deprecated('Use constArgumentsDescriptor instead') +const ConstArguments$json = { + '1': 'ConstArguments', + '2': [ + { + '1': 'positional', + '3': 1, + '4': 3, + '5': 11, + '6': '.usages_shared.ConstArguments.PositionalEntry', + '10': 'positional' + }, + { + '1': 'named', + '3': 2, + '4': 3, + '5': 11, + '6': '.usages_shared.ConstArguments.NamedEntry', + '10': 'named' + }, + ], + '3': [ConstArguments_PositionalEntry$json, ConstArguments_NamedEntry$json], +}; + +@$core.Deprecated('Use constArgumentsDescriptor instead') +const ConstArguments_PositionalEntry$json = { + '1': 'PositionalEntry', + '2': [ + {'1': 'key', '3': 1, '4': 1, '5': 13, '10': 'key'}, + { + '1': 'value', + '3': 2, + '4': 1, + '5': 11, + '6': '.usages_shared.FieldValue', + '10': 'value' + }, + ], + '7': {'7': true}, +}; + +@$core.Deprecated('Use constArgumentsDescriptor instead') +const ConstArguments_NamedEntry$json = { + '1': 'NamedEntry', + '2': [ + {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + { + '1': 'value', + '3': 2, + '4': 1, + '5': 11, + '6': '.usages_shared.FieldValue', + '10': 'value' + }, + ], + '7': {'7': true}, +}; + +/// Descriptor for `ConstArguments`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List constArgumentsDescriptor = $convert.base64Decode( + 'Cg5Db25zdEFyZ3VtZW50cxJNCgpwb3NpdGlvbmFsGAEgAygLMi0udXNhZ2VzX3NoYXJlZC5Db2' + '5zdEFyZ3VtZW50cy5Qb3NpdGlvbmFsRW50cnlSCnBvc2l0aW9uYWwSPgoFbmFtZWQYAiADKAsy' + 'KC51c2FnZXNfc2hhcmVkLkNvbnN0QXJndW1lbnRzLk5hbWVkRW50cnlSBW5hbWVkGlgKD1Bvc2' + 'l0aW9uYWxFbnRyeRIQCgNrZXkYASABKA1SA2tleRIvCgV2YWx1ZRgCIAEoCzIZLnVzYWdlc19z' + 'aGFyZWQuRmllbGRWYWx1ZVIFdmFsdWU6AjgBGlMKCk5hbWVkRW50cnkSEAoDa2V5GAEgASgJUg' + 'NrZXkSLwoFdmFsdWUYAiABKAsyGS51c2FnZXNfc2hhcmVkLkZpZWxkVmFsdWVSBXZhbHVlOgI4' + 'AQ=='); + +@$core.Deprecated('Use nonConstArgumentsDescriptor instead') +const NonConstArguments$json = { + '1': 'NonConstArguments', + '2': [ + {'1': 'positional', '3': 1, '4': 3, '5': 13, '10': 'positional'}, + {'1': 'named', '3': 2, '4': 3, '5': 9, '10': 'named'}, + ], +}; + +/// Descriptor for `NonConstArguments`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List nonConstArgumentsDescriptor = $convert.base64Decode( + 'ChFOb25Db25zdEFyZ3VtZW50cxIeCgpwb3NpdGlvbmFsGAEgAygNUgpwb3NpdGlvbmFsEhQKBW' + '5hbWVkGAIgAygJUgVuYW1lZA=='); + +@$core.Deprecated('Use fieldDescriptor instead') +const Field$json = { + '1': 'Field', + '2': [ + {'1': 'class_name', '3': 1, '4': 1, '5': 9, '10': 'className'}, + {'1': 'name', '3': 2, '4': 1, '5': 9, '10': 'name'}, + { + '1': 'value', + '3': 3, + '4': 1, + '5': 11, + '6': '.usages_shared.FieldValue', + '10': 'value' + }, + ], +}; + +/// Descriptor for `Field`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List fieldDescriptor = $convert.base64Decode( + 'CgVGaWVsZBIdCgpjbGFzc19uYW1lGAEgASgJUgljbGFzc05hbWUSEgoEbmFtZRgCIAEoCVIEbm' + 'FtZRIvCgV2YWx1ZRgDIAEoCzIZLnVzYWdlc19zaGFyZWQuRmllbGRWYWx1ZVIFdmFsdWU='); + +@$core.Deprecated('Use fieldValueDescriptor instead') +const FieldValue$json = { + '1': 'FieldValue', + '2': [ + { + '1': 'map_value', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages_shared.StringMapValue', + '9': 0, + '10': 'mapValue' + }, + { + '1': 'list_value', + '3': 2, + '4': 1, + '5': 11, + '6': '.usages_shared.ListValue', + '9': 0, + '10': 'listValue' + }, + {'1': 'int_value', '3': 3, '4': 1, '5': 5, '9': 0, '10': 'intValue'}, + {'1': 'double_value', '3': 4, '4': 1, '5': 1, '9': 0, '10': 'doubleValue'}, + {'1': 'bool_value', '3': 5, '4': 1, '5': 8, '9': 0, '10': 'boolValue'}, + {'1': 'string_value', '3': 6, '4': 1, '5': 9, '9': 0, '10': 'stringValue'}, + {'1': 'null_value', '3': 7, '4': 1, '5': 8, '9': 0, '10': 'nullValue'}, + ], + '8': [ + {'1': 'value'}, + ], +}; + +/// Descriptor for `FieldValue`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List fieldValueDescriptor = $convert.base64Decode( + 'CgpGaWVsZFZhbHVlEjwKCW1hcF92YWx1ZRgBIAEoCzIdLnVzYWdlc19zaGFyZWQuU3RyaW5nTW' + 'FwVmFsdWVIAFIIbWFwVmFsdWUSOQoKbGlzdF92YWx1ZRgCIAEoCzIYLnVzYWdlc19zaGFyZWQu' + 'TGlzdFZhbHVlSABSCWxpc3RWYWx1ZRIdCglpbnRfdmFsdWUYAyABKAVIAFIIaW50VmFsdWUSIw' + 'oMZG91YmxlX3ZhbHVlGAQgASgBSABSC2RvdWJsZVZhbHVlEh8KCmJvb2xfdmFsdWUYBSABKAhI' + 'AFIJYm9vbFZhbHVlEiMKDHN0cmluZ192YWx1ZRgGIAEoCUgAUgtzdHJpbmdWYWx1ZRIfCgpudW' + 'xsX3ZhbHVlGAcgASgISABSCW51bGxWYWx1ZUIHCgV2YWx1ZQ=='); + +@$core.Deprecated('Use listValueDescriptor instead') +const ListValue$json = { + '1': 'ListValue', + '2': [ + { + '1': 'value', + '3': 1, + '4': 3, + '5': 11, + '6': '.usages_shared.FieldValue', + '10': 'value' + }, + ], +}; + +/// Descriptor for `ListValue`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List listValueDescriptor = $convert.base64Decode( + 'CglMaXN0VmFsdWUSLwoFdmFsdWUYASADKAsyGS51c2FnZXNfc2hhcmVkLkZpZWxkVmFsdWVSBX' + 'ZhbHVl'); + +@$core.Deprecated('Use stringMapValueDescriptor instead') +const StringMapValue$json = { + '1': 'StringMapValue', + '2': [ + { + '1': 'value', + '3': 1, + '4': 3, + '5': 11, + '6': '.usages_shared.StringMapValue.ValueEntry', + '10': 'value' + }, + ], + '3': [StringMapValue_ValueEntry$json], +}; + +@$core.Deprecated('Use stringMapValueDescriptor instead') +const StringMapValue_ValueEntry$json = { + '1': 'ValueEntry', + '2': [ + {'1': 'key', '3': 1, '4': 1, '5': 9, '10': 'key'}, + { + '1': 'value', + '3': 2, + '4': 1, + '5': 11, + '6': '.usages_shared.FieldValue', + '10': 'value' + }, + ], + '7': {'7': true}, +}; + +/// Descriptor for `StringMapValue`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List stringMapValueDescriptor = $convert.base64Decode( + 'Cg5TdHJpbmdNYXBWYWx1ZRI+CgV2YWx1ZRgBIAMoCzIoLnVzYWdlc19zaGFyZWQuU3RyaW5nTW' + 'FwVmFsdWUuVmFsdWVFbnRyeVIFdmFsdWUaUwoKVmFsdWVFbnRyeRIQCgNrZXkYASABKAlSA2tl' + 'eRIvCgV2YWx1ZRgCIAEoCzIZLnVzYWdlc19zaGFyZWQuRmllbGRWYWx1ZVIFdmFsdWU6AjgB'); diff --git a/pkgs/record_use/lib/src/proto/usages_shared.pbserver.dart b/pkgs/record_use/lib/src/proto/usages_shared.pbserver.dart new file mode 100644 index 00000000..567d265c --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_shared.pbserver.dart @@ -0,0 +1,13 @@ +// +// Generated code. Do not modify. +// source: usages_shared.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names +// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +export 'usages_shared.pb.dart'; diff --git a/pkgs/record_use/lib/src/proto/usages_shared.proto b/pkgs/record_use/lib/src/proto/usages_shared.proto new file mode 100644 index 00000000..e3284c1a --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_shared.proto @@ -0,0 +1,56 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +syntax = "proto3"; +package usages_shared; + +message Metadata { + optional string comment = 1; + string version = 2; +} + +message Fields { + repeated Field fields = 1; +} + +message Arguments { + ConstArguments const_arguments = 1; + NonConstArguments non_const_arguments = 2; +} + +message ConstArguments { + map positional = 1; + map named = 2; +} + +message NonConstArguments { + repeated uint32 positional = 1; + repeated string named = 2; +} + +message Field { + string class_name = 1; + string name = 2; + FieldValue value = 3; +} + +message FieldValue { + oneof value { + StringMapValue map_value = 1; + ListValue list_value = 2; + int32 int_value = 3; + double double_value = 4; + bool bool_value = 5; + string string_value = 6; + bool null_value = 7; + } +} + +message ListValue { + repeated FieldValue value = 1; +} + +message StringMapValue { + map value = 1; +} diff --git a/pkgs/record_use/lib/src/proto/usages_storage.pb.dart b/pkgs/record_use/lib/src/proto/usages_storage.pb.dart new file mode 100644 index 00000000..6087a26a --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_storage.pb.dart @@ -0,0 +1,617 @@ +// +// Generated code. Do not modify. +// source: usages_storage.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:core' as $core; + +import 'package:protobuf/protobuf.dart' as $pb; + +import 'usages_shared.pb.dart' as $0; + +class Usages extends $pb.GeneratedMessage { + factory Usages({ + $0.Metadata? metadata, + $core.Iterable<$core.String>? uris, + $core.Iterable? definitions, + $core.Iterable? calls, + $core.Iterable? instances, + }) { + final $result = create(); + if (metadata != null) { + $result.metadata = metadata; + } + if (uris != null) { + $result.uris.addAll(uris); + } + if (definitions != null) { + $result.definitions.addAll(definitions); + } + if (calls != null) { + $result.calls.addAll(calls); + } + if (instances != null) { + $result.instances.addAll(instances); + } + return $result; + } + Usages._() : super(); + factory Usages.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Usages.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Usages', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..aOM<$0.Metadata>(1, _omitFieldNames ? '' : 'metadata', + subBuilder: $0.Metadata.create) + ..pPS(2, _omitFieldNames ? '' : 'uris') + ..pc( + 3, _omitFieldNames ? '' : 'definitions', $pb.PbFieldType.PM, + subBuilder: Definition.create) + ..pc(4, _omitFieldNames ? '' : 'calls', $pb.PbFieldType.PM, + subBuilder: Usage.create) + ..pc(5, _omitFieldNames ? '' : 'instances', $pb.PbFieldType.PM, + subBuilder: Usage.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Usages clone() => Usages()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Usages copyWith(void Function(Usages) updates) => + super.copyWith((message) => updates(message as Usages)) as Usages; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Usages create() => Usages._(); + Usages createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Usages getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Usages? _defaultInstance; + + @$pb.TagNumber(1) + $0.Metadata get metadata => $_getN(0); + @$pb.TagNumber(1) + set metadata($0.Metadata v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasMetadata() => $_has(0); + @$pb.TagNumber(1) + void clearMetadata() => clearField(1); + @$pb.TagNumber(1) + $0.Metadata ensureMetadata() => $_ensure(0); + + @$pb.TagNumber(2) + $core.List<$core.String> get uris => $_getList(1); + + @$pb.TagNumber(3) + $core.List get definitions => $_getList(2); + + @$pb.TagNumber(4) + $core.List get calls => $_getList(3); + + @$pb.TagNumber(5) + $core.List get instances => $_getList(4); +} + +class Usage extends $pb.GeneratedMessage { + factory Usage({ + $core.int? definition, + $core.Iterable? references, + }) { + final $result = create(); + if (definition != null) { + $result.definition = definition; + } + if (references != null) { + $result.references.addAll(references); + } + return $result; + } + Usage._() : super(); + factory Usage.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Usage.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Usage', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'definition', $pb.PbFieldType.OU3) + ..pc(2, _omitFieldNames ? '' : 'references', $pb.PbFieldType.PM, + subBuilder: Reference.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Usage clone() => Usage()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Usage copyWith(void Function(Usage) updates) => + super.copyWith((message) => updates(message as Usage)) as Usage; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Usage create() => Usage._(); + Usage createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Usage getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Usage? _defaultInstance; + + @$pb.TagNumber(1) + $core.int get definition => $_getIZ(0); + @$pb.TagNumber(1) + set definition($core.int v) { + $_setUnsignedInt32(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasDefinition() => $_has(0); + @$pb.TagNumber(1) + void clearDefinition() => clearField(1); + + @$pb.TagNumber(2) + $core.List get references => $_getList(1); +} + +class Location extends $pb.GeneratedMessage { + factory Location({ + $core.int? uri, + $core.int? line, + $core.int? column, + }) { + final $result = create(); + if (uri != null) { + $result.uri = uri; + } + if (line != null) { + $result.line = line; + } + if (column != null) { + $result.column = column; + } + return $result; + } + Location._() : super(); + factory Location.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Location.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Location', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'uri', $pb.PbFieldType.OU3) + ..a<$core.int>(2, _omitFieldNames ? '' : 'line', $pb.PbFieldType.OU3) + ..a<$core.int>(3, _omitFieldNames ? '' : 'column', $pb.PbFieldType.OU3) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Location clone() => Location()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Location copyWith(void Function(Location) updates) => + super.copyWith((message) => updates(message as Location)) as Location; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Location create() => Location._(); + Location createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Location getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Location? _defaultInstance; + + @$pb.TagNumber(1) + $core.int get uri => $_getIZ(0); + @$pb.TagNumber(1) + set uri($core.int v) { + $_setUnsignedInt32(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasUri() => $_has(0); + @$pb.TagNumber(1) + void clearUri() => clearField(1); + + @$pb.TagNumber(2) + $core.int get line => $_getIZ(1); + @$pb.TagNumber(2) + set line($core.int v) { + $_setUnsignedInt32(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasLine() => $_has(1); + @$pb.TagNumber(2) + void clearLine() => clearField(2); + + @$pb.TagNumber(3) + $core.int get column => $_getIZ(2); + @$pb.TagNumber(3) + set column($core.int v) { + $_setUnsignedInt32(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasColumn() => $_has(2); + @$pb.TagNumber(3) + void clearColumn() => clearField(3); +} + +enum Reference_Reference { arguments, fields, notSet } + +class Reference extends $pb.GeneratedMessage { + factory Reference({ + Location? location, + $core.String? loadingUnit, + $0.Arguments? arguments, + $0.Fields? fields, + }) { + final $result = create(); + if (location != null) { + $result.location = location; + } + if (loadingUnit != null) { + $result.loadingUnit = loadingUnit; + } + if (arguments != null) { + $result.arguments = arguments; + } + if (fields != null) { + $result.fields = fields; + } + return $result; + } + Reference._() : super(); + factory Reference.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Reference.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static const $core.Map<$core.int, Reference_Reference> + _Reference_ReferenceByTag = { + 3: Reference_Reference.arguments, + 4: Reference_Reference.fields, + 0: Reference_Reference.notSet + }; + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Reference', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..oo(0, [3, 4]) + ..aOM(1, _omitFieldNames ? '' : 'location', + subBuilder: Location.create) + ..aOS(2, _omitFieldNames ? '' : 'loadingUnit') + ..aOM<$0.Arguments>(3, _omitFieldNames ? '' : 'arguments', + subBuilder: $0.Arguments.create) + ..aOM<$0.Fields>(4, _omitFieldNames ? '' : 'fields', + subBuilder: $0.Fields.create) + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Reference clone() => Reference()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Reference copyWith(void Function(Reference) updates) => + super.copyWith((message) => updates(message as Reference)) as Reference; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Reference create() => Reference._(); + Reference createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Reference getDefault() => + _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); + static Reference? _defaultInstance; + + Reference_Reference whichReference() => + _Reference_ReferenceByTag[$_whichOneof(0)]!; + void clearReference() => clearField($_whichOneof(0)); + + @$pb.TagNumber(1) + Location get location => $_getN(0); + @$pb.TagNumber(1) + set location(Location v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasLocation() => $_has(0); + @$pb.TagNumber(1) + void clearLocation() => clearField(1); + @$pb.TagNumber(1) + Location ensureLocation() => $_ensure(0); + + @$pb.TagNumber(2) + $core.String get loadingUnit => $_getSZ(1); + @$pb.TagNumber(2) + set loadingUnit($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasLoadingUnit() => $_has(1); + @$pb.TagNumber(2) + void clearLoadingUnit() => clearField(2); + + @$pb.TagNumber(3) + $0.Arguments get arguments => $_getN(2); + @$pb.TagNumber(3) + set arguments($0.Arguments v) { + setField(3, v); + } + + @$pb.TagNumber(3) + $core.bool hasArguments() => $_has(2); + @$pb.TagNumber(3) + void clearArguments() => clearField(3); + @$pb.TagNumber(3) + $0.Arguments ensureArguments() => $_ensure(2); + + @$pb.TagNumber(4) + $0.Fields get fields => $_getN(3); + @$pb.TagNumber(4) + set fields($0.Fields v) { + setField(4, v); + } + + @$pb.TagNumber(4) + $core.bool hasFields() => $_has(3); + @$pb.TagNumber(4) + void clearFields() => clearField(4); + @$pb.TagNumber(4) + $0.Fields ensureFields() => $_ensure(3); +} + +class Definition extends $pb.GeneratedMessage { + factory Definition({ + Identifier? identifier, + $core.int? line, + $core.int? column, + $core.String? loadingUnit, + }) { + final $result = create(); + if (identifier != null) { + $result.identifier = identifier; + } + if (line != null) { + $result.line = line; + } + if (column != null) { + $result.column = column; + } + if (loadingUnit != null) { + $result.loadingUnit = loadingUnit; + } + return $result; + } + Definition._() : super(); + factory Definition.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Definition.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Definition', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..aOM(1, _omitFieldNames ? '' : 'identifier', + subBuilder: Identifier.create) + ..a<$core.int>(2, _omitFieldNames ? '' : 'line', $pb.PbFieldType.OU3) + ..a<$core.int>(3, _omitFieldNames ? '' : 'column', $pb.PbFieldType.OU3) + ..aOS(4, _omitFieldNames ? '' : 'loadingUnit') + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Definition clone() => Definition()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Definition copyWith(void Function(Definition) updates) => + super.copyWith((message) => updates(message as Definition)) as Definition; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Definition create() => Definition._(); + Definition createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Definition getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static Definition? _defaultInstance; + + @$pb.TagNumber(1) + Identifier get identifier => $_getN(0); + @$pb.TagNumber(1) + set identifier(Identifier v) { + setField(1, v); + } + + @$pb.TagNumber(1) + $core.bool hasIdentifier() => $_has(0); + @$pb.TagNumber(1) + void clearIdentifier() => clearField(1); + @$pb.TagNumber(1) + Identifier ensureIdentifier() => $_ensure(0); + + @$pb.TagNumber(2) + $core.int get line => $_getIZ(1); + @$pb.TagNumber(2) + set line($core.int v) { + $_setUnsignedInt32(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasLine() => $_has(1); + @$pb.TagNumber(2) + void clearLine() => clearField(2); + + @$pb.TagNumber(3) + $core.int get column => $_getIZ(2); + @$pb.TagNumber(3) + set column($core.int v) { + $_setUnsignedInt32(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasColumn() => $_has(2); + @$pb.TagNumber(3) + void clearColumn() => clearField(3); + + @$pb.TagNumber(4) + $core.String get loadingUnit => $_getSZ(3); + @$pb.TagNumber(4) + set loadingUnit($core.String v) { + $_setString(3, v); + } + + @$pb.TagNumber(4) + $core.bool hasLoadingUnit() => $_has(3); + @$pb.TagNumber(4) + void clearLoadingUnit() => clearField(4); +} + +class Identifier extends $pb.GeneratedMessage { + factory Identifier({ + $core.int? uri, + $core.String? parent, + $core.String? name, + }) { + final $result = create(); + if (uri != null) { + $result.uri = uri; + } + if (parent != null) { + $result.parent = parent; + } + if (name != null) { + $result.name = name; + } + return $result; + } + Identifier._() : super(); + factory Identifier.fromBuffer($core.List<$core.int> i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromBuffer(i, r); + factory Identifier.fromJson($core.String i, + [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => + create()..mergeFromJson(i, r); + + static final $pb.BuilderInfo _i = $pb.BuilderInfo( + _omitMessageNames ? '' : 'Identifier', + package: const $pb.PackageName(_omitMessageNames ? '' : 'usages'), + createEmptyInstance: create) + ..a<$core.int>(1, _omitFieldNames ? '' : 'uri', $pb.PbFieldType.OU3) + ..aOS(2, _omitFieldNames ? '' : 'parent') + ..aOS(3, _omitFieldNames ? '' : 'name') + ..hasRequiredFields = false; + + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' + 'Will be removed in next major version') + Identifier clone() => Identifier()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' + 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' + 'Will be removed in next major version') + Identifier copyWith(void Function(Identifier) updates) => + super.copyWith((message) => updates(message as Identifier)) as Identifier; + + $pb.BuilderInfo get info_ => _i; + + @$core.pragma('dart2js:noInline') + static Identifier create() => Identifier._(); + Identifier createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') + static Identifier getDefault() => _defaultInstance ??= + $pb.GeneratedMessage.$_defaultFor(create); + static Identifier? _defaultInstance; + + @$pb.TagNumber(1) + $core.int get uri => $_getIZ(0); + @$pb.TagNumber(1) + set uri($core.int v) { + $_setUnsignedInt32(0, v); + } + + @$pb.TagNumber(1) + $core.bool hasUri() => $_has(0); + @$pb.TagNumber(1) + void clearUri() => clearField(1); + + @$pb.TagNumber(2) + $core.String get parent => $_getSZ(1); + @$pb.TagNumber(2) + set parent($core.String v) { + $_setString(1, v); + } + + @$pb.TagNumber(2) + $core.bool hasParent() => $_has(1); + @$pb.TagNumber(2) + void clearParent() => clearField(2); + + @$pb.TagNumber(3) + $core.String get name => $_getSZ(2); + @$pb.TagNumber(3) + set name($core.String v) { + $_setString(2, v); + } + + @$pb.TagNumber(3) + $core.bool hasName() => $_has(2); + @$pb.TagNumber(3) + void clearName() => clearField(3); +} + +const _omitFieldNames = $core.bool.fromEnvironment('protobuf.omit_field_names'); +const _omitMessageNames = + $core.bool.fromEnvironment('protobuf.omit_message_names'); diff --git a/pkgs/record_use/lib/src/proto/usages_storage.pbenum.dart b/pkgs/record_use/lib/src/proto/usages_storage.pbenum.dart new file mode 100644 index 00000000..59dbb677 --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_storage.pbenum.dart @@ -0,0 +1,10 @@ +// +// Generated code. Do not modify. +// source: usages_storage.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import diff --git a/pkgs/record_use/lib/src/proto/usages_storage.pbjson.dart b/pkgs/record_use/lib/src/proto/usages_storage.pbjson.dart new file mode 100644 index 00000000..3eca781b --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_storage.pbjson.dart @@ -0,0 +1,194 @@ +// +// Generated code. Do not modify. +// source: usages_storage.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +import 'dart:convert' as $convert; +import 'dart:core' as $core; +import 'dart:typed_data' as $typed_data; + +@$core.Deprecated('Use usagesDescriptor instead') +const Usages$json = { + '1': 'Usages', + '2': [ + { + '1': 'metadata', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages_shared.Metadata', + '10': 'metadata' + }, + {'1': 'uris', '3': 2, '4': 3, '5': 9, '10': 'uris'}, + { + '1': 'definitions', + '3': 3, + '4': 3, + '5': 11, + '6': '.usages.Definition', + '10': 'definitions' + }, + { + '1': 'calls', + '3': 4, + '4': 3, + '5': 11, + '6': '.usages.Usage', + '10': 'calls' + }, + { + '1': 'instances', + '3': 5, + '4': 3, + '5': 11, + '6': '.usages.Usage', + '10': 'instances' + }, + ], +}; + +/// Descriptor for `Usages`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List usagesDescriptor = $convert.base64Decode( + 'CgZVc2FnZXMSMwoIbWV0YWRhdGEYASABKAsyFy51c2FnZXNfc2hhcmVkLk1ldGFkYXRhUghtZX' + 'RhZGF0YRISCgR1cmlzGAIgAygJUgR1cmlzEjQKC2RlZmluaXRpb25zGAMgAygLMhIudXNhZ2Vz' + 'LkRlZmluaXRpb25SC2RlZmluaXRpb25zEiMKBWNhbGxzGAQgAygLMg0udXNhZ2VzLlVzYWdlUg' + 'VjYWxscxIrCglpbnN0YW5jZXMYBSADKAsyDS51c2FnZXMuVXNhZ2VSCWluc3RhbmNlcw=='); + +@$core.Deprecated('Use usageDescriptor instead') +const Usage$json = { + '1': 'Usage', + '2': [ + {'1': 'definition', '3': 1, '4': 1, '5': 13, '10': 'definition'}, + { + '1': 'references', + '3': 2, + '4': 3, + '5': 11, + '6': '.usages.Reference', + '10': 'references' + }, + ], +}; + +/// Descriptor for `Usage`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List usageDescriptor = $convert.base64Decode( + 'CgVVc2FnZRIeCgpkZWZpbml0aW9uGAEgASgNUgpkZWZpbml0aW9uEjEKCnJlZmVyZW5jZXMYAi' + 'ADKAsyES51c2FnZXMuUmVmZXJlbmNlUgpyZWZlcmVuY2Vz'); + +@$core.Deprecated('Use locationDescriptor instead') +const Location$json = { + '1': 'Location', + '2': [ + {'1': 'uri', '3': 1, '4': 1, '5': 13, '10': 'uri'}, + {'1': 'line', '3': 2, '4': 1, '5': 13, '10': 'line'}, + {'1': 'column', '3': 3, '4': 1, '5': 13, '10': 'column'}, + ], +}; + +/// Descriptor for `Location`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List locationDescriptor = $convert.base64Decode( + 'CghMb2NhdGlvbhIQCgN1cmkYASABKA1SA3VyaRISCgRsaW5lGAIgASgNUgRsaW5lEhYKBmNvbH' + 'VtbhgDIAEoDVIGY29sdW1u'); + +@$core.Deprecated('Use referenceDescriptor instead') +const Reference$json = { + '1': 'Reference', + '2': [ + { + '1': 'location', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages.Location', + '10': 'location' + }, + {'1': 'loading_unit', '3': 2, '4': 1, '5': 9, '10': 'loadingUnit'}, + { + '1': 'arguments', + '3': 3, + '4': 1, + '5': 11, + '6': '.usages_shared.Arguments', + '9': 0, + '10': 'arguments' + }, + { + '1': 'fields', + '3': 4, + '4': 1, + '5': 11, + '6': '.usages_shared.Fields', + '9': 0, + '10': 'fields' + }, + ], + '8': [ + {'1': 'reference'}, + ], +}; + +/// Descriptor for `Reference`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List referenceDescriptor = $convert.base64Decode( + 'CglSZWZlcmVuY2USLAoIbG9jYXRpb24YASABKAsyEC51c2FnZXMuTG9jYXRpb25SCGxvY2F0aW' + '9uEiEKDGxvYWRpbmdfdW5pdBgCIAEoCVILbG9hZGluZ1VuaXQSOAoJYXJndW1lbnRzGAMgASgL' + 'MhgudXNhZ2VzX3NoYXJlZC5Bcmd1bWVudHNIAFIJYXJndW1lbnRzEi8KBmZpZWxkcxgEIAEoCz' + 'IVLnVzYWdlc19zaGFyZWQuRmllbGRzSABSBmZpZWxkc0ILCglyZWZlcmVuY2U='); + +@$core.Deprecated('Use definitionDescriptor instead') +const Definition$json = { + '1': 'Definition', + '2': [ + { + '1': 'identifier', + '3': 1, + '4': 1, + '5': 11, + '6': '.usages.Identifier', + '10': 'identifier' + }, + {'1': 'line', '3': 2, '4': 1, '5': 13, '10': 'line'}, + {'1': 'column', '3': 3, '4': 1, '5': 13, '10': 'column'}, + { + '1': 'loading_unit', + '3': 4, + '4': 1, + '5': 9, + '9': 0, + '10': 'loadingUnit', + '17': true + }, + ], + '8': [ + {'1': '_loading_unit'}, + ], +}; + +/// Descriptor for `Definition`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List definitionDescriptor = $convert.base64Decode( + 'CgpEZWZpbml0aW9uEjIKCmlkZW50aWZpZXIYASABKAsyEi51c2FnZXMuSWRlbnRpZmllclIKaW' + 'RlbnRpZmllchISCgRsaW5lGAIgASgNUgRsaW5lEhYKBmNvbHVtbhgDIAEoDVIGY29sdW1uEiYK' + 'DGxvYWRpbmdfdW5pdBgEIAEoCUgAUgtsb2FkaW5nVW5pdIgBAUIPCg1fbG9hZGluZ191bml0'); + +@$core.Deprecated('Use identifierDescriptor instead') +const Identifier$json = { + '1': 'Identifier', + '2': [ + {'1': 'uri', '3': 1, '4': 1, '5': 13, '10': 'uri'}, + {'1': 'parent', '3': 2, '4': 1, '5': 9, '9': 0, '10': 'parent', '17': true}, + {'1': 'name', '3': 3, '4': 1, '5': 9, '10': 'name'}, + ], + '8': [ + {'1': '_parent'}, + ], +}; + +/// Descriptor for `Identifier`. Decode as a `google.protobuf.DescriptorProto`. +final $typed_data.Uint8List identifierDescriptor = $convert.base64Decode( + 'CgpJZGVudGlmaWVyEhAKA3VyaRgBIAEoDVIDdXJpEhsKBnBhcmVudBgCIAEoCUgAUgZwYXJlbn' + 'SIAQESEgoEbmFtZRgDIAEoCVIEbmFtZUIJCgdfcGFyZW50'); diff --git a/pkgs/record_use/lib/src/proto/usages_storage.pbserver.dart b/pkgs/record_use/lib/src/proto/usages_storage.pbserver.dart new file mode 100644 index 00000000..8b31b651 --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_storage.pbserver.dart @@ -0,0 +1,13 @@ +// +// Generated code. Do not modify. +// source: usages_storage.proto +// +// @dart = 2.12 + +// ignore_for_file: annotate_overrides, camel_case_types, comment_references +// ignore_for_file: constant_identifier_names +// ignore_for_file: deprecated_member_use_from_same_package, library_prefixes +// ignore_for_file: non_constant_identifier_names, prefer_final_fields +// ignore_for_file: unnecessary_import, unnecessary_this, unused_import + +export 'usages_storage.pb.dart'; diff --git a/pkgs/record_use/lib/src/proto/usages_storage.proto b/pkgs/record_use/lib/src/proto/usages_storage.proto new file mode 100644 index 00000000..8cef7943 --- /dev/null +++ b/pkgs/record_use/lib/src/proto/usages_storage.proto @@ -0,0 +1,49 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +syntax = "proto3"; +package usages; + +import "usages_shared.proto"; + +message Usages { + usages_shared.Metadata metadata = 1; + repeated string uris = 2; + repeated Definition definitions = 3; + repeated Usage calls = 4; + repeated Usage instances = 5; +} + +message Usage { + uint32 definition = 1; + repeated Reference references = 2; +} + +message Location { + uint32 uri = 1; + uint32 line = 2; + uint32 column = 3; +} + +message Reference { + Location location = 1; + string loading_unit = 2; + oneof reference { + usages_shared.Arguments arguments = 3; + usages_shared.Fields fields = 4; + } +} + +message Definition { + Identifier identifier = 1; + uint32 line = 2; + uint32 column = 3; + optional string loading_unit = 4; // Optional, as some loading units are null +} + +message Identifier { + uint32 uri = 1; + optional string parent = 2; + string name = 3; +} diff --git a/pkgs/record_use/lib/src/record_use.dart b/pkgs/record_use/lib/src/record_use.dart new file mode 100644 index 00000000..5016691a --- /dev/null +++ b/pkgs/record_use/lib/src/record_use.dart @@ -0,0 +1,147 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:typed_data'; + +import 'package:collection/collection.dart'; +import 'package:pub_semver/pub_semver.dart'; + +import 'data_classes/extensions.dart'; +import 'proto/usages_read.pb.dart' as pb; +import 'proto/usages_storage.pb.dart' as pb_storage; + +class Identifier { + final String uri; + final String? parent; + final String name; + + const Identifier({required this.uri, this.parent, required this.name}); +} + +extension type RecordedUsages._(pb.Usages _usages) { + RecordedUsages.fromFile(Uint8List contents) + : this._(pb_storage.Usages.fromBuffer(contents).toApi()); + + /// Show the metadata for this recording of usages. + Version get version => Version.parse(_usages.metadata.version); + + /// Finds all arguments for calls to the [method]. + /// + /// The definition must be annotated with `@RecordUse()`. If there are no + /// calls to the definition, either because it was treeshaken, because it was + /// not annotated, or because it does not exist, returns `null`. + /// + /// Returns an empty iterable if the arguments were not collected. + /// + /// Example: + /// ```dart + /// import 'package:meta/meta.dart' show ResourceIdentifier; + /// void main() { + /// print(SomeClass.someStaticMethod(42)); + /// } + /// + /// class SomeClass { + /// @ResourceIdentifier('id') + /// static someStaticMethod(int i) { + /// return i + 1; + /// } + /// } + /// ``` + /// + /// Would mean that + /// ``` + /// argumentsForCallsTo(Identifier( + /// uri: 'path/to/file.dart', + /// parent: 'SomeClass', + /// name: 'someStaticMethod'), + /// ).first == + /// Arguments( + /// constArguments: ConstArguments(positional: {1: 42}), + /// ); + /// ``` + Iterable<({Map named, Map positional})>? + constArgumentsTo(Identifier method) => + _callTo(method)?.references.map((reference) => ( + named: reference.arguments.constArguments.named.map( + (key, value) => MapEntry(key, value.toObject()), + ), + positional: reference.arguments.constArguments.positional.map( + (key, value) => MapEntry(key, value.toObject()), + ), + )); + + /// Finds all fields of a const instance of the class at [classIdentifier]. + /// + /// The definition must be annotated with `@RecordUse()`. If there are + /// no instances of the definition, either because it was treeshaken, because + /// it was not annotated, or because it does not exist, returns `null`. + /// + /// The types of fields supported are defined at + /// TODO: insert reference to the supported field types for serialization + /// + /// Example: + /// ```dart + /// void main() { + /// print(SomeClass.someStaticMethod(42)); + /// } + /// + /// class SomeClass { + /// @AnnotationClass('freddie') + /// static someStaticMethod(int i) { + /// return i + 1; + /// } + /// } + /// + /// @ResourceIdentifier() + /// class AnnotationClass { + /// final String s; + /// const AnnotationClass(this.s); + /// } + /// ``` + /// + /// Would mean that + /// ``` + /// fieldsForConstructionOf(Identifier( + /// uri: 'path/to/file.dart', + /// name: 'AnnotationClass'), + /// ).first == + /// [ + /// Field(name: "s", className: "AnnotationClass", value: "freddie") + /// ]; + /// ``` + /// + /// What kinds of fields can be recorded depends on the implementation of + /// https://dart-review.googlesource.com/c/sdk/+/369620/13/pkg/vm/lib/transformations/record_use/record_instance.dart + Iterable>? instanceReferencesTo(Identifier classIdentifier) { + final instances = _usages.instances; + final firstWhereOrNull = instances.firstWhereOrNull((instance) => + _compareIdentifiers(instance.definition.identifier, classIdentifier)); + return firstWhereOrNull?.references.map((reference) => + reference.fields.fields.map((field) => field.value.toObject())); + } + + /// Checks if any call to [method] has non-const arguments. + /// + /// The definition must be annotated with `@RecordUse()`. If there are no + /// calls to the definition, either because it was treeshaken, because it was + /// not annotated, or because it does not exist, returns `false`. + bool hasNonConstArguments(Identifier method) => + _callTo(method)?.references.any( + (reference) { + final nonConstArguments = reference.arguments.nonConstArguments; + final hasNamed = nonConstArguments.named.isNotEmpty; + final hasPositional = nonConstArguments.positional.isNotEmpty; + return hasNamed || hasPositional; + }, + ) ?? + false; + + pb.Usage? _callTo(Identifier identifier) => _usages.calls.firstWhereOrNull( + (call) => _compareIdentifiers(call.definition.identifier, identifier)); + + bool _compareIdentifiers(pb.Identifier id1, Identifier id2) => + id1.uri == id2.uri && + (id1.hasParent() ? id1.parent : null) == id2.parent && + id1.name == id2.name; +} diff --git a/pkgs/record_use/pubspec.yaml b/pkgs/record_use/pubspec.yaml new file mode 100644 index 00000000..e4517996 --- /dev/null +++ b/pkgs/record_use/pubspec.yaml @@ -0,0 +1,17 @@ +name: record_use +description: > + The serialization logic and API for the usage recording SDK feature. +repository: https://github.com/mosuem/record_use +version: 0.1.0 +environment: + sdk: ^3.4.0 + +dependencies: + collection: ^1.18.0 + protobuf: ^3.1.0 + pub_semver: ^2.1.4 + +dev_dependencies: + dart_flutter_team_lints: ^3.1.0 + lints: ^4.0.0 + test: ^1.24.0 diff --git a/pkgs/record_use/test/storage_test.dart b/pkgs/record_use/test/storage_test.dart new file mode 100644 index 00000000..4a3ec099 --- /dev/null +++ b/pkgs/record_use/test/storage_test.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:record_use/record_use_internal.dart'; +import 'package:record_use/src/record_use.dart'; +import 'package:test/test.dart'; + +import 'testdata/data.dart'; + +void main() { + test('Buffer->Object->Buffer', () { + // Uncomment to reset test files + // File('test/testdata/data.json') + // .writeAsStringSync(recordedUses.toDebugJson()); + // File('test/testdata/data.binpb').writeAsBytesSync(recordedUses.toBuffer()); + final recordedUsesPb = File('test/testdata/data.binpb').readAsBytesSync(); + expect((RecordedUsages.fromFile(recordedUsesPb) as Usages).toBuffer(), + recordedUsesPb); + }); + test('Object->Buffer->Object', () { + expect( + RecordedUsages.fromFile(recordedUses.toBuffer()), + recordedUses, + ); + }); + test('empty Object->Buffer->Object', () { + expect( + RecordedUsages.fromFile(emptyUsages.toBuffer()), + emptyUsages, + ); + }); +} diff --git a/pkgs/record_use/test/testdata/data.binpb b/pkgs/record_use/test/testdata/data.binpb new file mode 100644 index 00000000..f7779a6a Binary files /dev/null and b/pkgs/record_use/test/testdata/data.binpb differ diff --git a/pkgs/record_use/test/testdata/data.dart b/pkgs/record_use/test/testdata/data.dart new file mode 100644 index 00000000..7d772999 --- /dev/null +++ b/pkgs/record_use/test/testdata/data.dart @@ -0,0 +1,133 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:pub_semver/pub_semver.dart'; + +import 'package:record_use/record_use_internal.dart'; + +final Usages emptyUsages = Usages( + metadata: Metadata(version: Version(1, 2, 3).toString()), + calls: [], + instances: [], +); + +final Usages recordedUses = Usages( + metadata: Metadata( + version: Version(1, 6, 2, pre: 'wip', build: '5.-.2.z').toString(), + comment: + 'Recorded references at compile time and their argument values, as far' + ' as known, to definitions annotated with @RecordReference', + ), + instances: [ + Usage( + definition: Definition( + identifier: Identifier( + uri: Uri.parse('file://lib/_internal/js_runtime/lib/js_helper.dart') + .toString(), + name: 'MyAnnotation', + ), + line: 15, + column: 30, + ), + references: [ + Reference( + location: Location( + uri: Uri.parse('file://lib/_internal/js_runtime/lib/js_helper.dart') + .toString(), + line: 40, + column: 30, + ), + fields: Fields(fields: [ + Field( + className: 'className', + name: 'a', + value: FieldValue(intValue: 42), + ), + ]), + loadingUnit: '3', + ), + ], + ), + ], + calls: [ + Usage( + definition: Definition( + identifier: Identifier( + uri: Uri.parse('file://lib/_internal/js_runtime/lib/js_helper.dart') + .toString(), + parent: 'MyClass', + name: 'get:loadDeferredLibrary', + ), + line: 12, + column: 67, + loadingUnit: 'part_15.js', + ), + references: [ + Reference( + arguments: Arguments( + constArguments: ConstArguments( + positional: { + 0: FieldValue(stringValue: 'lib_SHA1'), + 1: FieldValue(boolValue: false), + 2: FieldValue(intValue: 1), + }, + named: { + 'leroy': FieldValue(stringValue: 'jenkins'), + 'freddy': FieldValue(stringValue: 'mercury'), + }, + ), + ), + location: Location( + uri: Uri.parse( + 'file://benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart') + .toString(), + line: 14, + column: 49, + ), + loadingUnit: 'o.js', + ), + Reference( + arguments: Arguments( + constArguments: ConstArguments( + positional: { + 0: FieldValue(stringValue: 'lib_SHA1'), + 2: FieldValue(intValue: 0), + 4: FieldValue( + mapValue: StringMapValue( + value: { + 'key': FieldValue(intValue: 99), + }, + ), + ) + }, + named: { + 'leroy': FieldValue(stringValue: 'jenkins'), + 'albert': FieldValue( + listValue: ListValue( + value: [ + FieldValue(stringValue: 'camus'), + FieldValue(stringValue: 'einstein'), + ], + ), + ), + }, + ), + nonConstArguments: NonConstArguments( + positional: [1], + named: ['freddy'], + ), + ), + location: Location( + uri: Uri.parse( + 'file://benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart') + .toString(), + line: 14, + column: 48, + ), + loadingUnit: 'o.js', + ), + ], + ), + ], +); diff --git a/pkgs/record_use/test/testdata/data.json b/pkgs/record_use/test/testdata/data.json new file mode 100644 index 00000000..3e2bd7cf --- /dev/null +++ b/pkgs/record_use/test/testdata/data.json @@ -0,0 +1,181 @@ +{ + "1": { + "1": "Recorded references at compile time and their argument values, as far as known, to definitions annotated with @RecordReference", + "2": "1.6.2-wip+5.-.2.z" + }, + "2": [ + "file://lib/_internal/js_runtime/lib/js_helper.dart", + "file://benchmarks/OmnibusDeferred/dart/OmnibusDeferred.dart" + ], + "3": [ + { + "1": { + "1": 0, + "2": "MyClass", + "3": "get:loadDeferredLibrary" + }, + "2": 12, + "3": 67, + "4": "part_15.js" + }, + { + "1": { + "1": 0, + "3": "MyAnnotation" + }, + "2": 15, + "3": 30 + } + ], + "4": [ + { + "1": 0, + "2": [ + { + "1": { + "1": 1, + "2": 14, + "3": 49 + }, + "2": "o.js", + "3": { + "1": { + "1": [ + { + "1": 0, + "2": { + "6": "lib_SHA1" + } + }, + { + "1": 1, + "2": { + "5": false + } + }, + { + "1": 2, + "2": { + "3": 1 + } + } + ], + "2": [ + { + "1": "leroy", + "2": { + "6": "jenkins" + } + }, + { + "1": "freddy", + "2": { + "6": "mercury" + } + } + ] + } + } + }, + { + "1": { + "1": 1, + "2": 14, + "3": 48 + }, + "2": "o.js", + "3": { + "1": { + "1": [ + { + "1": 0, + "2": { + "6": "lib_SHA1" + } + }, + { + "1": 2, + "2": { + "3": 0 + } + }, + { + "1": 4, + "2": { + "1": { + "1": [ + { + "1": "key", + "2": { + "3": 99 + } + } + ] + } + } + } + ], + "2": [ + { + "1": "leroy", + "2": { + "6": "jenkins" + } + }, + { + "1": "albert", + "2": { + "2": { + "1": [ + { + "6": "camus" + }, + { + "6": "einstein" + } + ] + } + } + } + ] + }, + "2": { + "1": [ + 1 + ], + "2": [ + "freddy" + ] + } + } + } + ] + } + ], + "5": [ + { + "1": 1, + "2": [ + { + "1": { + "1": 0, + "2": 40, + "3": 30 + }, + "2": "3", + "4": { + "1": [ + { + "1": "className", + "2": "a", + "3": { + "3": 42 + } + } + ] + } + } + ] + } + ] +} \ No newline at end of file diff --git a/pkgs/record_use/test/usage_test.dart b/pkgs/record_use/test/usage_test.dart new file mode 100644 index 00000000..ccd4dcd4 --- /dev/null +++ b/pkgs/record_use/test/usage_test.dart @@ -0,0 +1,56 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; + +import 'package:record_use/src/data_classes/extensions.dart'; +import 'package:record_use/src/record_use.dart'; +import 'package:test/test.dart'; + +import 'testdata/data.dart'; + +void main() { + test('API calls', () { + final callId = Identifier( + uri: Uri.parse('file://lib/_internal/js_runtime/lib/js_helper.dart') + .toString(), + parent: 'MyClass', + name: 'get:loadDeferredLibrary', + ); + final arguments = RecordedUsages.fromFile(recordedUses.toBuffer()) + .constArgumentsTo(callId)! + .toList(); + expect( + arguments[0].named, + {'leroy': 'jenkins', 'freddy': 'mercury'}, + ); + expect( + arguments[0].positional, + {0: 'lib_SHA1', 1: false, 2: 1}, + ); + expect(arguments[1].named, { + 'leroy': 'jenkins', + 'albert': ['camus', 'einstein'] + }); + expect(arguments[1].positional, { + 0: 'lib_SHA1', + 2: 0, + 4: {'key': 99} + }); + }); + test('API instances', () { + final recordedUsesPb = File('test/testdata/data.binpb').readAsBytesSync(); + final instanceId = Identifier( + uri: Uri.parse('file://lib/_internal/js_runtime/lib/js_helper.dart') + .toString(), + name: 'MyAnnotation', + ); + expect( + RecordedUsages.fromFile(recordedUsesPb).instanceReferencesTo(instanceId), + [ + [42] + ], + ); + }); +}