Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dart.googlesource.com-pub
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
dart.googlesource.com-pub
Commits
71a95f22
Commit
71a95f22
authored
8 years ago
by
Natalie Weizenbaum
Browse files
Options
Downloads
Patches
Plain Diff
Partial implementation of dependencyIntoDependency.
parent
745f067b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/src/solver/deducer.dart
+92
-0
92 additions, 0 deletions
lib/src/solver/deducer.dart
with
92 additions
and
0 deletions
lib/src/solver/deducer.dart
+
92
−
0
View file @
71a95f22
...
...
@@ -286,6 +286,98 @@ class Deducer {
}
}
Dependency
_dependencyIntoDependency
(
Dependency
fact
)
{
// Check whether [fact] can be merged with other dependencies with the same
// depender and allowed.
for
(
var
dependency
in
_dependenciesByDepender
(
fact
.
depender
.
toRef
()))
{
if
(
dependency
.
allowed
.
toRef
()
!=
fact
.
allowed
.
toRef
())
continue
;
if
(
dependency
.
allowed
.
constraint
==
fact
.
allowed
.
constraint
)
{
// If [fact] has the same allowed constraint as [dependency], they can
// be merged.
var
merged
=
_mergeDeps
([
dependency
.
depender
,
fact
.
depender
]);
if
(
merged
.
constraint
!=
dependency
.
depender
.
constraint
)
{
// If [fact] adds new information to [dependency], create a new
// dependency for it.
_removeDependency
(
dependency
);
_dependenciesByDepender
[
fact
.
depender
.
toRef
()]
=
new
Dependency
(
merged
,
fact
.
allowed
,
[
dependency
,
fact
]);
}
return
null
;
}
else
if
(
dependency
.
depender
.
constraint
.
allowsAny
(
fact
.
depender
.
constraint
))
{
// If [fact] has a different allowed constraint than [dependency] but
// their dependers overlap, remove the part that's overlapping and maybe
// create a new narrower constraint from the overlap.
if
(
fact
.
allowed
.
constraint
.
allowsAll
(
dependency
.
allowed
.
constraint
))
{
// If [fact] allows strictly more versions than [dependency], remove
// any overlap from [fact] because it's less specific.
var
difference
=
fact
.
depender
.
constraint
.
difference
(
dependency
.
depender
.
constraint
);
if
(
difference
.
isEmpty
)
return
null
;
fact
=
new
Dependency
(
fact
.
depender
.
withConstraint
(
difference
),
fact
.
allowed
,
[
dependency
,
fact
]);
}
else
if
(
dependency
.
allowed
.
constraint
.
allowsAll
(
fact
.
allowed
.
constraint
))
{
_removeDependency
(
dependency
);
// If [dependency] allows strictly more versions than [fact], remove
// any overlap from [dependency] because it's less specific.
var
difference
=
dependency
.
depender
.
constraint
.
difference
(
fact
.
depender
.
constraint
);
if
(
difference
.
isEmpty
)
continue
;
_toProcess
.
add
(
new
Dependency
(
dependency
.
depender
.
withConstraint
(
difference
),
dependency
.
allowed
,
[
dependency
,
fact
]));
}
else
{
// If [fact] and [dependency]'s allowed targets overlap without one
// being a subset of the other, we need to create a third dependency
// that represents the intersection.
_removeDependency
(
dependency
);
var
intersection
=
_intersectDeps
(
dependency
.
depender
,
fact
.
depender
);
_toProcess
.
add
(
new
Dependency
(
intersection
,
_intersectDeps
(
dependency
.
allowed
,
fact
.
allowed
),
[
dependency
,
fact
]));
if
(
!
intersection
.
constraint
.
allowsAll
(
dependency
.
depender
.
constraint
))
{
// If [intersection] covers the entirety of [dependency], throw it
// away; otherwise, trim it to exclude [intersection].
_toProcess
.
add
(
new
Dependency
(
dependency
.
depender
.
withConstraint
(
dependency
.
depender
.
constraint
.
difference
(
intersection
.
constraint
)),
dependency
.
allowed
,
[
dependency
,
fact
]));
}
if
(
!
intersection
.
constraint
.
allowsAll
(
fact
.
depender
.
constraint
))
{
// If [intersection] covers the entirety of [fact], throw it away;
// otherwise, trim it to exclude [intersection].
fact
=
new
Dependency
(
fact
.
depender
.
withConstraint
(
fact
.
depender
.
constraint
.
difference
(
intersection
.
constraint
)),
fact
.
allowed
,
[
dependency
,
fact
]);
}
else
{
return
null
;
}
}
}
}
}
// Resolves [required] and [disallowed], which should refer to the same
// package. Returns whether any required versions were trimmed.
bool
_requiredAndDisallowed
(
Required
required
,
Disallowed
disallowed
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment