Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Commit 69bf965

Browse files
author
jchapuis
committed
adjusted namings in CompletionExpansionSupport
1 parent aed5c18 commit 69bf965

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/main/scala/com/nexthink/utils/parsing/combinator/completion/CompletionExpansionSupport.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ trait CompletionExpansionSupport extends RegexCompletionSupport {
2020
* @tparam T the parser type
2121
* @return a parser adapter performing completion expansion
2222
*/
23-
def allExpandedCompletions[T](p: Parser[T], onlyAtInputEnd: Boolean = true): Parser[T] = expandedCompletions(p, p, onlyAtInputEnd)
23+
def expandedCompletions[T](p: Parser[T], onlyAtInputEnd: Boolean = true): Parser[T] = expandedCompletionsWithLimiter(p, p, onlyAtInputEnd)
2424

2525
/**
2626
* Adapts a parser so that completing it will construct the list of all possible alternatives up to the point
27-
* where the passed `stop` parser successfully parses the expansions.
27+
* where the passed `limiter` parser successfully parses the expansions.
2828
* (note that if this is used within the context of a grammar allowing for infinitely growing expressions,
29-
* selecting the relevant stop parser is critical to avoid infinite recursion)
29+
* selecting the relevant limiter parser is critical to avoid infinite recursion)
3030
* @param p the parser
3131
* @param onlyAtInputEnd expansion happens only when input is positioned exactly at the end upon completion
32-
* @param stop the parser signalling the end of exploration upon successful parse
32+
* @param limiter the parser signalling the end of exploration upon successful parse
3333
* @tparam T the parser type
34-
* @return a parser adapter performing completion expansion limited according to `stop` parser
34+
* @return a parser adapter performing completion expansion limited according to `limiter` parser
3535
*/
36-
def expandedCompletions[T](p: Parser[T], stop: Parser[Any], onlyAtInputEnd: Boolean = true): Parser[T] =
36+
def expandedCompletionsWithLimiter[T](p: Parser[T], limiter: Parser[Any], onlyAtInputEnd: Boolean = true): Parser[T] =
3737
Parser(
3838
p,
3939
in => {
4040
lazy val isAtInputEnd = dropAnyWhiteSpace(in).atEnd
4141
if (!onlyAtInputEnd || isAtInputEnd) {
42-
val Completions(_, sets) = exploreCompletions(p, stop, in)
42+
val Completions(_, sets) = exploreCompletions(p, limiter, in)
4343
Completions(OffsetPosition(in.source, handleWhiteSpace(in)), sets)
4444
} else
4545
p.completions(in)

src/test/scala/com/nexthink/utils/parsing/combinator/completion/CompletionExpansionSupportTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CompletionExpansionSupportTest {
2020
def term(maxNesting: Int) = factor(maxNesting) ~ "*" ~! factor(maxNesting)
2121
def factor(maxNesting: Int): Parser[Any] = if (maxNesting == 0) number else number | "(" ~> expr(maxNesting - 1) <~ ")"
2222

23-
def exprWithExpandedCompletions() = allExpandedCompletions(expr(1))
23+
def exprWithExpandedCompletions() = expandedCompletions(expr(1))
2424
}
2525

2626
@Test
@@ -41,7 +41,7 @@ class CompletionExpansionSupportTest {
4141
val jumpsOver = "which jumps over the lazy" % "action"
4242
val jumpsOverDogOrCat = jumpsOver ~ ("dog" | "cat") % "animal" %? "dogs and cats" % 10
4343
lazy val parser = jumpsOverDogOrCat | jumpsOverDogOrCat ~ which()
44-
def which(): Parser[Any] = expandedCompletions(parser, stop = jumpsOverDogOrCat ~ jumpsOverDogOrCat)
44+
def which(): Parser[Any] = expandedCompletionsWithLimiter(parser, limiter = jumpsOverDogOrCat ~ jumpsOverDogOrCat)
4545
lazy val infiniteDogsAndCats = fox ~ which
4646
}
4747

0 commit comments

Comments
 (0)