UNPKG

3.63 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
4 * This code may only be used under the BSD style license found at
5 * http://polymer.github.io/LICENSE.txt
6 * The complete set of authors may be found at
7 * http://polymer.github.io/AUTHORS.txt
8 * The complete set of contributors may be found at
9 * http://polymer.github.io/CONTRIBUTORS.txt
10 * Code distributed by Google as part of the polymer project is also
11 * subject to an additional IP rights grant found at
12 * http://polymer.github.io/PATENTS.txt
13 */
14import * as babel from '@babel/types';
15import { Feature } from './feature';
16import { Warning } from './warning';
17export interface FeatureKindMap {
18}
19export declare type FeatureKind = keyof FeatureKindMap;
20export declare type BaseQueryOptions = {
21 /**
22 * Do not include the containing document or any features from the
23 * containing document; allows querying for features specific to an inline
24 * document and/or its descendents.
25 */
26 excludeBackreferences?: boolean;
27 /**
28 * If true then results will include features from outside the package, e.g.
29 * from files in bower_components or node_modules directories.
30 *
31 * Note that even with this option you'll only get results from external files
32 * that are referenced from within the package.
33 */
34 externalPackages?: boolean;
35 /**
36 * Do not include any features that are only reachable via paths that include
37 * lazy import edges.
38 */
39 noLazyImports?: boolean;
40 /**
41 * If given, the query results will all have the given identifier.
42 *
43 * There identifiers mean different things for different kinds of features.
44 * For example documents are identified by their url, and elements are
45 * identified by their tag and class names.
46 */
47 id?: string;
48} & object;
49export declare type BaseAnalysisQuery = BaseQueryOptions & {
50 /**
51 * When querying over an Analysis, the results would not be defined if
52 * imports are not considered, so it is legal to specify this parameter,
53 * but it must be true (and it will be ignored in any case).
54 */
55 imported?: true;
56};
57export declare type BaseDocumentQuery = BaseQueryOptions & {
58 /**
59 * If given, returns any features which are defined by the given statement.
60 * This argument implies `imported: false`.
61 *
62 * See esutil.getStatement for going from a babel-traverse NodePath to the
63 * canonical statment node.
64 */
65 statement?: babel.Statement;
66 /**
67 * If true, the query will return results from the document and its
68 * dependencies. Otherwise it will only include results from the document.
69 */
70 imported?: boolean;
71};
72export declare type BaseQuery = BaseQueryOptions & {
73 kind?: string;
74};
75export declare type BaseQueryWithKind<K extends FeatureKind> = BaseQueryOptions & {
76 kind: K;
77};
78export declare type DocumentQuery = BaseDocumentQuery & {
79 kind?: string;
80};
81export declare type DocumentQueryWithKind<K extends FeatureKind> = BaseDocumentQuery & {
82 kind: K;
83};
84export declare type AnalysisQuery = BaseAnalysisQuery & {
85 kind?: string;
86};
87export declare type AnalysisQueryWithKind<K extends FeatureKind> = BaseAnalysisQuery & {
88 kind: K;
89};
90/**
91 * Represents something like a Document or an Analysis. A container of features
92 * and warnings that's queryable in a few different ways.
93 */
94export interface Queryable {
95 getFeatures<K extends FeatureKind>(query: BaseQueryWithKind<K>): Set<FeatureKindMap[K]>;
96 getFeatures(query?: BaseQuery): Set<Feature>;
97 getWarnings(options?: BaseQuery): Warning[];
98}