-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect dependency loops in module migrator
- Loading branch information
1 parent
dce67db
commit 76e48bd
Showing
5 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
## 2.0.4 | ||
* Detect dependency loops in module migrator fix. | ||
|
||
## 2.0.3 | ||
|
||
### Module Migrator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Use of this source code is governed by an MIT-style | ||
// license that can be found in the LICENSE file or at | ||
// https://opensource.org/licenses/MIT. | ||
|
||
/// A graph data structure to manage dependencies between URIs. | ||
/// | ||
/// This class allows adding, removing, and querying dependencies | ||
/// between source URIs and their imported paths. | ||
class DependencyGraph { | ||
final Map<Uri, Set<Uri>> _graph = {}; | ||
|
||
/// Adds a dependency relationship between source and importedPath. | ||
void add(Uri source, Uri importedPath) { | ||
_graph.putIfAbsent(source, () => {}).add(importedPath); | ||
} | ||
|
||
/// Removes a dependency relationship between source and importedPath. | ||
void remove(Uri source, Uri importedPath) { | ||
_graph[source]?.remove(importedPath); | ||
} | ||
|
||
/// Finds all dependencies of a given source. | ||
Set<Uri>? find(Uri source) { | ||
return _graph[source]; | ||
} | ||
|
||
/// Checks if a specific dependency exists. | ||
bool hasDependency(Uri source, Uri importedPath) { | ||
return _graph.containsKey(source) && _graph[source]!.contains(importedPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<==> arguments | ||
--migrate-deps | ||
|
||
<==> input/entrypoint.scss | ||
$a: red; | ||
@import "ejemplo"; | ||
a { | ||
background: $b; | ||
} | ||
|
||
<==> input/_ejemplo.scss | ||
$b: blue; | ||
a { | ||
color: $a; | ||
} | ||
|
||
<==> error.txt | ||
Error: Dependency loop detected: entrypoint -> ejemplo | ||
, | ||
1 | $b: blue; | ||
| ^^^^^^^^ | ||
' | ||
_ejemplo.scss 1:1 root stylesheet | ||
Migration failed! |