-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Sourceforge repositories
- Loading branch information
1 parent
d13e12b
commit 9866c73
Showing
5 changed files
with
195 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
extensions/github1s/src/adapters/sourceforge1s/data-source.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* @file Sourceforge1s data-source-provider | ||
* @author Your Name | ||
*/ | ||
|
||
import { | ||
DataSource, | ||
Directory, | ||
File, | ||
Branch, | ||
Tag, | ||
Commit, | ||
TextSearchResults, | ||
TextSearchQuery, | ||
TextSearchOptions, | ||
BlameRange, | ||
SymbolDefinitions, | ||
SymbolReferences, | ||
SymbolHover, | ||
} from '../types'; | ||
|
||
export class Sourceforge1sDataSource extends DataSource { | ||
private static instance: Sourceforge1sDataSource | null = null; | ||
|
||
public static getInstance(): Sourceforge1sDataSource { | ||
if (Sourceforge1sDataSource.instance) { | ||
return Sourceforge1sDataSource.instance; | ||
} | ||
return (Sourceforge1sDataSource.instance = new Sourceforge1sDataSource()); | ||
} | ||
|
||
// Implement the DataSource methods for Sourceforge | ||
async provideDirectory(repo: string, ref: string, path: string, recursive = false): Promise<Directory | null> { | ||
// Implementation for fetching a directory from Sourceforge | ||
return null; | ||
} | ||
|
||
async provideFile(repo: string, ref: string, path: string): Promise<File | null> { | ||
// Implementation for fetching a file from Sourceforge | ||
return null; | ||
} | ||
|
||
async provideBranches(repo: string, options?: CommonQueryOptions): Promise<Branch[]> { | ||
// Implementation for fetching branches from Sourceforge | ||
return []; | ||
} | ||
|
||
async provideTags(repo: string, options?: CommonQueryOptions): Promise<Tag[]> { | ||
// Implementation for fetching tags from Sourceforge | ||
return []; | ||
} | ||
|
||
async provideCommits(repo: string, options?: CommitsQueryOptions): Promise<Commit[]> { | ||
// Implementation for fetching commits from Sourceforge | ||
return []; | ||
} | ||
|
||
async provideTextSearchResults( | ||
repo: string, | ||
ref: string, | ||
query: TextSearchQuery, | ||
options?: TextSearchOptions | ||
): Promise<TextSearchResults> { | ||
// Implementation for text search in Sourceforge | ||
return { results: [], truncated: false }; | ||
} | ||
|
||
async provideFileBlameRanges(repo: string, ref: string, path: string): Promise<BlameRange[]> { | ||
// Implementation for fetching file blame ranges from Sourceforge | ||
return []; | ||
} | ||
|
||
async provideSymbolDefinitions( | ||
repo: string, | ||
ref: string, | ||
path: string, | ||
line: number, | ||
character: number, | ||
symbol: string | ||
): Promise<SymbolDefinitions> { | ||
// Implementation for fetching symbol definitions from Sourceforge | ||
return []; | ||
} | ||
|
||
async provideSymbolReferences( | ||
repo: string, | ||
ref: string, | ||
path: string, | ||
line: number, | ||
character: number, | ||
symbol: string | ||
): Promise<SymbolReferences> { | ||
// Implementation for fetching symbol references from Sourceforge | ||
return []; | ||
} | ||
|
||
async provideSymbolHover( | ||
repo: string, | ||
ref: string, | ||
path: string, | ||
line: number, | ||
character: number, | ||
symbol: string | ||
): Promise<SymbolHover | null> { | ||
// Implementation for fetching symbol hover information from Sourceforge | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @file Sourceforge1s adapter | ||
* @author Your Name | ||
*/ | ||
|
||
import { Sourceforge1sDataSource } from './data-source'; | ||
import { Sourceforge1sRouterParser } from './router-parser'; | ||
import { Adapter, CodeReviewType, PlatformName } from '../types'; | ||
import { setVSCodeContext } from '@/helpers/vscode'; | ||
|
||
export class Sourceforge1sAdapter implements Adapter { | ||
public scheme: string = 'sourceforge1s'; | ||
public platformName = PlatformName.OfficialPage; // Adjust as needed | ||
public codeReviewType = CodeReviewType.CodeReview; // Adjust as needed | ||
|
||
resolveDataSource() { | ||
return Promise.resolve(Sourceforge1sDataSource.getInstance()); | ||
} | ||
|
||
resolveRouterParser() { | ||
return Promise.resolve(Sourceforge1sRouterParser.getInstance()); | ||
} | ||
|
||
activateAsDefault() { | ||
// Implement activation logic here | ||
setVSCodeContext('github1s:views:settings:visible', true); | ||
} | ||
|
||
deactivateAsDefault() { | ||
// Implement deactivation logic here | ||
setVSCodeContext('github1s:views:settings:visible', false); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
extensions/github1s/src/adapters/sourceforge1s/router-parser.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* @file router parser for Sourceforge1s | ||
* @author Your Name | ||
*/ | ||
|
||
import * as adapterTypes from '../types'; | ||
import { parseSourceforgePath } from './parse-path'; | ||
|
||
export class Sourceforge1sRouterParser extends adapterTypes.RouterParser { | ||
private static instance: Sourceforge1sRouterParser | null = null; | ||
|
||
public static getInstance(): Sourceforge1sRouterParser { | ||
if (Sourceforge1sRouterParser.instance) { | ||
return Sourceforge1sRouterParser.instance; | ||
} | ||
return (Sourceforge1sRouterParser.instance = new Sourceforge1sRouterParser()); | ||
} | ||
|
||
parsePath(path: string): Promise<adapterTypes.RouterState> { | ||
return parseSourceforgePath(path); | ||
} | ||
|
||
buildTreePath(repo: string, ref?: string, filePath?: string): string { | ||
return ref ? (filePath ? `/${repo}/tree/${ref}/${filePath}` : `/${repo}/tree/${ref}`) : `/${repo}`; | ||
} | ||
|
||
buildBlobPath(repo: string, ref: string, filePath: string, startLine?: number, endLine?: number): string { | ||
const hash = startLine ? (endLine ? `#L${startLine}-L${endLine}` : `#L${startLine}`) : ''; | ||
return `/${repo}/blob/${ref}/${filePath}${hash}`; | ||
} | ||
|
||
buildCommitListPath(repo: string): string { | ||
return `/${repo}/commits`; | ||
} | ||
|
||
buildCommitPath(repo: string, commitSha: string): string { | ||
return `/${repo}/commit/${commitSha}`; | ||
} | ||
|
||
buildCodeReviewListPath(repo: string): string { | ||
return `/${repo}/pull-requests`; | ||
} | ||
|
||
buildCodeReviewPath(repo: string, codeReviewId: string): string { | ||
return `/${repo}/pull-request/${codeReviewId}`; | ||
} | ||
|
||
buildExternalLink(path: string): string { | ||
return `https://sourceforge.net${path.startsWith('/') ? path : `/${path}`}`; | ||
} | ||
} |