diff options
9 files changed, 39 insertions, 12 deletions
diff --git a/server/sonar-web/src/main/js/apps/issues/components/App.js b/server/sonar-web/src/main/js/apps/issues/components/App.js index 4a9dca21d04..e56811d72c3 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/App.js +++ b/server/sonar-web/src/main/js/apps/issues/components/App.js @@ -453,7 +453,7 @@ export default class App extends React.PureComponent { if (lastIssue.component !== openIssue.component) { return true; } - return lastIssue.line != null && lastIssue.line > to; + return lastIssue.textRange != null && lastIssue.textRange.endLine > to; }; if (done(issues, paging)) { diff --git a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js index 062d8530e6d..8580fcff5b6 100644 --- a/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js +++ b/server/sonar-web/src/main/js/apps/issues/components/IssuesSourceViewer.js @@ -78,7 +78,7 @@ export default class IssuesSourceViewer extends React.PureComponent { return ( <div ref={node => (this.node = node)}> <SourceViewer - aroundLine={openIssue.line} + aroundLine={openIssue.textRange ? openIssue.textRange.endLine : undefined} component={openIssue.component} displayAllIssues={true} highlightedLocations={locations} diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js index 59a21aa332d..69af047648c 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js @@ -189,7 +189,7 @@ export default class SourceViewerCode extends React.PureComponent { const displayFiltered = this.props.filterLine != null; const hasIssues = this.props.issues.length > 0; - const hasFileIssues = hasIssues && this.props.issues.some(issue => !issue.line); + const hasFileIssues = hasIssues && this.props.issues.some(issue => !issue.textRange); return ( <div> diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js b/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js index 0047ee41fef..eac2170df15 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/indexing.js @@ -46,7 +46,7 @@ export type IndexedIssueLocationMessage = { export const issuesByLine = (issues: Array<Issue>) => { const index = {}; issues.forEach(issue => { - const line = issue.line || 0; + const line = issue.textRange ? issue.textRange.endLine : 0; if (!(line in index)) { index[line] = []; } diff --git a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js index 0e56ceab7b9..737b9acedda 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js +++ b/server/sonar-web/src/main/js/components/SourceViewer/helpers/loadIssues.js @@ -62,7 +62,10 @@ export const loadPageAndNext = ( const lastIssue = issues[issues.length - 1]; - if ((lastIssue.line != null && lastIssue.line > toLine) || issues.length < pageSize) { + if ( + (lastIssue.textRange != null && lastIssue.textRange.endLine > toLine) || + issues.length < pageSize + ) { return issues; } diff --git a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js index 8621fce9439..6e0fe943f07 100644 --- a/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js +++ b/server/sonar-web/src/main/js/components/issue/components/IssueTitleBar.js @@ -86,10 +86,10 @@ export default function IssueTitleBar(props: Props) { onFail={props.onFail} /> </li> - {issue.line != null && + {issue.textRange != null && <li className="issue-meta"> <span className="issue-meta-label" title={translate('line_number')}> - L{issue.line} + L{issue.textRange.endLine} </span> </li>} {locationsCount > 0 && diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js index f09d709908f..407b05eb189 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/IssueTitleBar-test.js @@ -22,7 +22,13 @@ import React from 'react'; import IssueTitleBar from '../IssueTitleBar'; const issue = { - line: 26, + line: 25, + textRange: { + startLine: 25, + endLine: 26, + startOffset: 0, + endOffset: 15 + }, creationDate: '2017-03-01T09:36:01+0100', organization: 'myorg', project: 'myproject', diff --git a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap index 2a7d3bdbcea..5d61fbfb7d2 100644 --- a/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap +++ b/server/sonar-web/src/main/js/components/issue/components/__tests__/__snapshots__/IssueTitleBar-test.js.snap @@ -30,12 +30,18 @@ exports[`should render the titlebar correctly 1`] = ` "creationDate": "2017-03-01T09:36:01+0100", "flows": Array [], "key": "AVsae-CQS-9G3txfbFN2", - "line": 26, + "line": 25, "message": "Reduce the number of conditional operators (4) used in the expression", "organization": "myorg", "project": "myproject", "rule": "javascript:S1067", "secondaryLocations": Array [], + "textRange": Object { + "endLine": 26, + "endOffset": 15, + "startLine": 25, + "startOffset": 0, + }, } } onFail={[Function]} @@ -111,12 +117,18 @@ exports[`should render the titlebar with the filter 1`] = ` "creationDate": "2017-03-01T09:36:01+0100", "flows": Array [], "key": "AVsae-CQS-9G3txfbFN2", - "line": 26, + "line": 25, "message": "Reduce the number of conditional operators (4) used in the expression", "organization": "myorg", "project": "myproject", "rule": "javascript:S1067", "secondaryLocations": Array [], + "textRange": Object { + "endLine": 26, + "endOffset": 15, + "startLine": 25, + "startOffset": 0, + }, } } onFail={[Function]} @@ -165,12 +177,18 @@ exports[`should render the titlebar with the filter 1`] = ` "creationDate": "2017-03-01T09:36:01+0100", "flows": Array [], "key": "AVsae-CQS-9G3txfbFN2", - "line": 26, + "line": 25, "message": "Reduce the number of conditional operators (4) used in the expression", "organization": "myorg", "project": "myproject", "rule": "javascript:S1067", "secondaryLocations": Array [], + "textRange": Object { + "endLine": 26, + "endOffset": 15, + "startLine": 25, + "startOffset": 0, + }, } } onFail={[Function]} diff --git a/server/sonar-web/src/main/js/components/issue/types.js b/server/sonar-web/src/main/js/components/issue/types.js index 45fb150ad30..8788dc4d206 100644 --- a/server/sonar-web/src/main/js/components/issue/types.js +++ b/server/sonar-web/src/main/js/components/issue/types.js @@ -77,7 +77,7 @@ export type Issue = { subProjectName?: string, subProjectUuid?: string, tags?: Array<string>, - textRange: TextRange, + textRange?: TextRange, transitions?: Array<string>, type: string }; |