Skip to content

Commit

Permalink
refactor: IdentifierPart and Identifiers documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
pattobrien committed Feb 14, 2024
1 parent 8cbac85 commit 7a74bd7
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 57 deletions.
3 changes: 2 additions & 1 deletion src/cli_gen/lib/src/types/arg_identifiers.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '../utils/identifier_part.dart';
import 'models/identifier_part.dart';

/// Identifiers for the `args` package.
class ArgsIdentifiers {
const ArgsIdentifiers();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import '../utils/identifier_part.dart';
import 'models/identifier_part.dart';

class MacroArgIdentifiers {
const MacroArgIdentifiers();
/// Identifiers for the `cli_annotations` package.
class CliGenIdentifiers {
const CliGenIdentifiers();

Uri get _uri => Uri.parse('package:cli_annotations/cli_annotations.dart');

IdentifierPart get cliCommand => IdentifierPart('CliCommand', _uri);

IdentifierPart get cliSubCommand => IdentifierPart('CliSubCommand', _uri);
IdentifierPart get cliSubCommand => IdentifierPart('CliSubcommand', _uri);

IdentifierPart get cliArgs => IdentifierPart('CliArgs', _uri);
}
3 changes: 2 additions & 1 deletion src/cli_gen/lib/src/types/dart_identifiers.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '../utils/identifier_part.dart';
import 'models/identifier_part.dart';

/// Identifiers for the `dart:core` library.
class DartCoreIdentifiers {
const DartCoreIdentifiers();

Expand Down
8 changes: 3 additions & 5 deletions src/cli_gen/lib/src/types/identifiers.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import 'arg_identifiers.dart';
import 'cli_gen_identifiers.dart';
import 'dart_identifiers.dart';
import 'keyword_identifiers.dart';
import 'macro_identifiers.dart';

/// A collection of common identifiers used for code generation.
class Identifiers {
const Identifiers._();

static const args = ArgsIdentifiers();

static const keywords = KeywordIdentifiers();

static const dart = DartCoreIdentifiers();

static const macro = MacroArgIdentifiers();
static const cliGen = CliGenIdentifiers();
}
8 changes: 0 additions & 8 deletions src/cli_gen/lib/src/types/keyword_identifiers.dart

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import 'package:code_builder/code_builder.dart';

/// A utility class that represents a part of code.
///
/// Each instance/part can be either a String or an Identifier. This utility
/// class was created to make it easier to share code geneation logic between
/// `macros` and `builders`.
sealed class EmitterPart {
const EmitterPart();

Expand Down
38 changes: 38 additions & 0 deletions src/cli_gen/lib/src/types/models/macro_identifier_part.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// // ignore: implementation_imports, depend_on_referenced_packages
// import 'package:_fe_analyzer_shared/src/macros/api.dart';

// import 'identifier_part.dart';

// /// A reference to a Macro identifier.
// class MacroIdentifierPart extends IdentifierPart {
// MacroIdentifierPart(
// this.identifier,
// Uri uri,
// ) : super(identifier.name, uri);

// final Identifier identifier;

// @override
// String get name => identifier.name;

// @override
// String toCodeString() => name;

// @override
// String toString() {
// return 'MacroIdentifier{name: $name, uri: $uri}';
// }

// @override
// int get hashCode => name.hashCode ^ uri.hashCode ^ identifier.hashCode;

// @override
// bool operator ==(Object other) {
// if (identical(this, other)) return true;

// return other is MacroIdentifierPart &&
// other.name == name &&
// other.uri == uri &&
// other.identifier == identifier;
// }
// }
4 changes: 4 additions & 0 deletions src/cli_gen/lib/src/types/types.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export 'arg_identifiers.dart';
export 'cli_gen_identifiers.dart';
export 'dart_identifiers.dart';
export 'identifiers.dart';
38 changes: 0 additions & 38 deletions src/cli_gen/lib/src/utils/identifiers/macro_identifier_part.dart

This file was deleted.

0 comments on commit 7a74bd7

Please sign in to comment.