diff options
Diffstat (limited to 'server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx')
-rw-r--r-- | server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx index c1a034d4dc5..6f8c04ecb54 100644 --- a/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx +++ b/server/sonar-web/src/main/js/components/SourceViewer/SourceViewerCode.tsx @@ -21,14 +21,6 @@ import * as React from 'react'; import { intersection } from 'lodash'; import Line from './components/Line'; import { getLinearLocations } from './helpers/issueLocations'; -import { - BranchLike, - Duplication, - FlowLocation, - Issue, - LinearIssueLocation, - SourceLine -} from '../../app/types'; import { translate } from '../../helpers/l10n'; import { Button } from '../ui/buttons'; @@ -42,13 +34,13 @@ const ZERO_LINE = { }; interface Props { - branchLike: BranchLike | undefined; + branchLike: T.BranchLike | undefined; componentKey: string; displayAllIssues?: boolean; displayIssueLocationsCount?: boolean; displayIssueLocationsLink?: boolean; displayLocationMarkers?: boolean; - duplications: Duplication[] | undefined; + duplications: T.Duplication[] | undefined; duplicationsByLine: { [line: number]: number[] }; hasSourcesAfter: boolean; hasSourcesBefore: boolean; @@ -56,23 +48,23 @@ interface Props { highlightedLocationMessage: { index: number; text: string | undefined } | undefined; // `undefined` elements mean they are located in a different file, // but kept to maintain the location indexes - highlightedLocations: (FlowLocation | undefined)[] | undefined; + highlightedLocations: (T.FlowLocation | undefined)[] | undefined; highlightedSymbols: string[]; - issueLocationsByLine: { [line: number]: LinearIssueLocation[] }; + issueLocationsByLine: { [line: number]: T.LinearIssueLocation[] }; issuePopup: { issue: string; name: string } | undefined; - issues: Issue[] | undefined; - issuesByLine: { [line: number]: Issue[] }; + issues: T.Issue[] | undefined; + issuesByLine: { [line: number]: T.Issue[] }; linePopup: { index?: number; line: number; name: string } | undefined; - loadDuplications: (line: SourceLine) => void; + loadDuplications: (line: T.SourceLine) => void; loadingSourcesAfter: boolean; loadingSourcesBefore: boolean; loadSourcesAfter: () => void; loadSourcesBefore: () => void; - onIssueChange: (issue: Issue) => void; + onIssueChange: (issue: T.Issue) => void; onIssuePopupToggle: (issue: string, popupName: string, open?: boolean) => void; - onIssuesClose: (line: SourceLine) => void; + onIssuesClose: (line: T.SourceLine) => void; onIssueSelect: (issueKey: string) => void; - onIssuesOpen: (line: SourceLine) => void; + onIssuesOpen: (line: T.SourceLine) => void; onIssueUnselect: () => void; onLinePopupToggle: (x: { index?: number; line: number; name: string; open?: boolean }) => void; onLocationSelect: ((index: number) => void) | undefined; @@ -81,30 +73,30 @@ interface Props { renderDuplicationPopup: (index: number, line: number) => JSX.Element; scroll?: (element: HTMLElement) => void; selectedIssue: string | undefined; - sources: SourceLine[]; + sources: T.SourceLine[]; symbolsByLine: { [line: number]: string[] }; } export default class SourceViewerCode extends React.PureComponent<Props> { - getDuplicationsForLine = (line: SourceLine): number[] => { + getDuplicationsForLine = (line: T.SourceLine): number[] => { return this.props.duplicationsByLine[line.line] || EMPTY_ARRAY; }; - getIssuesForLine = (line: SourceLine): Issue[] => { + getIssuesForLine = (line: T.SourceLine): T.Issue[] => { return this.props.issuesByLine[line.line] || EMPTY_ARRAY; }; - getIssueLocationsForLine = (line: SourceLine): LinearIssueLocation[] => { + getIssueLocationsForLine = (line: T.SourceLine): T.LinearIssueLocation[] => { return this.props.issueLocationsByLine[line.line] || EMPTY_ARRAY; }; - getSecondaryIssueLocationsForLine = (line: SourceLine): LinearIssueLocation[] => { + getSecondaryIssueLocationsForLine = (line: T.SourceLine): T.LinearIssueLocation[] => { const { highlightedLocations } = this.props; if (!highlightedLocations) { return EMPTY_ARRAY; } return highlightedLocations.reduce((locations, location, index) => { - const linearLocations: LinearIssueLocation[] = location + const linearLocations: T.LinearIssueLocation[] = location ? getLinearLocations(location.textRange) .filter(l => l.line === line.line) .map(l => ({ ...l, startLine: location.textRange.startLine, index })) @@ -120,7 +112,7 @@ export default class SourceViewerCode extends React.PureComponent<Props> { displayDuplications, displayIssues }: { - line: SourceLine; + line: T.SourceLine; index: number; displayCoverage: boolean; displayDuplications: boolean; |