Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fetchHover: position => getHover(this.getLSPTextDocumentPositionParams(position), this.props),
fetchJumpURL: position => getJumpURL(this.getLSPTextDocumentPositionParams(position), this.props),
})
this.subscriptions.add(hoverifier)
const resolveContext = () => ({
repoPath: this.props.repoPath,
rev: this.props.rev,
commitID: this.props.commitID,
filePath: this.props.filePath,
})
this.subscriptions.add(
hoverifier.hoverify({
positionEvents: this.codeViewElements.pipe(
filter(isDefined),
findPositionsFromEvents(domFunctions)
),
positionJumps: locationPositions.pipe(
withLatestFrom(this.codeViewElements, this.blobElements),
map(([position, codeView, scrollElement]) => ({
position,
// locationPositions is derived from componentUpdates,
// so these elements are guaranteed to have been rendered.
codeView: codeView!,
scrollElement: scrollElement!,
}))
),
resolveContext,
dom: domFunctions,
})
)
this.subscriptions.add(
map(({ hoverOverlayElement, codeIntellifyBlobElement }) => ({
hoverOverlayElement,
relativeElement: codeIntellifyBlobElement.closest(this.props.parentElement) as HTMLElement | null,
})),
// Can't reposition HoverOverlay or file weren't rendered
filter(propertyIsDefined('relativeElement')),
filter(propertyIsDefined('hoverOverlayElement'))
),
fetchHover: hoveredToken => getHover(this.getLSPTextDocumentPositionParams(hoveredToken), this.props),
fetchJumpURL: hoveredToken => getJumpURL(this.getLSPTextDocumentPositionParams(hoveredToken), this.props),
})
this.subscriptions.add(hoverifier)
const positionEvents = this.codeViewElements.pipe(
filter(isDefined),
findPositionsFromEvents(domFunctions)
)
const targets = positionEvents.pipe(map(({ event: { target } }) => target))
targets.subscribe(target => (this.target = target))
this.subscriptions.add(
hoverifier.hoverify({
positionEvents,
resolveContext: () => ({
repoPath: REPO_PATH,
commitID: COMMIT_ID,
rev: REV || '',
filePath: FILE_PATH,
}),
dom: domFunctions,
// After componentDidUpdate, the blob element is guaranteed to have been rendered
map(([, hoverOverlayElement, blobElement]) => ({ hoverOverlayElement, relativeElement: blobElement! })),
// Can't reposition HoverOverlay if it wasn't rendered
filter(propertyIsDefined('hoverOverlayElement'))
),
getHover: position => getHover(this.getLSPTextDocumentPositionParams(position), this.props),
getActions: context => getHoverActions(this.props, context),
pinningEnabled: !singleClickGoToDefinition,
})
this.subscriptions.add(hoverifier)
this.subscriptions.add(
hoverifier.hoverify({
positionEvents: this.codeViewElements.pipe(
filter(isDefined),
findPositionsFromEvents({ domFunctions })
),
positionJumps: locationPositions.pipe(
withLatestFrom(this.codeViewElements, this.blobElements),
map(([position, codeView, scrollElement]) => ({
position,
// locationPositions is derived from componentUpdates,
// so these elements are guaranteed to have been rendered.
codeView: codeView!,
scrollElement: scrollElement!,
}))
),
resolveContext: () => ({
repoName: this.props.repoName,
rev: this.props.rev,
commitID: this.props.commitID,
filePath: this.props.filePath,
map(({ hoverOverlayElement, codeIntellifyBlobElement }) => ({
hoverOverlayElement,
relativeElement: codeIntellifyBlobElement.closest(this.props.parentElement) as HTMLElement | null,
})),
// Can't reposition HoverOverlay or file weren't rendered
filter(propertyIsDefined('relativeElement')),
filter(propertyIsDefined('hoverOverlayElement'))
),
getHover: hoveredToken => getHover(this.getLSPTextDocumentPositionParams(hoveredToken), this.props),
getActions: context => getHoverActions(this.props, context),
})
this.subscriptions.add(hoverifier)
const positionEvents = this.codeViewElements.pipe(
filter(isDefined),
findPositionsFromEvents(domFunctions)
)
const targets = positionEvents.pipe(map(({ event: { target } }) => target))
targets.subscribe(target => (this.target = target))
this.subscriptions.add(
hoverifier.hoverify({
positionEvents,
resolveContext: () => ({
repoName: REPO_NAME,
commitID: COMMIT_ID,
rev: REV || '',
filePath: FILE_PATH,
}),
dom: domFunctions,
constructor(props: Props) {
super(props)
this.state = {
hoverOverlayIsFixed: false,
clickedGoToDefinition: false,
mouseIsMoving: false,
}
this.subscriptions.add(
this.props.hoverifier.hoverify({
dom: diffDomFunctions,
positionEvents: this.codeElements.pipe(
filter(isDefined),
findPositionsFromEvents(diffDomFunctions)
),
positionJumps: NEVER, // TODO support diff URLs
resolveContext: hoveredToken => {
// if part is undefined, it doesn't matter whether we chose head or base, the line stayed the same
const { repoPath, rev, filePath, commitID } = this.props[hoveredToken.part || 'head']
// If a hover or go-to-definition was invoked on this part, we know the file path must exist
return { repoPath, filePath: filePath!, rev, commitID }
},
})
)
}
constructor(props: FileHunksProps) {
super(props)
this.state = {
decorations: { head: new Map(), base: new Map() },
}
if (this.props.extensionInfo) {
this.subscriptions.add(
this.props.extensionInfo.hoverifier.hoverify({
dom: diffDomFunctions,
positionEvents: this.codeElements.pipe(
filter(isDefined),
findPositionsFromEvents({ domFunctions: diffDomFunctions })
),
positionJumps: NEVER, // TODO support diff URLs
resolveContext: hoveredToken => {
// if part is undefined, it doesn't matter whether we chose head or base, the line stayed the same
const { repoName, rev, filePath, commitID } = this.props.extensionInfo![
hoveredToken.part || 'head'
]
// If a hover or go-to-definition was invoked on this part, we know the file path must exist
return { repoName, filePath: filePath!, rev, commitID }
},
})
)
}
// Listen to decorations from extensions and group them by line
this.subscriptions.add(
nativeTooltipsEnabled.subscribe(useNativeTooltips => {
hoverSubscription.unsubscribe()
if (!useNativeTooltips) {
hoverSubscription = hoverifier.hoverify({
dom: domFunctions,
positionEvents: of(element).pipe(
findPositionsFromEvents({
domFunctions,
tokenize: codeHost.codeViewsRequireTokenization !== false,
})
),
resolveContext,
adjustPosition,
scrollBoundaries: codeViewEvent.getScrollBoundaries
? codeViewEvent.getScrollBoundaries(codeViewEvent.element)
: [],
})
}
})
)
}
documentsSubject.next(documents)
}
const resolveContext: ContextResolver = ({ part }) => ({
repoPath: part === 'base' ? info.baseRepoPath || info.repoPath : info.repoPath,
commitID: part === 'base' ? info.baseCommitID! : info.commitID,
filePath: part === 'base' ? info.baseFilePath || info.filePath : info.filePath,
rev: part === 'base' ? info.baseRev || info.baseCommitID! : info.rev || info.commitID,
})
subscriptions.add(
hoverifier.hoverify({
dom,
positionEvents: of(codeView).pipe(findPositionsFromEvents(dom)),
resolveContext,
adjustPosition,
})
)
codeView.classList.add('sg-mounted')
if (!getToolbarMount) {
return
}
const mount = getToolbarMount(codeView)
render(
extensionsController.services.model.model.next({ roots, visibleViewComponents })
}
const resolveContext: ContextResolver = ({
part,
}) => ({
repoPath: part === 'base' ? info.baseRepoPath || info.repoPath : info.repoPath,
commitID: part === 'base' ? info.baseCommitID! : info.commitID,
filePath: part === 'base' ? info.baseFilePath || info.filePath : info.filePath,
rev: part === 'base' ? info.baseRev || info.baseCommitID! : info.rev || info.commitID,
})
subscriptions.add(
hoverifier.hoverify({
dom,
positionEvents: of(codeView).pipe(findPositionsFromEvents(dom)),
resolveContext,
adjustPosition,
})
)
codeView.classList.add('sg-mounted')
if (!getToolbarMount) {
return
}
const mount = getToolbarMount(codeView)
render(