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

Add hyperlinks of stack traces in Laravel logs #147

Closed
wants to merge 4 commits into from

Conversation

smirok
Copy link
Contributor

@smirok smirok commented Jun 28, 2023

I've added support for hyperlinks in the Laravel log stacktrace.

In the case Laravel logs, the position in the file is specified in parentheses:

/Users/me/Application.php(35)

While the default format expected the number after the semicolon:

/Users/me/Application.php:35

The feature is tested on file URI for Windows, Linux, and MacOS.


Before:

Screenshot 2023-06-28 at 19 15 20

After:

Screenshot 2023-06-28 at 19 16 07

@pestretsov pestretsov self-requested a review June 28, 2023 09:55
@smirok smirok marked this pull request as draft June 28, 2023 10:10
@smirok smirok marked this pull request as ready for review June 28, 2023 16:59
@smirok smirok closed this Jun 28, 2023
@smirok smirok reopened this Jun 28, 2023
}

private fun buildFileHyperlinkInfo(fileUri: String): HyperlinkInfo? {
var documentLine = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's always a better idea to declare variables as close to their first usage as possible. Also, let's avoid using vars when they are not needed

val documentLine = if (possibleDocumentLine != Int.MIN_VALUE) possibleDocumentLine - 1 else possibleDocumentLine


override fun applyFilter(line: String, entireLength: Int): Filter.Result? {
val textStartOffset = entireLength - line.length
val items = collectItems(textStartOffset, LINUX_MACOS_FILE_PATTERN.matcher(line)) +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items and collectItems are kinda too generic names, right?


override fun applyFilter(line: String, entireLength: Int): Filter.Result? {
val textStartOffset = entireLength - line.length
val items = collectItems(textStartOffset, LINUX_MACOS_FILE_PATTERN.matcher(line)) +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance: we probably should add some kind of fast check that line is not Url to avoid checking regexps

@smirok smirok requested a review from pestretsov June 29, 2023 20:53
@mfilippov mfilippov deleted the branch JetBrains:mf-fixes June 30, 2023 07:49
@mfilippov mfilippov closed this Jun 30, 2023
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.

3 participants