From 5b4c45206f22d2ca64ba90401b38f41bd220e645 Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Sun, 15 Oct 2023 14:21:15 +0400 Subject: [PATCH] #2780 Fixed line numbering for the frames Perl provides us zero-based line numbers --- .../java/com/perl5/lang/perl/debugger/PerlStackFrame.java | 4 ++-- .../perl/debugger/protocol/PerlStackFrameDescriptor.java | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/PerlStackFrame.java b/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/PerlStackFrame.java index 47de4ad2d2..e489e9a691 100644 --- a/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/PerlStackFrame.java +++ b/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/PerlStackFrame.java @@ -85,7 +85,7 @@ public PerlStackFrame(PerlStackFrameDescriptor frameDescriptor, PerlExecutionSta @Override public void customizePresentation(@NotNull ColoredTextContainer component) { @NlsSafe var frameName = - String.join(":", myFrameDescriptor.getFileDescriptor().getNameOrPath(), String.valueOf(myFrameDescriptor.getLine())); + String.join(":", myFrameDescriptor.getFileDescriptor().getNameOrPath(), String.valueOf(myFrameDescriptor.getOneBasedLine())); component.append(frameName, SimpleTextAttributes.REGULAR_ATTRIBUTES); component.setIcon(AllIcons.Debugger.Frame); } @@ -94,7 +94,7 @@ public void customizePresentation(@NotNull ColoredTextContainer component) { public @Nullable XSourcePosition getSourcePosition() { VirtualFile virtualFile = myVirtualFile.getValue(); if (virtualFile != null) { - return XSourcePositionImpl.create(virtualFile, myFrameDescriptor.getLine()); + return XSourcePositionImpl.create(virtualFile, myFrameDescriptor.getZeroBasedLine()); } return super.getSourcePosition(); } diff --git a/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/protocol/PerlStackFrameDescriptor.java b/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/protocol/PerlStackFrameDescriptor.java index 6b33d4a57a..bad9995375 100644 --- a/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/protocol/PerlStackFrameDescriptor.java +++ b/plugin/debugger/src/main/java/com/perl5/lang/perl/debugger/protocol/PerlStackFrameDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2022 Alexandr Evstigneev + * Copyright 2015-2023 Alexandr Evstigneev * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,10 +33,14 @@ public PerlLoadedFileDescriptor getFileDescriptor() { return file; } - public int getLine() { + public int getZeroBasedLine() { return line; } + public int getOneBasedLine() { + return line + 1; + } + public PerlValueDescriptor[] getLexicals() { return lexicals; }