-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Define and export SnippetId type
- Loading branch information
Showing
21 changed files
with
201 additions
and
152 deletions.
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
File renamed without changes.
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
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,8 @@ | ||
import { SearchRpc } from '@appland/rpc'; | ||
|
||
export default function appmapLocation(appmap: string, event?: SearchRpc.EventMatch): string { | ||
const appmapFile = [appmap, 'appmap.json'].join('.'); | ||
const tokens = [appmapFile]; | ||
if (event?.eventIds.length) tokens.push(String(event.eventIds[0])); | ||
return tokens.join(':'); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { AppMapFilter, serializeFilter } from '@appland/models'; | ||
import { SearchRpc } from '@appland/rpc'; | ||
import assert from 'assert'; | ||
|
||
import { handler as sequenceDiagramHandler } from '../appmap/sequenceDiagram'; | ||
import { ContextV2 } from '@appland/navie'; | ||
import appmapLocation from './appmap-location'; | ||
|
||
export default async function buildSequenceDiagram( | ||
result: SearchRpc.SearchResult | ||
): Promise<ContextV2.FileContextItem> { | ||
const codeObjects = result.events.map((event) => event.fqid); | ||
const appmapFilter = new AppMapFilter(); | ||
appmapFilter.declutter.context.on = true; | ||
appmapFilter.declutter.context.names = codeObjects; | ||
const filterState = serializeFilter(appmapFilter); | ||
|
||
const plantUML = await sequenceDiagramHandler(result.appmap, { | ||
filter: filterState, | ||
format: 'plantuml', | ||
formatOptions: { disableMarkup: true }, | ||
}); | ||
assert(typeof plantUML === 'string'); | ||
return { | ||
directory: result.directory, | ||
location: appmapLocation(result.appmap), | ||
type: ContextV2.ContextItemType.SequenceDiagram, | ||
content: plantUML, | ||
score: result.score, | ||
}; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { FilterFn, isBinaryFile, isDataFile, isLargeFile } from '@appland/search'; | ||
import makeDebug from 'debug'; | ||
import { fileNameMatchesFilterPatterns } from '../../fulltext/filter-patterns'; | ||
|
||
const debug = makeDebug('appmap:rpc:explain:file-filter'); | ||
|
||
export default function fileFilter( | ||
includePatterns: RegExp[] | undefined, | ||
excludePatterns: RegExp[] | undefined | ||
): FilterFn { | ||
return async (path: string) => { | ||
debug('Filtering: %s', path); | ||
if (isBinaryFile(path)) { | ||
debug('Skipping binary file: %s', path); | ||
return false; | ||
} | ||
|
||
const includeFile = fileNameMatchesFilterPatterns(path, includePatterns, excludePatterns); | ||
if (!includeFile) return false; | ||
|
||
const isData = isDataFile(path); | ||
if (isData && (await isLargeFile(path))) { | ||
debug('Skipping large data file: %s', path); | ||
return false; | ||
} | ||
|
||
return true; | ||
}; | ||
} |
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
16 changes: 16 additions & 0 deletions
16
packages/cli/src/rpc/explain/textSearchResultToRpcSearchResult.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,16 @@ | ||
import { SearchRpc } from '@appland/rpc'; | ||
import { SearchResult as EventSearchResult } from '../../fulltext/FindEvents'; | ||
|
||
export function textSearchResultToRpcSearchResult( | ||
eventResult: EventSearchResult | ||
): SearchRpc.EventMatch { | ||
const result: SearchRpc.EventMatch = { | ||
fqid: eventResult.fqid, | ||
score: eventResult.score, | ||
eventIds: eventResult.eventIds, | ||
}; | ||
if (eventResult.location) result.location = eventResult.location; | ||
if (eventResult.elapsed) result.elapsed = eventResult.elapsed; | ||
return result; | ||
} | ||
|
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
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
Oops, something went wrong.