Skip to content
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

Open
wants to merge 1 commit into
base: stable/20230725
Choose a base branch
from

Conversation

augusto2112
Copy link

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.

@augusto2112
Copy link
Author

@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.
@augusto2112
Copy link
Author

@swift-ci test

@augusto2112
Copy link
Author

@swift-ci test

Copy link

@adrian-prantl adrian-prantl left a 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 @@
{

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,

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}")

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))

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 {

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++

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 @@
//===----------------------------------------------------------------------===//

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.

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

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)

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants