mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
[DS-4464] added cell language providing for Jupyter files and added tests
[DS-4464] Changed intervals gen in NotebookOutputInlayControllerTest to custom because of non-backedNotebook file [DS-4464] changed name of function in RMarkdownCellLinesTest and in CodeCellLinesChecker and fixed formatting [DS-4464] changed name to call a proper function in each class [DS-4464] moved CodeCellLinesChecker.IntervalsSetter.interval to CodeCellLinesChecker, made public, removed duplications [DS-4464] reusing marker instead of creating new in markerSequence and fixed formatting in KotlinTest [DS-4464] made markerSequence map, added property for markdownLanguage in tests and removed unused cast [DS-4464] fixed params in markerSequence, moved intervalsGeneratorFromLexer to JupyterNotebookCellTypeAwareLexerProvider [DS-4464] added cell language providing for Jupyter files and added tests Merge-request: IJ-MR-105885 Merged-by: Georgii Zorabov <georgii.zorabov@jetbrains.com> GitOrigin-RevId: 4afcad6442ac795fe1f01a5662d770a716dbb407
This commit is contained in:
committed by
intellij-monorepo-bot
parent
51a371c2b5
commit
602bb2058a
@@ -10,7 +10,7 @@ import org.jetbrains.plugins.notebooks.visualization.NotebookCellLines.MarkersAt
|
|||||||
import kotlin.math.max
|
import kotlin.math.max
|
||||||
|
|
||||||
interface NotebookCellLinesLexer {
|
interface NotebookCellLinesLexer {
|
||||||
fun markerSequence(chars: CharSequence, ordinalIncrement: Int, offsetIncrement: Int): Sequence<Marker>
|
fun markerSequence(chars: CharSequence, ordinalIncrement: Int, offsetIncrement: Int, defaultLanguage: Language): Sequence<Marker>
|
||||||
|
|
||||||
data class Marker(
|
data class Marker(
|
||||||
val ordinal: Int,
|
val ordinal: Int,
|
||||||
@@ -47,7 +47,7 @@ interface NotebookCellLinesLexer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun defaultIntervals(document: Document, markers: List<Marker>): List<NotebookCellLines.Interval> {
|
fun defaultIntervals(document: Document, markers: List<Marker>): List<NotebookCellLines.Interval> {
|
||||||
val intervals = toIntervalsInfo(document, markers)
|
val intervals = toIntervalsInfo(document, markers)
|
||||||
|
|
||||||
val result = mutableListOf<NotebookCellLines.Interval>()
|
val result = mutableListOf<NotebookCellLines.Interval>()
|
||||||
@@ -60,12 +60,6 @@ interface NotebookCellLinesLexer {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun intervalsGeneratorFromLexer(lexer: NotebookCellLinesLexer): IntervalsGenerator = object : IntervalsGenerator {
|
|
||||||
override fun makeIntervals(document: Document): List<NotebookCellLines.Interval> {
|
|
||||||
val markers = lexer.markerSequence(document.charsSequence, 0, 0).toList()
|
|
||||||
return defaultIntervals(document, markers)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ class CodeCellLinesChecker(private val description: String,
|
|||||||
markers = mutableListOf()
|
markers = mutableListOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun marker(cellType: NotebookCellLines.CellType, offset: Int, length: Int, language : Language? = null) {
|
fun marker(cellType: NotebookCellLines.CellType, offset: Int, length: Int, language: Language? = null) {
|
||||||
markers!!.add(
|
markers!!.add(
|
||||||
NotebookCellLinesLexer.Marker(ordinal = markers!!.size + markersStartOrdinal, type = cellType, offset = offset, length = length, language = language))
|
NotebookCellLinesLexer.Marker(ordinal = markers!!.size + markersStartOrdinal, type = cellType, offset = offset, length = length,
|
||||||
|
language = language))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,9 +33,21 @@ class CodeCellLinesChecker(private val description: String,
|
|||||||
}
|
}
|
||||||
|
|
||||||
class IntervalsSetter(private val list: MutableList<NotebookCellLines.Interval>, private val startOrdinal: Int) {
|
class IntervalsSetter(private val list: MutableList<NotebookCellLines.Interval>, private val startOrdinal: Int) {
|
||||||
fun interval(cellType: NotebookCellLines.CellType, lines: IntRange, markers: NotebookCellLines.MarkersAtLines, language : Language? = null) {
|
fun interval(cellType: NotebookCellLines.CellType,
|
||||||
|
lines: IntRange,
|
||||||
|
markers: NotebookCellLines.MarkersAtLines,
|
||||||
|
language: Language? = null) {
|
||||||
list += NotebookCellLines.Interval(list.size + startOrdinal, cellType, lines, markers, language)
|
list += NotebookCellLines.Interval(list.size + startOrdinal, cellType, lines, markers, language)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun interval(cellType: NotebookCellLines.CellType, lines: IntRange, language: Language? = null) {
|
||||||
|
val markers =
|
||||||
|
if (cellType == NotebookCellLines.CellType.RAW && lines.first == 0)
|
||||||
|
NotebookCellLines.MarkersAtLines.NO
|
||||||
|
else
|
||||||
|
NotebookCellLines.MarkersAtLines.TOP
|
||||||
|
interval(cellType, lines, markers, language)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun intervals(startLine: Int = 0, startOrdinal: Int = 0, handler: IntervalsSetter.() -> Unit) {
|
fun intervals(startLine: Int = 0, startOrdinal: Int = 0, handler: IntervalsSetter.() -> Unit) {
|
||||||
|
|||||||
Reference in New Issue
Block a user