Search in sources :

Example 1 with DefaultTextPointer

use of org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextPointer in project sonarlint-core by SonarSource.

the class DefaultAnalysisErrorTests method setUp.

@BeforeEach
void setUp() {
    inputFile = new TestInputFileBuilder("src/File.java").build();
    textPointer = new DefaultTextPointer(5, 2);
    storage = mock(SensorStorage.class);
}
Also used : TestInputFileBuilder(testutils.TestInputFileBuilder) DefaultTextPointer(org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextPointer) SensorStorage(org.sonar.api.batch.sensor.internal.SensorStorage) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with DefaultTextPointer

use of org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextPointer in project sonarlint-core by SonarSource.

the class DefaultLocationTests method verify_accessors.

@Test
void verify_accessors() {
    var inputFile = mock(ClientInputFile.class);
    var message = "fummy";
    var sqApiTextRange = new DefaultTextRange(new DefaultTextPointer(1, 2), new DefaultTextPointer(3, 4));
    var defaultLocation = new DefaultLocation(inputFile, sqApiTextRange, message);
    assertThat(defaultLocation.getInputFile()).isSameAs(inputFile);
    assertThat(defaultLocation.getMessage()).isSameAs(message);
    assertThat(defaultLocation.getTextRange().getStartLine()).isEqualTo(1);
    assertThat(defaultLocation.getTextRange().getStartLineOffset()).isEqualTo(2);
    assertThat(defaultLocation.getTextRange().getEndLine()).isEqualTo(3);
    assertThat(defaultLocation.getTextRange().getEndLineOffset()).isEqualTo(4);
}
Also used : DefaultTextRange(org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextRange) DefaultTextPointer(org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextPointer) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultTextPointer

use of org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextPointer in project sonarlint-core by SonarSource.

the class DefaultFilterableIssueTests method delegate_textRange_to_rawIssue.

@Test
void delegate_textRange_to_rawIssue() {
    TextRange textRange = new DefaultTextRange(new DefaultTextPointer(0, 1), new DefaultTextPointer(2, 3));
    var activeRule = mock(ActiveRuleAdapter.class);
    when(activeRule.ruleKey()).thenReturn(RuleKey.of("foo", "S123"));
    var rawIssue = new Issue(activeRule, null, textRange, null, null, null);
    FilterableIssue underTest = new DefaultFilterableIssue(rawIssue, mock(InputComponent.class));
    assertThat(underTest.textRange()).usingRecursiveComparison().isEqualTo(textRange);
}
Also used : InputComponent(org.sonar.api.batch.fs.InputComponent) FilterableIssue(org.sonar.api.scan.issue.filter.FilterableIssue) Issue(org.sonarsource.sonarlint.core.analysis.api.Issue) FilterableIssue(org.sonar.api.scan.issue.filter.FilterableIssue) DefaultTextRange(org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextRange) TextRange(org.sonar.api.batch.fs.TextRange) DefaultTextRange(org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextRange) DefaultTextPointer(org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextPointer) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultTextPointer (org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextPointer)3 Test (org.junit.jupiter.api.Test)2 DefaultTextRange (org.sonarsource.sonarlint.core.analysis.container.analysis.filesystem.DefaultTextRange)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 InputComponent (org.sonar.api.batch.fs.InputComponent)1 TextRange (org.sonar.api.batch.fs.TextRange)1 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)1 FilterableIssue (org.sonar.api.scan.issue.filter.FilterableIssue)1 Issue (org.sonarsource.sonarlint.core.analysis.api.Issue)1 TestInputFileBuilder (testutils.TestInputFileBuilder)1