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

Expose URI of the analyzed file through DelphiCheckContext::getUri #317

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- **API:** `DelphiCheckContext::getUri` method.

### Fixed

- Parsing errors on semicolon-delimited generic type parameters in routine implementation headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import au.com.integradev.delphi.file.DelphiFile.DelphiInputFile;
import au.com.integradev.delphi.preprocessor.CompilerSwitchRegistry;
import au.com.integradev.delphi.reporting.DelphiIssueBuilderImpl;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -58,6 +59,11 @@ public DelphiCheckContextTester(
this.checkRegistrar = checkRegistrar;
}

@Override
public URI getUri() {
return delphiFile.getInputFile().uri();
}

@Override
public DelphiAst getAst() {
return delphiFile.getAst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import au.com.integradev.delphi.file.DelphiFile.DelphiInputFile;
import au.com.integradev.delphi.preprocessor.CompilerSwitchRegistry;
import au.com.integradev.delphi.reporting.DelphiIssueBuilderImpl;
import java.net.URI;
import java.util.List;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.plugins.communitydelphi.api.ast.DelphiAst;
Expand Down Expand Up @@ -51,6 +52,11 @@ public DelphiCheckContextImpl(
this.checkRegistrar = checkRegistrar;
}

@Override
public URI getUri() {
return delphiFile.getInputFile().uri();
}

@Override
public DelphiAst getAst() {
return delphiFile.getAst();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
package org.sonar.plugins.communitydelphi.api.check;

import au.com.integradev.delphi.preprocessor.CompilerSwitchRegistry;
import java.net.URI;
import java.util.List;
import java.util.Objects;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.plugins.communitydelphi.api.ast.DelphiAst;
import org.sonar.plugins.communitydelphi.api.ast.DelphiNode;
import org.sonar.plugins.communitydelphi.api.directive.CompilerDirectiveParser;
Expand All @@ -30,6 +32,15 @@

/** Context injected in check classes and used to report issues. */
public interface DelphiCheckContext {
/**
* Identifier of the file. The only guarantee is that it is unique in the project. You should not
* assume it is a file:// URI.
*
* @return identifier of the file
* @see InputFile#uri()
*/
URI getUri();

/**
* Returns the parsed ast of the current file.
*
Expand Down
Loading