-
Notifications
You must be signed in to change notification settings - Fork 330
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
[lldb] Add Swift syntax highlighting using SwiftSyntax #9216
base: stable/20230725
Are you sure you want to change the base?
Conversation
@swift-ci test |
Use SwiftSyntax to parse source code that will be displayed in command line LLDB and syntax highlight it. This adds a new CMake project under Plugins/Language/Swift/SwiftHighlighter, which has a dependency on the SwiftSyntax shared library which is already used by the compiler.
@swift-ci test |
b588c37
to
915077f
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! Left a couple of high-level comments inside.
@@ -0,0 +1,17 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should/Could this be project-wide and at a much higher directory level?
@@ -0,0 +1,17 @@ | |||
{ | |||
"version": 1, | |||
"lineLength": 120, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does Swift get a longer line length?
|
||
# Verify that we have a new enough compiler | ||
if("${CMAKE_Swift_COMPILER_VERSION}" VERSION_LESS 5.9) | ||
message(FATAL_ERROR "Bidirectional C++ Interop requires Swift 5.9 or greater. Have ${CMAKE_Swift_COMPILER_VERSION}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Have/Found/
|
||
enum AnsiColor { | ||
enum Bright { | ||
static let red = String(ansi.FormatAnsiTerminalCodes(std.string("${ansi.fg.bright.red}"), true)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could String(ansi.FormatAnsiTerminalCodes(std.string(someString), true))
be a helper function?
case function | ||
case functionLabel | ||
|
||
func getColor() -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc string?
@@ -0,0 +1,66 @@ | |||
# Generate the bridging header from Swift to C++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the word "bridging header" only used for the opposite direction?
@@ -0,0 +1,182 @@ | |||
//===----------------------------------------------------------------------===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing the C++ marker
// | ||
// This source file is part of the Swift open source project | ||
// | ||
// Copyright (c) 2023 Apple Inc. and the Swift project authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that year seems wrong
#ifndef SWIFTHIGHLIGHTERSUPPORT_H | ||
#define SWIFTHIGHLIGHTERSUPPORT_H | ||
|
||
#define ANSI_FG_COLOR_BLACK 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These probably shouldn't be #defines anyway. Could you factor these enums out into a new header upstream that you can import into Swift?
const char *value; | ||
} g_color_tokens[] = { | ||
#define _TO_STR2(_val) #_val | ||
#define _TO_STR(_val) _TO_STR2(_val) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be in the header?
Use SwiftSyntax to parse source code that will be displayed in command line LLDB and syntax highlight it. This adds a new CMake project under Plugins/Language/Swift/SwiftHighlighter, which has a dependency on the SwiftSyntax shared library which is already used by the compiler.