Skip to content

Commit

Permalink
Merge pull request #2107 from ballerina-platform/fix-location-matching
Browse files Browse the repository at this point in the history
Fix location matching logic for service contract implementation hint
  • Loading branch information
TharmiganK authored Aug 13, 2024
2 parents 5a6fc69 + 004ca36 commit 86214d9
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,19 @@ private static void checkForServiceImplementationErrors(SyntaxNodeAnalysisContex
Location diagnosticLocation = diagnostic.location();

if (diagnostic.message().contains("no implementation found for the method 'resource function")
&& diagnosticLocation.textRange().equals(location.textRange())
&& diagnosticLocation.lineRange().equals(location.lineRange())) {
&& intersects(location, diagnosticLocation)) {
enableImplementServiceContractCodeAction(context, serviceType, location);
return;
}
}
}

private static boolean intersects(Location targetLocation, Location diagnosticLocation) {
return targetLocation.lineRange().startLine().line() <= diagnosticLocation.lineRange().startLine().line() &&
targetLocation.lineRange().endLine().line() >= diagnosticLocation.lineRange().endLine().line() &&
targetLocation.textRange().intersectionExists(diagnosticLocation.textRange());
}

private static void validateResourceLinks(SyntaxNodeAnalysisContext syntaxNodeAnalysisContext,
LinksMetaData linksMetaData) {
if (!linksMetaData.hasNameReferenceObjects()) {
Expand Down

0 comments on commit 86214d9

Please sign in to comment.