Minor cleanup: remove DependentRulesSpec and its usages in RulesDiff
for historical documentation purposes, why it was needed: It was used for specifying and handling rules which must be simply removed without all related incremental invalidation machinery. Long time ago some of these dependencies weren't captured and such "simply dependent" rules must have been handled separately. Currently it's handled by general invalidation case.
This commit is contained in:
parent
7b33e0e31f
commit
45df4d845f
|
|
@ -16,15 +16,13 @@
|
|||
|
||||
package jetbrains.mps.logic.reactor.core
|
||||
|
||||
import jetbrains.mps.logic.reactor.program.DependentRulesSpec
|
||||
import jetbrains.mps.logic.reactor.program.Rule
|
||||
|
||||
|
||||
class RulesDiff(
|
||||
preserved: Iterable<Rule>,
|
||||
val added: Iterable<Rule>,
|
||||
val removed: Set<Any>,
|
||||
val removedDependent: Set<Any>
|
||||
val removed: Set<Any>
|
||||
) {
|
||||
private val preserved: Map<Any, Rule> = HashMap<Any, Rule>().apply {
|
||||
preserved.forEach { put(it.uniqueTag(), it) }
|
||||
|
|
@ -36,10 +34,10 @@ class RulesDiff(
|
|||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun emptyDiff() = RulesDiff(emptyList(), emptyList(), emptySet(), emptySet())
|
||||
fun emptyDiff() = RulesDiff(emptyList(), emptyList(), emptySet())
|
||||
|
||||
@JvmStatic
|
||||
fun findDiff(old: Iterable<Rule>, new: Iterable<Rule>, ruleDeps: DependentRulesSpec): RulesDiff {
|
||||
fun findDiff(old: Iterable<Rule>, new: Iterable<Rule>): RulesDiff {
|
||||
val oldTagsSet = old.map { it.uniqueTag() }.toHashSet()
|
||||
val newTagsSet = new.map { it.uniqueTag() }.toHashSet()
|
||||
|
||||
|
|
@ -47,21 +45,7 @@ class RulesDiff(
|
|||
val (preserved, removed) = old.partition { newTagsSet.contains(it.uniqueTag()) }
|
||||
val removedTags: Set<Any> = removed.map { it.uniqueTag() }.toSet()
|
||||
|
||||
//fixme: remove
|
||||
val removedDeps = HashSet<Any>()
|
||||
for (rule in added) {
|
||||
for (depRule in ruleDeps.getDependentRules(rule)) {
|
||||
if (!removedTags.contains(depRule)) {
|
||||
removedDeps.add(depRule)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return RulesDiff(preserved, added, removedTags, removedDeps)
|
||||
return RulesDiff(preserved, added, removedTags)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun findDiff(old: Iterable<Rule>, new: Iterable<Rule>): RulesDiff =
|
||||
findDiff(old, new, DependentRulesSpec.EmptySpec)
|
||||
}
|
||||
}
|
||||
|
|
@ -69,18 +69,6 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp
|
|||
return controller.reactivate(activeOcc)
|
||||
}
|
||||
|
||||
// todo: remove
|
||||
fun invalidateDependentRules(ruleIds: Set<Any>) {
|
||||
val it = this.iterator()
|
||||
while (it.hasNext()) {
|
||||
val chunk = it.next()
|
||||
if (chunk is MatchJournal.MatchChunk && ruleIds.contains(chunk.match.rule().uniqueTag())) {
|
||||
trace.invalidate(chunk.match)
|
||||
it.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidation includes several activities:
|
||||
* - removing chunks (i.e. principal matches) corresponding to
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright 2014-2019 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package jetbrains.mps.logic.reactor.program;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public interface DependentRulesSpec {
|
||||
@NotNull
|
||||
Iterable<Object> getDependentRules(Rule rule);
|
||||
|
||||
class EmptySpec implements DependentRulesSpec {
|
||||
@Override
|
||||
@NotNull
|
||||
public Iterable<Object> getDependentRules(Rule rule) {
|
||||
return new ArrayList<Object>();
|
||||
}
|
||||
}
|
||||
|
||||
EmptySpec EmptySpec = new EmptySpec();
|
||||
}
|
||||
Loading…
Reference in New Issue