From 45df4d845fab9b54d110646ab19bdd4e69ca860b Mon Sep 17 00:00:00 2001 From: Grigorii Kirgizov Date: Wed, 6 Nov 2019 19:08:42 +0300 Subject: [PATCH] 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. --- .../mps/logic/reactor/core/RulesDiff.kt | 24 +++---------- .../core/internal/ProcessingStateImpl.kt | 12 ------- .../reactor/program/DependentRulesSpec.java | 36 ------------------- 3 files changed, 4 insertions(+), 68 deletions(-) delete mode 100644 reactor/Core/src/jetbrains/mps/logic/reactor/program/DependentRulesSpec.java diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/RulesDiff.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/RulesDiff.kt index b89a11b1..de5baa1a 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/RulesDiff.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/RulesDiff.kt @@ -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, val added: Iterable, - val removed: Set, - val removedDependent: Set + val removed: Set ) { private val preserved: Map = HashMap().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, new: Iterable, ruleDeps: DependentRulesSpec): RulesDiff { + fun findDiff(old: Iterable, new: Iterable): 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 = removed.map { it.uniqueTag() }.toSet() - //fixme: remove - val removedDeps = HashSet() - 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, new: Iterable): RulesDiff = - findDiff(old, new, DependentRulesSpec.EmptySpec) } } \ No newline at end of file diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt index 3bc48f39..785b3f76 100644 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt +++ b/reactor/Core/src/jetbrains/mps/logic/reactor/core/internal/ProcessingStateImpl.kt @@ -69,18 +69,6 @@ internal class ProcessingStateImpl(private var dispatchingFront: Dispatcher.Disp return controller.reactivate(activeOcc) } - // todo: remove - fun invalidateDependentRules(ruleIds: Set) { - 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 diff --git a/reactor/Core/src/jetbrains/mps/logic/reactor/program/DependentRulesSpec.java b/reactor/Core/src/jetbrains/mps/logic/reactor/program/DependentRulesSpec.java deleted file mode 100644 index 54e4259c..00000000 --- a/reactor/Core/src/jetbrains/mps/logic/reactor/program/DependentRulesSpec.java +++ /dev/null @@ -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 getDependentRules(Rule rule); - - class EmptySpec implements DependentRulesSpec { - @Override - @NotNull - public Iterable getDependentRules(Rule rule) { - return new ArrayList(); - } - } - - EmptySpec EmptySpec = new EmptySpec(); -}