-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ast-query-test
- Loading branch information
Showing
7 changed files
with
77 additions
and
7 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
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,18 @@ | ||
import type { BasicQueryData } from '../../query'; | ||
import { log } from '../../../util/log'; | ||
import type { IdMapQuery, IdMapQueryResult } from './id-map-query-format'; | ||
|
||
|
||
export function executeIdMapQuery({ ast }: BasicQueryData, queries: readonly IdMapQuery[]): IdMapQueryResult { | ||
if(queries.length !== 1) { | ||
log.warn('Id-Map query expects only up to one query, but got', queries.length); | ||
} | ||
|
||
return { | ||
'.meta': { | ||
/* there is no sense in measuring a get */ | ||
timing: 0 | ||
}, | ||
idMap: ast.idMap | ||
}; | ||
} |
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,10 @@ | ||
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format'; | ||
import type { AstIdMap } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate'; | ||
|
||
export interface IdMapQuery extends BaseQueryFormat { | ||
readonly type: 'id-map'; | ||
} | ||
|
||
export interface IdMapQueryResult extends BaseQueryResult { | ||
readonly idMap: AstIdMap; | ||
} |
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,13 @@ | ||
import { assertQuery } from '../../_helper/query'; | ||
import { label } from '../../_helper/label'; | ||
import { withShell } from '../../_helper/shell'; | ||
import type { IdMapQuery } from '../../../../src/queries/catalog/id-map-query/id-map-query-format'; | ||
|
||
describe('Normalized AST Query', withShell(shell => { | ||
function testQuery(name: string, code: string, query: readonly IdMapQuery[]) { | ||
assertQuery(label(name), shell, code, query, (({ normalize }) => ({ 'id-map': { idMap: normalize.idMap } }))); | ||
} | ||
|
||
testQuery('Single normalized AST', 'x + 1', [{ type: 'id-map' }]); | ||
testQuery('Multiple Queries', 'x + 1', [{ type: 'id-map' }, { type: 'id-map' }, { type: 'id-map' }]); | ||
})); |