aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js')
-rw-r--r--server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js20
1 files changed, 13 insertions, 7 deletions
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 8b9cfb46bd5..64aeedd5ba6 100644
--- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
+++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.js
@@ -40,7 +40,7 @@ const ZERO_LINE = {
};
export default class SourceViewerCode extends React.PureComponent {
- props: {
+ props: {|
displayAllIssues: boolean,
duplications?: Array<Duplication>,
duplicationsByLine: { [number]: Array<number> },
@@ -51,7 +51,7 @@ export default class SourceViewerCode extends React.PureComponent {
highlightedLine: number | null,
highlightedSymbols: Array<string>,
issues: Array<Issue>,
- issuesByLine: { [number]: Array<string> },
+ issuesByLine: { [number]: Array<Issue> },
issueLocationsByLine: { [number]: Array<LinearIssueLocation> },
issueSecondaryLocationsByIssueByLine: IndexedIssueLocationsByIssueAndLine,
issueSecondaryLocationMessagesByIssueByLine: IndexedIssueLocationMessagesByIssueAndLine,
@@ -62,6 +62,7 @@ export default class SourceViewerCode extends React.PureComponent {
loadingSourcesBefore: boolean,
onCoverageClick: (SourceLine, HTMLElement) => void,
onDuplicationClick: (number, number) => void,
+ onIssueChange: (Issue) => void,
onIssueSelect: (string) => void,
onIssueUnselect: () => void,
onIssuesOpen: (SourceLine) => void,
@@ -75,13 +76,13 @@ export default class SourceViewerCode extends React.PureComponent {
selectedIssueLocation: IndexedIssueLocation | null,
sources: Array<SourceLine>,
symbolsByLine: { [number]: Array<string> }
- };
+ |};
getDuplicationsForLine(line: SourceLine) {
return this.props.duplicationsByLine[line.line] || EMPTY_ARRAY;
}
- getIssuesForLine(line: SourceLine): Array<string> {
+ getIssuesForLine(line: SourceLine): Array<Issue> {
return this.props.issuesByLine[line.line] || EMPTY_ARRAY;
}
@@ -98,8 +99,11 @@ export default class SourceViewerCode extends React.PureComponent {
}
getSecondaryIssueLocationMessagesForLine(line: SourceLine, issueKey: string) {
- return this.props.issueSecondaryLocationMessagesByIssueByLine[issueKey][line.line] ||
- EMPTY_ARRAY;
+ const index = this.props.issueSecondaryLocationMessagesByIssueByLine;
+ if (index[issueKey] == null) {
+ return EMPTY_ARRAY;
+ }
+ return index[issueKey][line.line] || EMPTY_ARRAY;
}
renderLine = (
@@ -131,7 +135,8 @@ export default class SourceViewerCode extends React.PureComponent {
optimizedHighlightedSymbols = EMPTY_ARRAY;
}
- const optimizedSelectedIssue = selectedIssue != null && issuesForLine.includes(selectedIssue)
+ const optimizedSelectedIssue = selectedIssue != null &&
+ issuesForLine.find(issue => issue.key === selectedIssue)
? selectedIssue
: null;
@@ -165,6 +170,7 @@ export default class SourceViewerCode extends React.PureComponent {
onClick={this.props.onLineClick}
onCoverageClick={this.props.onCoverageClick}
onDuplicationClick={this.props.onDuplicationClick}
+ onIssueChange={this.props.onIssueChange}
onIssueSelect={this.props.onIssueSelect}
onIssueUnselect={this.props.onIssueUnselect}
onIssuesOpen={this.props.onIssuesOpen}