type
stringclasses
7 values
content
stringlengths
4
9.55k
repo
stringlengths
7
96
path
stringlengths
4
178
language
stringclasses
1 value
ArrowFunction
thread => thread.resource && thread.resource.toString() === editorURI.toString()
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
thread => { let matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId && zoneWidget.commentThread.threadId !== ''); if (matchedZones.length) { let matchedZone = matchedZones[0]; let index = this._commentWidgets.indexOf(matchedZone); this._commentWidgets.splice(index, 1); matchedZone.dispose(); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId && zoneWidget.commentThread.threadId !== ''
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
thread => { let matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId); if (matchedZones.length) { let matchedZone = matchedZones[0]; matchedZone.update(thread); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
thread => { let matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId); if (matchedZones.length) { return; } let matchedNewCommentThreadZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && (zoneWidget.commentThread as any).commentThreadHandle === -1 && Range.equalsRange(zoneWidget.commentThread.range, thread.range)); if (matchedNewCommentThreadZones.length) { matchedNewCommentThreadZones[0].update(thread); return; } const pendingCommentText = this._pendingCommentCache[e.owner] && this._pendingCommentCache[e.owner][thread.threadId!]; this.displayCommentThread(e.owner, thread, pendingCommentText); this._commentInfos.filter(info => info.owner === e.owner)[0].threads.push(thread); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
zoneWidget => zoneWidget.owner === e.owner && (zoneWidget.commentThread as any).commentThreadHandle === -1 && Range.equalsRange(zoneWidget.commentThread.range, thread.range)
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
() => { if (this._commentWidgets.length && (this.configurationService.getValue<ICommentsConfiguration>(COMMENTS_SECTION).openView === 'file')) { this.viewsService.openView(COMMENTS_VIEW_ID); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
widget => widget.getGlyphPosition() === commentRange.endLineNumber
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
widget => widget.toggleExpand(commentRange.endLineNumber)
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
() => anchor
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
() => this.getContextMenuActions(newCommentInfos, range)
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
() => newCommentInfos.length ? newCommentInfos[0] : undefined
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
() => { this._addInProgress = false; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
pick => { if (!pick) { return; } const commentInfos = newCommentInfos.filter(info => info.ownerId === pick.id); if (commentInfos.length) { const { ownerId } = commentInfos[0]; this.addCommentAtLine2(range, ownerId); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
info => info.ownerId === pick.id
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
() => { this._addInProgress = false; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
(commentInfo) => { const { ownerId, extensionId, label } = commentInfo; return <IQuickPickItem>{ label: label || extensionId, id: ownerId }; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
commentInfo => { const { ownerId, extensionId, label } = commentInfo; actions.push(new Action( 'addCommentThread', `${label || extensionId}`, undefined, true, () => { this.addCommentAtLine2(commentRange, ownerId); return Promise.resolve(); } )); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
() => { this.addCommentAtLine2(commentRange, ownerId); return Promise.resolve(); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
info => Boolean(info.commentingRanges && (Array.isArray(info.commentingRanges) ? info.commentingRanges : info.commentingRanges.ranges).length)
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
info => { let providerCacheStore = this._pendingCommentCache[info.owner]; info.threads = info.threads.filter(thread => !thread.isDisposed); info.threads.forEach(thread => { let pendingComment: string | null = null; if (providerCacheStore) { pendingComment = providerCacheStore[thread.threadId!]; } if (pendingComment) { thread.collapsibleState = languages.CommentThreadCollapsibleState.Expanded; } this.displayCommentThread(info.owner, thread, pendingComment); }); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
thread => !thread.isDisposed
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
thread => { let pendingComment: string | null = null; if (providerCacheStore) { pendingComment = providerCacheStore[thread.threadId!]; } if (pendingComment) { thread.collapsibleState = languages.CommentThreadCollapsibleState.Expanded; } this.displayCommentThread(info.owner, thread, pendingComment); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
widget => widget.hide()
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
zone => { let pendingComment = zone.getPendingComment(); let providerCacheStore = this._pendingCommentCache[zone.owner]; if (pendingComment) { if (!providerCacheStore) { this._pendingCommentCache[zone.owner] = {}; } this._pendingCommentCache[zone.owner][zone.commentThread.threadId!] = pendingComment; } else { if (providerCacheStore) { delete providerCacheStore[zone.commentThread.threadId!]; } } zone.dispose(); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
(accessor) => { const activeEditor = getActiveEditor(accessor); if (!activeEditor) { return Promise.resolve(); } const controller = CommentController.get(activeEditor); if (!controller) { return Promise.resolve(); } const position = activeEditor.getSelection(); return controller.addOrToggleCommentAtLine(position, undefined); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
(accessor, args) => { const activeCodeEditor = accessor.get(ICodeEditorService).getFocusedCodeEditor(); if (activeCodeEditor instanceof SimpleCommentEditor) { activeCodeEditor.getParentThread().submitComment(); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
(accessor, args) => { const activeCodeEditor = accessor.get(ICodeEditorService).getFocusedCodeEditor(); if (activeCodeEditor instanceof SimpleCommentEditor) { activeCodeEditor.getParentThread().collapse(); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
(theme, collector) => { const peekViewBackground = theme.getColor(peekViewResultsBackground); if (peekViewBackground) { collector.addRule( `.monaco-editor .review-widget,` + `.monaco-editor .review-widget {` + ` background-color: ${peekViewBackground};` + `}`); } const monacoEditorBackground = theme.getColor(peekViewTitleBackground); if (monacoEditorBackground) { collector.addRule( `.review-widget .body .comment-form .review-thread-reply-button {` + ` background-color: ${monacoEditorBackground}` + `}` ); } const monacoEditorForeground = theme.getColor(editorForeground); if (monacoEditorForeground) { collector.addRule( `.review-widget .body .monaco-editor {` + ` color: ${monacoEditorForeground}` + `}` + `.review-widget .body .comment-form .review-thread-reply-button {` + ` color: ${monacoEditorForeground};` + ` font-size: inherit` + `}` ); } const selectionBackground = theme.getColor(peekViewResultsSelectionBackground); if (selectionBackground) { collector.addRule( `@keyframes monaco-review-widget-focus {` + ` 0% { background: ${selectionBackground}; }` + ` 100% { background: transparent; }` + `}` + `.review-widget .body .review-comment.focus {` + ` animation: monaco-review-widget-focus 3s ease 0s;` + `}` ); } const commentingRangeForeground = theme.getColor(overviewRulerCommentingRangeForeground); if (commentingRangeForeground) { collector.addRule(` .monaco-editor .comment-diff-added { border-left: 3px solid ${commentingRangeForeground}; } .monaco-editor .comment-diff-added:before { background: ${commentingRangeForeground}; } .monaco-editor .comment-thread { border-left: 3px solid ${commentingRangeForeground}; } .monaco-editor .comment-thread:before { background: ${commentingRangeForeground}; } `); } const statusBarItemHoverBackground = theme.getColor(STATUS_BAR_ITEM_HOVER_BACKGROUND); if (statusBarItemHoverBackground) { collector.addRule(`.review-widget .body .review-comment .review-comment-contents .comment-reactions .action-item a.action-label.active:hover { background-color: ${statusBarItemHoverBackground};}`); } const statusBarItemActiveBackground = theme.getColor(STATUS_BAR_ITEM_ACTIVE_BACKGROUND); if (statusBarItemActiveBackground) { collector.addRule(`.review-widget .body .review-comment .review-comment-contents .comment-reactions .action-item a.action-label:active { background-color: ${statusBarItemActiveBackground}; border: 1px solid transparent;}`); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ClassDeclaration
export class ReviewViewZone implements IViewZone { public readonly afterLineNumber: number; public readonly domNode: HTMLElement; private callback: (top: number) => void; constructor(afterLineNumber: number, onDomNodeTop: (top: number) => void) { this.afterLineNumber = afterLineNumber; this.callback = onDomNodeTop; this.domNode = $('.review-viewzone'); } onDomNodeTop(top: number): void { this.callback(top); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ClassDeclaration
class CommentingRangeDecoration implements IModelDeltaDecoration { private _decorationId: string | undefined; private _startLineNumber: number; private _endLineNumber: number; public get id(): string | undefined { return this._decorationId; } public set id(id: string | undefined) { this._decorationId = id; } public get range(): IRange { return { startLineNumber: this._startLineNumber, startColumn: 1, endLineNumber: this._endLineNumber, endColumn: 1 }; } constructor(private _editor: ICodeEditor, private _ownerId: string, private _extensionId: string | undefined, private _label: string | undefined, private _range: IRange, public readonly options: ModelDecorationOptions, private commentingRangesInfo: languages.CommentingRanges, public readonly isHover: boolean = false) { this._startLineNumber = _range.startLineNumber; this._endLineNumber = _range.endLineNumber; } public getCommentAction(): CommentRangeAction { return { extensionId: this._extensionId, label: this._label, ownerId: this._ownerId, commentingRangesInfo: this.commentingRangesInfo }; } public getOriginalRange() { return this._range; } public getActiveRange() { return this.id ? this._editor.getModel()!.getDecorationRange(this.id) : undefined; } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ClassDeclaration
class CommentingRangeDecorator { public static description = 'commenting-range-decorator'; private decorationOptions!: ModelDecorationOptions; private hoverDecorationOptions!: ModelDecorationOptions; private commentingRangeDecorations: CommentingRangeDecoration[] = []; private decorationIds: string[] = []; private _editor: ICodeEditor | undefined; private _infos: ICommentInfo[] | undefined; private _lastHover: number = -1; private _onDidChangeDecorationsCount: Emitter<number> = new Emitter(); public readonly onDidChangeDecorationsCount = this._onDidChangeDecorationsCount.event; constructor() { const decorationOptions: IModelDecorationOptions = { description: CommentingRangeDecorator.description, isWholeLine: true, linesDecorationsClassName: 'comment-range-glyph comment-diff-added' }; this.decorationOptions = ModelDecorationOptions.createDynamic(decorationOptions); const hoverDecorationOptions: IModelDecorationOptions = { description: CommentingRangeDecorator.description, isWholeLine: true, linesDecorationsClassName: `comment-range-glyph comment-diff-added line-hover` }; this.hoverDecorationOptions = ModelDecorationOptions.createDynamic(hoverDecorationOptions); } public updateHover(hoverLine?: number) { if (this._editor && this._infos && (hoverLine !== this._lastHover)) { this._doUpdate(this._editor, this._infos, hoverLine); } this._lastHover = hoverLine ?? -1; } public update(editor: ICodeEditor, commentInfos: ICommentInfo[]) { this._editor = editor; this._infos = commentInfos; this._doUpdate(editor, commentInfos); } private _doUpdate(editor: ICodeEditor, commentInfos: ICommentInfo[], hoverLine: number = -1) { let model = editor.getModel(); if (!model) { return; } let commentingRangeDecorations: CommentingRangeDecoration[] = []; for (const info of commentInfos) { info.commentingRanges.ranges.forEach(range => { if ((range.startLineNumber <= hoverLine) && (range.endLineNumber >= hoverLine)) { const beforeRange = new Range(range.startLineNumber, 1, hoverLine, 1); const hoverRange = new Range(hoverLine, 1, hoverLine, 1); const afterRange = new Range(hoverLine, 1, range.endLineNumber, 1); commentingRangeDecorations.push(new CommentingRangeDecoration(editor, info.owner, info.extensionId, info.label, beforeRange, this.decorationOptions, info.commentingRanges, true)); commentingRangeDecorations.push(new CommentingRangeDecoration(editor, info.owner, info.extensionId, info.label, hoverRange, this.hoverDecorationOptions, info.commentingRanges, true)); commentingRangeDecorations.push(new CommentingRangeDecoration(editor, info.owner, info.extensionId, info.label, afterRange, this.decorationOptions, info.commentingRanges, true)); } else { commentingRangeDecorations.push(new CommentingRangeDecoration(editor, info.owner, info.extensionId, info.label, range, this.decorationOptions, info.commentingRanges)); } }); } this.decorationIds = editor.deltaDecorations(this.decorationIds, commentingRangeDecorations); commentingRangeDecorations.forEach((decoration, index) => decoration.id = this.decorationIds[index]); const rangesDifference = this.commentingRangeDecorations.length - commentingRangeDecorations.length; this.commentingRangeDecorations = commentingRangeDecorations; if (rangesDifference) { this._onDidChangeDecorationsCount.fire(this.commentingRangeDecorations.length); } } public getMatchedCommentAction(commentRange: Range): CommentRangeAction[] { // keys is ownerId const foundHoverActions = new Map<string, { range: Range; action: CommentRangeAction }>(); for (const decoration of this.commentingRangeDecorations) { const range = decoration.getActiveRange(); if (range && ((range.startLineNumber <= commentRange.startLineNumber) || (commentRange.endLineNumber <= range.endLineNumber))) { // We can have 3 commenting ranges that match from the same owner because of how // the line hover decoration is done. // The 3 ranges must be merged so that we can see if the new commentRange fits within them. const action = decoration.getCommentAction(); const alreadyFoundInfo = foundHoverActions.get(action.ownerId); if (alreadyFoundInfo?.action.commentingRangesInfo === action.commentingRangesInfo) { // Merge ranges. const newRange = new Range( range.startLineNumber < alreadyFoundInfo.range.startLineNumber ? range.startLineNumber : alreadyFoundInfo.range.startLineNumber, range.startColumn < alreadyFoundInfo.range.startColumn ? range.startColumn : alreadyFoundInfo.range.startColumn, range.endLineNumber > alreadyFoundInfo.range.endLineNumber ? range.endLineNumber : alreadyFoundInfo.range.endLineNumber, range.endColumn > alreadyFoundInfo.range.endColumn ? range.endColumn : alreadyFoundInfo.range.endColumn ); foundHoverActions.set(action.ownerId, { range: newRange, action }); } else { foundHoverActions.set(action.ownerId, { range, action }); } } } return Array.from(foundHoverActions.values()).filter(action => { return (action.range.startLineNumber <= commentRange.startLineNumber) && (commentRange.endLineNumber <= action.range.endLineNumber); }).map(actions => actions.action); } public dispose(): void { this.commentingRangeDecorations = []; } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ClassDeclaration
export class NextCommentThreadAction extends EditorAction { constructor() { super({ id: 'editor.action.nextCommentThreadAction', label: nls.localize('nextCommentThreadAction', "Go to Next Comment Thread"), alias: 'Go to Next Comment Thread', precondition: undefined, kbOpts: { kbExpr: EditorContextKeys.focus, primary: KeyMod.Alt | KeyCode.F9, weight: KeybindingWeight.EditorContrib } }); } public run(accessor: ServicesAccessor, editor: ICodeEditor): void { let controller = CommentController.get(editor); if (controller) { controller.nextCommentThread(); } } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ClassDeclaration
export class PreviousCommentThreadAction extends EditorAction { constructor() { super({ id: 'editor.action.previousCommentThreadAction', label: nls.localize('previousCommentThreadAction', "Go to Previous Comment Thread"), alias: 'Go to Previous Comment Thread', precondition: undefined, kbOpts: { kbExpr: EditorContextKeys.focus, primary: KeyMod.Shift | KeyMod.Alt | KeyCode.F9, weight: KeybindingWeight.EditorContrib } }); } public run(accessor: ServicesAccessor, editor: ICodeEditor): void { let controller = CommentController.get(editor); if (controller) { controller.previousCommentThread(); } } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
InterfaceDeclaration
interface CommentRangeAction { ownerId: string; extensionId: string | undefined; label: string | undefined; commentingRangesInfo: languages.CommentingRanges; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
onDomNodeTop(top: number): void { this.callback(top); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public getCommentAction(): CommentRangeAction { return { extensionId: this._extensionId, label: this._label, ownerId: this._ownerId, commentingRangesInfo: this.commentingRangesInfo }; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public getOriginalRange() { return this._range; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public getActiveRange() { return this.id ? this._editor.getModel()!.getDecorationRange(this.id) : undefined; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public updateHover(hoverLine?: number) { if (this._editor && this._infos && (hoverLine !== this._lastHover)) { this._doUpdate(this._editor, this._infos, hoverLine); } this._lastHover = hoverLine ?? -1; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public update(editor: ICodeEditor, commentInfos: ICommentInfo[]) { this._editor = editor; this._infos = commentInfos; this._doUpdate(editor, commentInfos); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private _doUpdate(editor: ICodeEditor, commentInfos: ICommentInfo[], hoverLine: number = -1) { let model = editor.getModel(); if (!model) { return; } let commentingRangeDecorations: CommentingRangeDecoration[] = []; for (const info of commentInfos) { info.commentingRanges.ranges.forEach(range => { if ((range.startLineNumber <= hoverLine) && (range.endLineNumber >= hoverLine)) { const beforeRange = new Range(range.startLineNumber, 1, hoverLine, 1); const hoverRange = new Range(hoverLine, 1, hoverLine, 1); const afterRange = new Range(hoverLine, 1, range.endLineNumber, 1); commentingRangeDecorations.push(new CommentingRangeDecoration(editor, info.owner, info.extensionId, info.label, beforeRange, this.decorationOptions, info.commentingRanges, true)); commentingRangeDecorations.push(new CommentingRangeDecoration(editor, info.owner, info.extensionId, info.label, hoverRange, this.hoverDecorationOptions, info.commentingRanges, true)); commentingRangeDecorations.push(new CommentingRangeDecoration(editor, info.owner, info.extensionId, info.label, afterRange, this.decorationOptions, info.commentingRanges, true)); } else { commentingRangeDecorations.push(new CommentingRangeDecoration(editor, info.owner, info.extensionId, info.label, range, this.decorationOptions, info.commentingRanges)); } }); } this.decorationIds = editor.deltaDecorations(this.decorationIds, commentingRangeDecorations); commentingRangeDecorations.forEach((decoration, index) => decoration.id = this.decorationIds[index]); const rangesDifference = this.commentingRangeDecorations.length - commentingRangeDecorations.length; this.commentingRangeDecorations = commentingRangeDecorations; if (rangesDifference) { this._onDidChangeDecorationsCount.fire(this.commentingRangeDecorations.length); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public getMatchedCommentAction(commentRange: Range): CommentRangeAction[] { // keys is ownerId const foundHoverActions = new Map<string, { range: Range; action: CommentRangeAction }>(); for (const decoration of this.commentingRangeDecorations) { const range = decoration.getActiveRange(); if (range && ((range.startLineNumber <= commentRange.startLineNumber) || (commentRange.endLineNumber <= range.endLineNumber))) { // We can have 3 commenting ranges that match from the same owner because of how // the line hover decoration is done. // The 3 ranges must be merged so that we can see if the new commentRange fits within them. const action = decoration.getCommentAction(); const alreadyFoundInfo = foundHoverActions.get(action.ownerId); if (alreadyFoundInfo?.action.commentingRangesInfo === action.commentingRangesInfo) { // Merge ranges. const newRange = new Range( range.startLineNumber < alreadyFoundInfo.range.startLineNumber ? range.startLineNumber : alreadyFoundInfo.range.startLineNumber, range.startColumn < alreadyFoundInfo.range.startColumn ? range.startColumn : alreadyFoundInfo.range.startColumn, range.endLineNumber > alreadyFoundInfo.range.endLineNumber ? range.endLineNumber : alreadyFoundInfo.range.endLineNumber, range.endColumn > alreadyFoundInfo.range.endColumn ? range.endColumn : alreadyFoundInfo.range.endColumn ); foundHoverActions.set(action.ownerId, { range: newRange, action }); } else { foundHoverActions.set(action.ownerId, { range, action }); } } } return Array.from(foundHoverActions.values()).filter(action => { return (action.range.startLineNumber <= commentRange.startLineNumber) && (commentRange.endLineNumber <= action.range.endLineNumber); }).map(actions => actions.action); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public dispose(): void { this.commentingRangeDecorations = []; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private registerEditorListeners() { this._editorDisposables = []; this._editorDisposables.push(this.editor.onMouseMove(e => this.onEditorMouseMove(e))); this._editorDisposables.push(this.editor.onDidChangeCursorPosition(e => this.onEditorChangeCursorPosition(e.position))); this._editorDisposables.push(this.editor.onDidFocusEditorWidget(() => this.onEditorChangeCursorPosition(this.editor.getPosition()))); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private clearEditorListeners() { this._editorDisposables?.forEach(disposable => disposable.dispose()); this._editorDisposables = undefined; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private onEditorMouseMove(e: IEditorMouseEvent): void { this._commentingRangeDecorator.updateHover(e.target.position?.lineNumber); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private onEditorChangeCursorPosition(e: Position | null) { const decorations = e ? this.editor.getDecorationsInRange(Range.fromPositions(e, { column: -1, lineNumber: e.lineNumber })) : undefined; let hasCommentingRange = false; if (decorations) { for (const decoration of decorations) { if (decoration.options.description === CommentGlyphWidget.description) { // We don't allow multiple comments on the same line. hasCommentingRange = false; break; } else if (decoration.options.description === CommentingRangeDecorator.description) { hasCommentingRange = true; } } } this._activeCursorHasCommentingRange.set(hasCommentingRange); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private beginCompute(): Promise<void> { this._computePromise = createCancelablePromise(token => { const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri; if (editorURI) { return this.commentService.getDocumentComments(editorURI); } return Promise.resolve([]); }); return this._computePromise.then(commentInfos => { this.setComments(coalesce(commentInfos)); this._computePromise = null; }, error => console.log(error)); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private beginComputeCommentingRanges() { if (this._computeCommentingRangeScheduler) { if (this._computeCommentingRangePromise) { this._computeCommentingRangePromise.cancel(); this._computeCommentingRangePromise = null; } this._computeCommentingRangeScheduler.trigger(() => { const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri; if (editorURI) { return this.commentService.getDocumentComments(editorURI); } return Promise.resolve([]); }).then(commentInfos => { const meaningfulCommentInfos = coalesce(commentInfos); this._commentingRangeDecorator.update(this.editor, meaningfulCommentInfos); }, (err) => { onUnexpectedError(err); return null; }); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public static get(editor: ICodeEditor): CommentController | null { return editor.getContribution<CommentController>(ID); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public revealCommentThread(threadId: string, commentUniqueId: number, fetchOnceIfNotExist: boolean): void { const commentThreadWidget = this._commentWidgets.filter(widget => widget.commentThread.threadId === threadId); if (commentThreadWidget.length === 1) { commentThreadWidget[0].reveal(commentUniqueId); } else if (fetchOnceIfNotExist) { if (this._computePromise) { this._computePromise.then(_ => { this.revealCommentThread(threadId, commentUniqueId, false); }); } else { this.beginCompute().then(_ => { this.revealCommentThread(threadId, commentUniqueId, false); }); } } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public nextCommentThread(): void { this._findNearestCommentThread(); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private _findNearestCommentThread(reverse?: boolean): void { if (!this._commentWidgets.length || !this.editor.hasModel()) { return; } const after = this.editor.getSelection().getEndPosition(); const sortedWidgets = this._commentWidgets.sort((a, b) => { if (reverse) { const temp = a; a = b; b = temp; } if (a.commentThread.range.startLineNumber < b.commentThread.range.startLineNumber) { return -1; } if (a.commentThread.range.startLineNumber > b.commentThread.range.startLineNumber) { return 1; } if (a.commentThread.range.startColumn < b.commentThread.range.startColumn) { return -1; } if (a.commentThread.range.startColumn > b.commentThread.range.startColumn) { return 1; } return 0; }); let idx = findFirstInSorted(sortedWidgets, widget => { let lineValueOne = reverse ? after.lineNumber : widget.commentThread.range.startLineNumber; let lineValueTwo = reverse ? widget.commentThread.range.startLineNumber : after.lineNumber; let columnValueOne = reverse ? after.column : widget.commentThread.range.startColumn; let columnValueTwo = reverse ? widget.commentThread.range.startColumn : after.column; if (lineValueOne > lineValueTwo) { return true; } if (lineValueOne < lineValueTwo) { return false; } if (columnValueOne > columnValueTwo) { return true; } return false; }); let nextWidget: ReviewZoneWidget; if (idx === this._commentWidgets.length) { nextWidget = this._commentWidgets[0]; } else { nextWidget = sortedWidgets[idx]; } this.editor.setSelection(nextWidget.commentThread.range); nextWidget.reveal(undefined, true); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public previousCommentThread(): void { this._findNearestCommentThread(true); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public dispose(): void { this.globalToDispose.dispose(); this.localToDispose.dispose(); this._editorDisposables?.forEach(disposable => disposable.dispose()); this._commentWidgets.forEach(widget => widget.dispose()); this.editor = null!; // Strict null override - nulling out in dispose }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public onModelChanged(e: IModelChangedEvent): void { this.localToDispose.clear(); this.removeCommentWidgetsAndStoreCache(); this.localToDispose.add(this.editor.onMouseDown(e => this.onEditorMouseDown(e))); this.localToDispose.add(this.editor.onMouseUp(e => this.onEditorMouseUp(e))); if (this._editorDisposables) { this.clearEditorListeners(); this.registerEditorListeners(); } this._computeCommentingRangeScheduler = new Delayer<ICommentInfo[]>(200); this.localToDispose.add({ dispose: () => { if (this._computeCommentingRangeScheduler) { this._computeCommentingRangeScheduler.cancel(); } this._computeCommentingRangeScheduler = null; } }); this.localToDispose.add(this.editor.onDidChangeModelContent(async () => { this.beginComputeCommentingRanges(); })); this.localToDispose.add(this.commentService.onDidUpdateCommentThreads(async e => { const editorURI = this.editor && this.editor.hasModel() && this.editor.getModel().uri; if (!editorURI) { return; } if (this._computePromise) { await this._computePromise; } let commentInfo = this._commentInfos.filter(info => info.owner === e.owner); if (!commentInfo || !commentInfo.length) { return; } let added = e.added.filter(thread => thread.resource && thread.resource.toString() === editorURI.toString()); let removed = e.removed.filter(thread => thread.resource && thread.resource.toString() === editorURI.toString()); let changed = e.changed.filter(thread => thread.resource && thread.resource.toString() === editorURI.toString()); removed.forEach(thread => { let matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId && zoneWidget.commentThread.threadId !== ''); if (matchedZones.length) { let matchedZone = matchedZones[0]; let index = this._commentWidgets.indexOf(matchedZone); this._commentWidgets.splice(index, 1); matchedZone.dispose(); } }); changed.forEach(thread => { let matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId); if (matchedZones.length) { let matchedZone = matchedZones[0]; matchedZone.update(thread); } }); added.forEach(thread => { let matchedZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && zoneWidget.commentThread.threadId === thread.threadId); if (matchedZones.length) { return; } let matchedNewCommentThreadZones = this._commentWidgets.filter(zoneWidget => zoneWidget.owner === e.owner && (zoneWidget.commentThread as any).commentThreadHandle === -1 && Range.equalsRange(zoneWidget.commentThread.range, thread.range)); if (matchedNewCommentThreadZones.length) { matchedNewCommentThreadZones[0].update(thread); return; } const pendingCommentText = this._pendingCommentCache[e.owner] && this._pendingCommentCache[e.owner][thread.threadId!]; this.displayCommentThread(e.owner, thread, pendingCommentText); this._commentInfos.filter(info => info.owner === e.owner)[0].threads.push(thread); }); })); this.beginCompute().then(() => { if (this._commentWidgets.length && (this.configurationService.getValue<ICommentsConfiguration>(COMMENTS_SECTION).openView === 'file')) { this.viewsService.openView(COMMENTS_VIEW_ID); } }); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private displayCommentThread(owner: string, thread: languages.CommentThread, pendingComment: string | null): void { const zoneWidget = this.instantiationService.createInstance(ReviewZoneWidget, this.editor, owner, thread, pendingComment); zoneWidget.display(thread.range.startLineNumber); this._commentWidgets.push(zoneWidget); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private onEditorMouseDown(e: IEditorMouseEvent): void { this.mouseDownInfo = parseMouseDownInfoFromEvent(e); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private onEditorMouseUp(e: IEditorMouseEvent): void { const matchedLineNumber = isMouseUpEventMatchMouseDown(this.mouseDownInfo, e); this.mouseDownInfo = null; if (matchedLineNumber === null || !e.target.element) { return; } if (e.target.element.className.indexOf('comment-diff-added') >= 0) { const lineNumber = e.target.position!.lineNumber; this.addOrToggleCommentAtLine(new Range(lineNumber, 1, lineNumber, 1), e); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public async addOrToggleCommentAtLine(commentRange: Range, e: IEditorMouseEvent | undefined): Promise<void> { // If an add is already in progress, queue the next add and process it after the current one finishes to // prevent empty comment threads from being added to the same line. if (!this._addInProgress) { this._addInProgress = true; // The widget's position is undefined until the widget has been displayed, so rely on the glyph position instead const existingCommentsAtLine = this._commentWidgets.filter(widget => widget.getGlyphPosition() === commentRange.endLineNumber); if (existingCommentsAtLine.length) { existingCommentsAtLine.forEach(widget => widget.toggleExpand(commentRange.endLineNumber)); this.processNextThreadToAdd(); return; } else { this.addCommentAtLine(commentRange, e); } } else { this._emptyThreadsToAddQueue.push([commentRange, e]); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private processNextThreadToAdd(): void { this._addInProgress = false; const info = this._emptyThreadsToAddQueue.shift(); if (info) { this.addOrToggleCommentAtLine(info[0], info[1]); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public addCommentAtLine(range: Range, e: IEditorMouseEvent | undefined): Promise<void> { const newCommentInfos = this._commentingRangeDecorator.getMatchedCommentAction(range); if (!newCommentInfos.length || !this.editor.hasModel()) { return Promise.resolve(); } if (newCommentInfos.length > 1) { if (e) { const anchor = { x: e.event.posx, y: e.event.posy }; this.contextMenuService.showContextMenu({ getAnchor: () => anchor, getActions: () => this.getContextMenuActions(newCommentInfos, range), getActionsContext: () => newCommentInfos.length ? newCommentInfos[0] : undefined, onHide: () => { this._addInProgress = false; } }); return Promise.resolve(); } else { const picks = this.getCommentProvidersQuickPicks(newCommentInfos); return this.quickInputService.pick(picks, { placeHolder: nls.localize('pickCommentService', "Select Comment Provider"), matchOnDescription: true }).then(pick => { if (!pick) { return; } const commentInfos = newCommentInfos.filter(info => info.ownerId === pick.id); if (commentInfos.length) { const { ownerId } = commentInfos[0]; this.addCommentAtLine2(range, ownerId); } }).then(() => { this._addInProgress = false; }); } } else { const { ownerId } = newCommentInfos[0]!; this.addCommentAtLine2(range, ownerId); } return Promise.resolve(); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private getCommentProvidersQuickPicks(commentInfos: { ownerId: string; extensionId: string | undefined; label: string | undefined; commentingRangesInfo: languages.CommentingRanges | undefined }[]) { const picks: QuickPickInput[] = commentInfos.map((commentInfo) => { const { ownerId, extensionId, label } = commentInfo; return <IQuickPickItem>{ label: label || extensionId, id: ownerId }; }); return picks; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private getContextMenuActions(commentInfos: { ownerId: string; extensionId: string | undefined; label: string | undefined; commentingRangesInfo: languages.CommentingRanges }[], commentRange: Range): IAction[] { const actions: IAction[] = []; commentInfos.forEach(commentInfo => { const { ownerId, extensionId, label } = commentInfo; actions.push(new Action( 'addCommentThread', `${label || extensionId}`, undefined, true, () => { this.addCommentAtLine2(commentRange, ownerId); return Promise.resolve(); } )); }); return actions; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public addCommentAtLine2(range: Range, ownerId: string) { this.commentService.createCommentThreadTemplate(ownerId, this.editor.getModel()!.uri, range); this.processNextThreadToAdd(); return; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private setComments(commentInfos: ICommentInfo[]): void { if (!this.editor) { return; } this._commentInfos = commentInfos; let lineDecorationsWidth: number = this.editor.getLayoutInfo().decorationsWidth; if (this._commentInfos.some(info => Boolean(info.commentingRanges && (Array.isArray(info.commentingRanges) ? info.commentingRanges : info.commentingRanges.ranges).length))) { if (!this._commentingRangeSpaceReserved) { this._commentingRangeSpaceReserved = true; let extraEditorClassName: string[] = []; const configuredExtraClassName = this.editor.getRawOptions().extraEditorClassName; if (configuredExtraClassName) { extraEditorClassName = configuredExtraClassName.split(' '); } const options = this.editor.getOptions(); if (options.get(EditorOption.folding)) { lineDecorationsWidth -= 16; } lineDecorationsWidth += 9; extraEditorClassName.push('inline-comment'); this.editor.updateOptions({ extraEditorClassName: extraEditorClassName.join(' '), lineDecorationsWidth: lineDecorationsWidth }); // we only update the lineDecorationsWidth property but keep the width of the whole editor. const originalLayoutInfo = this.editor.getLayoutInfo(); this.editor.layout({ width: originalLayoutInfo.width, height: originalLayoutInfo.height }); } } // create viewzones this.removeCommentWidgetsAndStoreCache(); this._commentInfos.forEach(info => { let providerCacheStore = this._pendingCommentCache[info.owner]; info.threads = info.threads.filter(thread => !thread.isDisposed); info.threads.forEach(thread => { let pendingComment: string | null = null; if (providerCacheStore) { pendingComment = providerCacheStore[thread.threadId!]; } if (pendingComment) { thread.collapsibleState = languages.CommentThreadCollapsibleState.Expanded; } this.displayCommentThread(info.owner, thread, pendingComment); }); }); this._commentingRangeDecorator.update(this.editor, this._commentInfos); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public closeWidget(): void { if (this._commentWidgets) { this._commentWidgets.forEach(widget => widget.hide()); } this.editor.focus(); this.editor.revealRangeInCenter(this.editor.getSelection()!); }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
private removeCommentWidgetsAndStoreCache() { if (this._commentWidgets) { this._commentWidgets.forEach(zone => { let pendingComment = zone.getPendingComment(); let providerCacheStore = this._pendingCommentCache[zone.owner]; if (pendingComment) { if (!providerCacheStore) { this._pendingCommentCache[zone.owner] = {}; } this._pendingCommentCache[zone.owner][zone.commentThread.threadId!] = pendingComment; } else { if (providerCacheStore) { delete providerCacheStore[zone.commentThread.threadId!]; } } zone.dispose(); }); } this._commentWidgets = []; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public hasComments(): boolean { return !!this._commentWidgets.length; }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public run(accessor: ServicesAccessor, editor: ICodeEditor): void { let controller = CommentController.get(editor); if (controller) { controller.nextCommentThread(); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
MethodDeclaration
public run(accessor: ServicesAccessor, editor: ICodeEditor): void { let controller = CommentController.get(editor); if (controller) { controller.previousCommentThread(); } }
CUBETIQ/vscode
src/vs/workbench/contrib/comments/browser/commentsEditorContribution.ts
TypeScript
ArrowFunction
({ className, stop, color, onChange, onFocus, onRemove, globalMin, globalMax, localMin, localMax, min, max, isRangeMin = false, isRangeMax = false, parentRef, colorPickerMode, colorPickerShowAlpha, colorPickerSwatches, disabled, readOnly, isPopoverOpen, openPopover, closePopover, 'data-index': dataIndex, 'aria-valuetext': ariaValueText, valueInputProps = {}, }) => { const background = useMemo(() => { const chromaColor = getChromaColor(color, colorPickerShowAlpha); return chromaColor ? chromaColor.css() : undefined; }, [color, colorPickerShowAlpha]); const [hasFocus, setHasFocus] = useState(isPopoverOpen); const [colorIsInvalid, setColorIsInvalid] = useState( isColorInvalid(color, colorPickerShowAlpha) ); const [stopIsInvalid, setStopIsInvalid] = useState(isStopInvalid(stop)); const [numberInputRef, setNumberInputRef] = useState<HTMLInputElement | null>( null ); const popoverRef = useRef<EuiPopover>(null); useEffect(() => { if (isPopoverOpen && popoverRef && popoverRef.current) { popoverRef.current.positionPopoverFixed(); } }, [isPopoverOpen, stop]); const getStopFromMouseLocationFn = (location: { x: number; y: number }) => { // Guard against `null` ref in usage return getStopFromMouseLocation(location, parentRef!, globalMin, globalMax); }; const getPositionFromStopFn = (stop: ColorStop['stop']) => { // Guard against `null` ref in usage return getPositionFromStop(stop, parentRef!, globalMin, globalMax); }; const handleOnRemove = () => { if (onRemove) { closePopover(); onRemove(); } }; const handleFocus = () => { setHasFocus(true); if (onFocus) { onFocus(); } }; const setHasFocusTrue = () => setHasFocus(true); const setHasFocusFalse = () => setHasFocus(false); const handleColorChange = (value: ColorStop['color']) => { setColorIsInvalid(isColorInvalid(value, colorPickerShowAlpha)); onChange({ stop, color: value }); }; const handleStopChange = (value: ColorStop['stop']) => { const willBeInvalid = value > localMax || value < localMin; if (willBeInvalid) { if (value > localMax) { value = localMax; } if (value < localMin) { value = localMin; } } setStopIsInvalid(isStopInvalid(value)); onChange({ stop: value, color }); }; const handleStopInputChange = (e: React.ChangeEvent<HTMLInputElement>) => { let value = parseFloat(e.target.value); const willBeInvalid = value > globalMax || value < globalMin; if (willBeInvalid) { if (value > globalMax && max != null) { value = globalMax; } if (value < globalMin && min != null) { value = globalMin; } } setStopIsInvalid(isStopInvalid(value)); onChange({ stop: value, color }); }; const handlePointerChange = ( location: { x: number; y: number }, isFirstInteraction?: boolean ) => { if (isFirstInteraction) return; // Prevents change on the initial MouseDown event if (parentRef == null) { return; } const newStop = getStopFromMouseLocationFn(location); handleStopChange(newStop); }; const handleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => { switch (event.key) { case keys.ENTER: event.preventDefault(); openPopover(); break; case keys.ARROW_LEFT: event.preventDefault(); if (readOnly) return; handleStopChange(stop - 1); break; case keys.ARROW_RIGHT: event.preventDefault(); if (readOnly) return; handleStopChange(stop + 1); break; } }; const [handleMouseDown, handleInteraction] = useMouseMove<HTMLButtonElement>( handlePointerChange ); const handleOnMouseDown = (e: React.MouseEvent<HTMLButtonElement>) => { if (!readOnly) { handleMouseDown(e); } openPopover(); }; const handleTouchInteraction = (e: React.TouchEvent<HTMLButtonElement>) => { if (!readOnly) { handleInteraction(e); } }; const handleTouchStart = (e: React.TouchEvent<HTMLButtonElement>) => { handleTouchInteraction(e); if (!isPopoverOpen) { openPopover(); } }; const classes = classNames( 'euiColorStopPopover', { 'euiColorStopPopover-hasFocus': hasFocus || isPopoverOpen, }, className ); return ( <EuiPopover ref={popoverRef} className={classes} anchorClassName="euiColorStopPopover__anchor" panelPaddingSize="s" isOpen={isPopoverOpen} closePopover={closePopover} initialFocus={numberInputRef || undefined}
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
() => { const chromaColor = getChromaColor(color, colorPickerShowAlpha); return chromaColor ? chromaColor.css() : undefined; }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
() => { if (isPopoverOpen && popoverRef && popoverRef.current) { popoverRef.current.positionPopoverFixed(); } }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(location: { x: number; y: number }) => { // Guard against `null` ref in usage return getStopFromMouseLocation(location, parentRef!, globalMin, globalMax); }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(stop: ColorStop['stop']) => { // Guard against `null` ref in usage return getPositionFromStop(stop, parentRef!, globalMin, globalMax); }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
() => { if (onRemove) { closePopover(); onRemove(); } }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
() => { setHasFocus(true); if (onFocus) { onFocus(); } }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
() => setHasFocus(true)
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
() => setHasFocus(false)
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(value: ColorStop['color']) => { setColorIsInvalid(isColorInvalid(value, colorPickerShowAlpha)); onChange({ stop, color: value }); }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(value: ColorStop['stop']) => { const willBeInvalid = value > localMax || value < localMin; if (willBeInvalid) { if (value > localMax) { value = localMax; } if (value < localMin) { value = localMin; } } setStopIsInvalid(isStopInvalid(value)); onChange({ stop: value, color }); }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(e: React.ChangeEvent<HTMLInputElement>) => { let value = parseFloat(e.target.value); const willBeInvalid = value > globalMax || value < globalMin; if (willBeInvalid) { if (value > globalMax && max != null) { value = globalMax; } if (value < globalMin && min != null) { value = globalMin; } } setStopIsInvalid(isStopInvalid(value)); onChange({ stop: value, color }); }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
( location: { x: number; y: number }, isFirstInteraction?: boolean ) => { if (isFirstInteraction) return; // Prevents change on the initial MouseDown event if (parentRef == null) { return; } const newStop = getStopFromMouseLocationFn(location); handleStopChange(newStop); }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(event: React.KeyboardEvent<HTMLButtonElement>) => { switch (event.key) { case keys.ENTER: event.preventDefault(); openPopover(); break; case keys.ARROW_LEFT: event.preventDefault(); if (readOnly) return; handleStopChange(stop - 1); break; case keys.ARROW_RIGHT: event.preventDefault(); if (readOnly) return; handleStopChange(stop + 1); break; } }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(e: React.MouseEvent<HTMLButtonElement>) => { if (!readOnly) { handleMouseDown(e); } openPopover(); }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(e: React.TouchEvent<HTMLButtonElement>) => { if (!readOnly) { handleInteraction(e); } }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
(e: React.TouchEvent<HTMLButtonElement>) => { handleTouchInteraction(e); if (!isPopoverOpen) { openPopover(); } }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
InterfaceDeclaration
export interface ColorStop { stop: number; color: string; }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
InterfaceDeclaration
interface EuiColorStopThumbProps extends CommonProps, ColorStop { className?: string; onChange: (colorStop: ColorStop) => void; onFocus?: () => void; onRemove?: () => void; globalMin: number; globalMax: number; localMin: number; localMax: number; min?: number; max?: number; isRangeMin?: boolean; isRangeMax?: boolean; parentRef?: HTMLDivElement | null; colorPickerMode: EuiColorPickerProps['mode']; colorPickerShowAlpha?: EuiColorPickerProps['showAlpha']; colorPickerSwatches?: EuiColorPickerProps['swatches']; disabled?: boolean; readOnly?: boolean; isPopoverOpen: boolean; openPopover: () => void; closePopover: () => void; 'data-index'?: string; 'aria-valuetext'?: string; valueInputProps?: Partial<EuiFieldNumberProps>; }
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
MethodDeclaration
isStopInvalid(stop)
ChrisJamesC/eui
src/components/color_picker/color_stops/color_stop_thumb.tsx
TypeScript
ArrowFunction
() => { return ( <div css={containerStyles}> <Global styles={globalStyles} /> <Router> <Redirect from="/" to="/page/0" /> <MerchantListView path="/page/:pageId" /> <MerchantView path="/merchant/:merchantId" /> <AddMerchantView path="/add-merchant" /> </Router> </div>
are/auto1-zadanie
src/App.tsx
TypeScript
EnumDeclaration
export enum Status { Online = "online", DoNotDisturb = "dnd", Idle = "idle", AFK = "idle", Invisible = "invisible", Offline = "offline", }
edqx/Wilson
packages/constants/lib/gateway/Status.ts
TypeScript
ArrowFunction
(txtype:number, ...args:Array<any>):BaseTx => { if (txtype === AVMConstants.BASETX) { return new BaseTx(...args); } else if (txtype === AVMConstants.CREATEASSETTX) { return new CreateAssetTx(...args); } else if (txtype === AVMConstants.OPERATIONTX) { return new OperationTx(...args); } else if (txtype === AVMConstants.IMPORTTX) { return new ImportTx(...args); } else if (txtype === AVMConstants.EXPORTTX) { return new ExportTx(...args); } /* istanbul ignore next */ throw new Error("Error - SelectTxClass: unknown txtype"); }
Dijets-Inc/dijetsJS
src/apis/avm/tx.ts
TypeScript
ClassDeclaration
export class UnsignedTx extends StandardUnsignedTx<KeyPair, KeyChain, BaseTx> { protected _typeName = "UnsignedTx"; protected _typeID = undefined; //serialize is inherited deserialize(fields:object, encoding:SerializedEncoding = "hex") { super.deserialize(fields, encoding); this.transaction = SelectTxClass(fields["transaction"]["_typeID"]); this.transaction.deserialize(fields["transaction"], encoding); } getTransaction():BaseTx{ return this.transaction as BaseTx; } fromBuffer(bytes:Buffer, offset:number = 0):number { this.codecid = bintools.copyFrom(bytes, offset, offset + 2).readUInt16BE(0); offset += 2; const txtype:number = bintools.copyFrom(bytes, offset, offset + 4).readUInt32BE(0); offset += 4; this.transaction = SelectTxClass(txtype); return this.transaction.fromBuffer(bytes, offset); } /** * Signs this [[UnsignedTx]] and returns signed [[StandardTx]] * * @param kc An [[KeyChain]] used in signing * * @returns A signed [[StandardTx]] */ sign(kc:KeyChain):Tx { const txbuff = this.toBuffer(); const msg:Buffer = Buffer.from(createHash('sha256').update(txbuff).digest()); const sigs:Array<Credential> = this.transaction.sign(msg, kc); return new Tx(this, sigs); } }
Dijets-Inc/dijetsJS
src/apis/avm/tx.ts
TypeScript
ClassDeclaration
export class Tx extends StandardTx<KeyPair, KeyChain, UnsignedTx> { protected _typeName = "Tx"; protected _typeID = undefined; //serialize is inherited deserialize(fields:object, encoding:SerializedEncoding = "hex") { super.deserialize(fields, encoding); this.unsignedTx = new UnsignedTx(); this.unsignedTx.deserialize(fields["unsignedTx"], encoding); this.credentials = []; for(let i = 0; i < fields["credentials"].length; i++){ const cred:Credential = SelectCredentialClass(fields["credentials"][i]["_typeID"]); cred.deserialize(fields["credentials"][i], encoding); this.credentials.push(cred); } } /** * Takes a {@link https://github.com/feross/buffer|Buffer} containing an [[Tx]], parses it, populates the class, and returns the length of the Tx in bytes. * * @param bytes A {@link https://github.com/feross/buffer|Buffer} containing a raw [[Tx]] * @param offset A number representing the starting point of the bytes to begin parsing * * @returns The length of the raw [[Tx]] */ fromBuffer(bytes:Buffer, offset:number = 0):number { this.unsignedTx = new UnsignedTx(); offset = this.unsignedTx.fromBuffer(bytes, offset); const numcreds:number = bintools.copyFrom(bytes, offset, offset + 4).readUInt32BE(0); offset += 4; this.credentials = []; for (let i = 0; i < numcreds; i++) { const credid:number = bintools.copyFrom(bytes, offset, offset + 4).readUInt32BE(0); offset += 4; const cred:Credential = SelectCredentialClass(credid); offset = cred.fromBuffer(bytes, offset); this.credentials.push(cred); } return offset; } }
Dijets-Inc/dijetsJS
src/apis/avm/tx.ts
TypeScript
MethodDeclaration
//serialize is inherited deserialize(fields:object, encoding:SerializedEncoding = "hex") { super.deserialize(fields, encoding); this.transaction = SelectTxClass(fields["transaction"]["_typeID"]); this.transaction.deserialize(fields["transaction"], encoding); }
Dijets-Inc/dijetsJS
src/apis/avm/tx.ts
TypeScript
MethodDeclaration
getTransaction():BaseTx{ return this.transaction as BaseTx; }
Dijets-Inc/dijetsJS
src/apis/avm/tx.ts
TypeScript