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

Improve Location for Diagnostics #178

Closed
wants to merge 0 commits into from

Conversation

yasmewad
Copy link
Contributor

@yasmewad yasmewad commented Nov 5, 2024

Issue #, if available: 76

What is changed?

  • Updated SmithyLanguageServer.java to improve location for diagnostics.
  • Added a new method to find contiguousRange for non-whitespace characters given a source location.

Why is it necessary?

  • To improve location for diagnostics.
  • See Issue #76

How was the change tested?

  • Updated unit tests in SmithyLanguageServerTest.java and DocumentParserTest.java
  • Ran the full test suite to ensure no regressions
  • Manually tested the language server with various Smithy documents to verify improvements

Screenshots of fix:

Fixed the use diagnostic:

Before:
Issue

After:

Screenshot 2024-11-04 at 4 23 26 PM

Fixed the diagnostics for incorrect members in a structure to not extend till start of line.

Before:

member issue

After:

Screenshot 2024-11-04 at 4 39 38 PM

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@yasmewad yasmewad requested a review from a team as a code owner November 5, 2024 03:45
@yasmewad yasmewad requested review from sugmanue and milesziemer and removed request for sugmanue November 5, 2024 03:45

@ParameterizedTest
@MethodSource("contiguousRangeTestCases")
public void findsContiguousRange(SourceLocation input, Range expected) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add one where the source location is within whitespace? Not sure if that will ever be the case, but just in case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Can add that.

String uri = workspace.getUri("main.smithy");

List<Diagnostic> diagnostics = server.getFileDiagnostics(uri);
diagnostics.forEach(it -> System.out.println(it.toString()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Fyi, can remove. Also in above test case

Copy link
Contributor Author

@yasmewad yasmewad Nov 5, 2024

Choose a reason for hiding this comment

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

Ahh yes, I removed it, but added it back by mistake lol.

@yasmewad yasmewad closed this Nov 5, 2024
@yasmewad yasmewad force-pushed the diagnostic-improvements branch from 4b87258 to 3b1ea23 Compare November 5, 2024 21:20
@yasmewad yasmewad deleted the diagnostic-improvements branch November 5, 2024 21:37
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