Skip to content

Commit

Permalink
remove unused code (#3265)
Browse files Browse the repository at this point in the history
  • Loading branch information
sqs authored Feb 25, 2024
1 parent 60c96bf commit 9157a57
Show file tree
Hide file tree
Showing 48 changed files with 33 additions and 454 deletions.
2 changes: 1 addition & 1 deletion lib/shared/src/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ export enum CustomCommandType {
User = 'user',
}

export type DefaultCommandType = 'default' | 'experimental'
type DefaultCommandType = 'default' | 'experimental'
2 changes: 1 addition & 1 deletion lib/shared/src/common/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { URI } from 'vscode-uri'

import { isWindows as _isWindows } from './platform'

export interface PathFunctions {
interface PathFunctions {
/**
* All but the last element of path, or "." if that would be the empty path.
*/
Expand Down
4 changes: 1 addition & 3 deletions lib/shared/src/common/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ export function isWindows(): boolean {
return false // default
}

export const isPlatform = (platform: string) => process.platform === platform

export const isMac = () => isPlatform('darwin')
export const isMac = () => process.platform === 'darwin'
21 changes: 0 additions & 21 deletions lib/shared/src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,7 @@ export interface Editor {

getActiveTextEditor(): ActiveTextEditor | null
getActiveTextEditorSelection(): ActiveTextEditorSelection | null
getActiveTextEditorSmartSelection(): Promise<ActiveTextEditorSelection | null>

/**
* Gets the active text editor's selection, or the entire file if the selected range is empty.
*/
getActiveTextEditorSelectionOrEntireFile(): ActiveTextEditorSelection | null
/**
* Gets the active text editor's selection, or the visible content if the selected range is empty.
*/
getActiveTextEditorSelectionOrVisibleContent(): ActiveTextEditorSelection | null
/**
* Get diagnostics (errors, warnings, hints) for a range within the active text editor.
*/
Expand Down Expand Up @@ -93,18 +84,6 @@ export class NoopEditor implements Editor {
return null
}

public getActiveTextEditorSmartSelection(): Promise<ActiveTextEditorSelection | null> {
return Promise.resolve(null)
}

public getActiveTextEditorSelectionOrEntireFile(): ActiveTextEditorSelection | null {
return null
}

public getActiveTextEditorSelectionOrVisibleContent(): ActiveTextEditorSelection | null {
return null
}

public getActiveTextEditorDiagnosticsForRange(): ActiveTextEditorDiagnostic[] | null {
return null
}
Expand Down
2 changes: 1 addition & 1 deletion lib/shared/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* all Cody clients over how messages get logged. For example, the JetBrains
* plugin may want to display warnings/errors in a custom way.
*/
export interface CodyLogger {
interface CodyLogger {
logDebug(filterLabel: string, text: string, ...args: unknown[]): void
logError(filterLabel: string, text: string, ...args: unknown[]): void
}
Expand Down
12 changes: 0 additions & 12 deletions lib/shared/src/test/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ export class MockEditor implements Editor {
return this.mocks.getActiveTextEditorSelection?.() ?? null
}

public getActiveTextEditorSmartSelection(): Promise<ActiveTextEditorSelection | null> {
return this.mocks.getActiveTextEditorSmartSelection?.() ?? Promise.resolve(null)
}

public getActiveTextEditorSelectionOrEntireFile(): ActiveTextEditorSelection | null {
return this.mocks.getActiveTextEditorSelection?.() ?? null
}

public getActiveTextEditorSelectionOrVisibleContent(): ActiveTextEditorSelection | null {
return this.mocks.getActiveTextEditorSelection?.() ?? null
}

public getActiveTextEditorDiagnosticsForRange(
range: ActiveTextEditorSelectionRange
): ActiveTextEditorDiagnostic[] | null {
Expand Down
19 changes: 0 additions & 19 deletions lib/shared/src/unified-context/index.ts

This file was deleted.

9 changes: 0 additions & 9 deletions lib/ui/src/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ interface ChatProps extends ChatClassNames {
chatCommands: [string, CodyCommand][],
input: string
) => [string, CodyCommand][]
ChatCommandsComponent?: React.FunctionComponent<ChatCommandsProps>
isTranscriptError?: boolean
contextSelection?: ContextFile[] | null
setContextSelection: (context: ContextFile[] | null) => void
Expand Down Expand Up @@ -157,14 +156,6 @@ export interface CodeBlockActionsProps {
insertButtonOnSubmit: (text: string, newFile?: boolean, metadata?: CodeBlockMeta) => void
}

export interface ChatCommandsProps {
setFormInput: (input: string) => void
setSelectedChatCommand: (index: number) => void
chatCommands?: [string, CodyCommand][] | null
selectedChatCommand?: number
onSubmit: (input: string, inputType: WebviewChatSubmitType) => void
}

export interface UserContextSelectorProps {
onSelected: (context: ContextFile, queryEndsWithColon?: boolean) => void
contextSelection?: ContextFile[]
Expand Down
13 changes: 0 additions & 13 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,6 @@
"@pollyjs/persister": "^6.0.6",
"@pollyjs/persister-fs": "^6.0.6",
"@types/axios": "^0.14.0",
"@types/blueimp-md5": "^2.18.2",
"@types/crypto-js": "^4.2.2",
"@types/dedent": "^0.7.0",
"@types/express": "^4.17.17",
Expand All @@ -1125,11 +1124,9 @@
"@vscode/test-electron": "^2.3.8",
"@vscode/test-web": "^0.0.47",
"@vscode/vsce": "^2.22.0",
"blueimp-md5": "^2.19.0",
"concurrently": "^8.2.0",
"dedent": "^0.7.0",
"express": "^4.18.2",
"fast-json-stable-stringify": "^2.1.0",
"fs-extra": "^11.2.0",
"fuzzysort": "^2.0.4",
"mocha": "^10.2.0",
Expand Down
26 changes: 1 addition & 25 deletions vscode/src/chat/ContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class ContextProvider implements vscode.Disposable, ContextStatusProvider

private statusAggregator: ContextStatusAggregator = new ContextStatusAggregator()
private statusEmbeddings: vscode.Disposable | undefined = undefined
private codebaseContext: CodebaseContext | undefined

constructor(
public config: Omit<Config, 'codebase'>, // should use codebaseContext.getCodebase() rather than config.codebase
Expand Down Expand Up @@ -104,13 +103,6 @@ export class ContextProvider implements vscode.Disposable, ContextStatusProvider
}
}

public get context(): CodebaseContext {
if (!this.codebaseContext) {
throw new Error('retrieved codebase context before initialization')
}
return this.codebaseContext
}

// Initializes context provider state. This blocks extension activation and
// chat startup. Despite being called 'init', this is called multiple times:
// - Once on extension activation.
Expand Down Expand Up @@ -138,7 +130,7 @@ export class ContextProvider implements vscode.Disposable, ContextStatusProvider
return Promise.resolve()
}

public async forceUpdateCodebaseContext(): Promise<void> {
private async forceUpdateCodebaseContext(): Promise<void> {
this.currentWorkspaceRoot = undefined
return this.syncAuthStatus()
}
Expand Down Expand Up @@ -173,8 +165,6 @@ export class ContextProvider implements vscode.Disposable, ContextStatusProvider
return
}

this.codebaseContext = codebaseContext

this.statusEmbeddings?.dispose()
if (this.localEmbeddings) {
this.statusEmbeddings = this.statusAggregator.addProvider(this.localEmbeddings)
Expand All @@ -189,20 +179,6 @@ export class ContextProvider implements vscode.Disposable, ContextStatusProvider
const authStatus = this.authProvider.getAuthStatus()
// Update config to the latest one and fire configure change event to update external services
const newConfig = await getFullConfig()
if (authStatus.siteVersion) {
// Update codebase context
const codebaseContext = await getCodebaseContext(
newConfig,
this.authProvider.getAuthStatus(),
this.symf,
this.editor,
this.localEmbeddings,
this.remoteSearch
)
if (codebaseContext) {
this.codebaseContext = codebaseContext
}
}
await this.publishConfig()
await this.onConfigurationChange(newConfig)
// When logged out, user's endpoint will be set to null
Expand Down
4 changes: 0 additions & 4 deletions vscode/src/chat/chat-view/SidebarViewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ export class SidebarViewController implements vscode.WebviewViewProvider {
}
}

public async simplifiedOnboardingReloadEmbeddingsState(): Promise<void> {
await this.contextProvider.forceUpdateCodebaseContext()
}

/**
* Display error message in webview as a banner alongside the chat.
*/
Expand Down
13 changes: 0 additions & 13 deletions vscode/src/chat/chat-view/SimpleChatModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,6 @@ export class SimpleChatModel {
this.messagesWithContext.splice(index)
}

public updateLastHumanMessage(message: Omit<Message, 'speaker'>, displayText?: string): void {
const lastMessage = this.messagesWithContext.at(-1)
if (!lastMessage) {
return
}
if (lastMessage.message.speaker === 'human') {
this.messagesWithContext.pop()
} else if (lastMessage.message.speaker === 'assistant') {
this.messagesWithContext.splice(-2, 2)
}
this.addHumanMessage(message, displayText)
}

public getMessagesWithContext(): MessageWithContext[] {
return this.messagesWithContext
}
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/chat/chat-view/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { logDebug, logError } from '../../log'
import type { ContextItem } from '../../prompt-builder/types'
import { viewRangeToRange } from './chat-helpers'

export interface GetEnhancedContextOptions {
interface GetEnhancedContextOptions {
strategy: ConfigurationUseContext
editor: VSCodeEditor
text: string
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/commands/GhostHintDecorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function getGhostHintEnablement(): Promise<boolean> {
* We should also ensure that `activationEvent` `onLanguage` is set to provide the best chance of
* executing this code early, without impacting VS Code startup time.
*/
export const ghostHintDecoration = vscode.window.createTextEditorDecorationType({
const ghostHintDecoration = vscode.window.createTextEditorDecorationType({
isWholeLine: true,
after: {
color: new vscode.ThemeColor('editorGhostText.foreground'),
Expand Down
56 changes: 0 additions & 56 deletions vscode/src/commands/context/file-imports.ts

This file was deleted.

Loading

0 comments on commit 9157a57

Please sign in to comment.