Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improved diagnostic rendering #42236

Draft
wants to merge 55 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
49316b7
Improve diagnostic rendering for simple cases
RadCod3 Jan 30, 2024
0e214c3
Handling tab chars in user code
RadCod3 Jan 31, 2024
61bc9fc
Add caret underline for multi lined diagnostics
RadCod3 Feb 1, 2024
affe957
Filter duplicate diagnostics
RadCod3 Feb 2, 2024
5585a3b
Change tree traversal approach
RadCod3 Feb 9, 2024
6399787
Move classes to shell-cli to access jansi
RadCod3 Feb 9, 2024
a43a4ff
Truncate singleline diagnostics by terminal width
RadCod3 Feb 12, 2024
f5477c0
Change tree traversal to direct line access
RadCod3 Feb 12, 2024
c79a1c8
Handle extreme terminal window sizes
RadCod3 Feb 13, 2024
662b8df
Use existing syntaxtree, handle bal build projects
RadCod3 Feb 15, 2024
bd77867
Bump jline version to access jansi from within it
RadCod3 Feb 16, 2024
ac7c15f
Pass missing tokens through diagnosticproperties
RadCod3 Feb 21, 2024
05373ed
Clean up
RadCod3 Feb 21, 2024
837a200
Move back to ballerina-cli, show error code
RadCod3 Feb 27, 2024
5cf9400
Annotate errors in module tests
RadCod3 Feb 27, 2024
5b43f9c
Fix padding before colon when single digit
RadCod3 Feb 27, 2024
ea57515
Add license header and class comment
RadCod3 Feb 28, 2024
3d3a6f0
Fix checkstyle fail and add review suggestions
RadCod3 Feb 28, 2024
ec2b328
Update jline version for test compatibility
RadCod3 Mar 3, 2024
163df5f
Move usage of jansi to AnnotateDiagnostics class
RadCod3 Mar 3, 2024
e3dfaaf
Add option to disable color for tests
RadCod3 Mar 3, 2024
8eb0560
Update ballerina-cli tests for new diagnostics
RadCod3 Mar 4, 2024
c6d4865
Fix to pass jballerina-integration-test
RadCod3 Mar 5, 2024
710f66d
Update testerina-tests for new diagnostics
RadCod3 Mar 5, 2024
151f957
Add tests for AnnotateDiagnostics
RadCod3 Mar 8, 2024
b061f95
Remove unused imports
RadCod3 Mar 8, 2024
0f86532
Add newline
RadCod3 Mar 8, 2024
4fc62c6
Fix testerina windows test
RadCod3 Mar 9, 2024
bb5bc5e
Handle forward slashes in document names
RadCod3 Mar 10, 2024
b3ac8ab
Add more tests to improve codecov score
RadCod3 Mar 11, 2024
95f0cd2
Add tests for DiagnosticAnnotation
RadCod3 Mar 12, 2024
4c4d8fb
Improve truncate function
RadCod3 Mar 12, 2024
89ab5b8
Add a workaround for tests not running
RadCod3 Mar 20, 2024
36a762e
Fix cannot resolve module error
RadCod3 Mar 21, 2024
0fc64f0
Change back to regular compile method
RadCod3 Mar 21, 2024
03d4b31
Update tests
RadCod3 Mar 21, 2024
3a9a080
Optimize logic and add more tests
RadCod3 Mar 22, 2024
8d5cfb1
Add newlines and more tests
RadCod3 Mar 22, 2024
32e2373
Address code review comments
RadCod3 Mar 28, 2024
c67a40d
Fix tests for new diagnostics
RadCod3 Mar 29, 2024
bb72797
Use string builder for truncation
RadCod3 Mar 29, 2024
a81b064
Refactor truncation logic, rename function name
RadCod3 Apr 9, 2024
a4ece31
Pull reusable method calls into variables
RadCod3 Apr 10, 2024
7cf46e5
Address code review comments
RadCod3 Apr 17, 2024
ce37ed7
Move logic from CompileTask to AnnotateDiagnostics
RadCod3 Apr 17, 2024
998bfd3
Address suggestions made at code review
RadCod3 Apr 30, 2024
b903b1b
Format test bal files, update toml files
RadCod3 May 6, 2024
85d3c98
Integrate dataprovider for resilient tests
RadCod3 May 6, 2024
a66495b
Use listener class instead of http library
RadCod3 May 6, 2024
7f4f3ed
Update color annotation test with new hint color
RadCod3 May 6, 2024
2ede880
Fix bug found in code review
RadCod3 May 7, 2024
4129911
Refactor method visibility for cleaner code
RadCod3 May 7, 2024
fda2128
Use string builder for efficiency
RadCod3 May 9, 2024
12e70f6
WIP diagnostic area text wrap
RadCod3 May 24, 2024
ca8c192
Apply suggestions from code review
gimantha Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bug found in code review
  • Loading branch information
RadCod3 committed May 7, 2024
commit 2ede880a2aa63aa39f680c36d5226e3be87b08bc
Original file line number Diff line number Diff line change
@@ -195,19 +195,22 @@ protected static TruncateResult truncate(String line, int maxLength, int diagnos
}

StringBuilder truncatedLineBuilder = new StringBuilder();
if (diagnosticStart + diagnosticLength <= maxLength - 3) {
truncatedLineBuilder.append(line, 0, maxLength - 3).append(ELLIPSIS);
if (diagnosticStart + diagnosticLength <= maxLength - ELLIPSIS.length()) {
truncatedLineBuilder.append(line, 0, maxLength - ELLIPSIS.length()).append(ELLIPSIS);
return new TruncateResult(truncatedLineBuilder.toString(), diagnosticStart, diagnosticLength);
}

int diagnosticMid = diagnosticStart + (diagnosticLength / 2);
int stepsToMoveWindow = Math.max(0, diagnosticMid - (maxLength / 2));
int border = Math.min(line.length() - 1, stepsToMoveWindow + maxLength - 3);
int newDiagnosticStart = Math.max(3, diagnosticStart - stepsToMoveWindow);
int newDiagnosticLength = Math.min(diagnosticLength, maxLength - newDiagnosticStart - 3);
int stringStart = Math.min(stepsToMoveWindow + 3, border);

truncatedLineBuilder.append(ELLIPSIS).append(line, stringStart, border).append(ELLIPSIS);
int border = Math.min(line.length(), stepsToMoveWindow + maxLength - ELLIPSIS.length());
int newDiagnosticStart = Math.max(ELLIPSIS.length(), diagnosticStart - stepsToMoveWindow);
int newDiagnosticLength = Math.min(diagnosticLength, maxLength - newDiagnosticStart - ELLIPSIS.length());
int stringStart = Math.min(stepsToMoveWindow + ELLIPSIS.length(), border);

truncatedLineBuilder.append(ELLIPSIS).append(line, stringStart, border);
if (border < line.length()) {
truncatedLineBuilder.append(ELLIPSIS);
}
return new TruncateResult(truncatedLineBuilder.toString(), newDiagnosticStart,
Math.max(0, newDiagnosticLength));
}