Refactor: drop unused on MPS level java interfaces

This commit is contained in:
Grigorii Kirgizov 2020-02-28 14:17:14 +03:00
parent 37dd3ee4a8
commit 8102080809
8 changed files with 16 additions and 72 deletions

View File

@ -16,7 +16,6 @@
package jetbrains.mps.logic.reactor.core
import jetbrains.mps.logic.reactor.evaluation.RuleMatchingProbeState
import jetbrains.mps.logic.reactor.program.Rule
import jetbrains.mps.logic.reactor.util.Profiler
@ -27,7 +26,7 @@ import java.util.BitSet
*
* @author Fedor Isakov
*/
interface RuleMatchingProbe : RuleMatchingProbeState {
interface RuleMatchingProbe {
fun rule(): Rule

View File

@ -71,7 +71,7 @@ internal class EvaluationSessionImpl private constructor (
val processing = ConstraintsProcessing(
Dispatcher(ruleIndex, tkn.getFrontState()).front(),
MatchJournalImpl(ispec, tkn.journalView),
MatchJournalImpl(ispec, tkn.journalView as MatchJournal.View),
ruleIndex, logicalState, ispec, trace, profiler
)
val controller = ControllerImpl(supervisor, processing, ispec, trace, profiler)

View File

@ -133,23 +133,21 @@ interface MatchJournal : MutableIterable<MatchJournal.Chunk>, EvidenceSource {
/**
* Immutable snapshot of [MatchJournal].
*/
data class View(private val chunks: List<Chunk>, private val evidenceSeed: Evidence) : MatchJournalView {
override fun getChunks(): List<Chunk> = chunks
override fun getEvidenceSeed(): Evidence = evidenceSeed
data class View(val chunks: List<Chunk>, val evidenceSeed: Evidence) : MatchJournalView {
override fun getStoreView(): StoreView = StoreViewImpl(
chunks.flatMap { it.entriesLog() }.allOccurrences().asSequence()
)
}
interface Chunk : MatchJournalChunk, Justified {
interface Chunk : Justified {
// fixme: hide rm-mutability
var entries: MutableList<Entry>
override fun entriesLog(): List<Entry> = entries
fun entriesLog(): List<Entry> = entries
data class Entry(val occ: Occurrence, val discarded: Boolean = false) : MatchJournalChunk.Entry {
override fun occ(): Occurrence = occ
override fun discarded(): Boolean = discarded
data class Entry(val occ: Occurrence, val discarded: Boolean = false) {
fun occ(): Occurrence = occ
fun discarded(): Boolean = discarded
override fun toString() = (if (discarded) '-' else '+') + occ.toString()
}
@ -219,7 +217,7 @@ internal class StoreViewImpl(occurrences: Sequence<Occurrence>) : StoreView {
}
private fun Iterable<MatchJournalChunk.Entry>.allOccurrences(): List<Occurrence> {
private fun Iterable<MatchJournal.Chunk.Entry>.allOccurrences(): List<Occurrence> {
val set = HashSet<Id<Occurrence>>()
for (it in this) {
val idOcc = Id(it.occ() as Occurrence)

View File

@ -32,7 +32,7 @@ import java.util.*
internal open class MatchJournalImpl(
private val ispec: IncrementalProgramSpec,
view: MatchJournalView? = null
view: MatchJournal.View? = null
) : MatchJournal {
// invariant: never empty

View File

@ -1,29 +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.evaluation;
import java.util.List;
public interface MatchJournalChunk {
interface Entry {
ConstraintOccurrence occ();
boolean discarded();
}
List<Entry> entriesLog();
}

View File

@ -20,10 +20,5 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface MatchJournalView {
@NotNull
List<MatchJournalChunk> getChunks();
int getEvidenceSeed();
StoreView getStoreView();
}

View File

@ -1,21 +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.evaluation;
// fixme: empty interface and unchecked cast to RuleMatchingProbe in EvaluationSessionImpl
public interface RuleMatchingProbeState {
}

View File

@ -76,14 +76,16 @@ class TestIncrementalProgram {
return this to result
}
private fun SessionToken.chunks(): Collection<MatchJournal.Chunk> =
(this.journalView as MatchJournal.View).chunks
private fun EvaluationResult.chunksSymbolView() = this.token().journalView.chunks.map {
private fun EvaluationResult.chunksSymbolView() = this.token().chunks().map {
it.entriesLog().map { entry -> !entry.discarded() to entry.occ().constraint().symbol() }
}
private fun EvaluationResult.lastChunk() = this.token().journalView.chunks.last() as MatchJournal.Chunk
private fun EvaluationResult.lastChunk() = this.token().chunks().last() as MatchJournal.Chunk
private fun EvaluationResult.countChunks() = this.token().journalView.chunks.size
private fun EvaluationResult.countChunks() = this.token().chunks().size
private fun Iterable<Occurrence>.constraintSymbols() = this.map { it.constraint.symbol() }
@ -624,7 +626,7 @@ class TestIncrementalProgram {
))
).relaunch("withBar", progSpec, evalRes.token()) { result ->
println(result.token().journalView.chunks)
println(result.token().chunks())
// if "foobar" happens too early, "1st" occ won't be produced
result.storeView().constraintSymbols() shouldBe setOf(sym0("start"), sym0("1st"), sym0("2nd"))