Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ class AggregateBuilder implements Builder {
imports.addAll(findAllImports(contents));
final newContents = contents
.replaceAll(importRegex, '')
.replaceAll(RegExp("part of '.*';"), '')
.replaceAll(RegExp(r"^part\s'.*';", multiLine: true), '')
.replaceAll(RegExp(r'^export\s.*;', multiLine: true), '');
.replaceAll(RegExp(r'^\s*part(?: of)?\s+["\x27][^"\x27]*["\x27];', multiLine: true), '')
.replaceAll(RegExp(r'^\s*part\s+["\x27][^"\x27]*["\x27];', multiLine: true), '')
Comment thread
KiddoV marked this conversation as resolved.
Outdated
.replaceAll(RegExp(r'^\s*export\s+[^\n;]+;', multiLine: true), '');
Comment thread
KiddoV marked this conversation as resolved.
Outdated
files.add(newContents);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ class ModelDictionaryBuilder<_ClassAnnotation> extends BaseBuilder<_ClassAnnotat
{
for (final annotation in annotations)
'${annotation.element.name}': filesToContents.entries
.firstWhere((entry) => entry.value.contains(RegExp(r'class\s+${annotation.element.name}\s*')))
.firstWhere(
(entry) =>
entry.key.endsWith('.model.dart') && // Only use model files
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good fix

entry.value.contains(RegExp('class\\s+${annotation.element.name}\\b')),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the word boundary necessary here or could it remain that the ending is an optional whitespace character?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep this...
If you remove \b, this will match wrong classes:
Example:

class UserProfile {}
class User {}

Searching for User:
=> Without \b → matches UserProfile
=> With \b → only matches User

)
.key
// Make relative from the `brick/` folder
.replaceAll(RegExp('^lib/'), '../'),
Expand Down
Loading