mirror of
https://github.com/apple/pkl.git
synced 2026-03-29 21:31:51 +02:00
Add syntax highlighting of Pkl code (#1385)
This adds syntax highlighting of Pkl code! It adds highlighting for: * Stack frames within error messages * CLI REPL (highlights as you type, highlights error output) * Power assertions (coming in https://github.com/apple/pkl/pull/1384) This uses the lexer for highlighting. It will highlight strings, numbers, keywords, but doesn't understand how to highlight nodes like types, function params, etc. The reason for this is because a single line of code by itself may not be grammatically valid.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,6 +65,14 @@ public class Lexer {
|
||||
return new String(source, sCursor, cursor - sCursor);
|
||||
}
|
||||
|
||||
public int getStartCursor() {
|
||||
return sCursor;
|
||||
}
|
||||
|
||||
public int getCursor() {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public char[] getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user