Skip to content

New highlighter based on tokens and untyped trees #5137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Sep 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
263c377
Add UntypedTreeTraverser
slothspot May 16, 2018
5c337a8
Introduce Parser and Scanner based highlighter
slothspot May 16, 2018
abaaa27
Small improvements in highlighter
slothspot May 16, 2018
c639ab8
Switch highlighting tests to new highlighter implementation
slothspot May 16, 2018
88bdbd4
Address review comments
slothspot May 18, 2018
9c85db2
Highlight Ident as type when it is type
slothspot May 18, 2018
90c4107
Update expected highlight for union types
slothspot May 18, 2018
02926b6
Change ctx.error to println
slothspot May 23, 2018
f1662d6
Add annotations highlight
slothspot May 23, 2018
8dc30f4
Remove old highlighter code and ignore tests with unsupported features
slothspot May 28, 2018
ffdc530
Polishing
allanrenucci Jun 1, 2018
9c73b0b
Let's turn on debug mode by default
allanrenucci Jun 1, 2018
368fc5b
Fix position error in annotation parameter list parsing
danielyli Jun 19, 2018
2645cab
Add tests for mid-expression user inputs
danielyli Jun 20, 2018
f95dfb7
Add tests for long and float literals
danielyli Jun 20, 2018
049eafe
Fix rebase breakages
allanrenucci Jun 29, 2018
0748eea
Fix position of parsed applications
smarter Jun 29, 2018
cfe896d
Fix rebase breakage
allanrenucci Sep 19, 2018
01768ca
Use tokens (instead of trees) to highlight literals
allanrenucci Sep 21, 2018
a8dc7e8
Add syntax highlighting support for string interpolator
allanrenucci Sep 21, 2018
2b67780
Highlight `inline` as a "soft" keyword
allanrenucci Sep 24, 2018
feeb420
Address review comments
allanrenucci Sep 26, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,12 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
}
}

abstract class UntypedTreeTraverser extends UntypedTreeAccumulator[Unit] {
def traverse(tree: Tree)(implicit ctx: Context): Unit
def apply(x: Unit, tree: Tree)(implicit ctx: Context) = traverse(tree)
protected def traverseChildren(tree: Tree)(implicit ctx: Context) = foldOver((), tree)
}

/** Fold `f` over all tree nodes, in depth-first, prefix order */
class UntypedDeepFolder[X](f: (X, Tree) => X) extends UntypedTreeAccumulator[X] {
def apply(x: X, tree: Tree)(implicit ctx: Context): X = foldOver(f(x, tree), tree)
Expand Down
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,9 @@ object Parsers {
}
}
if (in.token == LPAREN && (!inClassConstrAnnots || isLegalAnnotArg))
parArgumentExprss(Apply(fn, parArgumentExprs()))
parArgumentExprss(
atPos(startOffset(fn)) { Apply(fn, parArgumentExprs()) }
)
else fn
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/printing/Formatting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ object Formatting {
hl.show
case hb: HighlightBuffer =>
hb.toString
case str: String if ctx.settings.color.value != "never" =>
new String(SyntaxHighlighting(str).toArray)
case str: String =>
SyntaxHighlighting.highlight(str)
case _ => super.showArg(arg)
}
}
Expand Down
Loading